Applets
layoutwidget.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * Copyright (C) 2007 by Robert Knight <robertknight@gmail.com> * 00003 * Copyright (C) 2008 by Alexis Ménard <darktears31@gmail.com> * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 00019 ***************************************************************************/ 00020 00021 00022 #ifndef LAYOUTWIDGET_H 00023 #define LAYOUTWIDGET_H 00024 00025 //Own 00026 #include "tasks.h" 00027 00028 // Qt 00029 #include <QObject> 00030 #include <QGraphicsGridLayout> 00031 #include <QList> 00032 #include <QMultiMap> 00033 00034 00035 class TaskGroupItem; 00036 class AbstractTaskItem; 00037 00038 using TaskManager::StartupPtr; 00039 using TaskManager::TaskPtr; 00040 using TaskManager::GroupManager; 00041 00042 00046 class LayoutWidget : public QObject 00047 { 00048 Q_OBJECT 00049 00050 public: 00051 LayoutWidget(TaskGroupItem * parent, Tasks *applet); 00052 ~LayoutWidget(); 00054 void addTaskItem(AbstractTaskItem*); 00055 void removeTaskItem(AbstractTaskItem*); 00057 bool insert(int index, AbstractTaskItem* item); 00058 00060 int insertionIndexAt(const QPointF &pos); 00062 void setMaximumRows(int); 00064 void setForceRows(bool); 00065 00067 int size(); 00068 00070 int numberOfRows(); 00072 int numberOfColumns(); 00073 00075 int maximumRows(); 00077 int preferredColumns(); 00078 00079 public Q_SLOTS: 00080 void update(); 00081 00082 private Q_SLOTS: 00083 void constraintsChanged(Plasma::Constraints); 00084 00085 Q_SIGNALS: 00086 void sizeHintChanged(Qt::SizeHint); 00087 00088 private: 00089 void init(); 00090 00091 //void calculatePreferredRowSize(); 00092 bool remove(AbstractTaskItem* item); 00093 00094 void adjustStretch(); 00095 void updatePreferredSize(); 00096 00098 void layoutItems(); 00099 00100 bool m_hasSpacer; 00101 QGraphicsWidget *m_spacer; 00102 00103 TaskGroupItem *m_groupItem; 00104 QList <AbstractTaskItem*> m_itemPositions; 00106 QPair<int, int> gridLayoutSize(); 00107 00109 int m_rowSize; 00111 int m_maxRows; 00112 00113 bool m_forceRows; 00114 00115 Tasks *m_applet; 00117 void createLayout(); 00118 QGraphicsGridLayout *m_layout; 00119 }; 00120 00121 #endif