qtmobility/examples/keepintouch/addressfinder.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
--- a/qtmobility/examples/keepintouch/addressfinder.cpp	Fri Jun 11 14:26:25 2010 +0300
+++ b/qtmobility/examples/keepintouch/addressfinder.cpp	Wed Jun 23 19:08:38 2010 +0300
@@ -354,9 +354,21 @@
         tabChanged(1);
 #endif
 
-        if (contactList->currentItem()) {
+        if (
+#ifdef USE_CONTACTS_COMBOBOX
+                contactList->currentIndex() != -1
+#else
+                contactList->currentItem()
+#endif
+                ) {
             // Select the first address automatically
-            addressSelected(contactList->currentItem()->text());
+            addressSelected(
+#ifdef USE_CONTACTS_COMBOBOX
+                    contactList->currentText()
+#else
+                    contactList->currentItem()->text()
+#endif
+                    );
         }
     }
 }
@@ -407,16 +419,15 @@
     filterLayout->setContentsMargins(0, spacingHack, 0, 0);
 #endif
 
-    QLabel *includeLabel = new QLabel(tr("Contacted this"));
+    QLabel *includeLabel = new QLabel(tr("Contacted in the last"));
     filterLayout->addWidget(includeLabel, 0, 0);
     filterLayout->setAlignment(includeLabel, Qt::AlignRight);
 
-    excludeCheckBox = new QCheckBox(tr("But not last"));
+    excludeCheckBox = new QCheckBox(tr("But not in the last"));
 #ifdef Q_WS_MAEMO_5
     // Maemo 5 style cuts off check box text.
     excludeCheckBox->setText(excludeCheckBox->text() + "  ");
 #endif
-    excludeCheckBox->setCheckState(Qt::Checked);
     connect(excludeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(excludePeriodEnabled(int)));
     filterLayout->addWidget(excludeCheckBox, 1, 0);
     filterLayout->setAlignment(excludeCheckBox, Qt::AlignRight);
@@ -435,6 +446,7 @@
     excludePeriod = new QComboBox;
     excludePeriod->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     filterLayout->addWidget(excludePeriod, 1, 1);
+    excludePeriod->setEnabled(false);
 
 #ifdef USE_SEARCH_BUTTON
     searchButton = new QPushButton(tr("Search"));
@@ -443,8 +455,13 @@
     filterLayout->addWidget(searchButton, 2, 1);
 #endif
 
+#ifdef USE_CONTACTS_COMBOBOX
+    contactList = new QComboBox(this);
+    connect(contactList, SIGNAL(currentIndexChanged(QString)), this, SLOT(addressSelected(QString)));
+#else
     contactList = new QListWidget(this);
     connect(contactList, SIGNAL(currentTextChanged(QString)), this, SLOT(addressSelected(QString)));
+#endif
 
 #ifndef USE_SEARCH_BUTTON
     QWidget* resultsWidget = new QWidget(this);
@@ -546,7 +563,13 @@
     int index = messageCombo->currentIndex();
     if (index != -1) {
         // Find the address currently selected
-        const QString &selectedAddress(addressList[contactList->currentRow()]);
+        const QString &selectedAddress(addressList[
+#ifdef USE_CONTACTS_COMBOBOX
+                contactList->currentIndex()
+#else
+                contactList->currentRow()
+#endif
+                ]);
 
         // Show the message selected
         QMessageId &messageId((addressMessages[selectedAddress])[index].second);
@@ -561,7 +584,13 @@
     int index = messageCombo->currentIndex();
     if (index != -1) {
         // Find the address currently selected
-        const QString &selectedAddress(addressList[contactList->currentRow()]);
+        const QString &selectedAddress(addressList[
+#ifdef USE_CONTACTS_COMBOBOX
+                contactList->currentIndex()
+#else
+                contactList->currentRow()
+#endif
+                ]);
 
         // Find the selected message
         QMessageId &messageId((addressMessages[selectedAddress])[index].second);