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">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<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>
<widget class="QDialogButtonBox" name="buttonBox">

View File

@ -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

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;
}
sleep(1);
msleep(100);
emit someSignal(index++);
}
}

View File

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

View File

@ -1,4 +1,5 @@
#include "importtypepage.h"
#include "ui_importtypepage.h"
#include <QVBoxLayout>
#include <QRadioButton>
@ -14,69 +15,40 @@
#include "common.h"
ImportTypePage::ImportTypePage(QWidget *parent) :
QWizardPage(parent)
QWizardPage(parent),
m_ui(std::make_unique<Ui::ImportTypePage>())
{
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);
}

View File

@ -2,8 +2,9 @@
#include <QWizardPage>
class QRadioButton;
class QLineEdit;
#include <memory>
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<Ui::ImportTypePage> m_ui;
};

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 "ui_tablespage.h"
#include <QGridLayout>
#include <QLabel>
#include "importwizard.h"
#include "threads/tablecreatorthread.h"