Skip to content

Commit d5de7b6

Browse files
antonyereshchenko-mobiusantonyereshchenko-mobius
authored andcommitted
Initial Release
Releasing first version
1 parent 151ee48 commit d5de7b6

File tree

194 files changed

+13331
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+13331
-0
lines changed

HEAD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/master

accountslistdialog.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "accountslistdialog.h"
2+
#include "ui_accountslistdialog.h"
3+
4+
AccountsListDialog::AccountsListDialog(QWidget *parent) :
5+
QDialog(parent),
6+
ui(new Ui::AccountsListDialog)
7+
{
8+
ui->setupUi(this);
9+
10+
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
11+
12+
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(addButtonDidClick()));
13+
connect(ui->listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(rowDidSelect(QListWidgetItem*)));
14+
}
15+
16+
void AccountsListDialog::addCell(QString name, QString clientID, QString host, int port)
17+
{
18+
CellAccountItem *cell = CellAccountItem::createCellWith(name, clientID, host, QString::number(port), ui->listWidget);
19+
connect(cell, SIGNAL(deleteButtonClickOn(int)), this, SLOT(deleteItemAt(int)));
20+
}
21+
22+
void AccountsListDialog::setAccountList(DQList<AccountEntity> list)
23+
{
24+
for (int i = 0 ; i < ui->listWidget->count(); i++) {
25+
QListWidgetItem *item = ui->listWidget->item(i);
26+
ui->listWidget->removeItemWidget(item);
27+
}
28+
ui->listWidget->clear();
29+
30+
this->accounts = list;
31+
32+
for (int i = 0; i < this->accounts.size(); i++) {
33+
AccountEntity *item = this->accounts.at(i);
34+
this->addCell(item->username, item->clientID, item->serverHost, item->port);
35+
}
36+
}
37+
38+
void AccountsListDialog::rowDidSelect(QListWidgetItem *item)
39+
{
40+
int row = ui->listWidget->row(item);
41+
AccountEntity *accountItem = this->accounts.at(row);
42+
43+
emit accountDidSelect(accountItem);
44+
accept();
45+
}
46+
47+
void AccountsListDialog::addButtonDidClick()
48+
{
49+
emit newAccountDidClick();
50+
accept();
51+
}
52+
53+
void AccountsListDialog::deleteItemAt(int row)
54+
{
55+
AccountEntity *item = this->accounts.at(row);
56+
57+
emit deleteAccount(item);
58+
}
59+
60+
AccountsListDialog::~AccountsListDialog()
61+
{
62+
delete ui;
63+
}

accountslistdialog.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifndef ACCOUNTSLISTDIALOG_H
2+
#define ACCOUNTSLISTDIALOG_H
3+
4+
#include <QDialog>
5+
#include <cells/cellaccountitem.h>
6+
#include <database/entities/accountentity.h>
7+
8+
namespace Ui {
9+
class AccountsListDialog;
10+
}
11+
12+
/**
13+
* @brief The AccountsListDialog class
14+
*/
15+
16+
class AccountsListDialog : public QDialog
17+
{
18+
Q_OBJECT
19+
20+
private:
21+
22+
Ui::AccountsListDialog *ui;
23+
24+
DQList<AccountEntity> accounts;
25+
26+
void addCell(QString name, QString clientID, QString host, int port);
27+
28+
public:
29+
explicit AccountsListDialog(QWidget *parent = 0);
30+
~AccountsListDialog();
31+
32+
void setAccountList(DQList<AccountEntity> list);
33+
34+
signals:
35+
void deleteAccount(AccountEntity *account);
36+
void accountDidSelect(AccountEntity *account);
37+
void newAccountDidClick();
38+
39+
private slots:
40+
void rowDidSelect(QListWidgetItem* item);
41+
void addButtonDidClick();
42+
void deleteItemAt(int row);
43+
};
44+
45+
#endif // ACCOUNTSLISTDIALOG_H

