]> ruin.nu Git - adress.git/blobdiff - contactmodifyer.cpp
This class is made for adding and modify (actually delete the old contact and add...
[adress.git] / contactmodifyer.cpp
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();
+}
+