1
0
forked from blue/squawk
squawk/ui/accounts.cpp

38 lines
873 B
C++
Raw Normal View History

2019-03-29 14:54:34 +00:00
#include "accounts.h"
#include "ui_accounts.h"
2019-03-30 20:13:13 +00:00
#include <QDebug>
2019-04-03 18:15:36 +00:00
Accounts::Accounts(Models::Accounts* model, QWidget *parent) :
m_ui(new Ui::Accounts)
2019-03-29 14:54:34 +00:00
{
m_ui->setupUi(this);
2019-03-30 20:13:13 +00:00
connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(onAddButton(bool)));
2019-04-03 18:15:36 +00:00
m_ui->tableView->setModel(model);
2019-03-29 14:54:34 +00:00
}
Accounts::~Accounts() = default;
2019-03-30 20:13:13 +00:00
void Accounts::onAddButton(bool clicked)
{
Account* acc = new Account();
connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted()));
connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected()));
acc->exec();
}
void Accounts::onAccountAccepted()
{
Account* acc = static_cast<Account*>(sender());
QMap<QString, QVariant> map = acc->value();
emit newAccount(map);
}
void Accounts::onAccountRejected()
{
Account* acc = static_cast<Account*>(sender());
acc->deleteLater();
}