Vidalia
0.3.1
Main Page
Namespaces
Classes
Files
File List
File Members
src
vidalia
config
ConfigPageStack.cpp
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.cpp
13
** \brief A collection of configuration pages
14
*/
15
16
#include "
ConfigPageStack.h
"
17
18
#include <QAction>
19
20
21
/** Default constructor. */
22
ConfigPageStack::ConfigPageStack
(QWidget *parent)
23
: QStackedWidget(parent)
24
{
25
}
26
27
/** Adds a page to the stack. */
28
void
29
ConfigPageStack::add
(
ConfigPage
*page, QAction *action)
30
{
31
_pages
.insert(action, page);
32
insertWidget(count(), page);
33
}
34
35
/** Sets the current config page and checks its action. */
36
void
37
ConfigPageStack::setCurrentPage
(
ConfigPage
*page)
38
{
39
foreach
(QAction *action,
_pages
.keys(page)) {
40
action->setChecked(
true
);
41
}
42
setCurrentWidget(page);
43
}
44
45
/** Sets the current config page index and checks its action. */
46
void
47
ConfigPageStack::setCurrentIndex
(
int
index)
48
{
49
setCurrentPage
((
ConfigPage
*)widget(index));
50
}
51
52
/** Shows the config page associated with the activated action. */
53
void
54
ConfigPageStack::showPage
(QAction *pageAction)
55
{
56
setCurrentWidget(
_pages
.value(pageAction));
57
}
58
59
/** Returns a list of all pages in the stack. The order of the pages in the
60
* returned QList is the same as the order in which the pages were initially
61
* added to the stack. */
62
QList<ConfigPage *>
63
ConfigPageStack::pages
()
const
64
{
65
QList<ConfigPage *>
pages
;
66
for
(
int
i
= 0;
i
< count();
i
++)
67
pages << dynamic_cast<ConfigPage *>(widget(
i
));
68
return
pages
;
69
}
70
Generated on Mon Jan 14 2013 08:44:27 for Vidalia by
1.8.3