This class is made for adding and modify (actually delete the old contact and add...
authorMichael Andreen <harv@ruin.nu>
Sat, 2 Dec 2000 15:04:35 +0000 (15:04 +0000)
committerMichael Andreen <harv@ruin.nu>
Sat, 2 Dec 2000 15:04:35 +0000 (15:04 +0000)
Makefile
adress.pro
contactmodifyer.cpp [new file with mode: 0644]
contactmodifyer.h [new file with mode: 0644]

index 7d6e717..75bb5b5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building adress
-# Generated by tmake at 15:20, 2000/12/02
+# Generated by tmake at 15:56, 2000/12/02
 #     Project: adress
 #    Template: app
 #############################################################################
@@ -24,11 +24,14 @@ GZIP        =       gzip -9f
 ####### Files
 
 HEADERS =      contact.h \
+               contactmodifyer.h \
                mainwindow.h
 SOURCES =      contact.cpp \
+               contactmodifyer.cpp \
                main.cpp \
                mainwindow.cpp
 OBJECTS =      contact.o \
+               contactmodifyer.o \
                main.o \
                mainwindow.o \
                ui/contactmodifyerbase.o \
@@ -43,11 +46,13 @@ UICDECLS =  ui/contactmodifyerbase.h \
 UICIMPLS =     ui/contactmodifyerbase.cpp \
                ui/mainwindowbase.cpp \
                ui/searchresultbase.cpp
-SRCMOC =       moc_mainwindow.cpp \
+SRCMOC =       moc_contactmodifyer.cpp \
+               moc_mainwindow.cpp \
                ui/moc_contactmodifyerbase.cpp \
                ui/moc_mainwindowbase.cpp \
                ui/moc_searchresultbase.cpp
-OBJMOC =       moc_mainwindow.o \
+OBJMOC =       moc_contactmodifyer.o \
+               moc_mainwindow.o \
                ui/moc_contactmodifyerbase.o \
                ui/moc_mainwindowbase.o \
                ui/moc_searchresultbase.o
@@ -107,6 +112,11 @@ clean:
 contact.o: contact.cpp \
                contact.h
 
+contactmodifyer.o: contactmodifyer.cpp \
+               contactmodifyer.h \
+               ui/contactmodifyerbase.h \
+               contact.h
+
 main.o: main.cpp \
                mainwindow.h \
                ui/mainwindowbase.h \
@@ -150,6 +160,10 @@ ui/mainwindowbase.o: ui/mainwindowbase.cpp
 
 ui/searchresultbase.o: ui/searchresultbase.cpp
 
+moc_contactmodifyer.o: moc_contactmodifyer.cpp \
+               contactmodifyer.h \
+               ui/contactmodifyerbase.h
+
 moc_mainwindow.o: moc_mainwindow.cpp \
                mainwindow.h \
                ui/mainwindowbase.h \
@@ -164,6 +178,9 @@ ui/moc_mainwindowbase.o: ui/moc_mainwindowbase.cpp \
 ui/moc_searchresultbase.o: ui/moc_searchresultbase.cpp \
                ui/searchresultbase.h
 
+moc_contactmodifyer.cpp: contactmodifyer.h
+       $(MOC) contactmodifyer.h -o moc_contactmodifyer.cpp
+
 moc_mainwindow.cpp: mainwindow.h
        $(MOC) mainwindow.h -o moc_mainwindow.cpp
 
index b597883..5bb0a66 100644 (file)
@@ -1,8 +1,10 @@
 TEMPLATE       = app
 CONFIG         = qt warn_on debug
 HEADERS                = contact.h \
+                 contactmodifyer.h \
                  mainwindow.h
 SOURCES                = contact.cpp \
+                 contactmodifyer.cpp \
                  main.cpp \
                  mainwindow.cpp
 INTERFACES     = ui/contactmodifyerbase.ui \
diff --git a/contactmodifyer.cpp b/contactmodifyer.cpp
new file mode 100644 (file)
index 0000000..da73481
--- /dev/null
@@ -0,0 +1,50 @@
+#include "contactmodifyer.h"
+#include "contact.h"
+
+
+//QT included
+#include <qlineedit.h>
+/* 
+ *  Constructs a ContactModifier which is a child of 'parent', with the 
+ *  name 'name' and widget flags set to 'f' 
+ *
+ *  The dialog will by default be modeless, unless you set 'modal' to
+ *  TRUE to construct a modal dialog.
+ */
+ContactModifier::ContactModifier(CContact* contact, QWidget* parent,  const char* name, bool modal, WFlags fl )
+    : ContactModifierBase( parent, name, modal, fl )
+{
+       m_contact = contact;
+
+       if (m_contact != '\0')
+       {
+               FirstnameLine->setText(contact->firstname());
+               LastnameLine->setText(contact->lastname());
+               AdressLine->setText(contact->adress());
+               PhoneNumberLine->setText(contact->phoneNumber());
+       }
+}
+
+/*  
+ *  Destroys the object and frees any allocated resources
+ */
+ContactModifier::~ContactModifier()
+{
+    // no need to delete child widgets, Qt does it all for us
+}
+
+/* 
+ * public slot
+ */
+void ContactModifier::slotOK()
+{
+       (void) new CContact( FirstnameLine->text(), LastnameLine->text(), AdressLine->text(), PhoneNumberLine->text());
+       
+       if (m_contact != '\0')
+       {
+               delete m_contact;
+       }
+
+       accept();
+}
+
diff --git a/contactmodifyer.h b/contactmodifyer.h
new file mode 100644 (file)
index 0000000..df4d4a6
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef CONTACTMODIFIER_H
+#define CONTACTMODIFIER_H
+#include "ui/contactmodifyerbase.h"
+
+class CContact;
+
+class ContactModifier : public ContactModifierBase
+{ 
+    Q_OBJECT
+
+public:
+    ContactModifier(CContact* contact = 0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+    ~ContactModifier();
+
+
+public slots:
+    void slotOK();
+
+protected:
+               CContact* m_contact;
+
+};
+
+#endif // CONTACTMODIFIER_H