/*! \brief Constructor */ MyLocalDirPanel::MyLocalDirPanel(QWidget * parent) : XLet(parent) { setTitle( tr("Personal Directory") ); m_searchBox = new SearchDialog(this); connect(m_searchBox, SIGNAL(findNext()), this, SLOT(findNext())); QVBoxLayout *vlayout = new QVBoxLayout(this); // button line QHBoxLayout *hlayout = new QHBoxLayout(); QPushButton *addNewBtn = new QPushButton(tr("&New Contact")); connect(addNewBtn, SIGNAL(clicked()), this, SLOT(openNewContactDialog())); hlayout->addWidget( addNewBtn ); QPushButton *exportBtn = new QPushButton(tr("&Export Contacts")); connect(exportBtn, SIGNAL(clicked()), this, SLOT(exportContacts()) ); hlayout->addWidget( exportBtn ); QPushButton *importBtn = new QPushButton(tr("&Import Contacts")); connect(importBtn, SIGNAL(clicked()), this, SLOT(importContacts()) ); hlayout->addWidget( importBtn ); QPushButton *searchBtn = new QPushButton(tr("&Search")); connect(searchBtn, SIGNAL(clicked()), m_searchBox, SLOT(show()) ); hlayout->addWidget( searchBtn ); QPushButton *removeAllBtn = new QPushButton(tr("&Remove all Contacts")); connect(removeAllBtn, SIGNAL(clicked()), this, SLOT(removeAllContacts()) ); hlayout->addWidget( removeAllBtn ); vlayout->addLayout(hlayout); m_table = new ExtendedTableWidget; m_table->setEditable( true ); QStringList columnNames; columnNames.append(tr("First Name")); columnNames.append(tr("Last Name")); columnNames.append(tr("Phone Number")); columnNames.append(tr("Email Address")); columnNames.append(tr("Company")); columnNames.append(tr("Fax Number")); columnNames.append(tr("Mobile Number")); m_table->setColumnCount(contacts_index.size()); m_table->setHorizontalHeaderLabels(columnNames); m_table->setSortingEnabled(true); vlayout->addWidget(m_table); QFile file(getSaveFile()); file.copy(getBackupFile()); loadFromFile(file); }
People::People(QWidget *parent) : XLet(parent, tr("People"), ":/images/tab-people.svg"), m_proxy_model(NULL), m_model(NULL), m_waiting_status(NULL) { this->ui.setupUi(this); m_waiting_status = new QMovie(":/images/waiting-status.gif", QByteArray(), this); m_proxy_model = new PeopleEntrySortFilterProxyModel(this); m_model = new PeopleEntryModel(this); m_proxy_model->setSourceModel(m_model); ui.entry_table->setModel(m_proxy_model); QAction *search_action = ui.menu->addAction(tr("all")); QAction *favorite_action = ui.menu->addAction(tr("favorites")); QAction *my_contacts_action = ui.menu->addAction(tr("my contacts")); connect(search_action, SIGNAL(triggered()), this, SLOT(searchMode())); connect(favorite_action, SIGNAL(triggered()), this, SLOT(favoriteMode())); connect(my_contacts_action, SIGNAL(triggered()), this, SLOT(personalContactsMode())); this->ui.menu->setSelectedAction(1); connect(m_proxy_model, SIGNAL(columnsInserted(const QModelIndex &, int, int)), ui.entry_table, SLOT(updateColumnsDelegates(const QModelIndex &, int, int))); connect(m_proxy_model, SIGNAL(columnsInserted(const QModelIndex &, int, int)), ui.entry_table, SLOT(updateColumnsVisibility(const QModelIndex &, int, int))); connect(m_model, SIGNAL(columnsInserted(const QModelIndex &, int, int)), this, SLOT(defaultColumnSort(const QModelIndex &, int, int))); connect(this->ui.entry_table, SIGNAL(favoriteToggled(const QVariantMap &)), this, SLOT(setFavoriteStatus(const QVariantMap &))); connect(this->ui.entry_table, SIGNAL(deletePersonalContactClicked(const QVariantMap &)), this, SLOT(deletePersonalContact(const QVariantMap &))); connect(this->ui.entry_table, SIGNAL(editPersonalContactClicked(const QVariantMap &)), this, SLOT(requestEditPersonalContact(const QVariantMap &))); connect(this->ui.entry_filter, SIGNAL(textChanged(const QString &)), this, SLOT(schedulePeopleLookup(const QString &))); connect(this->ui.entry_filter, SIGNAL(returnPressed()), this, SLOT(searchPeople())); connect(this->ui.new_contact_button, SIGNAL(clicked()), this, SLOT(openNewContactDialog())); connect(this->ui.import_button, SIGNAL(clicked()), this, SLOT(openImportDialog())); connect(this->ui.export_button, SIGNAL(clicked()), this, SLOT(requestExportPersonalContacts())); connect(this->ui.purge_contacts_button, SIGNAL(clicked()), this, SLOT(purgePersonalContacts())); connect(signal_relayer, SIGNAL(numberSelectionRequested()), this, SLOT(numberSelectionRequested())); connect(this->ui.entry_filter, SIGNAL(returnPressed()), this, SLOT(focusEntryTable())); connect(&m_lookup_timer, SIGNAL(timeout()), this, SLOT(searchPeople())); m_lookup_timer.setSingleShot(true); m_lookup_timer.setInterval(delay_before_lookup); connect(&m_failure_timer, SIGNAL(timeout()), this, SLOT(setFailureStatus())); m_failure_timer.setSingleShot(true); m_failure_timer.setInterval(delay_before_failure); connect(&m_before_waiting_timer, SIGNAL(timeout()), this, SLOT(setWaitingStatus())); m_before_waiting_timer.setSingleShot(true); m_before_waiting_timer.setInterval(delay_before_waiting); b_engine->sendJsonCommand(MessageFactory::getPeopleHeaders()); b_engine->sendJsonCommand(MessageFactory::getRelations()); this->registerListener("people_headers_result"); this->registerListener("people_search_result"); this->registerListener("relations"); this->registerListener("agent_status_update"); this->registerListener("endpoint_status_update"); this->registerListener("user_status_update"); this->registerListener("people_favorite_update"); this->registerListener("people_favorites_result"); this->registerListener("people_export_personal_contacts_csv_result"); this->registerListener("people_import_personal_contacts_csv_result"); this->registerListener("people_personal_contact_created"); this->registerListener("people_personal_contact_deleted"); this->registerListener("people_personal_contact_raw_result"); this->registerListener("people_personal_contact_raw_update"); this->registerListener("people_personal_contacts_purged"); this->registerListener("people_personal_contacts_result"); if (PeoplePersonalMigration::needMigration()) { PeoplePersonalMigration::noticeAndMigratePersonalContacts(this); } }