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

50 lines
1.1 KiB
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-03-29 14:54:34 +00:00
Accounts::Accounts(QWidget *parent) :
2019-03-30 20:13:13 +00:00
m_ui(new Ui::Accounts),
tableModel()
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)));
m_ui->tableView->setModel(&tableModel);
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();
}
void Accounts::addAccount(const QMap<QString, QVariant>& map)
{
tableModel.addAccount(map);
}
2019-04-02 15:46:18 +00:00
void Accounts::updateAccount(const QString& account, const QString& field, const QVariant& value)
{
tableModel.updateAccount(account, field, value);
}