summaryrefslogtreecommitdiffstats
path: root/library/optionsitem.h
blob: e6130ca91ebfb1d346a89b2a1bf492f1827a4cd6 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef OPTIONSITEM_H
#define OPTIONSITEM_H

#include "remotecontrolwidget_global.h"

#include <QtCore/QObject>
#include <QtCore/QStringList>

class QLayout;
class QLabel;
class QHBoxLayout;

class REMOTECONTROLWIDGETSHARED_EXPORT OptionsItem: public QObject
{
    Q_OBJECT
public:
    enum OptionsType {
        DefaultType,
        FullWidthType,
        AdvancedType
    };

    OptionsItem(const QString &name, QWidget *inputWidget, bool fullWidth = false, QObject *parent = 0);
    virtual ~OptionsItem();

    QLabel *label() const;
    QWidget *inputWidget() const;
    QHBoxLayout *inputLayout() const;

    void setVisible(bool visible, bool explicitly = false);
    bool setAdvancedPage(OptionsItem *advancedPage);
    OptionsItem *advancedPage() const;

    bool addTag(const QString &tag);
    bool addTags(const QStringList &tags);
    bool removeTag(const QString &tag);
    bool removeTags(const QStringList &tags);
    bool setTags(const QStringList &tags);
    bool matchTag(const QString &tag) const;
    OptionsType type() const;
    bool isExplicitlyHidden() const;
    void setAdvanced(bool advanced = true);
    bool isAdvanced() const;

private:
    friend class ToolBoxPage;
    QLabel *mLabel;
    QWidget *mInputWidget;
    QHBoxLayout *mInputLayout;
    OptionsItem *mAdvancedPage;
    QStringList mTags;
    OptionsType mType;
    bool mHidden;
    bool mAdvanced;

private slots:
    void buttonClicked();

signals:
    void toggleAdvanced(OptionsItem *item);
};

#endif //OPTIONSITEM_H