Vidalia  0.2.15
ConfigPageStack.h
Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
00007 **  including this file, may be copied, modified, propagated, or distributed 
00008 **  except according to the terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file ConfigPageStack.h
00013 ** \brief A collection of configuration pages
00014 */
00015 
00016 #ifndef _CONFIGPAGESTACK_H
00017 #define _CONFIGPAGESTACK_H
00018 
00019 #include "ConfigPage.h"
00020 
00021 #include <QStackedWidget>
00022 #include <QHash>
00023 
00024 
00025 class ConfigPageStack : public QStackedWidget
00026 {
00027   Q_OBJECT
00028 
00029 public:
00030   /** Constructor. */
00031   ConfigPageStack(QWidget *parent = 0);
00032 
00033   /** Adds a configuration page to the stack. */
00034   void add(ConfigPage *page, QAction *action);
00035   /** Sets the current config page and checks its action. */
00036   void setCurrentPage(ConfigPage *page);
00037   /** Sets the current config page index and checks its action. */
00038   void setCurrentIndex(int index);
00039   
00040   /** Returns a list of all pages in the stack. The order of the pages in the
00041    * returned QList is the same as the order in which the pages were
00042    * initially added to the stack. */
00043   QList<ConfigPage *> pages() const;
00044 
00045 public slots:
00046   /** Displays the page associated with the activated action. */
00047   void showPage(QAction *pageAction);
00048   
00049 private:
00050   /** Maps an action to a config page. */
00051   QHash<QAction*, ConfigPage*> _pages;
00052 };
00053 
00054 #endif
00055