Plasma
desktoplayout.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _DESKTOPLAYOUT_H
00011 #define _DESKTOPLAYOUT_H
00012
00013 #include <QGraphicsLayout>
00014 #include <QHash>
00015 #include <QMap>
00016 #include <QList>
00017 #include <QObject>
00018
00019 #include "itemspace.h"
00020
00021 class QGraphicsItem;
00022
00023 class DesktopLayout : public QObject, public QGraphicsLayout
00024 {
00025 Q_OBJECT
00026
00027 public:
00028 DesktopLayout (QGraphicsLayoutItem *parent = 0);
00029
00041 void addItem(QGraphicsLayoutItem *item, bool pushBack = true, const QSizeF &size = QSizeF());
00042
00046 void addItem(QGraphicsLayoutItem *item, bool pushBack, const QRectF &preferredGeom, const QRectF &lastGeom = QRectF());
00047
00048 bool getPushBack(int index);
00049 QRectF getPreferredGeometry(int index);
00050 QRectF getLastGeometry(int index);
00051
00056 void setPlacementSpacing(qreal spacing);
00057
00063 void setScreenSpacing(qreal spacing);
00064
00068 void setShiftingSpacing(qreal spacing);
00069
00074 void setVisibilityTolerance(qreal part);
00075
00081 void setAutoWorkingArea(bool value);
00082
00088 void setWorkingArea(QRectF area);
00089
00097 void setAlignment(Qt::Alignment alignment);
00098
00102 void setTemporaryPlacement(bool enabled);
00103
00109 void itemGeometryChanged(QGraphicsLayoutItem *layoutItem);
00110
00111
00112 int count() const;
00113 QGraphicsLayoutItem *itemAt(int index) const;
00114 void removeAt(int index);
00115
00116
00117 void setGeometry(const QRectF &rect);
00118 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
00119
00120 private slots:
00121 void movementFinished(QGraphicsItem*);
00122
00123 private:
00124
00125 class DesktopLayoutItem
00126 {
00127 public:
00128 QGraphicsLayoutItem *item;
00129 QRectF temporaryGeometry;
00130 };
00131
00132 int newItemKey();
00133
00134
00135
00141 ItemSpace itemSpace;
00142
00147 QMap<int, DesktopLayoutItem> items;
00148
00149 QHash<QGraphicsItem*, int> m_animatingItems;
00150 QPointF workingStart;
00151
00152
00153
00154 bool autoWorkingArea;
00155 bool temporaryPlacement;
00156
00157 qreal visibilityTolerance;
00158
00159
00160 void performTemporaryPlacement(int group, int itemInGroup);
00161 void revertTemporaryPlacement(int group, int itemInGroup);
00162
00163 bool m_activated;
00164 };
00165
00166 #endif