Converted ImportTypePage to designer file

This commit is contained in:
2019-04-07 19:26:06 +02:00
parent 0704012542
commit 0f9983b6be
10 changed files with 135 additions and 69 deletions

View File

@ -13,9 +13,12 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0"> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item> <item>
<widget class="DatabaseWidget" name="databaseWidget" native="true"/> <widget class="QStackedWidget" name="stackedWidget">
<widget class="DatabaseWidget" name="databaseWidget"/>
<widget class="QTreeView" name="treeView"/>
</widget>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">

View File

@ -38,7 +38,8 @@ SOURCES += main.cpp \
gzipdevice.cpp \ gzipdevice.cpp \
dialogs/graphdialog.cpp \ dialogs/graphdialog.cpp \
models/logmodel.cpp \ models/logmodel.cpp \
models/progressmodel.cpp models/progressmodel.cpp \
threads/projectopenerthread.cpp
HEADERS += \ HEADERS += \
mainwindow.h \ mainwindow.h \
@ -63,7 +64,8 @@ HEADERS += \
gzipdevice.h \ gzipdevice.h \
dialogs/graphdialog.h \ dialogs/graphdialog.h \
models/logmodel.h \ models/logmodel.h \
models/progressmodel.h models/progressmodel.h \
threads/projectopenerthread.h
FORMS += \ FORMS += \
mainwindow.ui \ mainwindow.ui \
@ -73,7 +75,8 @@ FORMS += \
wizard/intropage.ui \ wizard/intropage.ui \
wizard/databasepage.ui \ wizard/databasepage.ui \
dialogs/graphdialog.ui \ dialogs/graphdialog.ui \
wizard/tablespage.ui wizard/tablespage.ui \
wizard/importtypepage.ui
RESOURCES += \ RESOURCES += \
resources.qrc resources.qrc

View File

@ -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()
{
}

View File

@ -0,0 +1,22 @@
#pragma once
#include <QThread>
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;
};

View File

@ -96,7 +96,7 @@ void TableCreatorThread::run()
return; return;
} }
sleep(1); msleep(100);
emit someSignal(index++); emit someSignal(index++);
} }
} }

View File

@ -1,12 +1,9 @@
#include "databasepage.h" #include "databasepage.h"
#include "ui_databasepage.h" #include "ui_databasepage.h"
#include <QVBoxLayout>
#include <QSqlError> #include <QSqlError>
#include <QMessageBox> #include <QMessageBox>
#include <QStringBuilder> #include <QStringBuilder>
#include <QSqlQuery>
#include <QFileDialog>
#include "widgets/databasewidget.h" #include "widgets/databasewidget.h"
#include "importwizard.h" #include "importwizard.h"

View File

@ -1,4 +1,5 @@
#include "importtypepage.h" #include "importtypepage.h"
#include "ui_importtypepage.h"
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QRadioButton> #include <QRadioButton>
@ -14,69 +15,40 @@
#include "common.h" #include "common.h"
ImportTypePage::ImportTypePage(QWidget *parent) : ImportTypePage::ImportTypePage(QWidget *parent) :
QWizardPage(parent) QWizardPage(parent),
m_ui(std::make_unique<Ui::ImportTypePage>())
{ {
setTitle(tr("Import type")); m_ui->setupUi(this);
setSubTitle(tr("Please select which type of log files you would like to import.")); m_ui->fileSelectionWidget->setMode(FileSelectionWidget::Mode::ExistingDirectory);
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);
} }
ImportTypePage::~ImportTypePage() = default;
int ImportTypePage::nextId() const int ImportTypePage::nextId() const
{ {
if (m_radioLocal->isChecked()) if (m_ui->radioButtonLocal->isChecked())
return int(ImportWizard::Pages::LocalImport); return int(ImportWizard::Pages::LocalImport);
if (m_radioRemote->isChecked()) if (m_ui->radioButtonRemote->isChecked())
return int(ImportWizard::Pages::RemoteImportScan); return int(ImportWizard::Pages::RemoteImportScan);
Q_UNREACHABLE(); Q_UNREACHABLE();
} }
bool ImportTypePage::validatePage() 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!")); QMessageBox::warning(this, tr("No logfolder defined!"), tr("No logfolder defined!"));
return false; return false;
} }
QDir dir(m_lineEdit->text()); QDir dir(m_ui->fileSelectionWidget->path());
if (!dir.exists()) if (!dir.exists())
{ {
QMessageBox::warning(this, tr("Could not find logfolder!"), tr("Could not find logfolder!")); QMessageBox::warning(this, tr("Could not find logfolder!"), tr("Could not find logfolder!"));
return false; return false;
} }
if (m_radioLocal->isChecked()) if (m_ui->radioButtonLocal->isChecked())
{ {
ScanResult result; ScanResult result;
auto &host = result["__dummyHost"]; auto &host = result["__dummyHost"];
@ -103,15 +75,8 @@ bool ImportTypePage::validatePage()
wizard()->setProperty("result", QVariant::fromValue(result)); wizard()->setProperty("result", QVariant::fromValue(result));
} }
if (m_radioRemote->isChecked()) if (m_ui->radioButtonRemote->isChecked())
wizard()->setProperty("folder", dir.absolutePath()); wizard()->setProperty("folder", dir.absolutePath());
return true; return true;
} }
void ImportTypePage::selectFolder()
{
const auto path = QFileDialog::getExistingDirectory(this, tr("Select log folder"));
if (!path.isEmpty())
m_lineEdit->setText(path);
}

View File

@ -2,8 +2,9 @@
#include <QWizardPage> #include <QWizardPage>
class QRadioButton; #include <memory>
class QLineEdit;
namespace Ui { class ImportTypePage; }
class ImportTypePage : public QWizardPage class ImportTypePage : public QWizardPage
{ {
@ -11,17 +12,12 @@ class ImportTypePage : public QWizardPage
public: public:
explicit ImportTypePage(QWidget *parent = nullptr); explicit ImportTypePage(QWidget *parent = nullptr);
~ImportTypePage() override;
int nextId() const override; int nextId() const override;
bool validatePage() override; bool validatePage() override;
private slots:
void selectFolder();
private: private:
QRadioButton *m_radioLocal; const std::unique_ptr<Ui::ImportTypePage> m_ui;
QRadioButton *m_radioRemote;
QLineEdit *m_lineEdit;
}; };

68
wizard/importtypepage.ui Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ImportTypePage</class>
<widget class="QWizardPage" name="ImportTypePage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<property name="title">
<string>Import type</string>
</property>
<property name="subTitle">
<string>Please select which type of log files you would like to import.</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="radioButtonLocal">
<property name="text">
<string>Local: Typically found under /tmp/testfw_log/tests</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonRemote">
<property name="text">
<string>Remote: Typically found under /log or /log2</string>
</property>
</widget>
</item>
<item>
<widget class="FileSelectionWidget" name="fileSelectionWidget" native="true"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>209</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>FileSelectionWidget</class>
<extends>QWidget</extends>
<header>widgets/fileselectionwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -1,9 +1,6 @@
#include "tablespage.h" #include "tablespage.h"
#include "ui_tablespage.h" #include "ui_tablespage.h"
#include <QGridLayout>
#include <QLabel>
#include "importwizard.h" #include "importwizard.h"
#include "threads/tablecreatorthread.h" #include "threads/tablecreatorthread.h"