void ContactDetails::init( const QContact &entry ) { // If we redisplay the same entry, don't shift our view around too much bool sameEntry = (entry.uid() == ent.uid()); ent = entry; mLink.clear(); /* Create our members, if we haven't */ if ( !mModel ) { mModel = new QContactModel(this); connect(mModel, SIGNAL(modelReset()), this, SLOT(modelChanged())); mTabs = new QTabWidget(); mQuickTab = new ContactOverview(0); mDetailsTab = new ContactBrowser(0); #if defined(QTOPIA_TELEPHONY) mCallHistoryTab = new ContactCallHistoryList(0); #endif mMessageHistoryTab = new ContactMessageHistoryList(0); mTabs->addTab(mQuickTab, QIcon(":icon/contactdetails"), tr("Overview")); mTabs->addTab(mDetailsTab, QIcon(":icon/details"), tr("Details")); #if defined(QTOPIA_TELEPHONY) mTabs->addTab(mCallHistoryTab, QIcon(":icon/phone/calls"), tr("Calls")); #endif mTabs->addTab(mMessageHistoryTab, QIcon(":icon/email"), tr("Messages")); connect(mQuickTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mQuickTab, SIGNAL(backClicked()), this, SIGNAL(backClicked())); connect(mDetailsTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mDetailsTab, SIGNAL(backClicked()), this, SIGNAL(backClicked())); #if defined(QTOPIA_TELEPHONY) connect(mCallHistoryTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mCallHistoryTab, SIGNAL(backClicked()), this, SIGNAL(backClicked())); #endif connect(mMessageHistoryTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mMessageHistoryTab, SIGNAL(backClicked()), this, SIGNAL(backClicked())); connect(mQuickTab, SIGNAL(callContact()), this, SIGNAL(callContact())); connect(mQuickTab, SIGNAL(textContact()), this, SIGNAL(textContact())); connect(mQuickTab, SIGNAL(emailContact()), this, SIGNAL(emailContact())); connect(mQuickTab, SIGNAL(editContact()), this, SIGNAL(editContact())); connect(mDetailsTab, SIGNAL(highlighted(QString)), this, SIGNAL(highlighted(QString))); QVBoxLayout *v = new QVBoxLayout(); v->addWidget(mTabs); v->setMargin(0); setLayout(v); } modelChanged(); if (!sameEntry) mTabs->setCurrentIndex(0); mTabs->currentWidget()->setFocus(); }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent), ui(new Ui::AddressBook) { ui->setupUi(this); ui->nameLine->setReadOnly(true); ui->addressText->setReadOnly(true); ui->submitButton->hide(); ui->cancelButton->hide(); ui->nextButton->setEnabled(false); ui->previousButton->setEnabled(false); ui->editButton->setEnabled(false); ui->removeButton->setEnabled(false); connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(ui->previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); //! [signal slot] connect(ui->findButton, SIGNAL(clicked()), this, SLOT(findContact())); //! [signal slot] setWindowTitle(tr("Simple Address Book")); }
ContactWidgetItem::ContactWidgetItem(const Akonadi::Item & item, QGraphicsWidget * parent) : Plasma::Frame(parent), m_edit(0), m_show(false), m_info(false) { m_item = item; KABC::Addressee addressee = m_item.payload<KABC::Addressee>(); m_addressee = new KABC::Addressee(addressee); m_mainLayout = new QGraphicsLinearLayout(Qt::Vertical, this); m_mainLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_edit = new Plasma::PushButton(this); m_edit->setMinimumHeight(25); m_edit->setMaximumHeight(25); m_edit->setText(i18n("Edit")); m_edit->hide(); m_icon = new Plasma::IconWidget(this); m_icon->setOrientation(Qt::Horizontal); m_icon->setDrawBackground(true); m_icon->setMinimumSize(250, 50); m_icon->setMaximumHeight(50); setContactIcon(); m_mainLayout->addItem(m_icon); setFrameShadow(Plasma::Frame::Raised); setLayout(m_mainLayout); QGraphicsOpacityEffect * effect = new QGraphicsOpacityEffect(this); effect->setOpacity(1); setGraphicsEffect(effect); m_animation = new QPropertyAnimation(effect, "opacity", effect); m_animation->setStartValue(0); m_animation->setEndValue(1); m_animation->setDuration(300); connect(m_animation, SIGNAL(finished()), this, SLOT(doHide())); connect(m_icon, SIGNAL(clicked()), SLOT(showContactInfo())); connect(m_edit, SIGNAL(clicked()), SLOT(editContact())); }
int Contacts::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: on_actionButton_clicked(); break; case 1: on_listWidget_itemClicked((*reinterpret_cast< QListWidgetItem*(*)>(_a[1]))); break; case 2: on_backButton_clicked(); break; case 3: addContact(); break; case 4: deleteContact(); break; case 5: loadPhoneContacts(); break; case 6: editContact(); break; case 7: aboutapp(); break; case 8: exitapp(); break; default: ; } _id -= 9; } return _id; }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent) { QLabel *nameLabel = new QLabel(tr("Name:")); nameLine = new QLineEdit; nameLine->setReadOnly(true); QLabel *addressLabel = new QLabel(tr("Address:")); addressText = new QTextEdit; addressText->setReadOnly(true); addButton = new QPushButton(tr("&Add")); editButton = new QPushButton(tr("&Edit")); editButton->setEnabled(false); removeButton = new QPushButton(tr("&Remove")); removeButton->setEnabled(false); findButton = new QPushButton(tr("&Find")); findButton->setEnabled(false); submitButton = new QPushButton(tr("&Submit")); submitButton->hide(); cancelButton = new QPushButton(tr("&Cancel")); cancelButton->hide(); nextButton = new QPushButton(tr("&Next")); nextButton->setEnabled(false); previousButton = new QPushButton(tr("&Previous")); previousButton->setEnabled(false); loadButton = new QPushButton(tr("&Load...")); //! [tooltip 1] loadButton->setToolTip(tr("Load contacts from a file")); //! [tooltip 1] saveButton = new QPushButton(tr("&Save...")); //! [tooltip 2] saveButton->setToolTip(tr("Save contacts to a file")); //! [tooltip 2] saveButton->setEnabled(false); dialog = new FindDialog; connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); connect(editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); connect(findButton, SIGNAL(clicked()), this, SLOT(findContact())); connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile())); connect(saveButton, SIGNAL(clicked()), this, SLOT(saveToFile())); QVBoxLayout *buttonLayout1 = new QVBoxLayout; buttonLayout1->addWidget(addButton); buttonLayout1->addWidget(editButton); buttonLayout1->addWidget(removeButton); buttonLayout1->addWidget(findButton); buttonLayout1->addWidget(submitButton); buttonLayout1->addWidget(cancelButton); buttonLayout1->addWidget(loadButton); buttonLayout1->addWidget(saveButton); buttonLayout1->addStretch(); QHBoxLayout *buttonLayout2 = new QHBoxLayout; buttonLayout2->addWidget(previousButton); buttonLayout2->addWidget(nextButton); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(nameLabel, 0, 0); mainLayout->addWidget(nameLine, 0, 1); mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop); mainLayout->addWidget(addressText, 1, 1); mainLayout->addLayout(buttonLayout1, 1, 2); mainLayout->addLayout(buttonLayout2, 2, 1); setLayout(mainLayout); setWindowTitle(tr("Simple Address Book")); }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent) { QLabel *nameLabel = new QLabel(tr("Name:")); nameLine = new QLineEdit; nameLine->setReadOnly(true); QLabel *addressLabel = new QLabel(tr("Address:")); addressText = new QTextEdit; addressText->setReadOnly(true); addButton = new QPushButton(tr("&Add")); //! [edit and remove buttons] editButton = new QPushButton(tr("&Edit")); editButton->setEnabled(false); removeButton = new QPushButton(tr("&Remove")); removeButton->setEnabled(false); //! [edit and remove buttons] submitButton = new QPushButton(tr("&Submit")); submitButton->hide(); cancelButton = new QPushButton(tr("&Cancel")); cancelButton->hide(); nextButton = new QPushButton(tr("&Next")); nextButton->setEnabled(false); previousButton = new QPushButton(tr("&Previous")); previousButton->setEnabled(false); connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); //! [connecting edit and remove] connect(editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); //! [connecting edit and remove] connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(previousButton, SIGNAL(clicked()), this, SLOT(previous())); QVBoxLayout *buttonLayout1 = new QVBoxLayout; buttonLayout1->addWidget(addButton); //! [adding edit and remove to the layout] buttonLayout1->addWidget(editButton); buttonLayout1->addWidget(removeButton); //! [adding edit and remove to the layout] buttonLayout1->addWidget(submitButton); buttonLayout1->addWidget(cancelButton); buttonLayout1->addStretch(); QHBoxLayout *buttonLayout2 = new QHBoxLayout; buttonLayout2->addWidget(previousButton); buttonLayout2->addWidget(nextButton); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(nameLabel, 0, 0); mainLayout->addWidget(nameLine, 0, 1); mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop); mainLayout->addWidget(addressText, 1, 1); mainLayout->addLayout(buttonLayout1, 1, 2); mainLayout->addLayout(buttonLayout2, 2, 1); setLayout(mainLayout); setWindowTitle(tr("Simple Address Book")); }
void ContactDetails::init( const QContact &entry ) { // If we redisplay the same entry, don't shift our view around too much bool sameEntry = (entry.uid() == ent.uid()); ent = entry; mLink.clear(); // We create tabs for each addressbook detail view plugin // We ask them if they want to be shown for this contact (or they can // just hide themselves in the init function) // they need to provide certain actions // and signals // maybe a view factory plugin // returns view plugins for list, details? // maybe string, maybe enum /* Create our members, if we haven't */ if ( !mModel ) { mModel = new QContactModel(this); connect(mModel, SIGNAL(modelReset()), this, SLOT(modelChanged())); mTabs = new QTabWidget(); mQuickTab = new ContactOverview(0); mDetailsTab = new ContactBrowser(0); #if defined(QTOPIA_TELEPHONY) mCallHistoryTab = new ContactCallHistoryList(0); #endif mMessageHistoryTab = new ContactMessageHistoryList(0); mTabs->addTab(mQuickTab, QIcon(":icon/contactdetails"), tr("Overview")); mTabs->addTab(mDetailsTab, QIcon(":icon/details"), tr("Details")); #if defined(QTOPIA_TELEPHONY) mTabs->addTab(mCallHistoryTab, QIcon(":icon/phone/calls"), tr("Calls")); #endif mTabs->addTab(mMessageHistoryTab, QIcon(":icon/email"), tr("Messages")); connect(mQuickTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mQuickTab, SIGNAL(closeView()), this, SIGNAL(closeView())); connect(mDetailsTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mDetailsTab, SIGNAL(closeView()), this, SIGNAL(closeView())); #if defined(QTOPIA_TELEPHONY) connect(mCallHistoryTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mCallHistoryTab, SIGNAL(closeView()), this, SIGNAL(closeView())); #endif connect(mMessageHistoryTab, SIGNAL(externalLinkActivated()), this, SIGNAL(externalLinkActivated())); connect(mMessageHistoryTab, SIGNAL(closeView()), this, SIGNAL(closeView())); connect(mQuickTab, SIGNAL(callContact()), this, SIGNAL(callContact())); connect(mQuickTab, SIGNAL(textContact()), this, SIGNAL(textContact())); connect(mQuickTab, SIGNAL(emailContact()), this, SIGNAL(emailContact())); connect(mQuickTab, SIGNAL(editContact()), this, SIGNAL(editContact())); connect(mDetailsTab, SIGNAL(highlighted(QString)), this, SIGNAL(highlighted(QString))); QVBoxLayout *v = new QVBoxLayout(); v->addWidget(mTabs); v->setMargin(0); setLayout(v); } modelChanged(); if (!sameEntry) mTabs->setCurrentIndex(0); mTabs->currentWidget()->setFocus(); }
AddressBook::AddressBook(QWidget *parent) : QWidget(parent) { QLabel *nameLabel = new QLabel(tr("Имя:")); // создаем объект QLabel nameLabel (поле ввода имени) nameLine = new QLineEdit; nameLine->setReadOnly(true); // устанавливаем в режим только для чтения QLabel *addressLabel = new QLabel(tr("Адрес:")); // создаем объект QLabel addressLabel (поле ввода адреса) addressText = new QTextEdit; addressText->setReadOnly(true); // устанавливаем в режим только для чтения addButton = new QPushButton(tr("&Добавить")); // создаем экземпляр кнопоки addButton->show(); // устанавливаем ее отображение на экране после вызова функции show submitButton = new QPushButton(tr("&Принять")); // создаем экземпляр кнопоки submitButton->hide(); // устанавливаем ее отображение на экране после вызова функции hide(после нажатия кнопки "Add") cancelButton = new QPushButton(tr("&Отмена")); // создаем экземпляр кнопоки cancelButton->hide(); // устанавливаем ее отображение на экране после вызова функции hide(после нажатия кнопки "Add") nextButton = new QPushButton(tr("&Следующий")); // создаем экземпляр кнопки nextButton->setEnabled(false); // отключаем ее previousButton = new QPushButton(tr("&Предыдущий")); previousButton->setEnabled(false); editButton = new QPushButton(tr("&Изменить")); editButton->setEnabled(false); removeButton = new QPushButton(tr("&Удалить")); removeButton->setEnabled(false); findButton = new QPushButton(tr("&Найти")); findButton->setEnabled(false); loadButton = new QPushButton(tr("&Загрузить...")); loadButton->setToolTip(tr("Загрузка контактов из файла")); saveButton = new QPushButton(tr("&Сохранить...")); saveButton->setToolTip(tr("Сохранить контакты в файл")); saveButton->setEnabled(false); cloudButton = new QPushButton(tr("&Хранилище")); cloudButton->setEnabled(false); webView = new QWebView; dialog = new finddialog; // создаем объект (для отображения) connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); // connect(submitButton, SIGNAL(clicked()), this, SLOT(submitContact())); // Соединяем кнопки с соответствующими им слотами (при нажатии срабатывает SLOT, который вызывает функцию) connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); // connect(nextButton, SIGNAL(clicked()), this, SLOT(next())); connect(previousButton, SIGNAL(clicked()), this, SLOT(previous())); connect(editButton, SIGNAL(clicked()), this, SLOT(editContact())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeContact())); connect(findButton, SIGNAL(clicked()), this, SLOT(findContact())); connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile())); connect(saveButton, SIGNAL(clicked()), this, SLOT(saveToFile())); connect(cloudButton, SIGNAL(clicked()), this, SLOT(cloudStorage())); QVBoxLayout *buttonLayout1 = new QVBoxLayout; // Вертикальное расположение кнопок buttonLayout1->addWidget(addButton, Qt::AlignTop); // Расположение кнопок виджета buttonLayout1->addWidget(submitButton); // buttonLayout1->addWidget(cancelButton); // buttonLayout1->addWidget(editButton); buttonLayout1->addWidget(removeButton); buttonLayout1->addWidget(findButton); buttonLayout1->addWidget(loadButton); buttonLayout1->addWidget(saveButton); buttonLayout1->addWidget(cloudButton); buttonLayout1->addStretch(); // чтобы расположить кнопки ближе к верхней части виджета QHBoxLayout *buttonLayout2 = new QHBoxLayout; // Горизонтальное расположение кнопок buttonLayout2->addWidget(previousButton); buttonLayout2->addWidget(nextButton); QGridLayout *mainLayout = new QGridLayout; // Табличное размещение (таблица состоит из ячеек, позиции которых задаютсяф строками и столбцами) mainLayout->addWidget(nameLabel, 0, 0); // поле ввода имени (в верхнем правом углу) mainLayout->addWidget(nameLine, 0, 1); mainLayout->addWidget(addressLabel, 1, 0, Qt::AlignTop); // Qt::AllignTop дополнительный параметр, который отвечает за расположение (чтобы поле располагалось не по центру) mainLayout->addWidget(addressText, 1, 1); mainLayout->addLayout(buttonLayout1, 1, 2); mainLayout->addLayout(buttonLayout2, 2, 1); setLayout(mainLayout); // вызывает компоновку виджета setWindowTitle(tr("Адресная книга")); // название заголовка виджета }