Vidalia  0.2.21
ConfigPageStack.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file ConfigPageStack.h
13 ** \brief A collection of configuration pages
14 */
15 
16 #ifndef _CONFIGPAGESTACK_H
17 #define _CONFIGPAGESTACK_H
18 
19 #include "ConfigPage.h"
20 
21 #include <QStackedWidget>
22 #include <QHash>
23 
24 
25 class ConfigPageStack : public QStackedWidget
26 {
27  Q_OBJECT
28 
29 public:
30  /** Constructor. */
31  ConfigPageStack(QWidget *parent = 0);
32 
33  /** Adds a configuration page to the stack. */
34  void add(ConfigPage *page, QAction *action);
35  /** Sets the current config page and checks its action. */
36  void setCurrentPage(ConfigPage *page);
37  /** Sets the current config page index and checks its action. */
38  void setCurrentIndex(int index);
39 
40  /** Returns a list of all pages in the stack. The order of the pages in the
41  * returned QList is the same as the order in which the pages were
42  * initially added to the stack. */
43  QList<ConfigPage *> pages() const;
44 
45 public slots:
46  /** Displays the page associated with the activated action. */
47  void showPage(QAction *pageAction);
48 
49 private:
50  /** Maps an action to a config page. */
51  QHash<QAction*, ConfigPage*> _pages;
52 };
53 
54 #endif
55