/**************************************************************************** Copyright (C) 2012-2013 by Eike Hein <hein@kde.org> ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the ** Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . ****************************************************************************/import QtQuick 2.0import org.kde.plasma.core 2.0 as PlasmaCoreimport org.kde.draganddrop 2.0import "../code/layout.js" as LayoutManagerPlasmaCore.Dialog {visible: falsetype: PlasmaCore.Dialog.PopupMenuflags: Qt.WindowStaysOnTopHinthideOnWindowDeactivate: truelocation: plasmoid.locationmainItem: Item {MouseHandler {id: mouseHandleranchors.fill: parenttarget: taskList}TaskList {id: taskListanchors.fill: parentRepeater {id: groupRepeateronCountChanged: updateSize()}}}data: [VisualDataModel {id: groupFilterdelegate: Task {visible: trueinPopup: true}}]onVisualParentChanged: {if (!visualParent) {visible = false;}}onVisibleChanged: {if (visible && visualParent) {groupFilter.model = tasksModel;groupFilter.rootIndex = groupFilter.modelIndex(visualParent.itemIndex);groupRepeater.model = groupFilter;} else {visualParent = null;groupRepeater.model = undefined;groupFilter.model = undefined;groupFilter.rootIndex = undefined;}}function updateSize() {if (!visible || !visualParent) {return;}if (!groupRepeater.count) {visible = false;} else {var task;var maxWidth = 0;for (var i = 0; i < taskList.children.length - 1; ++i) {task = taskList.children[i];if (task.textWidth > maxWidth) {maxWidth = task.textWidth;}task.textWidthChanged.connect(updateSize);}maxWidth += LayoutManager.horizontalMargins() + units.iconSizes.small + 6;// TODO: Properly derive limits from work area size (screen size sans struts).mainItem.width = Math.min(maxWidth, (tasks.vertical ? 640 - tasks.width : Math.max(tasks.width, 640)) - 20);mainItem.height = groupRepeater.count * (LayoutManager.verticalMargins() + Math.max(theme.mSize(theme.defaultFont).height, units.iconSizes.small));}}}