/*********************************************************************/ /* */ /* Copyright 2007 by Alex Merry */ /* Copyright 2008 by Alexis Ménard */ /* Copyright 2008 by Aaron Seigo */ /* Copyright 2009 by Marco Martin */ /* Copyright 2010 by Igor Oliveira #include namespace Plasma { class AbstractToolBox; class Applet; class Containment; class FrameSvg; } #include #include #include class AppletsView; class AppletsContainer : public QGraphicsWidget { Q_OBJECT public: AppletsContainer(AppletsView *parent); ~AppletsContainer(); void addApplet(Plasma::Applet* applet, const int row = -1, const int column = -1); void syncColumnSizes(); void createAppletTitle(Plasma::Applet *applet); QGraphicsLinearLayout *addColumn(); void removeColumn(int column); void setOrientation(Qt::Orientation orientation); int count() const; QGraphicsLayoutItem *itemAt(int i); void setViewportSize(const QSizeF &size); QSizeF viewportSize() const; void setExpandAll(const bool expand); bool expandAll() const; void setAutomaticAppletLayout(const bool automatic); bool automaticAppletLayout() const; void setCurrentApplet(Plasma::Applet *applet); Plasma::Applet *currentApplet() const; Qt::Orientation orientation() const; Plasma::Containment *containment() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); protected: QSizeF optimalAppletSize(Plasma::Applet *applet, const bool maximized) const; void updateSnapSize(); void mousePressEvent(QGraphicsSceneMouseEvent *event); void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void resizeEvent(QGraphicsSceneResizeEvent *event); public Q_SLOTS: void layoutApplet(Plasma::Applet *applet, const QPointF &post); void updateSize(); void cleanupColumns(); void themeChanged(); private Q_SLOTS: void viewportGeometryChanged(const QRectF &geometry); void updateViewportGeometry(); void scrollStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState); void syncView(); void syncBorders(); Q_SIGNALS: void appletSizeHintChanged(); void appletActivated(Plasma::Applet *applet); private: AppletsView *m_scrollWidget; QGraphicsLinearLayout *m_mainLayout; Qt::Orientation m_orientation; QWeakPointerm_currentApplet; QSizeF m_viewportSize; Plasma::Containment *m_containment; bool m_automaticAppletLayout; bool m_expandAll; QPropertyAnimation *m_preferredHeightAnimation; //the size of a M in the current font. the font size is used to decide //how many row/columns QSize m_mSize; QTimer *m_viewportGeometryUpdateTimer; int m_appletsPerColumn; int m_appletsPerRow; QAbstractAnimation::State m_viewScrollState; QTimer *m_viewSyncTimer; Plasma::AbstractToolBox *m_toolBox; Plasma::FrameSvg *m_background; }; #endif