Fluid Tabs

ftabbar.h

00001 #ifndef FTABBAR_H
00002 #define FTABBAR_H
00003 
00004 #include <QDeclarativeItem>
00005 
00006 class FTab : public QDeclarativeItem
00007 {
00008     Q_OBJECT
00009     Q_PROPERTY(QString title WRITE setTitle READ title NOTIFY titleChanged)
00010 
00011 public:
00012     FTab(QDeclarativeItem *parent = 0);
00013     inline ~FTab() { delete m_item; }
00014 
00015     void setTitle(const QString &title);
00016     inline QString title() const { return m_title; }
00017 
00018     void setDelegate(QDeclarativeComponent *delegate);
00019 
00020     inline void setItem(QDeclarativeItem *item) { m_item = item; }
00021     inline void setItemProperty(const char *property, const QVariant &value);
00022     inline QVariant itemProperty(const char *property) const;
00023 
00024     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00025     QRectF boundingRect() const;
00026 
00027 protected:
00028     void mousePressEvent(QGraphicsSceneMouseEvent *event);
00029 
00030 signals:
00031     void titleChanged();
00032     void tabSelected();
00033 
00034 private:
00035     void paintChildren(QDeclarativeItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00036 
00037     QString           m_title;
00038     QDeclarativeItem *m_item;
00039 };
00040 
00041 class FTabBar : public QDeclarativeItem
00042 {
00043     Q_OBJECT
00044     Q_PROPERTY(Qt::Orientation orientation WRITE setOrientation READ orientation NOTIFY orientationChanged)
00045     Q_PROPERTY(QDeclarativeComponent *delegate WRITE setDelegate READ delegate NOTIFY delegateChanged RESET resetDelegate)
00046     Q_PROPERTY(qreal tabMargin WRITE setTabMargin READ tabMargin NOTIFY tabMarginChanged)
00047 
00048 public:
00049     explicit FTabBar(QDeclarativeItem *parent = 0);
00050     inline ~FTabBar() { delete m_item; }
00051 
00052     void setOrientation(Qt::Orientation orientation);
00053     inline Qt::Orientation orientation() const { return m_orientation; }
00054 
00055     void setDelegate(QDeclarativeComponent *delegate);
00056     inline QDeclarativeComponent *delegate() const { return m_delegate; }
00057     inline void resetDelegate() { setDelegate(0); }
00058 
00059     void setTabMargin(qreal margin);
00060     qreal tabMargin() const;
00061 
00062     void componentComplete();
00063 
00064 protected slots:
00065     void activate();
00066 
00067 signals:
00068     void orientationChanged();
00069     void delegateChanged();
00070     void tabActivated(int);
00071     void tabMarginChanged();
00072 
00073 private:
00074     Qt::Orientation        m_orientation;
00075     int                    m_current;
00076     QList<FTab *>          m_tabs;
00077     qreal                  m_tabMargin;
00078     QDeclarativeComponent *m_delegate;
00079     QDeclarativeItem      *m_item;
00080 };
00081 
00082 #endif // FTABBAR_H
 All Classes Functions Properties