FixedAdding #1
@ -30,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(del, SIGNAL(trueDelete()), this, SLOT(acceptRecordDelete()));
|
||||
connect(deleteCardDial, SIGNAL(trueDelete()), this, SLOT(acceptCardDelete()));
|
||||
connect(addc, SIGNAL(sendCard(Card*)), this, SLOT(addCardSlot(Card*)));
|
||||
connect(movingDialog, SIGNAL(trueMove(QString directory)), this, SLOT(moveItemSlot(QString directory)));
|
||||
crypto = new SimpleCrypt(Q_UINT64_C(0x0c2ad4a4acb9f023));
|
||||
// createModel();
|
||||
ui->tableViewRecords->setEnabled(true);
|
||||
@ -126,8 +127,8 @@ void MainWindow::putRecord(Record* record){
|
||||
|
||||
QString password = crypto->encryptToString(record->getPassword());
|
||||
qDebug() << "Добавление строки:" <<
|
||||
query->prepare("INSERT INTO records(id, name, username, password, url, note, time, status)" \
|
||||
"VALUES(:id, :name, :username, :password, :url, :note, :time, :status)");
|
||||
query->prepare("INSERT INTO records(id, name, username, password, url, note, time, status, directory)" \
|
||||
"VALUES(:id, :name, :username, :password, :url, :note, :time, :status, :directory)");
|
||||
// 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->bindValue(":id", record->getId());
|
||||
@ -138,6 +139,7 @@ void MainWindow::putRecord(Record* record){
|
||||
query->bindValue(":note", record->getNote());
|
||||
query->bindValue(":time", record->getTime());
|
||||
query->bindValue(":status", record->getStatus());
|
||||
query->bindValue(":directory", ui->directoriesList->currentIndex().data(Qt::DisplayRole).toString());
|
||||
query->exec();
|
||||
recordsModel->select();
|
||||
}
|
||||
@ -372,8 +374,8 @@ void MainWindow::putCard(Card* card)
|
||||
query->clear();
|
||||
|
||||
qDebug() << "Добавление строки:" <<
|
||||
query->prepare("INSERT INTO cards(id, title, number, name, month, year, cvv, pin, note, time, status)" \
|
||||
"VALUES(:id, :title, :number, :name, :month, :year, :cvv, :pin, :note, :time, :status)");
|
||||
query->prepare("INSERT INTO cards(id, title, number, name, month, year, cvv, pin, note, time, status, directory)" \
|
||||
"VALUES(:id, :title, :number, :name, :month, :year, :cvv, :pin, :note, :time, :status, :directory)");
|
||||
query->bindValue(":id", card->getId());
|
||||
query->bindValue(":title", card->getTitle());
|
||||
query->bindValue(":number", crypto->encryptToString(card->getNumber()));
|
||||
@ -385,6 +387,7 @@ void MainWindow::putCard(Card* card)
|
||||
query->bindValue(":note", card->getNote());
|
||||
query->bindValue(":time", card->getTime());
|
||||
query->bindValue(":status", card->getStatus());
|
||||
query->bindValue(":directory", ui->directoriesList->currentIndex().data(Qt::DisplayRole).toString());
|
||||
query->exec();
|
||||
cardsModel->select();
|
||||
}
|
||||
@ -507,8 +510,31 @@ void MainWindow::createDirectoriesModel()
|
||||
ui->directoriesList->setCurrentIndex(ui->directoriesList->model()->index(0,1));
|
||||
|
||||
}
|
||||
void MainWindow::moveItem()
|
||||
void MainWindow::moveItem(QString directory)
|
||||
{
|
||||
if(ui->tablesStack->currentIndex() == 0)//PW
|
||||
{
|
||||
int num = ui->tableViewRecords->currentIndex().row();
|
||||
QVariant x = recordsModel->record(num).value(0);
|
||||
int id;
|
||||
id = x.toInt();
|
||||
query->clear();
|
||||
query->prepare("UPDATE records SET directory=:directory WHERE id=:id");
|
||||
query->bindValue(":id", id);
|
||||
query->bindValue(":directory", directory);
|
||||
recordsModel->select();
|
||||
}else if(ui->tablesStack->currentIndex() == 1)//CARD
|
||||
{
|
||||
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 directory=:directory WHERE id=:id");
|
||||
query->bindValue(":id", id);
|
||||
query->bindValue(":directory", directory);
|
||||
cardsModel->select();
|
||||
}
|
||||
|
||||
}
|
||||
// Метод показывающий диалоговое окно для выбора файла для новой базы данных:
|
||||
@ -680,9 +706,9 @@ void MainWindow::acceptCardDelete()
|
||||
{
|
||||
deleteCard();
|
||||
}
|
||||
void MainWindow::moveItemSlot()
|
||||
void MainWindow::moveItemSlot(QString directory)
|
||||
{
|
||||
moveItem();
|
||||
moveItem(directory);
|
||||
}
|
||||
|
||||
//void MainWindow::on_editSaveButton_clicked()
|
||||
@ -851,6 +877,8 @@ void MainWindow::on_addDirectoryButton_clicked()
|
||||
qDebug() << "newDir: " << newName;
|
||||
query->exec();
|
||||
directoriesModel->select();
|
||||
QModelIndex index = ui->directoriesList->model()->index(ui->directoriesList->colorCount(), 0);
|
||||
ui->directoriesList->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void MainWindow::on_directoriesList_clicked(const QModelIndex &index)
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
int getCardsCount();
|
||||
int getDirectoriesCount();
|
||||
void createDirectoriesModel();
|
||||
void moveItem();
|
||||
void moveItem(QString directory);
|
||||
private:
|
||||
// Manager* manager;
|
||||
Ui::MainWindow *ui;
|
||||
@ -99,7 +99,7 @@ private slots:
|
||||
// void openDBSlot(QString path);
|
||||
void acceptRecordDelete();
|
||||
void acceptCardDelete();
|
||||
void moveItemSlot();
|
||||
void moveItemSlot(QString directory);
|
||||
|
||||
void on_pushButton_clicked();
|
||||
// void on_pushButton_2_clicked();
|
||||
|
||||
@ -19,7 +19,6 @@ void MovingDialog::initialize(QStringList items)
|
||||
|
||||
void MovingDialog::on_buttonBox_accepted()
|
||||
{
|
||||
|
||||
emit trueMove(ui->comboBox->currentText());
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user