adding accounts has been fixed
This commit is contained in:
parent
796a3e4dc3
commit
5605e1e333
@ -71,6 +71,7 @@ void AddDialog::on_pushButton_2_clicked()
|
|||||||
|
|
||||||
void AddDialog::on_pushButton_3_clicked()
|
void AddDialog::on_pushButton_3_clicked()
|
||||||
{
|
{
|
||||||
|
qDebug() << "addAccount button in dialog clicked";
|
||||||
emit sendText(new Account(ui->nameLine->text(), ui->usernameLine->text(), ui->createPassword->text(), ui->createURL->text(), ui->noteLine->text()));//отправляет сигнал с текстом
|
emit sendText(new Account(ui->nameLine->text(), ui->usernameLine->text(), ui->createPassword->text(), ui->createURL->text(), ui->noteLine->text()));//отправляет сигнал с текстом
|
||||||
//m->putRecord(new Record(ui->nameLine->text(), ui->usernameLine->text(), ui->createPassword->text(), ui->urlLine->text(), ui->noteLine->text()));
|
//m->putRecord(new Record(ui->nameLine->text(), ui->usernameLine->text(), ui->createPassword->text(), ui->urlLine->text(), ui->noteLine->text()));
|
||||||
ui->nameLine->setText("");
|
ui->nameLine->setText("");
|
||||||
|
|||||||
@ -24,12 +24,14 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
// manager = new Manager();
|
// manager = new Manager();
|
||||||
dial = new AddDialog();
|
dial = new AddDialog();
|
||||||
del = new Del();
|
del = new Del();
|
||||||
connect(dial,SIGNAL(sendText(Record*)),this,SLOT(addRecordSlot(Record*)));
|
connect(dial,SIGNAL(sendText(Account*)),this,SLOT(addRecordSlot(Account*)));
|
||||||
connect(del, SIGNAL(trueDelete()), this, SLOT(acceptDelete()));
|
connect(del, SIGNAL(trueDelete()), this, SLOT(acceptDelete()));
|
||||||
crypto = new SimpleCrypt(Q_UINT64_C(0x0c2ad4a4acb9f023));
|
crypto = new SimpleCrypt(Q_UINT64_C(0x0c2ad4a4acb9f023));
|
||||||
// createModel();
|
// createModel();
|
||||||
ui->tableViewRecords->setEnabled(true);
|
ui->tableViewRecords->setEnabled(true);
|
||||||
ui->tableViewRecords->setVisible(true);
|
ui->tableViewRecords->setVisible(true);
|
||||||
|
ui->tableViewCards->setEnabled(true);
|
||||||
|
ui->tableViewCards->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::MainWindow* MainWindow::getUI()
|
Ui::MainWindow* MainWindow::getUI()
|
||||||
@ -59,7 +61,7 @@ void MainWindow::createModels()
|
|||||||
// recordsCount = ui->tableViewRecords->model()->rowCount();
|
// recordsCount = ui->tableViewRecords->model()->rowCount();
|
||||||
|
|
||||||
cardModel = new QSqlTableModel(this, m_db);
|
cardModel = new QSqlTableModel(this, m_db);
|
||||||
cardModel->setTable("credentials");
|
cardModel->setTable(cards);
|
||||||
cardModel->select();
|
cardModel->select();
|
||||||
cardModel->setEditStrategy(QSqlTableModel::OnFieldChange);
|
cardModel->setEditStrategy(QSqlTableModel::OnFieldChange);
|
||||||
ui->tableViewCards->setModel(cardModel);
|
ui->tableViewCards->setModel(cardModel);
|
||||||
@ -106,6 +108,8 @@ void MainWindow::putRecord(Record* record){
|
|||||||
query->bindValue(":url", account->getURL());
|
query->bindValue(":url", account->getURL());
|
||||||
query->bindValue(":note", account->getNote());
|
query->bindValue(":note", account->getNote());
|
||||||
query->bindValue(":time", account->getTime());
|
query->bindValue(":time", account->getTime());
|
||||||
|
qDebug() << query->exec();
|
||||||
|
accountModel->select();
|
||||||
}
|
}
|
||||||
else if(typeid (*record) == typeid (Card))
|
else if(typeid (*record) == typeid (Card))
|
||||||
{
|
{
|
||||||
@ -122,18 +126,11 @@ void MainWindow::putRecord(Record* record){
|
|||||||
query->bindValue(":cvv", crypto->encryptToString(card->getCVV()));
|
query->bindValue(":cvv", crypto->encryptToString(card->getCVV()));
|
||||||
query->bindValue(":pin", crypto->encryptToString(card->getPIN()));
|
query->bindValue(":pin", crypto->encryptToString(card->getPIN()));
|
||||||
query->bindValue(":time", card->getTime());
|
query->bindValue(":time", card->getTime());
|
||||||
|
qDebug() << query->exec();
|
||||||
|
cardModel->select();
|
||||||
}
|
}
|
||||||
query->clear();
|
|
||||||
|
|
||||||
|
|
||||||
// qDebug() << "Добавление строки:" <<
|
|
||||||
// query->prepare("INSERT INTO " + accounts + "(id, name, username, password, url, note, time)" \
|
|
||||||
// "VALUES(:id, :name, :username, :password, :url, :note, :time)");
|
|
||||||
// // query->prepare("INSERT INTO employees(id, last_name, first_name, occupation, year_of_admission) " \
|
|
||||||
// // "VALUES(:id, :last_name, :first_name, :occupation, :year_of_admission)");
|
|
||||||
|
|
||||||
query->exec();
|
|
||||||
accountModel->select();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Account* MainWindow::getRecord(int index)
|
Account* MainWindow::getRecord(int index)
|
||||||
|
|||||||
@ -26,9 +26,9 @@ public:
|
|||||||
~MainWindow();
|
~MainWindow();
|
||||||
Ui::MainWindow* getUI();
|
Ui::MainWindow* getUI();
|
||||||
void createModels();
|
void createModels();
|
||||||
void putRecord(Account* record);
|
void putRecord(Record* record);
|
||||||
Account* getRecord(int index);
|
Account* getRecord(int index);
|
||||||
void deleteRecord();
|
void deleteRecord(int index, QSqlTableModel* model, QString recordType);
|
||||||
int getRecordsCount();
|
int getRecordsCount();
|
||||||
|
|
||||||
void putCard(Card* card);
|
void putCard(Card* card);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user