From 0f9983b6be648609a0296353418b1a0939c1b399 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 7 Apr 2019 19:26:06 +0200 Subject: [PATCH] Converted ImportTypePage to designer file --- dialogs/opendialog.ui | 7 +++- loganalyzer.pro | 9 +++-- threads/projectopenerthread.cpp | 15 ++++++++ threads/projectopenerthread.h | 22 +++++++++++ threads/tablecreatorthread.cpp | 2 +- wizard/databasepage.cpp | 3 -- wizard/importtypepage.cpp | 61 +++++++---------------------- wizard/importtypepage.h | 14 +++---- wizard/importtypepage.ui | 68 +++++++++++++++++++++++++++++++++ wizard/tablespage.cpp | 3 -- 10 files changed, 135 insertions(+), 69 deletions(-) create mode 100644 threads/projectopenerthread.cpp create mode 100644 threads/projectopenerthread.h create mode 100644 wizard/importtypepage.ui diff --git a/dialogs/opendialog.ui b/dialogs/opendialog.ui index f4e8e2b..9bb7419 100644 --- a/dialogs/opendialog.ui +++ b/dialogs/opendialog.ui @@ -13,9 +13,12 @@ Dialog - + - + + + + diff --git a/loganalyzer.pro b/loganalyzer.pro index 6a3fa9f..094d0e9 100644 --- a/loganalyzer.pro +++ b/loganalyzer.pro @@ -38,7 +38,8 @@ SOURCES += main.cpp \ gzipdevice.cpp \ dialogs/graphdialog.cpp \ models/logmodel.cpp \ - models/progressmodel.cpp + models/progressmodel.cpp \ + threads/projectopenerthread.cpp HEADERS += \ mainwindow.h \ @@ -63,7 +64,8 @@ HEADERS += \ gzipdevice.h \ dialogs/graphdialog.h \ models/logmodel.h \ - models/progressmodel.h + models/progressmodel.h \ + threads/projectopenerthread.h FORMS += \ mainwindow.ui \ @@ -73,7 +75,8 @@ FORMS += \ wizard/intropage.ui \ wizard/databasepage.ui \ dialogs/graphdialog.ui \ - wizard/tablespage.ui + wizard/tablespage.ui \ + wizard/importtypepage.ui RESOURCES += \ resources.qrc diff --git a/threads/projectopenerthread.cpp b/threads/projectopenerthread.cpp new file mode 100644 index 0000000..68ced66 --- /dev/null +++ b/threads/projectopenerthread.cpp @@ -0,0 +1,15 @@ +#include "projectopenerthread.h" + +#include "common.h" + +ProjectOpenerThread::ProjectOpenerThread(QSqlDatabase &database, Project &project, QObject *parent) : + QThread(parent), + m_database(database), + m_project(project) +{ +} + +void ProjectOpenerThread::run() +{ + +} diff --git a/threads/projectopenerthread.h b/threads/projectopenerthread.h new file mode 100644 index 0000000..87e11aa --- /dev/null +++ b/threads/projectopenerthread.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +class QSqlDatabase; + +class Project; + +class ProjectOpenerThread : public QThread +{ + Q_OBJECT + +public: + ProjectOpenerThread(QSqlDatabase &database, Project &project, QObject *parent = nullptr); + +protected: + void run() override; + +private: + QSqlDatabase &m_database; + Project &m_project; +}; diff --git a/threads/tablecreatorthread.cpp b/threads/tablecreatorthread.cpp index ee844aa..d74144e 100644 --- a/threads/tablecreatorthread.cpp +++ b/threads/tablecreatorthread.cpp @@ -96,7 +96,7 @@ void TableCreatorThread::run() return; } - sleep(1); + msleep(100); emit someSignal(index++); } } diff --git a/wizard/databasepage.cpp b/wizard/databasepage.cpp index 5ffb0d0..162cacd 100644 --- a/wizard/databasepage.cpp +++ b/wizard/databasepage.cpp @@ -1,12 +1,9 @@ #include "databasepage.h" #include "ui_databasepage.h" -#include #include #include #include -#include -#include #include "widgets/databasewidget.h" #include "importwizard.h" diff --git a/wizard/importtypepage.cpp b/wizard/importtypepage.cpp index 9a5df1d..6d66b84 100644 --- a/wizard/importtypepage.cpp +++ b/wizard/importtypepage.cpp @@ -1,4 +1,5 @@ #include "importtypepage.h" +#include "ui_importtypepage.h" #include #include @@ -14,69 +15,40 @@ #include "common.h" ImportTypePage::ImportTypePage(QWidget *parent) : - QWizardPage(parent) + QWizardPage(parent), + m_ui(std::make_unique()) { - setTitle(tr("Import type")); - setSubTitle(tr("Please select which type of log files you would like to import.")); - - auto layout = new QVBoxLayout; - - m_radioLocal = new QRadioButton(tr("Local: Typically found under /tmp/testfw_log/tests")); - m_radioLocal->setChecked(true); - layout->addWidget(m_radioLocal); - - m_radioRemote = new QRadioButton(tr("Remote: Typically found under /log or /log2")); - layout->addWidget(m_radioRemote); - - layout->addStretch(1); - - { - auto hboxLayout = new QHBoxLayout; - - m_lineEdit = new QLineEdit; - hboxLayout->addWidget(m_lineEdit, 1); - registerField("folder", m_lineEdit); - - { - auto toolButton = new QToolButton; - toolButton->setText(tr("Select...")); - connect(toolButton, &QAbstractButton::pressed, this, &ImportTypePage::selectFolder); - hboxLayout->addWidget(toolButton); - } - - layout->addLayout(hboxLayout); - } - - layout->addStretch(1); - - setLayout(layout); + m_ui->setupUi(this); + m_ui->fileSelectionWidget->setMode(FileSelectionWidget::Mode::ExistingDirectory); } +ImportTypePage::~ImportTypePage() = default; + int ImportTypePage::nextId() const { - if (m_radioLocal->isChecked()) + if (m_ui->radioButtonLocal->isChecked()) return int(ImportWizard::Pages::LocalImport); - if (m_radioRemote->isChecked()) + if (m_ui->radioButtonRemote->isChecked()) return int(ImportWizard::Pages::RemoteImportScan); Q_UNREACHABLE(); } bool ImportTypePage::validatePage() { - if (m_lineEdit->text().isEmpty()) + if (m_ui->fileSelectionWidget->path().isEmpty()) { QMessageBox::warning(this, tr("No logfolder defined!"), tr("No logfolder defined!")); return false; } - QDir dir(m_lineEdit->text()); + QDir dir(m_ui->fileSelectionWidget->path()); if (!dir.exists()) { QMessageBox::warning(this, tr("Could not find logfolder!"), tr("Could not find logfolder!")); return false; } - if (m_radioLocal->isChecked()) + if (m_ui->radioButtonLocal->isChecked()) { ScanResult result; auto &host = result["__dummyHost"]; @@ -103,15 +75,8 @@ bool ImportTypePage::validatePage() wizard()->setProperty("result", QVariant::fromValue(result)); } - if (m_radioRemote->isChecked()) + if (m_ui->radioButtonRemote->isChecked()) wizard()->setProperty("folder", dir.absolutePath()); return true; } - -void ImportTypePage::selectFolder() -{ - const auto path = QFileDialog::getExistingDirectory(this, tr("Select log folder")); - if (!path.isEmpty()) - m_lineEdit->setText(path); -} diff --git a/wizard/importtypepage.h b/wizard/importtypepage.h index b2014e1..b464381 100644 --- a/wizard/importtypepage.h +++ b/wizard/importtypepage.h @@ -2,8 +2,9 @@ #include -class QRadioButton; -class QLineEdit; +#include + +namespace Ui { class ImportTypePage; } class ImportTypePage : public QWizardPage { @@ -11,17 +12,12 @@ class ImportTypePage : public QWizardPage public: explicit ImportTypePage(QWidget *parent = nullptr); + ~ImportTypePage() override; int nextId() const override; bool validatePage() override; -private slots: - void selectFolder(); - private: - QRadioButton *m_radioLocal; - QRadioButton *m_radioRemote; - - QLineEdit *m_lineEdit; + const std::unique_ptr m_ui; }; diff --git a/wizard/importtypepage.ui b/wizard/importtypepage.ui new file mode 100644 index 0000000..7ecc5f9 --- /dev/null +++ b/wizard/importtypepage.ui @@ -0,0 +1,68 @@ + + + ImportTypePage + + + + 0 + 0 + 400 + 300 + + + + WizardPage + + + Import type + + + Please select which type of log files you would like to import. + + + + + + Local: Typically found under /tmp/testfw_log/tests + + + true + + + + + + + Remote: Typically found under /log or /log2 + + + + + + + + + + Qt::Vertical + + + + 20 + 209 + + + + + + + + + FileSelectionWidget + QWidget +
widgets/fileselectionwidget.h
+ 1 +
+
+ + +
diff --git a/wizard/tablespage.cpp b/wizard/tablespage.cpp index dc02981..6a4b3d1 100644 --- a/wizard/tablespage.cpp +++ b/wizard/tablespage.cpp @@ -1,9 +1,6 @@ #include "tablespage.h" #include "ui_tablespage.h" -#include -#include - #include "importwizard.h" #include "threads/tablecreatorthread.h"