00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file configpagestack.cpp 00024 * \version $Id: configpagestack.cpp 1238 2006-09-25 17:50:57Z edmanm $ 00025 * \brief A collection of configuration pages 00026 */ 00027 00028 #include <QAction> 00029 #include "configpagestack.h" 00030 00031 /** Default constructor. */ 00032 ConfigPageStack::ConfigPageStack(QWidget *parent) 00033 : QStackedWidget(parent) 00034 { 00035 } 00036 00037 /** Adds a page to the stack. */ 00038 void 00039 ConfigPageStack::add(ConfigPage *page, QAction *action) 00040 { 00041 _pages.insert(action, page); 00042 insertWidget(count(), page); 00043 } 00044 00045 /** Sets the current config page and checks its action. */ 00046 void 00047 ConfigPageStack::setCurrentPage(ConfigPage *page) 00048 { 00049 foreach (QAction *action, _pages.keys(page)) { 00050 action->setChecked(true); 00051 } 00052 setCurrentWidget(page); 00053 } 00054 00055 /** Sets the current config page index and checks its action. */ 00056 void 00057 ConfigPageStack::setCurrentIndex(int index) 00058 { 00059 setCurrentPage((ConfigPage *)widget(index)); 00060 } 00061 00062 /** Shows the config page associated with the activated action. */ 00063 void 00064 ConfigPageStack::showPage(QAction *pageAction) 00065 { 00066 setCurrentWidget(_pages.value(pageAction)); 00067 } 00068