void MainWindow::createChatWindow() { if (!roster->size()) { QMaemo5InformationBox::information(this,"Contacts haven't been synchronized yet.", QMaemo5InformationBox::NoTimeout); } else { SelectContactDialog selectContactDialog(roster->getContactList(),this); connect(&selectContactDialog,SIGNAL(showContactInfo(Contact*)), this,SLOT(viewContact(Contact*))); connect(&selectContactDialog,SIGNAL(deleteContact(QString)), roster,SLOT(deleteContact(QString))); if (selectContactDialog.exec() == QDialog::Accepted) { Contact& contact = selectContactDialog.getSelectedContact(); createChatWindow(contact, true); } } }
int main(void) { int key; init(); while(1) { printf("\n 1.Add New Contact\n"); printf("\n 2.Find Contact\n"); printf("\n 3.Delete Contact\n"); printf("\n 3.Update Contact\n"); printf("\n Enter the choice\n"); scanf("%d",&key); switch(key) { case 1: addContact(); break; case 2: { char *p ="123"; Contact *a = findContact(p); if(a) { printf("%s \n %s\n%s \n%s",a->firstName,a->secondName,a->firstNumber,a->secondNumber); } break; } case 3: deleteContact(); break; case 4: updateContact(); break; case 0: default: { close(); printf("\n : Exitting\n"); } return 0; } } return 0; }
ContactList::ContactList(QWidget *parent) : QDialog(parent) { setWindowTitle("Legg til kontakt"); // Initializing Layouts hBoxLayout = new QHBoxLayout(this); gridLayout = new QGridLayout(); // Initializing widgets listWidget = new QListWidget(); textLine = new QLineEdit(); textLine->setPlaceholderText("Navn"); btnOk = new QPushButton("Lagre"); btnCancel = new QPushButton("Lukk"); btnDelete = new QPushButton("Slett"); // Adding and placing Widgets to the grid hBoxLayout->addWidget(listWidget); // Adder gridLayout i HBoxLayout hBoxLayout->addLayout(gridLayout); // Adding widgets to gridlayout gridLayout->addWidget(textLine, 0, 3, 1, 2, Qt::AlignRight); gridLayout->addWidget(btnOk, 3, 4, 1, 1, Qt::AlignRight); gridLayout->addWidget(btnCancel, 3, 3, 1, 1, Qt::AlignRight); gridLayout->addWidget(btnDelete, 4, 3, 1, 1, Qt::AlignLeft); // Connecting button connect(btnCancel, SIGNAL(clicked()), this, SLOT(close())); connect(btnOk, SIGNAL(clicked()), this, SLOT(makeNewContact())); connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteContact())); // Autmatisk justerer størrelsen på dialogboksen. adjustSize(); }
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; }
void GatewayTask::slotSubscription(const XMPP::Presence& p) { QString legacyNode = p.to().node(); if ( !p.to().node().isEmpty() ) { Jid user = p.from(); switch ( p.type() ) { case Presence::Subscribe: emit addContact(user, legacyNode); break; case Presence::Unsubscribe: emit deleteContact(user, legacyNode); break; case Presence::Subscribed: emit grantAuth(user, legacyNode); break; case Presence::Unsubscribed: emit denyAuth(user, legacyNode); break; default: break; } } }
int main () { int menuOption; contactList contactList; char name[40]; char phone_number[9]; char *email; char *mail; contactList.head=NULL; do { printf("(1) Find Contact by name\n"); printf("(2) Find Contact by phone number\n"); printf("(3) Show all contacts\n"); printf("(4) Modify Contact information\n"); printf("(5) Add contact\n"); printf("(6) Delete contact\n"); printf("(7) Load contacts from file\n"); printf("(8) Quit\n"); scanf("%d", &menuOption); fflush(stdin); switch (menuOption) { case 1: printf("Enter name: \n"); scanf(" %[^\n]s", name); findName(&contactList, name); break; case 2: printf("Enter phone number: \n"); scanf("%s", phone_number); findNumber(&contactList, phone_number); break; case 3: showAllContact(&contactList); break; case 4: printf("Enter name: \n"); scanf(" %[^\n]s", name); modifyContact(&contactList, name); break; case 5: printf("Please enter name: "); scanf(" %[^\n]s", name); printf("Please enter phone number: "); scanf(" %[^\n]s", phone_number); printf("Please enter email address: "); email = getAddress(); fflush(stdin); printf("Please enter mail address: "); mail = getAddress(); fflush(stdin); addContact(&contactList, name, phone_number, email, mail); break; case 6: printf("Enter name: \n"); scanf(" %[^\n]s", name); deleteContact(&contactList,name); break; case 7: loadFile(&contactList); break; case 8: printf("Bye Bye!"); break; } }while(menuOption != 8); return 0; }
// Main function: Program execution begins. main() { /* Phonebook points to (the first element) of an array of structures * of ContactType. Each element of the array contains all the * information for one record: first name, last name, and phone * number. Integer variables iLength and iCapacity each contain * information about the array. iCapacity indicates the number of * entries which can be stored according to current memory allocation; * when iCapacity = 5, then no more than 5 records can be stored. * iLength indicates the number of records that are currently stored. * (Therefore, the last element in the array is indexed by iLength - 1.) */ ContactType *PhoneBook; int iLength = 0; int iCapacity = 0; /* PhoneBook is allocated enough memory to match its current listed * capacity. Of course, here, the listed capacity is 0, so PhoneBook * is not assigned any memory according to the calloc function. This * assignment is included for form's sake, to match the free(PhoneBook) * statement at the end of the main() function. Adhering to the form * of matching memory allocation and memory freeing will ensure careful * programming. */ PhoneBook = (ContactType *) calloc(iCapacity, sizeof(ContactType)); /* cUserChoice will take on the value of the user's main menu choice. * The following loop will continue to execute until the user chooses * to exit. The constant identifier cLastChoice contains the character * representing the last available choice ('Exit'). If the program * is modified to accommodate a larger or smaller menu, this constant * can be changed conveniently. */ char cUserChoice = '\0'; const char cLastChoice = '9'; do { // The menu is displayed and the user enters her choice. printMainMenu (); getChoice (&cUserChoice, cLastChoice); // The appropriate function is called. switch (cUserChoice) { case '1': showAllContacts (PhoneBook, &iLength); break; case '2': addContact (&PhoneBook, &iLength, &iCapacity); break; case '3': findContact (PhoneBook, &iLength); break; case '4': getRandomContact (PhoneBook, &iLength); break; case '5': deleteContact (PhoneBook, &iLength); break; case '6': deleteAllContacts (&iLength, &iCapacity); break; case '7': saveContactsToFile (PhoneBook, &iLength); break; case '8': loadContactsFromFile (&PhoneBook, &iLength, &iCapacity); break; } // The application continues until the user chooses to exit. } while (cUserChoice != cLastChoice); // Freeing allocated memory. free (PhoneBook); printf ("\nGoodbye!\n\n"); }
/** * @author Macai * @connect signal and slot * @brief MainWindow::setActions */ void MainWindow::setActions() { connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(close()) ); connect(ui->action_Add, SIGNAL(triggered()), this, SLOT(showAddContactDlg()) ); connect(ui->action_Delete, SIGNAL(triggered()), this, SLOT(deleteContact()) ); connect(ui->action_Edit, SIGNAL(triggered()), this, SLOT(showEditContactDlg()) ); connect(ui->action_Query, SIGNAL(triggered()), this, SLOT(showFindWidget()) ); connect(ui->action_Favorites, SIGNAL(triggered()), this, SLOT(addFavourite()) ); connect(ui->action_Details, SIGNAL(triggered()), this, SLOT(showDetailDlg()) ); connect(ui->action_Settings, SIGNAL(triggered()), this, SLOT(showSettingDlg()) ); connect(ui->action_About, SIGNAL(triggered()), this, SLOT(showAboutDlg()) ); connect(ui->menu_Background, SIGNAL(triggered(QAction*)), this, SLOT(backgroundChanged(QAction*)) ); connect(ui->menu_Backmusic, SIGNAL(triggered(QAction*)), this, SLOT(backmusicChanged(QAction*)) ); connect(Global::g_settingThemes, SIGNAL(setMainWinBackground(QString)), this, SLOT(setBackground(QString)) ); connect(Global::g_settingThemes, SIGNAL(setMainWinFontColor(int,int,int)), this, SLOT(updateFontColor(int,int,int)) ); connect(ui->btn_findBtn, SIGNAL(clicked(bool)), this, SLOT(findContact(bool)) ); connect(ui->grouplistWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(filterGroup(QListWidgetItem*, QListWidgetItem*)) ); connect(ui->grouplistWidget, SIGNAL(updateGroupContacts(const QString&)), this, SLOT(updateGroupContacts(const QString&)) ); connect(ui->contactTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(showDetail(QModelIndex)) ); connect(ui->contactTableView, SIGNAL(updateButton(bool)), this, SLOT(updateButton(bool)) ); connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabWidgetChanged(int)) ); connect(ui->favoritTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(showDetail(QModelIndex)) ); connect(ui->favoritTableView, SIGNAL(updateButton(bool)), this, SLOT(updateButton(bool)) ); connect(ui->favoritTableView, SIGNAL(findContactAct()), this, SLOT(showFindWidget()) ); connect(ui->favoritTableView, SIGNAL(deleteContactAct()), this, SLOT(deleteContact()) ); connect(ui->favoritTableView, SIGNAL(sendMailAct()), this, SLOT(showDetailDlg()) ); connect(ui->favoritTableView, SIGNAL(viewDetailAct()), this, SLOT(showDetailDlg()) ); connect(ui->contactTableView, SIGNAL(addContactAct()), this, SLOT(showAddContactDlg()) ); connect(ui->contactTableView, SIGNAL(editContactAct()), this, SLOT(showEditContactDlg()) ); connect(ui->contactTableView, SIGNAL(findContactAct()), this, SLOT(showFindWidget()) ); connect(ui->contactTableView, SIGNAL(deleteContactAct()), this, SLOT(deleteContact()) ); connect(ui->contactTableView, SIGNAL(addFavouriteAct()), this, SLOT(addFavourite()) ); connect(ui->contactTableView, SIGNAL(sendMailAct()), this, SLOT(showDetailDlg()) ); connect(ui->contactTableView, SIGNAL(viewDetailAct()), this, SLOT(showDetailDlg()) ); }
AddressBook::AddressBook(QWidget *parent) : QMainWindow(parent) { // Init. de la BDD QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("addressbook.sqlite"); if(!db.open()) { // Si l'ouverture du fichier de données est impossible on le notifie à l'utilisateur et on ferme le programme QMessageBox::warning(this, "Init.", "Impossible d'accèder à la base de données.\nImpossible de lancer le programme\n"); exit(1); } // La table contient les données suivantes // id, nom, prénom, date de naissance, sexe, n° téléphone, n° téléphone portable, // n° téléphone professionnel, n° de fax, adresse e-mail, url du site internet, // adresse du domicile, ville du domicile, code postal du domicile // adresse du bureau, ville du bureau, code postal du bureau // l'id du 1er parent et du 2nd parent -- inutilisés mais dans les anciennes contraintes du programmes QSqlQuery query; query.exec("CREATE TABLE IF NOT EXISTS `addressbook` (" "`id` INTEGER PRIMARY KEY," "`lastname` TEXT NOT NULL," "`firstname` TEXT NOT NULL," "`date` TEXT ," "`gender` INTEGER ," "`phone` TEXT ," "`cellphone` TEXT ," "`prophone` TEXT ," "`fax` TEXT ," "`email` TEXT ," "`website` TEXT ," "`homeaddress` TEXT ," "`homecity` TEXT ," "`homezip` INTEGER ," "`proaddress` TEXT ," "`procity` TEXT ," "`prozip` INTEGER ," "`id_parent1` INTEGER ," "`id_parent2` INTEGER )"); // Les éléments du formulaire d'ajout/modification de contact // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREE PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // nameLine = new QLineEdit; nameLine = new QLineEdit; // Champ de saisie du prénom lastnameLine = new QLineEdit; dateLine = new QDateEdit; dateLine->setDisplayFormat("dd/MM/yyyy"); // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREE PAR "LA DOCUMENTATION QT - Line Edits Example" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/widgets-lineedits.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) /* QComboBox *validatorComboBox = new QComboBox; validatorComboBox->addItem(tr("No validator")); validatorComboBox->addItem(tr("Integer validator")); */ sexLine = new QComboBox; // Liste déroulante pour le sexe sexLine->addItem("Masculin"); sexLine->addItem("Féminin"); phoneLine = new QLineEdit; cellphoneLine = new QLineEdit; prophoneLine = new QLineEdit; faxLine = new QLineEdit; emailLine = new QLineEdit; websiteLine = new QLineEdit; // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // addressText = new QTextEdit; homeaddressLine = new QTextEdit; // Boîte de saise de l'adresse perso. homeaddressLine->setFixedHeight(48); // Définition d'une taille fixe pour la boîte de saisie pour ne pas avoir de problème lors du redimensionnement de la fenêtre homecityLine = new QLineEdit; homezipLine = new QLineEdit; proaddressLine = new QTextEdit; proaddressLine->setFixedHeight(48); procityLine = new QLineEdit; prozipLine = new QLineEdit; // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part1.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // addButton = new QPushButton(tr("&Add")); addButton = new QPushButton(tr("&Ajouter")); // Bouton pour l'ajout d'une fiche nommé "Ajouter" -- également renommé pour la modification cancelButton = new QPushButton(tr("A&nnuler")); // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE TUTORIEL CARNET D'ADRESSES QT" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/tutorials-addressbook-fr-part2.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // connect(addButton, SIGNAL(clicked()), this, SLOT(addContact())); connect(addButton, SIGNAL(clicked()), this, SLOT(submitContact())); // quand on clique sur addButton on exécute la fonction submitContact() connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); // Editeur de données. // Coordonnées pro. // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LA DOCUMENTATION QT - QFormLayout Class Reference" (disponible à l'adresse "http://doc.qt.nokia.com/4.6/qformlayout.html"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) // QFormLayout *formLayout = new QFormLayout; // formLayout->addRow(tr("&Name:"), nameLineEdit); EditorProfessionnalInfos = new QFormLayout; // Création du formulaire EditorProfessionnalInfos EditorProfessionnalInfos->addRow(tr("&Téléphone :"), prophoneLine); // Ajout de la ligne libellée "Téléphone" avec le widget prophoneLine EditorProfessionnalInfos->addRow(tr("&Fax :"), faxLine); EditorProfessionnalInfos->addRow(tr("&Adresse :"), proaddressLine); EditorProfessionnalInfos->addRow(tr("&Code postal :"), prozipLine); EditorProfessionnalInfos->addRow(tr("&Ville :"), procityLine); // Coordonnées perso. EditorPersonnalInfos = new QFormLayout; EditorPersonnalInfos->addRow(tr("&Téléphone :"), phoneLine); EditorPersonnalInfos->addRow(tr("&Portable :"), cellphoneLine); EditorPersonnalInfos->addRow(tr("&Adresse :"), homeaddressLine); EditorPersonnalInfos->addRow(tr("&Code postal :"), homezipLine); EditorPersonnalInfos->addRow(tr("&Ville :"), homecityLine); EditorPersonnalInfos->addRow(tr("&E-mail :"), emailLine); EditorPersonnalInfos->addRow(tr("&Site web :"), websiteLine); // Etat civil. EditorIdentity = new QFormLayout; EditorIdentity->addRow(tr("&Prénom :"), nameLine); EditorIdentity->addRow(tr("&Nom :"), lastnameLine); EditorIdentity->addRow(tr("&Sexe :"), sexLine); EditorIdentity->addRow(tr("&Date de naissance :"), dateLine); // /!\ CETTE (ces) LIGNE(s) (et les éventuelles lignes semblables) A (ont) ETE INSPIREEs PAR "LE SITE DU ZERO - Apprenez à programmer en C++ ! > [Pratique] Créez vos propres fenêtres avec Qt > Les principaux widgets" (disponible à l'adresse "http://www.siteduzero.com/tutoriel-3-11316-les-principaux-widgets.html#ss_part_5"). LE CODE REPRIS EST DISPONIBLE A LA (aux) LIGNE(s) SUIVANTE(s) /* QFrame *frame = new QFrame(&fenetre); frame->setFrameShape(QFrame::StyledPanel); frame->setGeometry(30, 20, 120, 90); QLineEdit *lineEdit = new QLineEdit("Entrez votre nom"); QPushButton *bouton1 = new QPushButton("Cliquez ici"); QPushButton *bouton2 = new QPushButton("Ou là..."); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(lineEdit); vbox->addWidget(bouton1); vbox->addWidget(bouton2); frame->setLayout(vbox); */ Editor = new QTabWidget(); // Création du widget à onglets Editor Editor->setGeometry(30, 20, 240, 160); // définition de la position 30,20 et de la taille 240*160 page1 = new QWidget; // Création du widget page1 - 1er onglet page1->setLayout(EditorIdentity); // Définition du contenu de page1 Editor->addTab(page1, "Identité"); // Ajout et définition du titre du 3ème onglet : "Identité" page2 = new QWidget; page2->setLayout(EditorPersonnalInfos); Editor->addTab(page2, "Coordonnées perso."); page3 = new QWidget; page3->setLayout(EditorProfessionnalInfos); Editor->addTab(page3, "Coordonnées pro."); ActionsButtons = new QHBoxLayout; // Création d'un layout horizontal pour les boutons ActionsButtons->addWidget(addButton); // Ajout du bouton addButton au layout ActionsButtons->addWidget(cancelButton); ActionsButtonsWidget = new QWidget; // Création d'un widget pour les boutons ActionsButtonsWidget->setLayout(ActionsButtons); // Définition du layout ActionsButtons au widget ActionsButtonsWidget dockLayout = new QVBoxLayout; // Création d'un layout vertical pour le dock dockLayout->addWidget(Editor); dockLayout->addWidget(ActionsButtonsWidget); DockWidget = new QWidget; // Création d'un widget pour le dock DockWidget->setLayout(dockLayout); // Définition du layout dockLayout au widget DockWidget dockInfos = new QDockWidget(tr("Informations"), this); // Création d'un widget dock de titre "Informations" addDockWidget(Qt::LeftDockWidgetArea, dockInfos); // Ajout du dock dockInfos à la gauche de la fenêtre infosLabel = new QTextBrowser(this); // Création d'un nouveau widget QTextBrowser infoLabel infosLabel->setText("<h1>Bienvenue !</h1><p>Sélectionnez un contact pour en afficher les détails ou ajoutez une nouvelle fiche au carnet d'adresses.</p>"); // Définition du contenu du QTextBrowser. Il autorise le formatage du texte avec du HTML infosLabel->setAlignment(Qt::AlignTop); // Définition de l'alignement vertical du texte : haut infosLabel->setReadOnly(1); // Définition du widget en lecture seule : il est utilisé uniquement pour l'affichage infosLabel->setOpenExternalLinks(1); // Autoriser l'ouverture des liens externes dans un navigateur infosLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); // Autoriser les liens et la sélection de texte à la souris connect(infosLabel, SIGNAL(anchorClicked(QUrl)), this, SLOT(inContextLink(QUrl))); // signal pour l'ouverture des liens internes (ancres #blabla) dockInfos->setWidget(infosLabel); dock = new QDockWidget(tr("Editeur"), this); dock->setAllowedAreas(Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea | Qt::LeftDockWidgetArea); dock->setWidget(DockWidget); addDockWidget(Qt::RightDockWidgetArea, dock); // Modèle. Objet désignant la table "addressbook" de la BDD. // Couche d'abstraction destinée à faciliter les accès, éviter les injections etc. model = new QSqlTableModel; model->setTable("addressbook"); // définition de la table traitée model->setEditStrategy(QSqlTableModel::OnManualSubmit); // stratégie d'édition du modèle (= quand on enregistre le fichier ?) - réglé sur un déclenchement manuel model->select(); // mise à jour des données (on selectionne tout) model->setHeaderData(0, Qt::Horizontal, tr("id")); // modification du titre de la colonne 0 model->setHeaderData(1, Qt::Horizontal, tr("Prénom")); model->setHeaderData(2, Qt::Horizontal, tr("Nom")); // Vue. Objet affichant le modèle // Widget proposé simplifiant les communications avec le modèle. view = new QTableView; view->setModel(model); // Définition du modèle sur model switchView(); // Appel de la fonction switchView de la classe. Elle retire la majeure partie des colonnes pour n'afficher que l'id, le nom et le prénom view->setShowGrid(0); // Ote la grille view->setEditTriggers(QAbstractItemView::NoEditTriggers); // Désactivation de l'édition au sein du tableau view->setSelectionBehavior(QAbstractItemView::SelectRows); // Permet la seule sélection d'une ligne view->setSelectionMode(QAbstractItemView::SingleSelection); // Permettre la sélection d'une seule ligne seulement view->sortByColumn(0,Qt::AscendingOrder); // Tri initial par id view->verticalHeader()->hide(); // Cache l'affichage des numéros de ligne view->setSortingEnabled(true); // Autorise le tri view->show(); // Affichage du tableau connect(view, SIGNAL(clicked(QModelIndex)), this, SLOT(retrieveContactData())); setCentralWidget(view); // défini view en tant que widget central de la fenêtre (celle de la classe) // Affichage de la barre de menu. menuFile = menuBar()->addMenu("&Fichier"); // Nouvelle barre de menu : Fichier menuitemNew = menuFile->addAction("&Nouvelle fiche"); // Nouvel élément de menu : Nouvelle fiche menuitemNew->setShortcut(QKeySequence::New); // Définition du raccourci clavier assigné à cette entrée du menu menuitemNew->setIcon(QIcon("./icons/list-add.png")); // Définition de l'icône associée à cette entrée du menu connect(menuitemNew, SIGNAL(triggered()), this, SLOT(editorClear())); menuitemDelete = menuFile->addAction("&Supprimer fiche"); menuitemDelete->setShortcut(QKeySequence::Delete); menuitemDelete->setIcon(QIcon("./icons/list-remove.png")); connect(menuitemDelete, SIGNAL(triggered()), this, SLOT(deleteContact())); menuitemExport = menuFile->addAction("&Exporter"); connect(menuitemExport, SIGNAL(triggered()), this, SLOT(csvExport())); menuitemQuit = menuFile->addAction("&Quitter"); menuitemQuit->setShortcut(QKeySequence::Quit); connect(menuitemQuit, SIGNAL(triggered()), qApp, SLOT(quit())); /* menuView = menuBar()->addMenu("&Affichage"); menuitemFullView = menuView->addAction("&Affichage complet"); menuitemFullView->setCheckable(true); connect(menuitemFullView, SIGNAL(triggered()), this, SLOT(switchView()));*/ menuHelp = menuBar()->addMenu("&Aide"); menuitemAboutapp = menuHelp->addAction("&A propos..."); connect(menuitemAboutapp, SIGNAL(triggered()), this, SLOT(aboutApp())); menuitemAboutQt = menuHelp->addAction("&A propos de Qt..."); connect(menuitemAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt())); // Affichage de la barre d'outils QToolBar *toolbar = addToolBar("Barre d'outils"); // Nouvelle barre d'outils toolbar->addAction(menuitemNew); // ajout du bouton menuitemNew à la barre (même élément que celui du menu) toolbar->addAction(menuitemDelete); quicksearchLabel = new QLabel(tr("Recherche : "),this); toolbar->addWidget(quicksearchLabel); // ajout champ de recherche quicksearchLine = new QLineEdit; toolbar->addWidget(quicksearchLine); connect(quicksearchLine, SIGNAL(textChanged(QString)), this, SLOT(updateSearch(QString))); // TODO : Trouver un titre pour cette application. setWindowTitle(tr("Swithom")); }
int rfx_remove_contact(time_t fromTime, uvast fromNode, uvast toNode) { Sdr sdr = getIonsdr(); PsmPartition ionwm = getIonwm(); IonVdb *vdb = getIonVdb(); IonCXref arg; PsmAddress cxelt; PsmAddress nextElt; PsmAddress cxaddr; IonCXref *cxref; /* Note: when the fromTime passed to ionadmin is '*' * a fromTime of zero is passed to rfx_remove_contact, * where it is interpreted as "all contacts between * these two nodes". */ memset((char *) &arg, 0, sizeof(IonCXref)); arg.fromNode = fromNode; arg.toNode = toNode; CHKERR(sdr_begin_xn(sdr)); if (fromTime) /* Not a wild-card deletion. */ { arg.fromTime = fromTime; cxelt = sm_rbt_search(ionwm, vdb->contactIndex, rfx_order_contacts, &arg, &nextElt); if (cxelt) /* Found it. */ { cxaddr = sm_rbt_data(ionwm, cxelt); deleteContact(cxaddr); } } else /* Wild-card deletion, start at time zero. */ { while (1) { /* Get first remaining contact for this * to/from node pair. */ oK(sm_rbt_search(ionwm, vdb->contactIndex, rfx_order_contacts, &arg, &cxelt)); if (cxelt == 0) { break; /* No more contacts. */ } cxaddr = sm_rbt_data(ionwm, cxelt); cxref = (IonCXref *) psp(ionwm, cxaddr); if (cxref->fromNode > fromNode || cxref->toNode > toNode) { break; /* No more matches. */ } deleteContact(cxaddr); } } if (sdr_end_xn(sdr) < 0) { putErrmsg("Can't remove contact(s).", NULL); return -1; } return 0; }