Deleting fixed, watch button broken
This commit is contained in:
parent
b26359a74f
commit
95fa263f92
@ -15,8 +15,16 @@ Del::~Del()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Del::on_pushButton_2_clicked()
|
||||
void Del::on_deleteCancelButton_clicked()
|
||||
{
|
||||
QWidget::close();
|
||||
QWidget::close();
|
||||
}
|
||||
|
||||
|
||||
void Del::on_deleteAcceptButton_clicked()
|
||||
{
|
||||
emit trueDelete();
|
||||
QWidget::close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -15,8 +15,12 @@ public:
|
||||
explicit Del(QWidget *parent = nullptr);
|
||||
~Del();
|
||||
|
||||
signals:
|
||||
void trueDelete();
|
||||
private slots:
|
||||
void on_pushButton_2_clicked();
|
||||
void on_deleteCancelButton_clicked();
|
||||
|
||||
void on_deleteAcceptButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::Del *ui;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<widget class="QPushButton" name="deleteAcceptButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
@ -26,7 +26,7 @@
|
||||
<string>Удалить</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="deleteCancelButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
@ -49,7 +49,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Вы уверены, что хотите удалить эту запись?
|
||||
<string>Вы уверены, что хотите удалить эту запись?
|
||||
P.S. Пути назад не будет.</string>
|
||||
</property>
|
||||
</widget>
|
||||
|
||||
@ -20,7 +20,9 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
this->setFixedSize(800,600);
|
||||
// manager = new Manager();
|
||||
dial = new AddDialog();
|
||||
del = new Del();
|
||||
connect(dial,SIGNAL(sendText(Record*)),this,SLOT(addRecordSlot(Record*)));
|
||||
connect(del, SIGNAL(trueDelete()), this, SLOT(acceptDelete()));
|
||||
crypto = new SimpleCrypt(Q_UINT64_C(0x0c2ad4a4acb9f023));
|
||||
createModel();
|
||||
ui->tableViewRecords->setEnabled(true);
|
||||
@ -72,9 +74,9 @@ void MainWindow::putRecord(Record* record){
|
||||
//// if (id.isEmpty() || lastName.isEmpty() || firstName.isEmpty() || occupation.isEmpty() || yeaOfAdmission.isEmpty())
|
||||
//// return;
|
||||
|
||||
query->clear();
|
||||
query->clear();
|
||||
|
||||
QString password = crypto->encryptToString(record->getPassword());
|
||||
QString password = crypto->encryptToString(record->getPassword());
|
||||
qDebug() << "Добавление строки:" <<
|
||||
query->prepare("INSERT INTO records(id, name, username, password, url, note, time)" \
|
||||
"VALUES(:id, :name, :username, :password, :url, :note, :time)");
|
||||
@ -136,17 +138,16 @@ void MainWindow::updateRecord(Record* r)
|
||||
}
|
||||
void MainWindow::deleteRecord()
|
||||
{
|
||||
// if (ui->spinBoxID->text().isEmpty())
|
||||
// return;
|
||||
QString id = "zzz";
|
||||
// QString id = ui->spinBoxID->text();
|
||||
|
||||
int num = ui->tableViewRecords->currentIndex().row();
|
||||
QVariant x = model->record(num).value(0);
|
||||
int id;
|
||||
id = x.toInt();
|
||||
qDebug() << "id = " << id;
|
||||
query->clear();
|
||||
|
||||
qDebug() << "Удаление строки:" <<
|
||||
query->exec(QString("DELETE FROM recordsn3ox WHERE id = %1;").arg(id));
|
||||
|
||||
// model->select(); // наполнить модель данными из таблицы, учитывая условия фильтрации и сортировки.
|
||||
query->exec(QString("DELETE FROM records WHERE id = %1;").arg(id));
|
||||
model->select();
|
||||
}
|
||||
|
||||
int MainWindow::getRecordsCount(){
|
||||
@ -262,7 +263,7 @@ void MainWindow::on_tableView_activated(const QModelIndex &index)
|
||||
|
||||
void MainWindow::on_deleteButton_clicked()
|
||||
{
|
||||
del.show();
|
||||
del->show();
|
||||
}
|
||||
|
||||
|
||||
@ -356,6 +357,12 @@ void MainWindow::openDBSlot(QString path)
|
||||
model->select();
|
||||
}
|
||||
|
||||
void MainWindow::acceptDelete()
|
||||
{
|
||||
|
||||
deleteRecord();
|
||||
}
|
||||
|
||||
//void MainWindow::on_editSaveButton_clicked()
|
||||
//{
|
||||
// Record* r = new Record();
|
||||
@ -375,17 +382,17 @@ void MainWindow::openDBSlot(QString path)
|
||||
|
||||
void MainWindow::on_pushButton_4_clicked()
|
||||
{
|
||||
// Record* record = getRecord(ui->tableViewRecords->currentIndex().row());
|
||||
// Record* record = getRecord(ui->tableViewRecords->currentIndex().row());
|
||||
int num = ui->tableViewRecords->currentIndex().row();//ui->tableViewRecords->selectionModel()->selection().indexes().at(0).row();
|
||||
qDebug() << ++num;
|
||||
Record* r = getRecord(num);
|
||||
QString password = crypto->decryptToString(r->getPassword());
|
||||
ui->lineEdit_name->setText(r->getName());
|
||||
ui->lineEdit_username->setText(r->getUsername());
|
||||
ui->lineEdit_password->setText(password);
|
||||
ui->lineEdit_url->setText(r->getURL());
|
||||
ui->lineEdit_note->setText(r->getNote());
|
||||
ui->stackedWidget->setCurrentIndex(2);
|
||||
qDebug() << ++num;
|
||||
Record* r = getRecord(num);
|
||||
QString password = crypto->decryptToString(r->getPassword());
|
||||
ui->lineEdit_name->setText(r->getName());
|
||||
ui->lineEdit_username->setText(r->getUsername());
|
||||
ui->lineEdit_password->setText(password);
|
||||
ui->lineEdit_url->setText(r->getURL());
|
||||
ui->lineEdit_note->setText(r->getNote());
|
||||
ui->stackedWidget->setCurrentIndex(2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ private:
|
||||
QSqlQuery *query; // указатель на запрос.
|
||||
QSqlTableModel *model; // указатель на таблицу данных в приложении.
|
||||
|
||||
Del del;
|
||||
Del* del;
|
||||
// AddSt addst;
|
||||
static const QString fileDialogFilterString;
|
||||
|
||||
@ -60,6 +60,7 @@ private slots:
|
||||
|
||||
void addRecordSlot(Record *r);//слот принимающий текст из LineEdit
|
||||
void openDBSlot(QString path);
|
||||
void acceptDelete();
|
||||
|
||||
void on_pushButton_clicked();
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user