1 /***************************************************************************
2 * Copyright (C) 2007 by Robert Knight <robertknight@gmail.com> *
3 * Copyright (C) 2008 by Alexis Ménard <darktears31@gmail.com> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
19 ***************************************************************************/
22 #ifndef LAYOUTWIDGET_H
23 #define LAYOUTWIDGET_H
30 #include <QGraphicsGridLayout>
36 class AbstractTaskItem
;
38 using TaskManager::StartupPtr
;
39 using TaskManager::TaskPtr
;
40 using TaskManager::GroupManager
;
44 * A Layout for the expanded group
46 class LayoutWidget
: public QObject
51 LayoutWidget(TaskGroupItem
* parent
, Tasks
*applet
);
53 /** insert the item on the index in TaskGroupItem::getMemberList */
54 void addTaskItem(AbstractTaskItem
*);
55 void removeTaskItem(AbstractTaskItem
*);
56 /** insert the item on a specific index*/
57 bool insert(int index
, AbstractTaskItem
* item
);
59 /** returns the insert index for a task drop on pos */
60 int insertionIndexAt(const QPointF
&pos
);
61 /** set the maximum number of rows */
62 void setMaximumRows(int);
63 /** force the layout to use maximumRows setting and fill rows before columns */
64 void setForceRows(bool);
66 /** the size including expanded groups*/
69 /** returns columnCount or rowCount depending on m_applet->formFactor() */
71 /** returns columnCount or rowCount depending on m_applet->formFactor()*/
72 int numberOfColumns();
74 /** Returns the preferred number of rows based on the user settings but limited by calculation to honor AbstractGroupableItem::basicPreferredSize()*/
76 /** Returns the preferred number of columns calculated on base of AbstractGroupableItem::basicPreferredSize()*/
77 int preferredColumns();
83 void constraintsChanged(Plasma::Constraints
);
86 void sizeHintChanged(Qt::SizeHint
);
91 //void calculatePreferredRowSize();
92 bool remove(AbstractTaskItem
* item
);
95 void updatePreferredSize();
97 /** Populates the actual QGraphicsGridLayout with items*/
101 QGraphicsWidget
*m_spacer
;
103 TaskGroupItem
*m_groupItem
;
104 QList
<AbstractTaskItem
*> m_itemPositions
;
105 /** Calculates the number of columns and rows for the layoutItems function and returns <columns/rows>*/
106 QPair
<int, int> gridLayoutSize();
108 /** Limit before row is full, more columns are added if maxRows is exeeded*/
110 /** How many rows should be used*/
116 /** Creates and initialises a new QGraphicsGridLayout*/
118 QGraphicsGridLayout
*m_layout
;