]> ruin.nu Git - adress.git/blobdiff - mainwindow.cpp
Added the files needed for searching..
[adress.git] / mainwindow.cpp
index 094e54f9156730600c168633283073fa350c3d55..69131c7eb461414b489ba474135557dd62d7eb95 100644 (file)
@@ -2,6 +2,7 @@
 #include <iostream>
 
 #include "contactmodifyer.h"
+#include "searchresult.h"
 
 /* BRÖÖL
  *  Constructs a MainWindow which is a child of 'parent', with the 
@@ -118,7 +119,7 @@ void MainWindow::slotLoad()
                QString adr             = t.readLine();
                QString pn              = t.readLine();
     if (fname == "" && lname == "" && lname == "" && pn == "")
-                             continue;
+                       continue;
                (void) new CContact(fname, lname, adr, pn);
        }
        updateView();
@@ -128,7 +129,12 @@ void MainWindow::slotLoad()
  */
 void MainWindow::slotSearch()
 {
-    qWarning( "MainWindow::slotSearch() not yet implemented!" ); 
+       if (SearchLine->text().isNull())
+               return;
+
+       SearchResult search(SearchLine->text(), SearchCombo->currentItem() + 1);
+       search.show();
+       updateView();
 }
 
 void MainWindow::slotModify(QListViewItem* lvi)
@@ -156,6 +162,34 @@ void MainWindow::slotModify(QListViewItem* lvi)
        if(modify.exec() == QDialog::Accepted)
                updateView();
 }
+
+void MainWindow::slotModify()
+{
+       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;
+               }
+       }
+       ContactModifier modify(contact);
+       if(modify.exec() == QDialog::Accepted)
+               updateView();
+}
 /*
  * This funtion puts all contacts in the listview
  */