summaryrefslogtreecommitdiffstats
path: root/src/qtsegmentcontrol.cpp
blob: 0367f7ce950626802977fa18fbee2ade3a106b71 (plain)
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
#include "qtsegmentcontrol.h"

struct SegmentInfo {
    SegmentInfo() : menu(0), selected(false) {}
    ~SegmentInfo() { delete menu; }
    QString text;
    QString toolTip;
    QString whatsThis;
    QIcon icon;
    QMenu *menu;
    bool selected;
};

class QtSegmentControlPrivate {
public:
    QtSegmentControlPrivate(QtSegmentControl *myQ) : q(myQ), count(0), lastSelected(-1) {};
    ~QtSegmentControlPrivate() {};

    QtSegmentControl *q;
    QtSegmentControl::SelectionBehavior selectionBehavior;
    QSize iconSize;
    QVector<SegmentInfo> segments;
    int lastSelected;
};

QtSegmentControl::QtSegmentControl(QWidget *parent)
    : QWidget(parent), d(new QtSegmentControl(this))
{
}

QtSegmentControl::~QtSegmentControl()
{
    delete d;
}

int QtSegmentControl::count() const
{
    return segments.count();
}

void QtSegmentControl::setCount(int newCount)
{
    segments.resize(newCount);
}

bool QtSegmentControl::isSegmentSelected(int index) const
{
    // Stuff Good.
    const SegmentInfo &info = segments.at(index);
}