make basic ui of Contact
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index 17d019f..14a89df 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -11,18 +11,43 @@
#include "contactpanel.h"
#include "ui_contactpanel.h"
+
+#include <QStringList>
+#include <QItemSelectionModel>
+#include <QModelIndex>
+
ContactPanel::ContactPanel(QWidget *parent) :
QDialog(parent),
- ui(new Ui::ContactPanel)
+ ui(new Ui::ContactPanel),
+ m_contactListModel(new QStringListModel)
{
ui->setupUi(this);
+
+ QStringList contactNameList;
+ contactNameList << "Alex" << "Wentao" << "Yingdi";
+
+ m_contactListModel->setStringList(contactNameList);
+ ui->ContactList->setModel(m_contactListModel);
+
+ QItemSelectionModel* selectionModel = ui->ContactList->selectionModel();
+ connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
+ this, SLOT(updateSelection(const QItemSelection &, const QItemSelection &)));
}
ContactPanel::~ContactPanel()
{
delete ui;
+ delete m_contactListModel;
}
+void
+ContactPanel::updateSelection(const QItemSelection &selected,
+ const QItemSelection &deselected)
+{
+ QModelIndexList items = selected.indexes();
+ QString text = m_contactListModel->data(items.first(), Qt::DisplayRole).toString();
+ ui->NameData->setText(text);
+}
#if WAF
#include "contactpanel.moc"
diff --git a/src/contactpanel.h b/src/contactpanel.h
index f017d6d..5b05b56 100644
--- a/src/contactpanel.h
+++ b/src/contactpanel.h
@@ -12,6 +12,7 @@
#define CONTACTPANEL_H
#include <QDialog>
+#include <QStringListModel>
namespace Ui {
class ContactPanel;
@@ -25,8 +26,14 @@
explicit ContactPanel(QWidget *parent = 0);
~ContactPanel();
+private slots:
+ void
+ updateSelection(const QItemSelection &selected,
+ const QItemSelection &deselected);
+
private:
Ui::ContactPanel *ui;
+ QStringListModel* m_contactListModel;
};
#endif // CONTACTPANEL_H
diff --git a/src/contactpanel.ui b/src/contactpanel.ui
index ec4ba9f..ae6392c 100644
--- a/src/contactpanel.ui
+++ b/src/contactpanel.ui
@@ -2,6 +2,9 @@
<ui version="4.0">
<class>ContactPanel</class>
<widget class="QDialog" name="ContactPanel">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
<property name="geometry">
<rect>
<x>0</x>
@@ -10,8 +13,14 @@
<height>450</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="windowTitle">
- <string>Dialog</string>
+ <string>Contacts</string>
</property>
<widget class="QWidget" name="">
<property name="geometry">
@@ -26,8 +35,21 @@
<property name="spacing">
<number>10</number>
</property>
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
<item>
- <widget class="QListWidget" name="ContactList"/>
+ <widget class="QListView" name="ContactList">
+ <property name="contextMenuPolicy">
+ <enum>Qt::DefaultContextMenu</enum>
+ </property>
+ <property name="acceptDrops">
+ <bool>false</bool>
+ </property>
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ </widget>
</item>
<item>
<widget class="QTabWidget" name="ContactInfo">
@@ -64,14 +86,25 @@
<number>-1</number>
</property>
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="NameSpaceLabel">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="text">
<string>Name space</string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="lineEdit">
+ <widget class="QLineEdit" name="NameSpaceData">
+ <property name="font">
+ <font>
+ <family>Lucida Grande</family>
+ </font>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
@@ -82,14 +115,25 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="35,100">
<item>
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="NameLabel">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="lineEdit_2">
+ <widget class="QLineEdit" name="NameData">
+ <property name="font">
+ <font>
+ <family>Lucida Grande</family>
+ </font>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>
@@ -100,14 +144,25 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="35,100">
<item>
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="InstitutionLabel">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="text">
<string>Institution </string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="lineEdit_3">
+ <widget class="QLineEdit" name="InstitutionData">
+ <property name="font">
+ <font>
+ <family>Lucida Grande</family>
+ </font>
+ </property>
<property name="readOnly">
<bool>true</bool>
</property>