FixedAdding #1
@ -51,6 +51,9 @@ set(PROJECT_SOURCES
|
||||
deletecarddialog.h
|
||||
deletecarddialog.cpp
|
||||
deletecarddialog.ui
|
||||
movingdialog.h
|
||||
movingdialog.cpp
|
||||
movingdialog.ui
|
||||
)
|
||||
|
||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||
|
||||
@ -25,6 +25,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
del = new Del();
|
||||
addc = new AddC();
|
||||
deleteCardDial = new DeleteCardDialog();
|
||||
movingDialog = new MovingDialog();
|
||||
connect(dial,SIGNAL(sendText(Record*)),this,SLOT(addRecordSlot(Record*)));
|
||||
connect(del, SIGNAL(trueDelete()), this, SLOT(acceptRecordDelete()));
|
||||
connect(deleteCardDial, SIGNAL(trueDelete()), this, SLOT(acceptCardDelete()));
|
||||
@ -294,14 +295,14 @@ void MainWindow::createDatabase(const QString &password)
|
||||
delete crypto;
|
||||
crypto = new SimpleCrypt(convertPassword(password));
|
||||
query->clear();
|
||||
query->exec("CREATE TABLE keys(id TEXT PRIMARY KEY NOT NULL, word TEXT);");
|
||||
qDebug() << "Создание таблицы keys:" << query->exec("CREATE TABLE keys(id TEXT PRIMARY KEY NOT NULL, word TEXT);");
|
||||
query->prepare("INSERT INTO keys(id, word)" \
|
||||
"VALUES(:id, :word)");
|
||||
query->bindValue(":id", 0);
|
||||
query->bindValue(":word", crypto->encryptToString(QString::fromStdString((checkpoint))));
|
||||
query->exec();
|
||||
query->clear();
|
||||
query->exec("CREATE TABLE directories(id TEXT PRIMARY KEY NOT NULL, name TEXT);");
|
||||
qDebug() << "Создание таблицы directories:" << query->exec("CREATE TABLE directories(name TEXT);");
|
||||
}
|
||||
|
||||
bool MainWindow::checkPassoword(QString word)
|
||||
@ -479,20 +480,14 @@ int MainWindow::getDirectoriesCount()
|
||||
query->prepare("SELECT * FROM directories");
|
||||
query->exec();
|
||||
QSqlRecord rec = query->record();
|
||||
query->next();
|
||||
|
||||
int max = query->value(rec.indexOf("id")).toInt();
|
||||
int cur = max;
|
||||
int i = 0;
|
||||
while(query->next())
|
||||
{
|
||||
cur = query->value(rec.indexOf("id")).toInt();
|
||||
if(max < cur)
|
||||
{
|
||||
max = cur;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
qDebug() << "max" << max;
|
||||
return max;
|
||||
qDebug() << "max = " << i;
|
||||
return i;
|
||||
}
|
||||
void MainWindow::createDirectoriesModel()
|
||||
{
|
||||
@ -504,13 +499,16 @@ void MainWindow::createDirectoriesModel()
|
||||
// Выбор стратегии сохранения изменений в базе данных:
|
||||
directoriesModel->setEditStrategy(QSqlTableModel::OnFieldChange); // сохранение происходит при переходе к другому полю.
|
||||
|
||||
|
||||
ui->direcoriesTable->setModel(directoriesModel); // соединение модели и ее табличного представления в форме.
|
||||
ui->directoriesList->setModel(directoriesModel); // соединение модели и ее табличного представления в форме.
|
||||
|
||||
directoriesModel->setHeaderData(0, Qt::Horizontal, tr("number"));
|
||||
directoriesModel->setHeaderData(1, Qt::Horizontal, tr("directories"));
|
||||
|
||||
ui->direcoriesTable->setCurrentIndex(ui->direcoriesTable->model()->index(0,1));
|
||||
ui->directoriesList->setCurrentIndex(ui->directoriesList->model()->index(0,1));
|
||||
|
||||
}
|
||||
void MainWindow::moveItem()
|
||||
{
|
||||
|
||||
}
|
||||
// Метод показывающий диалоговое окно для выбора файла для новой базы данных:
|
||||
@ -593,9 +591,22 @@ void MainWindow::on_pushButton_7_clicked()
|
||||
|
||||
void MainWindow::on_pushButton_9_clicked()
|
||||
{
|
||||
ui->stackedWidget->setCurrentIndex(3);
|
||||
// ui->stackedWidget->setCurrentIndex(3);
|
||||
|
||||
qApp->setStyleSheet("QWidget{background-color: #202020;color: #fff;selection-background-color: #ff732d; selection-color: #000;}");
|
||||
// qApp->setStyleSheet("QWidget{background-color: #202020;color: #fff;selection-background-color: #ff732d; selection-color: #000;}");
|
||||
QStringList list;
|
||||
query->clear();
|
||||
qDebug() << "query->clear();";
|
||||
query->prepare("SELECT * FROM directories");
|
||||
query->exec();
|
||||
QSqlRecord rec = query->record();
|
||||
while(query->next())
|
||||
{
|
||||
QString name = query->value(rec.indexOf("name")).toString();
|
||||
list.append(name);
|
||||
}
|
||||
movingDialog->initialize(list);
|
||||
movingDialog->show();
|
||||
|
||||
|
||||
}
|
||||
@ -669,6 +680,10 @@ void MainWindow::acceptCardDelete()
|
||||
{
|
||||
deleteCard();
|
||||
}
|
||||
void MainWindow::moveItemSlot()
|
||||
{
|
||||
moveItem();
|
||||
}
|
||||
|
||||
//void MainWindow::on_editSaveButton_clicked()
|
||||
//{
|
||||
@ -806,15 +821,51 @@ void MainWindow::on_cardEditCancelButton_clicked()
|
||||
|
||||
void MainWindow::on_addDirectoryButton_clicked()
|
||||
{
|
||||
QString newName = "Новая папка " + QString::number(getDirectoriesCount());
|
||||
query->clear();
|
||||
qDebug() << "query->clear();";
|
||||
query->prepare("SELECT * FROM directories");
|
||||
query->exec();
|
||||
QSqlRecord rec = query->record();
|
||||
while(query->next())
|
||||
{
|
||||
QString name = query->value(rec.indexOf("name")).toString();
|
||||
if(name.compare(newName) == 0)
|
||||
{
|
||||
return;
|
||||
qDebug() << "duplicates";
|
||||
}else
|
||||
{
|
||||
qDebug() << name;
|
||||
}
|
||||
}
|
||||
query->clear();
|
||||
|
||||
query->prepare("INSERT INTO directories(id, name)" \
|
||||
"VALUES(:id, :name)");
|
||||
// query->bindValue(":id", getDirectoriesCount());
|
||||
query->prepare("INSERT INTO directories(name)" \
|
||||
"VALUES(:name)");
|
||||
|
||||
// query->bindValue(":id", "text");
|
||||
// query->bindValue(":name", "dir");
|
||||
query->bindValue(":id", getDirectoriesCount()+1);
|
||||
query->bindValue(":name", "dir");
|
||||
// query->bindValue(":id", getDirectoriesCount()+1);
|
||||
query->bindValue(":name", newName);
|
||||
qDebug() << "newDir: " << newName;
|
||||
query->exec();
|
||||
directoriesModel->select();
|
||||
}
|
||||
|
||||
void MainWindow::on_directoriesList_clicked(const QModelIndex &index)
|
||||
{
|
||||
qDebug() << "indexes clicked number: " << index.row();
|
||||
qDebug() << "filtering...";
|
||||
// model->setFilter(QString("USERNAME="+ ui->lineEdit_7->text() +"OR PASSWORD="+ ui->lineEdit_7->text()));
|
||||
QString itemText = ui->directoriesList->currentIndex().data(Qt::DisplayRole).toString();
|
||||
QString f = QString("directory LIKE '%");
|
||||
f+= itemText + QString("%'");
|
||||
qDebug() << f;
|
||||
recordsModel->setFilter(f);
|
||||
recordsModel->select();
|
||||
cardsModel->setFilter(f);
|
||||
cardsModel->select();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include"card.h"
|
||||
#include"record.h"
|
||||
#include"deletecarddialog.h"
|
||||
#include"movingdialog.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class MainWindow; }
|
||||
@ -46,6 +47,7 @@ public:
|
||||
int getCardsCount();
|
||||
int getDirectoriesCount();
|
||||
void createDirectoriesModel();
|
||||
void moveItem();
|
||||
private:
|
||||
// Manager* manager;
|
||||
Ui::MainWindow *ui;
|
||||
@ -63,6 +65,7 @@ private:
|
||||
|
||||
Del* del;
|
||||
DeleteCardDialog* deleteCardDial;
|
||||
MovingDialog* movingDialog;
|
||||
// AddSt addst;
|
||||
static const QString fileDialogFilterString;
|
||||
static constexpr char* checkpoint = "checkpoint";
|
||||
@ -96,6 +99,7 @@ private slots:
|
||||
// void openDBSlot(QString path);
|
||||
void acceptRecordDelete();
|
||||
void acceptCardDelete();
|
||||
void moveItemSlot();
|
||||
|
||||
void on_pushButton_clicked();
|
||||
// void on_pushButton_2_clicked();
|
||||
@ -125,5 +129,6 @@ private slots:
|
||||
void on_cardEditOkButton_clicked();
|
||||
void on_cardEditCancelButton_clicked();
|
||||
void on_addDirectoryButton_clicked();
|
||||
void on_directoriesList_clicked(const QModelIndex &index);
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@ -566,16 +566,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QListView" name="direcoriesTable">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>200</width>
|
||||
<height>490</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -615,6 +605,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QListView" name="directoriesList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>201</width>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QTableView" name="tableView_2">
|
||||
|
||||
25
PasswordManager/movingdialog.cpp
Normal file
25
PasswordManager/movingdialog.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "movingdialog.h"
|
||||
#include "ui_movingdialog.h"
|
||||
|
||||
MovingDialog::MovingDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::MovingDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
MovingDialog::~MovingDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void MovingDialog::initialize(QStringList items)
|
||||
{
|
||||
ui->comboBox->addItems(items);
|
||||
}
|
||||
|
||||
void MovingDialog::on_buttonBox_accepted()
|
||||
{
|
||||
|
||||
emit trueMove(ui->comboBox->currentText());
|
||||
}
|
||||
|
||||
30
PasswordManager/movingdialog.h
Normal file
30
PasswordManager/movingdialog.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef MOVINGDIALOG_H
|
||||
#define MOVINGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QtSql>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MovingDialog;
|
||||
}
|
||||
|
||||
class MovingDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MovingDialog(QWidget *parent = nullptr);
|
||||
~MovingDialog();
|
||||
void initialize(QStringList items);
|
||||
signals:
|
||||
void trueMove(QString directory);
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::MovingDialog *ui;
|
||||
};
|
||||
|
||||
#endif // MOVINGDIALOG_H
|
||||
91
PasswordManager/movingdialog.ui
Normal file
91
PasswordManager/movingdialog.ui
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MovingDialog</class>
|
||||
<widget class="QDialog" name="MovingDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>180</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>110</y>
|
||||
<width>340</width>
|
||||
<height>61</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>201</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Выберите папку назначения:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>331</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>MovingDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>MovingDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Reference in New Issue
Block a user