PageRenderTime 40ms CodeModel.GetById 1ms app.highlight 33ms RepoModel.GetById 2ms app.codeStats 0ms

/src/VBox/Frontends/VirtualBox/src/settings/VBoxSettingsSelector.h

https://gitlab.com/ufo/virtualbox-ose-3-1-8
C Header | 178 lines | 99 code | 56 blank | 23 comment | 0 complexity | da4c9ce4e5ea1d8b1ca6a2d930dc9006 MD5 | raw file
  1/** @file
  2 *
  3 * VBox frontends: Qt4 GUI ("VirtualBox"):
  4 * VBoxSettingsSelector class declaration
  5 */
  6
  7/*
  8 * Copyright (C) 2008 Sun Microsystems, Inc.
  9 *
 10 * This file is part of VirtualBox Open Source Edition (OSE), as
 11 * available from http://www.virtualbox.org. This file is free software;
 12 * you can redistribute it and/or modify it under the terms of the GNU
 13 * General Public License (GPL) as published by the Free Software
 14 * Foundation, in version 2 as it comes in the "COPYING" file of the
 15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 17 *
 18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 20 * additional information or have any questions.
 21 */
 22
 23#ifndef __VBoxSettingsSelector_h__
 24#define __VBoxSettingsSelector_h__
 25
 26/* Qt includes */
 27#include <QObject>
 28
 29class QITreeWidget;
 30class VBoxToolBar;
 31class VBoxSettingsPage;
 32class SelectorItem;
 33class SelectorActionItem;
 34
 35class QTreeWidget;
 36class QTreeWidgetItem;
 37class QIcon;
 38class QAction;
 39class QActionGroup;
 40template <class Key, class T> class QMap;
 41class QTabWidget;
 42
 43class VBoxSettingsSelector: public QObject
 44{
 45    Q_OBJECT;
 46
 47public:
 48
 49    VBoxSettingsSelector (QWidget *aParent = NULL);
 50    ~VBoxSettingsSelector();
 51
 52    virtual QWidget *widget() const = 0;
 53
 54    virtual QWidget *addItem (const QString &aBigIcon, const QString &aBigIconDisabled, const QString &aSmallIcon, const QString &aSmallIconDisabled, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1) = 0;
 55
 56    virtual void setItemText (int aId, const QString &aText);
 57    virtual QString itemText (int aId) const = 0;
 58    virtual QString itemTextByPage (VBoxSettingsPage *aPage) const;
 59
 60    virtual int currentId () const = 0;
 61    virtual int linkToId (const QString &aLink) const = 0;
 62
 63    virtual QWidget *idToPage (int aId) const;
 64    virtual QWidget *rootPage (int aId) const { return idToPage (aId); }
 65
 66    virtual void selectById (int aId) = 0;
 67    virtual void selectByLink (const QString &aLink) { selectById (linkToId (aLink)); }
 68
 69    virtual void setVisibleById (int aId, bool aShow) = 0;
 70
 71    virtual QList<VBoxSettingsPage*> settingPages() const;
 72    virtual QList<QWidget*> rootPages() const;
 73
 74    virtual void polish() {};
 75
 76    virtual int minWidth () const { return 0; }
 77
 78signals:
 79
 80    void categoryChanged (int);
 81
 82protected:
 83
 84    virtual void clear() = 0;
 85
 86    SelectorItem* findItem (int aId) const;
 87    SelectorItem* findItemByLink (const QString &aLink) const;
 88    SelectorItem* findItemByPage (VBoxSettingsPage* aPage) const;
 89
 90    QList<SelectorItem*> mItemList;
 91};
 92
 93class VBoxSettingsTreeViewSelector: public VBoxSettingsSelector
 94{
 95    Q_OBJECT;
 96
 97public:
 98
 99    VBoxSettingsTreeViewSelector (QWidget *aParent = NULL);
100
101    virtual QWidget *widget() const;
102
103    virtual QWidget *addItem (const QString &aBigIcon, const QString &aBigIconDisabled, const QString &aSmallIcon, const QString &aSmallIconDisabled, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1);
104    virtual void setItemText (int aId, const QString &aText);
105    virtual QString itemText (int aId) const;
106
107    virtual int currentId() const;
108    virtual int linkToId (const QString &aLink) const;
109
110    virtual void selectById (int aId);
111
112    virtual void setVisibleById (int aId, bool aShow);
113
114    virtual void polish();
115
116private slots:
117
118    void settingsGroupChanged (QTreeWidgetItem *aItem, QTreeWidgetItem *aPrevItem);
119
120private:
121
122    virtual void clear();
123
124    QString pagePath (const QString &aMatch) const;
125    QTreeWidgetItem* findItem (QTreeWidget *aView, const QString &aMatch, int aColumn) const;
126    QString idToString (int aId) const;
127
128    /* Private member vars */
129    QITreeWidget *mTwSelector;
130};
131
132class VBoxSettingsToolBarSelector: public VBoxSettingsSelector
133{
134    Q_OBJECT;
135
136public:
137
138    VBoxSettingsToolBarSelector (QWidget *aParent = NULL);
139    ~VBoxSettingsToolBarSelector();
140
141    virtual QWidget *widget() const;
142
143    virtual QWidget *addItem (const QString &aBigIcon, const QString &aBigIconDisabled, const QString &aSmallIcon, const QString &aSmallIconDisabled, int aId, const QString &aLink, VBoxSettingsPage* aPage = NULL, int aParentId = -1);
144    virtual void setItemText (int aId, const QString &aText);
145    virtual QString itemText (int aId) const;
146
147    virtual int currentId() const;
148    virtual int linkToId (const QString &aLink) const;
149
150    virtual QWidget *idToPage (int aId) const;
151    virtual QWidget *rootPage (int aId) const;
152
153    virtual void selectById (int aId);
154
155    virtual void setVisibleById (int aId, bool aShow);
156
157    virtual int minWidth() const;
158
159    virtual QList<QWidget*> rootPages() const;
160private slots:
161
162    void settingsGroupChanged (QAction *aAction);
163    void settingsGroupChanged (int aIndex);
164
165private:
166
167    virtual void clear();
168
169    SelectorActionItem *findActionItem (int aId) const;
170    SelectorActionItem *findActionItemByAction (QAction *aAction) const;
171    SelectorActionItem *findActionItemByTabWidget (QTabWidget* aTabWidget, int aIndex) const;
172
173    /* Private member vars */
174    VBoxToolBar *mTbSelector;
175    QActionGroup *mActionGroup;
176};
177
178#endif /* __VBoxSettingsSelector_h__ */