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(this, 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*)));
connect(m_listPage, SIGNAL(clearFilter()), m_filterPage, SLOT(clearFilter()));
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)
{
#if !(defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5))
menuBar()->setVisible(false);
#endif
m_editorPage->setCurrentContact(m_manager, contactId);
m_stackedWidget->setCurrentIndex(1);
}
void PhoneBook::activateList(const QContactFilter& filter)
{
#if !(defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5))
menuBar()->setVisible(true);
#endif
m_currentFilter = filter;
activateList();
}
void PhoneBook::activateList()
{
#if !(defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5))
menuBar()->setVisible(true);
#endif
m_listPage->rebuildList(m_currentFilter);
m_stackedWidget->setCurrentIndex(0);
}
void PhoneBook::activateFind()
{
#if !(defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5))
menuBar()->setVisible(false);
#endif
m_stackedWidget->setCurrentIndex(2);
}
void PhoneBook::managerChanged(QContactManager *manager)
{
m_manager = manager;
m_editorPage->setCurrentContact(m_manager, 0);
}
[+] Documentation Feedback