|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "phonebook.h" |
|
43 #include "contactlistpage.h" |
|
44 #include "contacteditor.h" |
|
45 #include "filterpage.h" |
|
46 |
|
47 #include <QtGui> |
|
48 |
|
49 PhoneBook::PhoneBook(QWidget *parent) |
|
50 : QMainWindow(parent) |
|
51 { |
|
52 QWidget *centralWidget = new QWidget(this); |
|
53 |
|
54 m_editorPage = new ContactEditor(centralWidget); |
|
55 connect(m_editorPage, SIGNAL(showListPage()), this, SLOT(activateList())); |
|
56 |
|
57 m_filterPage = new FilterPage(centralWidget); |
|
58 connect(m_filterPage, SIGNAL(showListPage(QContactFilter)), this, SLOT(activateList(QContactFilter))); |
|
59 |
|
60 m_listPage = new ContactListPage(centralWidget); |
|
61 connect(m_listPage, SIGNAL(showEditorPage(QContactLocalId)), this, SLOT(activateEditor(QContactLocalId))); |
|
62 connect(m_listPage, SIGNAL(showFilterPage(QContactFilter)), this, SLOT(activateFind())); |
|
63 connect(m_listPage, SIGNAL(managerChanged(QContactManager*)), this, SLOT(managerChanged(QContactManager*))); |
|
64 |
|
65 m_stackedWidget = new QStackedWidget(centralWidget); |
|
66 m_stackedWidget->addWidget(m_listPage); |
|
67 m_stackedWidget->addWidget(m_editorPage); |
|
68 m_stackedWidget->addWidget(m_filterPage); |
|
69 m_stackedWidget->setCurrentIndex(0); |
|
70 |
|
71 QVBoxLayout *centralLayout = new QVBoxLayout; |
|
72 centralLayout->addWidget(m_stackedWidget); |
|
73 centralWidget->setLayout(centralLayout); |
|
74 |
|
75 setCentralWidget(centralWidget); |
|
76 } |
|
77 |
|
78 PhoneBook::~PhoneBook() |
|
79 { |
|
80 } |
|
81 |
|
82 void PhoneBook::activateEditor(QContactLocalId contactId) |
|
83 { |
|
84 m_editorPage->setCurrentContact(m_manager, contactId); |
|
85 m_stackedWidget->setCurrentIndex(1); // list = 0, editor = 1, find = 2. |
|
86 } |
|
87 |
|
88 void PhoneBook::activateList(const QContactFilter& filter) |
|
89 { |
|
90 m_currentFilter = filter; |
|
91 activateList(); // call base now. |
|
92 } |
|
93 |
|
94 void PhoneBook::activateList() |
|
95 { |
|
96 m_listPage->rebuildList(m_currentFilter); |
|
97 m_stackedWidget->setCurrentIndex(0); // list = 0, editor = 1, find = 2. |
|
98 } |
|
99 |
|
100 void PhoneBook::activateFind() |
|
101 { |
|
102 m_stackedWidget->setCurrentIndex(2); // list = 0, editor = 1, find = 2. |
|
103 } |
|
104 |
|
105 void PhoneBook::managerChanged(QContactManager *manager) |
|
106 { |
|
107 m_manager = manager; |
|
108 m_editorPage->setCurrentContact(m_manager, 0); // must reset the manager of the editor. |
|
109 } |