File: tabwidget.h

package info (click to toggle)
bornagain 1.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 118,800 kB
  • sloc: cpp: 469,684; python: 38,920; xml: 805; awk: 630; sh: 286; ansic: 37; makefile: 25
file content (61 lines) | stat: -rw-r--r-- 1,469 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef TABWIDGET_H
#define TABWIDGET_H

#include "../qt-manhattan-style_global.hpp"
#include <QVector>
#include <QWidget>

class QStackedWidget;

namespace Manhattan {

class QTMANHATTANSTYLESHARED_EXPORT TabWidget : public QWidget
{
    Q_OBJECT
public:
    TabWidget(QWidget *parent = 0);
    virtual ~TabWidget();

    void setTitle(const QString &title);
    QString title() const { return m_title; }

    void setFrameVisible(bool visible);

    void addTab(const QString &name, QWidget *widget, const QColor &color = Qt::black);
    void insertTab(int index, const QString &name, QWidget *widget, const QColor &color = Qt::black);
    QWidget* removeTab(int index);
    int tabCount() const;
    QString tabText(int index) const;

    int currentIndex() const;
    void setCurrentIndex(int index);

signals:
    void currentIndexChanged(int index);

protected:
    virtual void paintEvent(QPaintEvent *event);
    virtual void mousePressEvent(QMouseEvent *event);
    virtual bool event(QEvent *event);

private:
    struct Tab {
        QString name;
        QColor color;
        QWidget* widget;
    };
    enum HitArea { HITNOTHING, HITOVERFLOW, HITTAB };
    QPair<TabWidget::HitArea, int> convertPosToTab(QPoint pos);

    QString m_title;
    QList<Tab> m_tabs;
    int m_currentIndex;
    QVector<int> m_currentTabIndices;
    int m_lastVisibleIndex;
    QStackedWidget *m_stack;
    bool m_drawFrame;
};

} // namespace Manhattan

#endif // TABWIDGET_H