]> ruin.nu Git - adress.git/commitdiff
It is now possible to add, remove and modify contacts.
authorMichael Andreen <harv@ruin.nu>
Sat, 2 Dec 2000 16:01:18 +0000 (16:01 +0000)
committerMichael Andreen <harv@ruin.nu>
Sat, 2 Dec 2000 16:01:18 +0000 (16:01 +0000)
No known bugs so far..

contact.cpp
contact.h
contactmodifyer.cpp
contactmodifyer.h
mainwindow.cpp

index a8ffa356c4e85c0c9b4f57b11fd535f26a18a321..7eec7134501239893e380cf2cb0513514e741498 100644 (file)
@@ -14,7 +14,7 @@ QString toLower(QString& s)
 }*/
 
 
 }*/
 
 
-CContact::CContact(QString &firstname, QString &lastname, QString &adress, QString &phonenumber)
+CContact::CContact(const QString &firstname, const QString &lastname, const QString &adress, const QString &phonenumber)
 {
        strings[0] = firstname;
        strings[1] = lastname;
 {
        strings[0] = firstname;
        strings[1] = lastname;
index 3f16e26c1bbb9c2fe1b3dc6da50dad8b52a3955d..b9c0a560d2eba72892a25a94d0f4497d7c3b036b 100644 (file)
--- a/contact.h
+++ b/contact.h
@@ -8,7 +8,7 @@
 class CContact
 {
 public:
 class CContact
 {
 public:
-       CContact(QString &firstname, QString &lastname, QString &adress, QString &phonenumber);
+       CContact(const QString &firstname, const QString &lastname, const QString &adress, const QString &phonenumber);
        ~CContact();
 
        QString firstname();
        ~CContact();
 
        QString firstname();
index da7348164381bc4dc45b82ca292cc513a472064b..ac66e5041a20efdbf09d8b1c16a0d9bd323ad449 100644 (file)
@@ -39,6 +39,7 @@ ContactModifier::~ContactModifier()
 void ContactModifier::slotOK()
 {
        (void) new CContact( FirstnameLine->text(), LastnameLine->text(), AdressLine->text(), PhoneNumberLine->text());
 void ContactModifier::slotOK()
 {
        (void) new CContact( FirstnameLine->text(), LastnameLine->text(), AdressLine->text(), PhoneNumberLine->text());
+       //qWarning("Har skapat sakerna");
        
        if (m_contact != '\0')
        {
        
        if (m_contact != '\0')
        {
index df4d4a6ccaf423262dacbd9b6e967d545cf145af..26e274c0888ca1296df8abd5b882f7de541f03c0 100644 (file)
@@ -9,7 +9,7 @@ class ContactModifier : public ContactModifierBase
     Q_OBJECT
 
 public:
     Q_OBJECT
 
 public:
-    ContactModifier(CContact* contact = 0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+    ContactModifier(CContact* contact = '\0', QWidget* parent = 0, const char* name = 0, bool modal = true, WFlags fl = 0 );
     ~ContactModifier();
 
 
     ~ContactModifier();
 
 
index ce83c8cae5d1f6b7baa8638b04c60dfe53cb3476..094e54f9156730600c168633283073fa350c3d55 100644 (file)
@@ -1,6 +1,8 @@
 #include "mainwindow.h"
 #include <iostream>
 
 #include "mainwindow.h"
 #include <iostream>
 
+#include "contactmodifyer.h"
+
 /* BRÖÖL
  *  Constructs a MainWindow which is a child of 'parent', with the 
  *  name 'name' and widget flags set to 'f' 
 /* 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()
 {
  */
 void MainWindow::slotAdd()
 {
-    qWarning( "MainWindow::slotAdd() not yet implemented!" ); 
+       ContactModifier add;
+       if(add.exec() == QDialog::Accepted)
+               updateView();
 }
 /* 
  * public slot
  */
 void MainWindow::slotDel()
 {
 }
 /* 
  * 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
 }
 /* 
  * public slot
@@ -105,7 +133,28 @@ void MainWindow::slotSearch()
 
 void MainWindow::slotModify(QListViewItem* lvi)
 {
 
 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
 }
 /*
  * This funtion puts all contacts in the listview