accountslistdialog.ui

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>AccountsListDialog</class>
4+
<widget class="QDialog" name="AccountsListDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>300</width>
10+
<height>430</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Accounts</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<property name="leftMargin">
18+
<number>0</number>
19+
</property>
20+
<property name="topMargin">
21+
<number>0</number>
22+
</property>
23+
<property name="rightMargin">
24+
<number>0</number>
25+
</property>
26+
<property name="bottomMargin">
27+
<number>0</number>
28+
</property>
29+
<property name="spacing">
30+
<number>0</number>
31+
</property>
32+
<item row="0" column="0">
33+
<widget class="QLabel" name="label">
34+
<property name="minimumSize">
35+
<size>
36+
<width>0</width>
37+
<height>32</height>
38+
</size>
39+
</property>
40+
<property name="maximumSize">
41+
<size>
42+
<width>16777215</width>
43+
<height>32</height>
44+
</size>
45+
</property>
46+
<property name="styleSheet">
47+
<string notr="true">QLabel {
48+
border-style: outset;
49+
border-width: 0px;
50+
color: white;
51+
background-color: rgb(25,163,219);
52+
}</string>
53+
</property>
54+
<property name="text">
55+
<string>Please select account</string>
56+
</property>
57+
<property name="alignment">
58+
<set>Qt::AlignCenter</set>
59+
</property>
60+
</widget>
61+
</item>
62+
<item row="1" column="0">
63+
<widget class="ListWidget" name="listWidget">
64+
<property name="alternatingRowColors">
65+
<bool>true</bool>
66+
</property>
67+
</widget>
68+
</item>
69+
<item row="2" column="0">
70+
<widget class="QPushButton" name="pushButton">
71+
<property name="minimumSize">
72+
<size>
73+
<width>0</width>
74+
<height>48</height>
75+
</size>
76+
</property>
77+
<property name="styleSheet">
78+
<string notr="true">QPushButton {
79+
font-size:16pt;
80+
border-style: outset;
81+
border-width: 0px;
82+
color: white;
83+
background-color: rgb(25,163,219);
84+
top:100px;
85+
}
86+
QPushButton:pressed {
87+
background-color: rgb(45,183,239);
88+
}</string>
89+
</property>
90+
<property name="text">
91+
<string>Add new account</string>
92+
</property>
93+
<property name="flat">
94+
<bool>false</bool>
95+
</property>
96+
</widget>
97+
</item>
98+
</layout>
99+
</widget>
100+
<customwidgets>
101+
<customwidget>
102+
<class>ListWidget</class>
103+
<extends>QListWidget</extends>
104+
<header>listwidget.h</header>
105+
</customwidget>
106+
</customwidgets>
107+
<resources/>
108+
<connections/>
109+
</ui>

cells/cellaccountitem.cpp

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include "cellaccountitem.h"
2+
#include "ui_cellaccountitem.h"
3+
4+
CellAccountItem::CellAccountItem(QWidget *parent) :
5+
QWidget(parent),
6+
ui(new Ui::CellAccountItem)
7+
{
8+
ui->setupUi(this);
9+
}
10+
11+
CellAccountItem *CellAccountItem::createCellWith(QString username, QString clientID, QString host, QString port, ListWidget *widget)
12+
{
13+
CellAccountItem *widgetForm = new CellAccountItem();
14+
widgetForm->setUsername(username);
15+
widgetForm->setClientID(clientID);
16+
widgetForm->setHost(host);
17+
widgetForm->setPort(port);
18+
QListWidgetItem *item = new QListWidgetItem();
19+
item->setSizeHint(QSize(0,56));
20+
widget->addItem(item);
21+
widget->setItemWidget(item, widgetForm);
22+
widgetForm->setProperty("row", widget->row(item));
23+
return widgetForm;
24+
}
25+
26+
QString CellAccountItem::getUsername()
27+
{
28+
return ui->usernameLabel->text();
29+
}
30+
31+
void CellAccountItem::setUsername(QString username)
32+
{
33+
ui->usernameLabel->setText(username);
34+
}
35+
36+
QString CellAccountItem::getClientID()
37+
{
38+
return ui->clientIDLabel->text();
39+
}
40+
41+
void CellAccountItem::setClientID(QString clientID)
42+
{
43+
ui->clientIDLabel->setText(clientID);
44+
}
45+
46+
QString CellAccountItem::getHost()
47+
{
48+
return ui->hostLabel->text();
49+
}
50+
51+
void CellAccountItem::setHost(QString host)
52+
{
53+
ui->hostLabel->setText(host);
54+
}
55+
56+
QString CellAccountItem::getPort()
57+
{
58+
return ui->portLabel->text();
59+
}
60+
61+
void CellAccountItem::setPort(QString port)
62+
{
63+
ui->portLabel->setText(port);
64+
}
65+
66+
void CellAccountItem::on_closeButton_clicked()
67+
{
68+
int row = this->property("row").toInt();
69+
emit deleteButtonClickOn(row);
70+
}
71+
72+
CellAccountItem::~CellAccountItem()
73+
{
74+
delete ui;
75+
}

cells/cellaccountitem.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#ifndef CELLACCOUNTITEM_H
2+
#define CELLACCOUNTITEM_H
3+
4+
#include <listwidget.h>
5+
6+
namespace Ui {
7+
class CellAccountItem;
8+
}
9+
10+
/**
11+
* @brief The CellAccountItem class
12+
*/
13+
14+
class CellAccountItem : public QWidget
15+
{
16+
Q_OBJECT
17+
18+
public:
19+
explicit CellAccountItem(QWidget *parent = 0);
20+
~CellAccountItem();
21+
22+
static CellAccountItem *createCellWith(QString username, QString clientID, QString host, QString port, ListWidget *widget);
23+
24+
QString getUsername();
25+
void setUsername(QString username);
26+
27+
QString getClientID();
28+
void setClientID(QString clientID);
29+
30+
QString getHost();
31+
void setHost(QString host);
32+
33+
QString getPort();
34+
void setPort(QString port);
35+
36+
signals:
37+
void deleteButtonClickOn(int row);
38+
39+
private slots:
40+
void on_closeButton_clicked();
41+
42+
private:
43+
Ui::CellAccountItem *ui;
44+
};
45+
46+
#endif // CELLACCOUNTITEM_H

0 commit comments

Comments
 (0)