FixedAdding #1
Binary file not shown.
@ -29,29 +29,6 @@ void Hello::on_pushButton_2_clicked()
|
||||
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()
|
||||
{
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
@ -60,9 +37,18 @@ void Hello::on_pushButton_6_clicked()
|
||||
|
||||
void Hello::on_okButton_clicked()
|
||||
{
|
||||
QString dbLogin;
|
||||
if(!ui->lineEdit->text().isEmpty()){
|
||||
dbLogin = ui->lineEdit->text();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
QString password = ui->passwordLine->text();
|
||||
|
||||
// mainwindow.createModel();
|
||||
if(mainwindow.initAppWithDatabaseFile(dbFileFullPath, password, false))
|
||||
if(mainwindow.initAppWithDatabaseFile(dbLogin, password, false))
|
||||
{
|
||||
|
||||
if(mainwindow.checkPassoword(password))
|
||||
@ -78,11 +64,22 @@ void Hello::on_okButton_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();
|
||||
QWidget::close() ;
|
||||
}
|
||||
}else
|
||||
{
|
||||
// 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_4_clicked();
|
||||
|
||||
void on_pushButton_5_clicked();
|
||||
|
||||
void on_pushButton_6_clicked();
|
||||
|
||||
void on_okButton_clicked();
|
||||
@ -37,7 +33,6 @@ private:
|
||||
Manager* manager;
|
||||
AddDialog dial;
|
||||
|
||||
QString dbFileFullPath;
|
||||
static const QString fileDialogFilterString;
|
||||
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Путь:</string>
|
||||
<string>Логин:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
@ -82,7 +82,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Войти</string>
|
||||
<string>Вход</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="okButton">
|
||||
@ -111,19 +111,6 @@
|
||||
<string>Создать</string>
|
||||
</property>
|
||||
</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 class="QWidget" name="page_2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
@ -136,7 +123,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Создать новую</string>
|
||||
<string>Регистрация</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_3">
|
||||
@ -179,7 +166,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Путь:</string>
|
||||
<string>Логин:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
@ -192,7 +179,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Пароль</string>
|
||||
<string>Пароль:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
@ -205,7 +192,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Подтвердить пароль</string>
|
||||
<string>Подтвердить пароль:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="createOkButton">
|
||||
@ -221,19 +208,6 @@
|
||||
<string>Ок</string>
|
||||
</property>
|
||||
</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">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
|
||||
@ -61,16 +61,36 @@ void MainWindow::createRecordsModel()
|
||||
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;
|
||||
if (dbFileFullPath.isEmpty())
|
||||
if( QFile::exists(dbFileFullPath))
|
||||
{
|
||||
return false;
|
||||
|
||||
if(isCreationNeed)
|
||||
{
|
||||
qDebug()<<"Data base exist....";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
connectToDatabase(dbFileFullPath);
|
||||
|
||||
}
|
||||
}
|
||||
connectToDatabase(dbFileFullPath);
|
||||
if(isCreationNeed)
|
||||
else
|
||||
{
|
||||
createDatabase(dbFileFullPath, password);
|
||||
if(isCreationNeed)
|
||||
{
|
||||
connectToDatabase(dbFileFullPath);
|
||||
createDatabase(password);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"Data base not exist....";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
createRecordsModel();
|
||||
createCardsModel();
|
||||
@ -213,7 +233,7 @@ void MainWindow::connectToDatabase(const QString &dbName)
|
||||
query = new QSqlQuery(m_db); // создание объекта для запроса.
|
||||
}
|
||||
|
||||
void MainWindow::createDatabase(const QString &dbName, const QString &password)
|
||||
void MainWindow::createDatabase(const QString &password)
|
||||
{
|
||||
qDebug() << "В базе не существует таблица records!";
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ public:
|
||||
int getRecordsCount();
|
||||
bool initAppWithDatabaseFile(const QString &dbFileFullPath, const QString &password, bool isCreationNeed);
|
||||
void connectToDatabase(const QString &dbName);
|
||||
void createDatabase(const QString &dbName, const QString &password);
|
||||
void createDatabase(const QString &password);
|
||||
bool checkPassoword(QString word);
|
||||
|
||||
void createCardsModel();
|
||||
@ -72,6 +72,10 @@ private:
|
||||
}
|
||||
return value;
|
||||
}
|
||||
inline QString getDbFileFullPath(const QString dbLogin)
|
||||
{
|
||||
return "./" + dbLogin;
|
||||
}
|
||||
|
||||
// void initAppWithDatabaseFile(const QString &dbFileFullPath);
|
||||
|
||||
|
||||
@ -1014,7 +1014,6 @@
|
||||
<string>Сервис</string>
|
||||
</property>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action"/>
|
||||
<addaction name="action_4"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_3">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user