Import dialog and import progress moved to core library.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user