Moving records and cards between directories was done
This commit is contained in:
parent
b84ab05bed
commit
bc0b863343
@ -30,6 +30,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(del, SIGNAL(trueDelete()), this, SLOT(acceptRecordDelete()));
|
connect(del, SIGNAL(trueDelete()), this, SLOT(acceptRecordDelete()));
|
||||||
connect(deleteCardDial, SIGNAL(trueDelete()), this, SLOT(acceptCardDelete()));
|
connect(deleteCardDial, SIGNAL(trueDelete()), this, SLOT(acceptCardDelete()));
|
||||||
connect(addc, SIGNAL(sendCard(Card*)), this, SLOT(addCardSlot(Card*)));
|
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));
|
crypto = new SimpleCrypt(Q_UINT64_C(0x0c2ad4a4acb9f023));
|
||||||
// createModel();
|
// createModel();
|
||||||
ui->tableViewRecords->setEnabled(true);
|
ui->tableViewRecords->setEnabled(true);
|
||||||
@ -126,8 +127,8 @@ void MainWindow::putRecord(Record* record){
|
|||||||
|
|
||||||
QString password = crypto->encryptToString(record->getPassword());
|
QString password = crypto->encryptToString(record->getPassword());
|
||||||
qDebug() << "Добавление строки:" <<
|
qDebug() << "Добавление строки:" <<
|
||||||
query->prepare("INSERT INTO records(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)");
|
"VALUES(:id, :name, :username, :password, :url, :note, :time, :status, :directory)");
|
||||||
// query->prepare("INSERT INTO employees(id, last_name, first_name, occupation, year_of_admission) " \
|
// query->prepare("INSERT INTO employees(id, last_name, first_name, occupation, year_of_admission) " \
|
||||||
// "VALUES(:id, :last_name, :first_name, :occupation, :year_of_admission)");
|
// "VALUES(:id, :last_name, :first_name, :occupation, :year_of_admission)");
|
||||||
query->bindValue(":id", record->getId());
|
query->bindValue(":id", record->getId());
|
||||||
@ -138,6 +139,7 @@ void MainWindow::putRecord(Record* record){
|
|||||||
query->bindValue(":note", record->getNote());
|
query->bindValue(":note", record->getNote());
|
||||||
query->bindValue(":time", record->getTime());
|
query->bindValue(":time", record->getTime());
|
||||||
query->bindValue(":status", record->getStatus());
|
query->bindValue(":status", record->getStatus());
|
||||||
|
query->bindValue(":directory", ui->directoriesList->currentIndex().data(Qt::DisplayRole).toString());
|
||||||
query->exec();
|
query->exec();
|
||||||
recordsModel->select();
|
recordsModel->select();
|
||||||
}
|
}
|
||||||
@ -372,8 +374,8 @@ void MainWindow::putCard(Card* card)
|
|||||||
query->clear();
|
query->clear();
|
||||||
|
|
||||||
qDebug() << "Добавление строки:" <<
|
qDebug() << "Добавление строки:" <<
|
||||||
query->prepare("INSERT INTO cards(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)");
|
"VALUES(:id, :title, :number, :name, :month, :year, :cvv, :pin, :note, :time, :status, :directory)");
|
||||||
query->bindValue(":id", card->getId());
|
query->bindValue(":id", card->getId());
|
||||||
query->bindValue(":title", card->getTitle());
|
query->bindValue(":title", card->getTitle());
|
||||||
query->bindValue(":number", crypto->encryptToString(card->getNumber()));
|
query->bindValue(":number", crypto->encryptToString(card->getNumber()));
|
||||||
@ -385,6 +387,7 @@ void MainWindow::putCard(Card* card)
|
|||||||
query->bindValue(":note", card->getNote());
|
query->bindValue(":note", card->getNote());
|
||||||
query->bindValue(":time", card->getTime());
|
query->bindValue(":time", card->getTime());
|
||||||
query->bindValue(":status", card->getStatus());
|
query->bindValue(":status", card->getStatus());
|
||||||
|
query->bindValue(":directory", ui->directoriesList->currentIndex().data(Qt::DisplayRole).toString());
|
||||||
query->exec();
|
query->exec();
|
||||||
cardsModel->select();
|
cardsModel->select();
|
||||||
}
|
}
|
||||||
@ -507,8 +510,31 @@ void MainWindow::createDirectoriesModel()
|
|||||||
ui->directoriesList->setCurrentIndex(ui->directoriesList->model()->index(0,1));
|
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();
|
deleteCard();
|
||||||
}
|
}
|
||||||
void MainWindow::moveItemSlot()
|
void MainWindow::moveItemSlot(QString directory)
|
||||||
{
|
{
|
||||||
moveItem();
|
moveItem(directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void MainWindow::on_editSaveButton_clicked()
|
//void MainWindow::on_editSaveButton_clicked()
|
||||||
@ -851,6 +877,8 @@ void MainWindow::on_addDirectoryButton_clicked()
|
|||||||
qDebug() << "newDir: " << newName;
|
qDebug() << "newDir: " << newName;
|
||||||
query->exec();
|
query->exec();
|
||||||
directoriesModel->select();
|
directoriesModel->select();
|
||||||
|
QModelIndex index = ui->directoriesList->model()->index(ui->directoriesList->colorCount(), 0);
|
||||||
|
ui->directoriesList->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_directoriesList_clicked(const QModelIndex &index)
|
void MainWindow::on_directoriesList_clicked(const QModelIndex &index)
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public:
|
|||||||
int getCardsCount();
|
int getCardsCount();
|
||||||
int getDirectoriesCount();
|
int getDirectoriesCount();
|
||||||
void createDirectoriesModel();
|
void createDirectoriesModel();
|
||||||
void moveItem();
|
void moveItem(QString directory);
|
||||||
private:
|
private:
|
||||||
// Manager* manager;
|
// Manager* manager;
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
@ -99,7 +99,7 @@ private slots:
|
|||||||
// void openDBSlot(QString path);
|
// void openDBSlot(QString path);
|
||||||
void acceptRecordDelete();
|
void acceptRecordDelete();
|
||||||
void acceptCardDelete();
|
void acceptCardDelete();
|
||||||
void moveItemSlot();
|
void moveItemSlot(QString directory);
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
// void on_pushButton_2_clicked();
|
// void on_pushButton_2_clicked();
|
||||||
|
|||||||
@ -19,7 +19,6 @@ void MovingDialog::initialize(QStringList items)
|
|||||||
|
|
||||||
void MovingDialog::on_buttonBox_accepted()
|
void MovingDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
|
|
||||||
emit trueMove(ui->comboBox->currentText());
|
emit trueMove(ui->comboBox->currentText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user