phonebook.cpp Example File
samplephonebook/phonebook.cpp
#include "phonebook.h"
#include "contactlistpage.h"
#include "contacteditor.h"
#include "filterpage.h"
#include <QtGui>
PhoneBook::PhoneBook(QWidget *parent)
: QMainWindow(parent)
{
QWidget *centralWidget = new QWidget(this);
m_editorPage = new ContactEditor(centralWidget);
connect(m_editorPage, SIGNAL(showListPage()), this, SLOT(activateList()));
m_filterPage = new FilterPage(centralWidget);
connect(m_filterPage, SIGNAL(showListPage(QContactFilter)), this, SLOT(activateList(QContactFilter)));
m_listPage = new ContactListPage(centralWidget);
connect(m_listPage, SIGNAL(showEditorPage(QContactLocalId)), this, SLOT(activateEditor(QContactLocalId)));
connect(m_listPage, SIGNAL(showFilterPage(QContactFilter)), this, SLOT(activateFind()));
connect(m_listPage, SIGNAL(managerChanged(QContactManager*)), this, SLOT(managerChanged(QContactManager*)));
m_stackedWidget = new QStackedWidget(centralWidget);
m_stackedWidget->addWidget(m_listPage);
m_stackedWidget->addWidget(m_editorPage);
m_stackedWidget->addWidget(m_filterPage);
m_stackedWidget->setCurrentIndex(0);
QVBoxLayout *centralLayout = new QVBoxLayout;
centralLayout->addWidget(m_stackedWidget);
centralWidget->setLayout(centralLayout);
setCentralWidget(centralWidget);
}
PhoneBook::~PhoneBook()
{
}
void PhoneBook::activateEditor(QContactLocalId contactId)
{
m_editorPage->setCurrentContact(m_manager, contactId);
m_stackedWidget->setCurrentIndex(1);
}
void PhoneBook::activateList(const QContactFilter& filter)
{
m_currentFilter = filter;
activateList();
}
void PhoneBook::activateList()
{
m_listPage->rebuildList(m_currentFilter);
m_stackedWidget->setCurrentIndex(0);
}
void PhoneBook::activateFind()
{
m_stackedWidget->setCurrentIndex(2);
}
void PhoneBook::managerChanged(QContactManager *manager)
{
m_manager = manager;
m_editorPage->setCurrentContact(m_manager, 0);
}
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) |
Trademarks |
Qt Mobility Project 1.0.0 |