| @@ -0,0 +1,140 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>FriendEditDialog</class> | ||
| <widget class="QDialog" name="FriendEditDialog"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>400</width> | ||
| <height>527</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Dialog</string> | ||
| </property> | ||
| <layout class="QVBoxLayout" name="verticalLayout"> | ||
| <item> | ||
| <widget class="QLabel" name="label_6"> | ||
| <property name="text"> | ||
| <string>Name</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QLineEdit" name="e_name"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QLabel" name="label_5"> | ||
| <property name="text"> | ||
| <string>PhoneNumber</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QLineEdit" name="e_phoneNumber"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QLabel" name="label_4"> | ||
| <property name="text"> | ||
| <string>Email</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QLineEdit" name="e_email"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QLabel" name="label_3"> | ||
| <property name="text"> | ||
| <string>BirthYear</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QLineEdit" name="e_birthYear"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QLabel" name="label_2"> | ||
| <property name="text"> | ||
| <string>Title</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QComboBox" name="e_title"> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Mr</string> | ||
| </property> | ||
| </item> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Mrs</string> | ||
| </property> | ||
| </item> | ||
| <item> | ||
| <property name="text"> | ||
| <string>Miss</string> | ||
| </property> | ||
| </item> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>HomeNumber</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QLineEdit" name="e_homeNumber"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QDialogButtonBox" name="buttonBox"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Vertical</enum> | ||
| </property> | ||
| <property name="standardButtons"> | ||
| <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <resources/> | ||
| <connections> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>accepted()</signal> | ||
| <receiver>FriendEditDialog</receiver> | ||
| <slot>accept()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>248</x> | ||
| <y>254</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>157</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>rejected()</signal> | ||
| <receiver>FriendEditDialog</receiver> | ||
| <slot>reject()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>316</x> | ||
| <y>260</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>286</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| </connections> | ||
| </ui> |
| @@ -1,14 +1,61 @@ | ||
| #include "mainwindow.h" | ||
| #include "ui_mainwindow.h" | ||
|
|
||
| // =================== | ||
| // private | ||
| // =================== | ||
|
|
||
| void MainWindow::reloadListWidget() | ||
| { | ||
| ui->listWidget->clear(); | ||
|
|
||
| for (unsigned int i = 0; i < this->list->size(); i++) { | ||
| try { | ||
| QString toAddStr = QString::fromStdString(this->list->elementAt(i)->getName()); | ||
| ui->listWidget->addItem(toAddStr); | ||
| } catch (const char * e) { | ||
| std::cout << e << std::endl; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // =================== | ||
| // public | ||
| // =================== | ||
|
|
||
| MainWindow::MainWindow(QWidget *parent) : | ||
| QMainWindow(parent), | ||
| ui(new Ui::MainWindow) | ||
| { | ||
| ui->setupUi(this); | ||
| this->list = new LinkedList<Person>(); | ||
| this->list->insert(new Friend("name", "03", "asdm@email.com", 1994, "MR", "034038889")); | ||
| this->list->insert(new Friend("name2", "03", "asdm@email.com", 1994, "MR", "034038889")); | ||
| this->list->insert(new Friend("name3", "03", "asdm@email.com", 1994, "MR", "034038889")); | ||
| this->list->insert(new Friend("name4", "03", "asdm@email.com", 1994, "MR", "034038889")); | ||
| this->list->insert(new Friend("name5", "03", "asdm@email.com", 1994, "MR", "034038889")); | ||
| this->list->insert(new Friend("name6", "03", "asdm@email.com", 1994, "MR", "034038889")); | ||
| this->reloadListWidget(); | ||
| this->vd = new ViewDialog(this); | ||
| } | ||
|
|
||
| MainWindow::~MainWindow() | ||
| { | ||
| delete list; | ||
| delete ui; | ||
| delete vd; | ||
| } | ||
|
|
||
| void MainWindow::on_pushButton_clicked() | ||
| { | ||
| int toview = ui->listWidget->currentRow(); | ||
| std::cout << "toview " << toview << std::endl; | ||
| if (toview >= 0) { | ||
| std::cout << toview << std::endl; | ||
| Person *p = this->list->elementAt(toview); | ||
|
|
||
| vd->addPerson(p); | ||
|
|
||
| vd->show(); | ||
| } | ||
| } |
| @@ -1,24 +1,99 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>MainWindow</class> | ||
| <widget class="QMainWindow" name="MainWindow"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>559</width> | ||
| <height>428</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>MainWindow</string> | ||
| </property> | ||
| <widget class="QWidget" name="centralWidget"> | ||
| <layout class="QGridLayout" name="gridLayout_2"> | ||
| <item row="0" column="0"> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <item row="0" column="0"> | ||
| <widget class="QTabWidget" name="tabWidget"> | ||
| <property name="currentIndex"> | ||
| <number>0</number> | ||
| </property> | ||
| <widget class="QWidget" name="tab"> | ||
| <attribute name="title"> | ||
| <string>Overview</string> | ||
| </attribute> | ||
| <layout class="QVBoxLayout" name="verticalLayout"> | ||
| <item> | ||
| <widget class="QListWidget" name="listWidget"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QPushButton" name="pushButton"> | ||
| <property name="text"> | ||
| <string>View</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <widget class="QWidget" name="tab_2"> | ||
| <attribute name="title"> | ||
| <string>Friends</string> | ||
| </attribute> | ||
| </widget> | ||
| <widget class="QWidget" name="tab_3"> | ||
| <attribute name="title"> | ||
| <string>Add Person</string> | ||
| </attribute> | ||
| </widget> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <widget class="QMenuBar" name="menuBar"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>559</width> | ||
| <height>29</height> | ||
| </rect> | ||
| </property> | ||
| <widget class="QMenu" name="menuPhonebook"> | ||
| <property name="title"> | ||
| <string>Phonebook</string> | ||
| </property> | ||
| <addaction name="actionSave"/> | ||
| <addaction name="actionLoad"/> | ||
| </widget> | ||
| <addaction name="menuPhonebook"/> | ||
| </widget> | ||
| <widget class="QToolBar" name="mainToolBar"> | ||
| <attribute name="toolBarArea"> | ||
| <enum>TopToolBarArea</enum> | ||
| </attribute> | ||
| <attribute name="toolBarBreak"> | ||
| <bool>false</bool> | ||
| </attribute> | ||
| </widget> | ||
| <widget class="QStatusBar" name="statusBar"/> | ||
| <action name="actionSave"> | ||
| <property name="text"> | ||
| <string>Save</string> | ||
| </property> | ||
| </action> | ||
| <action name="actionLoad"> | ||
| <property name="text"> | ||
| <string>Load</string> | ||
| </property> | ||
| </action> | ||
| </widget> | ||
| <layoutdefault spacing="6" margin="11"/> | ||
| <resources/> | ||
| <connections/> | ||
| </ui> |
| @@ -0,0 +1,39 @@ | ||
| #include "viewDialog.h" | ||
| #include "ui_viewDialog.h" | ||
|
|
||
| #include <iostream> | ||
| #include "Person.h" | ||
| #include "friendEditdialog.h" | ||
|
|
||
| ViewDialog::ViewDialog(QWidget *parent) : | ||
| QDialog(parent), | ||
| ui(new Ui::ViewDialog) | ||
| { | ||
| this->editView = new FriendEditDialog(this); | ||
| ui->setupUi(this); | ||
| } | ||
|
|
||
| void ViewDialog::addPerson(Person *p) | ||
| { | ||
| this->p = p; | ||
| ui->plainTextEdit->setPlainText(QString::fromStdString(this->p->toString())); | ||
| } | ||
|
|
||
| ViewDialog::~ViewDialog() | ||
| { | ||
| delete ui; | ||
| delete this->editView; | ||
| } | ||
|
|
||
| void ViewDialog::on_ViewDialog_accepted() | ||
| { | ||
| } | ||
|
|
||
| void ViewDialog::on_pushButton_clicked() | ||
| { | ||
| if (this->p->getClassName() == "Friend") { | ||
| this->editView = new FriendEditDialog(this); | ||
| this->editView->setFriend(this->p); | ||
| this->editView->show(); | ||
| } | ||
| } |
| @@ -0,0 +1,31 @@ | ||
| #ifndef VIEWDIALOG_H | ||
| #define VIEWDIALOG_H | ||
|
|
||
| #include <QDialog> | ||
| #include "Person.h" | ||
| #include "friendEditdialog.h" | ||
|
|
||
| namespace Ui { | ||
| class ViewDialog; | ||
| } | ||
|
|
||
| class ViewDialog : public QDialog | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| private: | ||
| Ui::ViewDialog *ui; | ||
| Person *p; | ||
| FriendEditDialog *editView; | ||
|
|
||
| public: | ||
| explicit ViewDialog(QWidget *parent = 0); | ||
| void addPerson(Person *p); | ||
| ~ViewDialog(); | ||
|
|
||
| private slots: | ||
| void on_ViewDialog_accepted(); | ||
| void on_pushButton_clicked(); | ||
| }; | ||
|
|
||
| #endif // VIEWDIALOG_H |
| @@ -0,0 +1,81 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>ViewDialog</class> | ||
| <widget class="QDialog" name="ViewDialog"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>400</width> | ||
| <height>300</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Dialog</string> | ||
| </property> | ||
| <layout class="QVBoxLayout" name="verticalLayout"> | ||
| <item> | ||
| <widget class="QPlainTextEdit" name="plainTextEdit"> | ||
| <property name="cursor" stdset="0"> | ||
| <cursorShape>WhatsThisCursor</cursorShape> | ||
| </property> | ||
| <property name="readOnly"> | ||
| <bool>true</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QPushButton" name="pushButton"> | ||
| <property name="text"> | ||
| <string>Edit</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QDialogButtonBox" name="buttonBox"> | ||
| <property name="orientation"> | ||
| <enum>Qt::Vertical</enum> | ||
| </property> | ||
| <property name="standardButtons"> | ||
| <set>QDialogButtonBox::Ok</set> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <resources/> | ||
| <connections> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>rejected()</signal> | ||
| <receiver>ViewDialog</receiver> | ||
| <slot>reject()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>316</x> | ||
| <y>260</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>286</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| <connection> | ||
| <sender>buttonBox</sender> | ||
| <signal>accepted()</signal> | ||
| <receiver>ViewDialog</receiver> | ||
| <slot>accept()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>248</x> | ||
| <y>254</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>157</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| </connections> | ||
| </ui> |