Cards editing fixed
This commit is contained in:
parent
3a8a464762
commit
b77d2dfe06
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -699,7 +699,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_8">
|
||||
<widget class="QLineEdit" name="NumberLine">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>102</x>
|
||||
@ -709,7 +709,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_9">
|
||||
<widget class="QLineEdit" name="NameLine">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
@ -730,7 +730,7 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="data1"/>
|
||||
<widget class="QLineEdit" name="monthLine"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_15">
|
||||
@ -740,7 +740,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="data2"/>
|
||||
<widget class="QLineEdit" name="yearLine"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -754,6 +754,9 @@
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="pinLine"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
@ -761,6 +764,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="titleLine"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
@ -768,12 +774,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_12"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_11"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
@ -781,8 +781,18 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_13"/>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="cvvLine"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="noteLine"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_28">
|
||||
<property name="text">
|
||||
<string>note</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -812,6 +822,32 @@
|
||||
<string>до</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="cardEditOkButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>550</x>
|
||||
<y>470</y>
|
||||
<width>80</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="cardEditCancelButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>470</y>
|
||||
<width>80</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_7">
|
||||
<widget class="QPushButton" name="pushButton_11">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user