diff --git a/PasswordManager/mainwindow.cpp b/PasswordManager/mainwindow.cpp
index 5a16a55..a5e8e00 100644
--- a/PasswordManager/mainwindow.cpp
+++ b/PasswordManager/mainwindow.cpp
@@ -360,7 +360,25 @@ Card* MainWindow::getCard(int index)
return r;
}
-void MainWindow::updateCard(Card* r){}
+void MainWindow::updateCard(Card* r)
+{
+ int num = ui->tableViewCards->currentIndex().row();
+ QVariant x = cardsModel->record(num).value(0);
+ int id;
+ id = x.toInt();
+ query->clear();
+ query->prepare("UPDATE cards SET title=:title, number=:number, name=:name, month=:month, year=:year, cvv=:cvv, pin=:pin, note=:note WHERE id=:id");
+ query->bindValue(":id", id);
+ query->bindValue(":title", r->getTitle());
+ query->bindValue(":number", crypto->encryptToString(r->getNumber()));
+ query->bindValue(":name", r->getName());
+ query->bindValue(":month", crypto->encryptToString(r->getMonth()));
+ query->bindValue(":year", crypto->encryptToString(r->getYear()));
+ query->bindValue(":cvv", crypto->encryptToString(r->getCVV()));
+ query->bindValue(":pin", crypto->encryptToString(r->getPIN()));
+ query->bindValue(":note", r->getNote());
+ qDebug() << query->exec();
+}
void MainWindow::deleteCard()
{
int num = ui->tableViewCards->currentIndex().row();
@@ -637,7 +655,48 @@ void MainWindow::on_pushButton_3_clicked()
void MainWindow::on_pushButton_12_clicked()
{
+ int num = ui->tableViewCards->currentIndex().row();
+ qDebug() << ++num;
+ Card* c = getCard(num);
+ ui->titleLine->setText(c->getTitle());
+ ui->NumberLine->setText(crypto->decryptToString(c->getNumber()));
+ ui->NameLine->setText(c->getName());
+ ui->monthLine->setText(crypto->decryptToString(c->getMonth()));
+ ui->yearLine->setText(crypto->decryptToString(c->getYear()));
+ ui->cvvLine->setText(crypto->decryptToString(c->getCVV()));
+ ui->pinLine->setText(crypto->decryptToString(c->getPIN()));
+ ui->noteLine->setText(c->getNote());
ui->stackedWidget->setCurrentIndex(4);
}
+
+void MainWindow::on_deleteButton_3_clicked()
+{
+ deleteCard();
+}
+
+
+void MainWindow::on_cardEditOkButton_clicked()
+{
+ Card* c = new Card();
+ c->setTitle(ui->titleLine->text());
+ c->setNumber(crypto->decryptToString(ui->NumberLine->text()));
+ c->setName(ui->NameLine->text());
+ c->setMonth(crypto->decryptToString(ui->monthLine->text()));
+ c->setYear(crypto->decryptToString(ui->yearLine->text()));
+ c->setCVV(crypto->decryptToString(ui->cvvLine->text()));
+ c->setPIN(crypto->decryptToString(ui->pinLine->text()));
+ c->setNote(ui->pinLine->text());
+ qDebug() << "updating initramfs...";
+ updateCard(c);
+ cardsModel->select();
+ ui->stackedWidget->setCurrentIndex(1);
+}
+
+
+void MainWindow::on_cardEditCancelButton_clicked()
+{
+ ui->stackedWidget->setCurrentIndex(1);
+}
+
diff --git a/PasswordManager/mainwindow.h b/PasswordManager/mainwindow.h
index e13b63b..c33d98c 100644
--- a/PasswordManager/mainwindow.h
+++ b/PasswordManager/mainwindow.h
@@ -111,5 +111,8 @@ private slots:
void on_CardButton_clicked();
void on_pushButton_3_clicked();
void on_pushButton_12_clicked();
+ void on_deleteButton_3_clicked();
+ void on_cardEditOkButton_clicked();
+ void on_cardEditCancelButton_clicked();
};
#endif // MAINWINDOW_H
diff --git a/PasswordManager/mainwindow.ui b/PasswordManager/mainwindow.ui
index c4765f9..7d88bc1 100644
--- a/PasswordManager/mainwindow.ui
+++ b/PasswordManager/mainwindow.ui
@@ -699,7 +699,7 @@
-
+
102
@@ -709,7 +709,7 @@
-
+
110
@@ -730,7 +730,7 @@
-
-
+
-
@@ -740,7 +740,7 @@
-
-
+
@@ -754,6 +754,9 @@
+ -
+
+
-
@@ -761,6 +764,9 @@
+ -
+
+
-
@@ -768,12 +774,6 @@
- -
-
-
- -
-
-
-
@@ -781,8 +781,18 @@
- -
-
+
-
+
+
+ -
+
+
+ -
+
+
+ note
+
+
@@ -812,6 +822,32 @@
до
+
+
+
+ 550
+ 470
+ 80
+ 26
+
+
+
+ Ok
+
+
+
+
+
+ 130
+ 470
+ 80
+ 26
+
+
+
+ Cancel
+
+