Changing the selection db File Path to the selection login completed
This commit is contained in:
parent
2b4f114adf
commit
5473128a16
Binary file not shown.
@ -29,29 +29,6 @@ void Hello::on_pushButton_2_clicked()
|
|||||||
ui->stackedWidget->setCurrentIndex(1);
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hello::on_pushButton_4_clicked()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dbFileFullPath = QFileDialog::getOpenFileName(this, tr("Open SQLite Database File"), "", Hello::fileDialogFilterString);
|
|
||||||
// manager->initAppWithDatabaseFile(dbFileFullPath);
|
|
||||||
ui->lineEdit->setText(dbFileFullPath);
|
|
||||||
|
|
||||||
// emit sendText(dbFileFullPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Hello::on_pushButton_5_clicked()
|
|
||||||
{
|
|
||||||
dbFileFullPath = QFileDialog::getSaveFileName(this, tr("Open SQLite Database File"), "", Hello::fileDialogFilterString);
|
|
||||||
// manager->initAppWithDatabaseFile(dbFileFullPath);
|
|
||||||
ui->lineEdit_3->setText(dbFileFullPath);
|
|
||||||
|
|
||||||
// emit sendText(dbFileFullPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Hello::on_pushButton_6_clicked()
|
void Hello::on_pushButton_6_clicked()
|
||||||
{
|
{
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
@ -60,9 +37,18 @@ void Hello::on_pushButton_6_clicked()
|
|||||||
|
|
||||||
void Hello::on_okButton_clicked()
|
void Hello::on_okButton_clicked()
|
||||||
{
|
{
|
||||||
|
QString dbLogin;
|
||||||
|
if(!ui->lineEdit->text().isEmpty()){
|
||||||
|
dbLogin = ui->lineEdit->text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
QString password = ui->passwordLine->text();
|
QString password = ui->passwordLine->text();
|
||||||
|
|
||||||
// mainwindow.createModel();
|
// mainwindow.createModel();
|
||||||
if(mainwindow.initAppWithDatabaseFile(dbFileFullPath, password, false))
|
if(mainwindow.initAppWithDatabaseFile(dbLogin, password, false))
|
||||||
{
|
{
|
||||||
|
|
||||||
if(mainwindow.checkPassoword(password))
|
if(mainwindow.checkPassoword(password))
|
||||||
@ -78,11 +64,22 @@ void Hello::on_okButton_clicked()
|
|||||||
|
|
||||||
void Hello::on_createOkButton_clicked()
|
void Hello::on_createOkButton_clicked()
|
||||||
{
|
{
|
||||||
if(QString::compare(ui->newPasswordLine1->text(), ui->newPasswordLine2->text()) == 0)
|
qDebug() << "creating db";
|
||||||
|
QString dbLogin;
|
||||||
|
if(!ui->lineEdit_3->text().isEmpty()){
|
||||||
|
dbLogin = ui->lineEdit_3->text();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
mainwindow.initAppWithDatabaseFile(dbFileFullPath, ui->newPasswordLine1->text(), true);
|
return;
|
||||||
|
}
|
||||||
|
if(QString::compare(ui->newPasswordLine1->text(), ui->newPasswordLine2->text()) == 0 && !dbLogin.isEmpty())
|
||||||
|
{
|
||||||
|
if(mainwindow.initAppWithDatabaseFile(dbLogin, ui->newPasswordLine1->text(), true))
|
||||||
|
{
|
||||||
mainwindow.show();
|
mainwindow.show();
|
||||||
QWidget::close() ;
|
QWidget::close() ;
|
||||||
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
// std::cout << "passwords not equals : " << ui->newPasswordLine1->text().toStdString() << "!=" << ui->newPasswordLine2->text().toStdString() << std::endl;
|
// std::cout << "passwords not equals : " << ui->newPasswordLine1->text().toStdString() << "!=" << ui->newPasswordLine2->text().toStdString() << std::endl;
|
||||||
|
|||||||
@ -21,10 +21,6 @@ private slots:
|
|||||||
|
|
||||||
void on_pushButton_2_clicked();
|
void on_pushButton_2_clicked();
|
||||||
|
|
||||||
void on_pushButton_4_clicked();
|
|
||||||
|
|
||||||
void on_pushButton_5_clicked();
|
|
||||||
|
|
||||||
void on_pushButton_6_clicked();
|
void on_pushButton_6_clicked();
|
||||||
|
|
||||||
void on_okButton_clicked();
|
void on_okButton_clicked();
|
||||||
@ -37,7 +33,6 @@ private:
|
|||||||
Manager* manager;
|
Manager* manager;
|
||||||
AddDialog dial;
|
AddDialog dial;
|
||||||
|
|
||||||
QString dbFileFullPath;
|
|
||||||
static const QString fileDialogFilterString;
|
static const QString fileDialogFilterString;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Путь:</string>
|
<string>Логин:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
@ -82,7 +82,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Войти</string>
|
<string>Вход</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="okButton">
|
<widget class="QPushButton" name="okButton">
|
||||||
@ -111,19 +111,6 @@
|
|||||||
<string>Создать</string>
|
<string>Создать</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_4">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>340</x>
|
|
||||||
<y>90</y>
|
|
||||||
<width>31</width>
|
|
||||||
<height>21</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_2">
|
<widget class="QWidget" name="page_2">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
@ -136,7 +123,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Создать новую</string>
|
<string>Регистрация</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLineEdit" name="lineEdit_3">
|
<widget class="QLineEdit" name="lineEdit_3">
|
||||||
@ -179,7 +166,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Путь:</string>
|
<string>Логин:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
@ -192,7 +179,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Пароль</string>
|
<string>Пароль:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_7">
|
<widget class="QLabel" name="label_7">
|
||||||
@ -205,7 +192,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Подтвердить пароль</string>
|
<string>Подтвердить пароль:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="createOkButton">
|
<widget class="QPushButton" name="createOkButton">
|
||||||
@ -221,19 +208,6 @@
|
|||||||
<string>Ок</string>
|
<string>Ок</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="pushButton_5">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>360</x>
|
|
||||||
<y>70</y>
|
|
||||||
<width>31</width>
|
|
||||||
<height>21</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton" name="pushButton_6">
|
<widget class="QPushButton" name="pushButton_6">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
|
|||||||
@ -61,16 +61,36 @@ void MainWindow::createRecordsModel()
|
|||||||
ui->tableViewRecords->horizontalHeader()->hideSection(3);
|
ui->tableViewRecords->horizontalHeader()->hideSection(3);
|
||||||
|
|
||||||
}
|
}
|
||||||
bool MainWindow::initAppWithDatabaseFile(const QString &dbFileFullPath, const QString &password, bool isCreationNeed) {
|
bool MainWindow::initAppWithDatabaseFile(const QString &dbLogin, const QString &password, bool isCreationNeed) {
|
||||||
|
QString dbFileFullPath = getDbFileFullPath(dbLogin);
|
||||||
qDebug() << "dbFileFullPath=" << dbFileFullPath;
|
qDebug() << "dbFileFullPath=" << dbFileFullPath;
|
||||||
if (dbFileFullPath.isEmpty())
|
if( QFile::exists(dbFileFullPath))
|
||||||
{
|
{
|
||||||
return false;
|
|
||||||
|
if(isCreationNeed)
|
||||||
|
{
|
||||||
|
qDebug()<<"Data base exist....";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connectToDatabase(dbFileFullPath);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
connectToDatabase(dbFileFullPath);
|
else
|
||||||
if(isCreationNeed)
|
|
||||||
{
|
{
|
||||||
createDatabase(dbFileFullPath, password);
|
if(isCreationNeed)
|
||||||
|
{
|
||||||
|
connectToDatabase(dbFileFullPath);
|
||||||
|
createDatabase(password);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug()<<"Data base not exist....";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
createRecordsModel();
|
createRecordsModel();
|
||||||
createCardsModel();
|
createCardsModel();
|
||||||
@ -213,7 +233,7 @@ void MainWindow::connectToDatabase(const QString &dbName)
|
|||||||
query = new QSqlQuery(m_db); // создание объекта для запроса.
|
query = new QSqlQuery(m_db); // создание объекта для запроса.
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createDatabase(const QString &dbName, const QString &password)
|
void MainWindow::createDatabase(const QString &password)
|
||||||
{
|
{
|
||||||
qDebug() << "В базе не существует таблица records!";
|
qDebug() << "В базе не существует таблица records!";
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public:
|
|||||||
int getRecordsCount();
|
int getRecordsCount();
|
||||||
bool initAppWithDatabaseFile(const QString &dbFileFullPath, const QString &password, bool isCreationNeed);
|
bool initAppWithDatabaseFile(const QString &dbFileFullPath, const QString &password, bool isCreationNeed);
|
||||||
void connectToDatabase(const QString &dbName);
|
void connectToDatabase(const QString &dbName);
|
||||||
void createDatabase(const QString &dbName, const QString &password);
|
void createDatabase(const QString &password);
|
||||||
bool checkPassoword(QString word);
|
bool checkPassoword(QString word);
|
||||||
|
|
||||||
void createCardsModel();
|
void createCardsModel();
|
||||||
@ -72,6 +72,10 @@ private:
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
inline QString getDbFileFullPath(const QString dbLogin)
|
||||||
|
{
|
||||||
|
return "./" + dbLogin;
|
||||||
|
}
|
||||||
|
|
||||||
// void initAppWithDatabaseFile(const QString &dbFileFullPath);
|
// void initAppWithDatabaseFile(const QString &dbFileFullPath);
|
||||||
|
|
||||||
|
|||||||
@ -1014,7 +1014,6 @@
|
|||||||
<string>Сервис</string>
|
<string>Сервис</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="action"/>
|
|
||||||
<addaction name="action_4"/>
|
<addaction name="action_4"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menu_3">
|
<widget class="QMenu" name="menu_3">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user