Import dialog and import progress moved to core library.
This commit is contained in:
+9
-3
@@ -63,7 +63,9 @@ SOURCES += \
|
||||
reporting/report.cpp \
|
||||
reporting/reportviewer.cpp \
|
||||
reporting/reportdialog.cpp \
|
||||
csvimporter.cpp
|
||||
csvimporter.cpp \
|
||||
importdialog.cpp \
|
||||
importprogress.cpp
|
||||
|
||||
HEADERS += core.h\
|
||||
core_global.h \
|
||||
@@ -126,7 +128,9 @@ HEADERS += core.h\
|
||||
reporting/reportdialog.h \
|
||||
iimporter.h \
|
||||
csvimporter.h \
|
||||
iimportprogress.h
|
||||
iimportprogress.h \
|
||||
importdialog.h \
|
||||
importprogress.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
@@ -161,7 +165,9 @@ FORMS += \
|
||||
settings/globalsettingsform.ui \
|
||||
settings/seasonnamedialog.ui \
|
||||
reporting/reportviewer.ui \
|
||||
reporting/reportdialog.ui
|
||||
reporting/reportdialog.ui \
|
||||
importdialog.ui \
|
||||
importprogress.ui
|
||||
|
||||
OTHER_FILES += \
|
||||
users/metaData.json \
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <QMessageBox>
|
||||
#include <QHeaderView>
|
||||
#include <QLayout>
|
||||
#include <QToolButton>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#include "autoform.h"
|
||||
#include "autotablemodel.h"
|
||||
@@ -12,6 +14,9 @@
|
||||
#include "iplugin.h"
|
||||
#include "igridform.h"
|
||||
#include "iservice.h"
|
||||
#include "importdialog.h"
|
||||
#include "csvimporter.h"
|
||||
#include "importprogress.h"
|
||||
|
||||
template<class T>
|
||||
class GridForm : public IGridForm
|
||||
@@ -164,6 +169,8 @@ private:
|
||||
bool m_serviceConnected;
|
||||
bool m_permissionDenied;
|
||||
|
||||
private slots:
|
||||
|
||||
// IGridForm interface
|
||||
protected:
|
||||
void handleNewRecord() override
|
||||
@@ -216,6 +223,42 @@ protected:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showImportButton()
|
||||
{
|
||||
QHBoxLayout *tbLayout = qobject_cast<QHBoxLayout*>(this->toolbar()->layout());
|
||||
|
||||
if (tbLayout != NULL)
|
||||
{
|
||||
QToolButton *btnImport = new QToolButton(this->toolbar());
|
||||
btnImport->setIcon(QIcon(":/icons/import.svg"));
|
||||
btnImport->setAutoRaise(true);
|
||||
btnImport->setIconSize(QSize(24, 24));
|
||||
btnImport->setToolTip(tr("Import"));
|
||||
tbLayout->insertWidget(tbLayout->count() - 1, btnImport);
|
||||
|
||||
connect(btnImport, &QToolButton::clicked, [this](){
|
||||
ImportDialog *dlg = new ImportDialog(this);
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dlg->show();
|
||||
|
||||
connect(dlg, &QDialog::accepted, [this, dlg](){
|
||||
T dataObj;
|
||||
CsvImporter importer(dataObj.metaObject());
|
||||
|
||||
importer.setImportFile(dlg->fileName());
|
||||
importer.setSeparator(dlg->separator());
|
||||
|
||||
ImportProgress *progress = new ImportProgress();
|
||||
progress->move(QApplication::desktop()->screen()->rect().center() - progress->rect().center());
|
||||
progress->setWindowModality(Qt::ApplicationModal);
|
||||
progress->show();
|
||||
|
||||
service()->importData(&importer, progress);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GRIDFORM_H
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient gradientUnits="userSpaceOnUse" id="a" x1="250" x2="250" y1="284.547" y2="122.267"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><g><circle cx="250" cy="250" fill="none" r="210" stroke="#434242" stroke-width="30"/><rect fill="#434242" height="29.998" rx="10" ry="10" width="260" x="120" y="350"/><path d="M270 90l60 60c5 5 10 10 10 20s-10 20-20 20h-40v125c0 8-7 15-15 15h-30c-8 0-15-7-15-15v-125h-40c-10 0-20-10-20-20s5-15 10-20l60-60c13-13 27-13 40 0z" fill="url(#a)" stroke="#434242" stroke-width="10"/></g></svg>
|
||||
|
After Width: | Height: | Size: 820 B |
@@ -0,0 +1,36 @@
|
||||
#include "importdialog.h"
|
||||
#include "ui_importdialog.h"
|
||||
#include "importprogress.h"
|
||||
#include "csvimporter.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
ImportDialog::ImportDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ImportDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
ImportDialog::~ImportDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
QString ImportDialog::fileName()
|
||||
{
|
||||
return ui->editFile->text();
|
||||
}
|
||||
|
||||
QString ImportDialog::separator()
|
||||
{
|
||||
return ui->editSeparator->text();
|
||||
}
|
||||
|
||||
void ImportDialog::on_btnFile_clicked()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(this, tr("Import file"), "", tr("All Files (*.*)"));
|
||||
ui->editFile->setText(file);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef IMPORTDIALOG_H
|
||||
#define IMPORTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMetaObject>
|
||||
#include "iservice.h"
|
||||
|
||||
namespace Ui {
|
||||
class ImportDialog;
|
||||
}
|
||||
|
||||
class ImportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImportDialog(QWidget *parent = 0);
|
||||
~ImportDialog();
|
||||
|
||||
QString fileName();
|
||||
QString separator();
|
||||
|
||||
private slots:
|
||||
void on_btnFile_clicked();
|
||||
|
||||
private:
|
||||
Ui::ImportDialog *ui;
|
||||
};
|
||||
|
||||
#endif // IMPORTDIALOG_H
|
||||
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImportDialog</class>
|
||||
<widget class="QDialog" name="ImportDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>115</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import data</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>File</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Separator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="editSeparator"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editFile"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnFile">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>ImportDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>ImportDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "importprogress.h"
|
||||
#include "ui_importprogress.h"
|
||||
|
||||
ImportProgress::ImportProgress(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ImportProgress)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->progressBar->setRange(0, 100);
|
||||
ui->progressBar->setValue(0);
|
||||
|
||||
m_terminate = false;
|
||||
}
|
||||
|
||||
ImportProgress::~ImportProgress()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ImportProgress::on_btnCancel_clicked()
|
||||
{
|
||||
m_terminate = true;
|
||||
this->close();
|
||||
}
|
||||
|
||||
void ImportProgress::updateProgress(int currentPos)
|
||||
{
|
||||
ui->progressBar->setValue(currentPos);
|
||||
}
|
||||
|
||||
bool ImportProgress::terminate()
|
||||
{
|
||||
return m_terminate;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef IMPORTPROGRESS_H
|
||||
#define IMPORTPROGRESS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "iimportprogress.h"
|
||||
|
||||
namespace Ui {
|
||||
class ImportProgress;
|
||||
}
|
||||
|
||||
class ImportProgress : public QWidget, public IImportProgress
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImportProgress(QWidget *parent = 0);
|
||||
~ImportProgress();
|
||||
|
||||
private slots:
|
||||
void on_btnCancel_clicked();
|
||||
|
||||
private:
|
||||
Ui::ImportProgress *ui;
|
||||
bool m_terminate;
|
||||
|
||||
// IImportProgress interface
|
||||
public:
|
||||
void updateProgress(int currentPos);
|
||||
bool terminate();
|
||||
};
|
||||
|
||||
#endif // IMPORTPROGRESS_H
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ImportProgress</class>
|
||||
<widget class="QWidget" name="ImportProgress">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>165</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import progress</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnCancel">
|
||||
<property name="text">
|
||||
<string>Cenacel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -24,5 +24,6 @@
|
||||
<file>icons/zoomIn.svg</file>
|
||||
<file>icons/zoomOut.svg</file>
|
||||
<file>icons/report.svg</file>
|
||||
<file>icons/import.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
Reference in New Issue
Block a user