X-Git-Url: https://ruin.nu/git/?p=adress.git;a=blobdiff_plain;f=mainwindow.cpp;fp=mainwindow.cpp;h=094e54f9156730600c168633283073fa350c3d55;hp=ce83c8cae5d1f6b7baa8638b04c60dfe53cb3476;hb=365dabc89c0592bc776ff088db44a6533a86b923;hpb=1197b29fa2d68f604352fe6eef3e9776a63bb87b diff --git a/mainwindow.cpp b/mainwindow.cpp index ce83c8c..094e54f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,8 @@ #include "mainwindow.h" #include +#include "contactmodifyer.h" + /* BRÖÖL * Constructs a MainWindow which is a child of 'parent', with the * name 'name' and widget flags set to 'f' @@ -56,14 +58,40 @@ void MainWindow::slotSave() */ void MainWindow::slotAdd() { - qWarning( "MainWindow::slotAdd() not yet implemented!" ); + ContactModifier add; + if(add.exec() == QDialog::Accepted) + updateView(); } /* * public slot */ void MainWindow::slotDel() { - qWarning( "MainWindow::slotDel() not yet implemented!" ); + QListViewItem* lvi = ContactView->selectedItem(); + + if (lvi == '\0') + { + return; + } + + int num = lvi->text(0).toInt(); + + if (num < 1 || num > CContact::getNum()) + return; + + CContact* contact = CContact::getFirst(); + + for (int i = 1; i < num; i++, contact = contact->getNext()) + { + if (contact->getNext() == '\0') + { + return; + } + } + + delete contact; + updateView(); + //qWarning( "MainWindow::slotDel() not yet implemented!" ); } /* * public slot @@ -105,7 +133,28 @@ void MainWindow::slotSearch() void MainWindow::slotModify(QListViewItem* lvi) { - qWarning( "MainWindow::slotModif(QListViewItem*) not yet implemented!" ); + if (lvi == '\0') + { + return; + } + + int num = lvi->text(0).toInt(); + + if (num < 1 || num > CContact::getNum()) + return; + + CContact* contact = CContact::getFirst(); + + for (int i = 1; i < num; i++, contact = contact->getNext()) + { + if (contact->getNext() == '\0') + { + return; + } + } + ContactModifier modify(contact); + if(modify.exec() == QDialog::Accepted) + updateView(); } /* * This funtion puts all contacts in the listview