1
+ /* *
2
+ * Mobius Software LTD
3
+ * Copyright 2015-2018, Mobius Software LTD
4
+ *
5
+ * This is free software; you can redistribute it and/or modify it
6
+ * under the terms of the GNU Lesser General Public License as
7
+ * published by the Free Software Foundation; either version 2.1 of
8
+ * the License, or (at your option) any later version.
9
+ *
10
+ * This software is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this software; if not, write to the Free
17
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
+ */
20
+
1
21
#include " accountlistform.h"
2
22
#include " ui_accountlistform.h"
3
23
@@ -6,6 +26,57 @@ AccountListForm::AccountListForm(QWidget *parent) :
6
26
ui(new Ui::AccountListForm)
7
27
{
8
28
ui->setupUi (this );
29
+
30
+ this ->setWindowFlags (Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
31
+
32
+ connect (ui->pushButton , SIGNAL (clicked ()), this , SLOT (addButtonDidClick ()));
33
+ connect (ui->listWidget , SIGNAL (itemClicked (QListWidgetItem*)), this , SLOT (rowDidSelect (QListWidgetItem*)));
34
+ }
35
+
36
+ void AccountListForm::addCell (QString name, QString clientID, QString host, int port)
37
+ {
38
+ CellAccountItem *cell = CellAccountItem::createCellWith (name, clientID, host, QString::number (port), ui->listWidget );
39
+ connect (cell, SIGNAL (deleteButtonClickOn (int )), this , SLOT (deleteItemAt (int )));
40
+ }
41
+
42
+ void AccountListForm::setAccountList (DQList<AccountEntity> list)
43
+ {
44
+ for (int i = 0 ; i < ui->listWidget ->count (); i++) {
45
+ QListWidgetItem *item = ui->listWidget ->item (i);
46
+ ui->listWidget ->removeItemWidget (item);
47
+ }
48
+ ui->listWidget ->clear ();
49
+
50
+ this ->accounts = list;
51
+
52
+ for (int i = 0 ; i < this ->accounts .size (); i++) {
53
+ AccountEntity *item = this ->accounts .at (i);
54
+ this ->addCell (item->username , item->clientID , item->serverHost , item->port );
55
+ }
56
+ }
57
+
58
+ void AccountListForm::rowDidSelect (QListWidgetItem *item)
59
+ {
60
+ int row = ui->listWidget ->row (item);
61
+ AccountEntity *accountItem = this ->accounts .at (row);
62
+
63
+ emit accountDidSelect (accountItem);
64
+ }
65
+
66
+ void AccountListForm::addButtonDidClick ()
67
+ {
68
+ emit newAccountDidClick ();
69
+ }
70
+
71
+ void AccountListForm::deleteItemAt (int row)
72
+ {
73
+ AccountEntity *item = this ->accounts .at (row);
74
+ emit deleteAccount (item);
75
+ }
76
+
77
+ QSize AccountListForm::getSize ()
78
+ {
79
+ return QSize (300 , 425 );
9
80
}
10
81
11
82
AccountListForm::~AccountListForm ()
0 commit comments