]> Shamusworld >> Repos - schematic/blobdiff - src/contacteditwidget.cpp
Added some basic functionality to the program.
[schematic] / src / contacteditwidget.cpp
index 110a8c77f4b1a70be3ce0d29e754cbc82e682424..e709596cfac1c8c8f2e1613f41ddb23e1b76b1f3 100644 (file)
@@ -20,10 +20,12 @@ ContactEditWidget::ContactEditWidget(QWidget * parent/*= 0*/): QWidget(parent),
        field4(new QLineEdit),
        field5(new QLineEdit),
        field6(new QLineEdit),
-       field7(new QLineEdit)
+       field7(new QLineEdit),
+       newContactType(false)
 {
        QFormLayout * form = new QFormLayout;
 
+       field1->setEditable(true);
        form->addRow(tr("Type:"), field1);
        form->addRow(tr("Name:"), field2);
        form->addRow(tr("Email:"), field3);
@@ -33,5 +35,24 @@ ContactEditWidget::ContactEditWidget(QWidget * parent/*= 0*/): QWidget(parent),
        form->addRow(tr("Fax:"), field7);
 
        setLayout(form);
+
+       connect(field1, SIGNAL(editTextChanged(const QString &)), this, SLOT(NewItem(const QString &)));
+       connect(field1, SIGNAL(highlighted(int)), this, SLOT(ExistingItem(int)));
+}
+
+
+// Here we make some assumptions:
+// - If the user types something in, they probably are creating a new category.
+// - If the user selects something, they probably want to use an existing one.
+
+void ContactEditWidget::NewItem(const QString &)
+{
+       newContactType = true;
+}
+
+
+void ContactEditWidget::ExistingItem(int)
+{
+       newContactType = false;
 }