Skip to content
Snippets Groups Projects
Commit 259a1aa7 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add convenience functions, docu, working tags, rm outdated code

parent 767a42a7
No related branches found
No related tags found
1 merge request!11Reflectometry import - read/write project, show import warnings/errors, item selection, UI improvements
...@@ -202,7 +202,7 @@ void JobModelFunctions::copyRealDataItem(JobItem* jobItem, const RealDataItem* r ...@@ -202,7 +202,7 @@ void JobModelFunctions::copyRealDataItem(JobItem* jobItem, const RealDataItem* r
// adapting the name to job name // adapting the name to job name
realDataItemCopy->dataItem()->setFileName(ItemFileNameUtils::jobReferenceFileName(*jobItem)); realDataItemCopy->dataItem()->setFileName(ItemFileNameUtils::jobReferenceFileName(*jobItem));
// #baimport ++ copy members of realDataItem // #baimport ++ copy members of realDataItem?
if (!realDataItem->hasNativeData()) if (!realDataItem->hasNativeData())
return; return;
......
...@@ -117,6 +117,16 @@ QVector<RealDataItem*> RealDataModel::realDataItems() const ...@@ -117,6 +117,16 @@ QVector<RealDataItem*> RealDataModel::realDataItems() const
return topItems<RealDataItem>(); return topItems<RealDataItem>();
} }
QVector<RealDataItem*> RealDataModel::realDataItems1D() const
{
return topItems<RealDataItem>([](const RealDataItem& item) { return item.isSpecularData(); });
}
QVector<RealDataItem*> RealDataModel::realDataItems2D() const
{
return topItems<RealDataItem>([](const RealDataItem& item) { return !item.isSpecularData(); });
}
InstrumentModel* RealDataModel::instrumentModel() const InstrumentModel* RealDataModel::instrumentModel() const
{ {
return m_instrumentModel; return m_instrumentModel;
......
...@@ -40,6 +40,9 @@ public: ...@@ -40,6 +40,9 @@ public:
RealDataItem* insertIntensityDataItem(); RealDataItem* insertIntensityDataItem();
QVector<RealDataItem*> realDataItems() const; QVector<RealDataItem*> realDataItems() const;
QVector<RealDataItem*> realDataItems1D() const;
QVector<RealDataItem*> realDataItems2D() const;
InstrumentModel* instrumentModel() const; InstrumentModel* instrumentModel() const;
signals: signals:
......
...@@ -28,7 +28,7 @@ class QListView; ...@@ -28,7 +28,7 @@ class QListView;
class SessionDecorationModel; class SessionDecorationModel;
//! The ItemSelectorWidget class holds QListView to show top level items of SessionModel. //! The ItemSelectorWidget class holds QListView to show top level items of SessionModel.
//! Used in InstrumentView, ImportDataView, JobSelectorView to switch between items. //! Used in InstrumentView and JobSelectorView to switch between items.
class ItemSelectorWidget : public QWidget { class ItemSelectorWidget : public QWidget {
Q_OBJECT Q_OBJECT
......
...@@ -210,7 +210,6 @@ void SpecularDataImportWidget::onFormatSelectionChanged() ...@@ -210,7 +210,6 @@ void SpecularDataImportWidget::onFormatSelectionChanged()
realDataItem()->setDataLoader(m_loader); realDataItem()->setDataLoader(m_loader);
updatePropertiesEdits(); updatePropertiesEdits();
updatePreview(); updatePreview();
applyProperties();
connect(m_loader, &AbstractDataLoader::propertiesChanged, this, connect(m_loader, &AbstractDataLoader::propertiesChanged, this,
&SpecularDataImportWidget::updatePreview); &SpecularDataImportWidget::updatePreview);
} }
...@@ -248,7 +247,6 @@ void SpecularDataImportWidget::onCreateNewFormatButton() ...@@ -248,7 +247,6 @@ void SpecularDataImportWidget::onCreateNewFormatButton()
void SpecularDataImportWidget::onPropertiesChanged() void SpecularDataImportWidget::onPropertiesChanged()
{ {
m_loader->applyProperties(); // #baTODO: may be duplicate m_loader->applyProperties(); // #baTODO: may be duplicate
applyProperties();
QStringList errors, warnings; QStringList errors, warnings;
m_loader->importFile(realDataItem()->nativeFileName(), realDataItem(), &errors, &warnings); m_loader->importFile(realDataItem()->nativeFileName(), realDataItem(), &errors, &warnings);
...@@ -266,8 +264,3 @@ QString SpecularDataImportWidget::currentFileName() const ...@@ -266,8 +264,3 @@ QString SpecularDataImportWidget::currentFileName() const
{ {
return realDataItem()->nativeFileName(); return realDataItem()->nativeFileName();
} }
void SpecularDataImportWidget::applyProperties()
{
// #baimport seems obsolete
}
...@@ -60,7 +60,6 @@ private: ...@@ -60,7 +60,6 @@ private:
void onCreateNewFormatButton(); void onCreateNewFormatButton();
void onPropertiesChanged(); void onPropertiesChanged();
QString currentFileName() const; QString currentFileName() const;
void applyProperties();
Ui::SpecularDataImportWidget* m_ui; Ui::SpecularDataImportWidget* m_ui;
AbstractDataLoader1D* m_loader; // only borrowed from realDataItem. Do not delete! AbstractDataLoader1D* m_loader; // only borrowed from realDataItem. Do not delete!
......
...@@ -38,6 +38,8 @@ const QString S_AUTOSAVE = "EnableAutosave"; ...@@ -38,6 +38,8 @@ const QString S_AUTOSAVE = "EnableAutosave";
const QString S_DEFAULTPROJECTPATH = "DefaultProjectPath"; const QString S_DEFAULTPROJECTPATH = "DefaultProjectPath";
const QString S_RECENTPROJECTS = "RecentProjects"; const QString S_RECENTPROJECTS = "RecentProjects";
const QString S_LASTUSEDIMPORTDIR = "LastUsedImportDir"; const QString S_LASTUSEDIMPORTDIR = "LastUsedImportDir";
const QString S_LASTUSEDIMPORFILTER1D = "LastUsedImportFilter1D";
const QString S_LASTUSEDIMPORFILTER2D = "LastUsedImportFilter2D";
} // namespace } // namespace
ProjectManager::ProjectManager(MainWindow* parent) ProjectManager::ProjectManager(MainWindow* parent)
...@@ -76,6 +78,9 @@ void ProjectManager::readSettings() ...@@ -76,6 +78,9 @@ void ProjectManager::readSettings()
if (settings.contains(S_LASTUSEDIMPORTDIR)) if (settings.contains(S_LASTUSEDIMPORTDIR))
m_importDirectory = settings.value(S_LASTUSEDIMPORTDIR, QString()).toString(); m_importDirectory = settings.value(S_LASTUSEDIMPORTDIR, QString()).toString();
m_importFilter1D = settings.value(S_LASTUSEDIMPORFILTER1D, m_importFilter1D).toString();
m_importFilter2D = settings.value(S_LASTUSEDIMPORFILTER2D, m_importFilter2D).toString();
setAutosaveEnabled(settings.value(S_AUTOSAVE).toBool()); setAutosaveEnabled(settings.value(S_AUTOSAVE).toBool());
settings.endGroup(); settings.endGroup();
...@@ -93,6 +98,8 @@ void ProjectManager::writeSettings() ...@@ -93,6 +98,8 @@ void ProjectManager::writeSettings()
if (!m_importDirectory.isEmpty()) if (!m_importDirectory.isEmpty())
settings.setValue(S_LASTUSEDIMPORTDIR, m_importDirectory); settings.setValue(S_LASTUSEDIMPORTDIR, m_importDirectory);
settings.setValue(S_LASTUSEDIMPORFILTER1D, m_importFilter1D);
settings.setValue(S_LASTUSEDIMPORFILTER2D, m_importFilter2D);
settings.endGroup(); settings.endGroup();
} }
...@@ -144,6 +151,16 @@ QString ProjectManager::userImportDir() const ...@@ -144,6 +151,16 @@ QString ProjectManager::userImportDir() const
return m_importDirectory.isEmpty() ? userExportDir() : m_importDirectory; return m_importDirectory.isEmpty() ? userExportDir() : m_importDirectory;
} }
QString ProjectManager::recentlyUsedImportFilter1D() const
{
return m_importFilter1D;
}
QString ProjectManager::recentlyUsedImportFilter2D() const
{
return m_importFilter2D;
}
//! Sets user import directory in system settings. //! Sets user import directory in system settings.
void ProjectManager::setImportDir(const QString& dirname) void ProjectManager::setImportDir(const QString& dirname)
...@@ -158,6 +175,16 @@ void ProjectManager::setImportDirFromFilePath(const QString& filePath) ...@@ -158,6 +175,16 @@ void ProjectManager::setImportDirFromFilePath(const QString& filePath)
m_importDirectory = QFileInfo(filePath).absolutePath(); m_importDirectory = QFileInfo(filePath).absolutePath();
} }
void ProjectManager::setRecentlyUsedImportFilter1D(const QString& filter)
{
m_importFilter1D = filter;
}
void ProjectManager::setRecentlyUsedImportFilter2D(const QString& filter)
{
m_importFilter2D = filter;
}
bool ProjectManager::isAutosaveEnabled() const bool ProjectManager::isAutosaveEnabled() const
{ {
return m_saveService->isAutosaveEnabled(); return m_saveService->isAutosaveEnabled();
......
...@@ -40,8 +40,12 @@ public: ...@@ -40,8 +40,12 @@ public:
QString projectDir() const; QString projectDir() const;
QString userExportDir() const; QString userExportDir() const;
QString userImportDir() const; QString userImportDir() const;
QString recentlyUsedImportFilter1D() const;
QString recentlyUsedImportFilter2D() const;
void setImportDir(const QString& dirname); void setImportDir(const QString& dirname);
void setImportDirFromFilePath(const QString& filePath); void setImportDirFromFilePath(const QString& filePath);
void setRecentlyUsedImportFilter1D(const QString& filter);
void setRecentlyUsedImportFilter2D(const QString& filter);
bool isAutosaveEnabled() const; bool isAutosaveEnabled() const;
...@@ -81,6 +85,12 @@ private: ...@@ -81,6 +85,12 @@ private:
//!< Name of directory from there user prefer to import files //!< Name of directory from there user prefer to import files
QString m_importDirectory; QString m_importDirectory;
//! Recently used import filter for 1D files
QString m_importFilter1D;
//! Recently used import filter for 2D files
QString m_importFilter2D;
QStringList m_recentProjects; QStringList m_recentProjects;
MessageService* m_messageService; MessageService* m_messageService;
SaveService* m_saveService; SaveService* m_saveService;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "BAVersion.h" #include "BAVersion.h"
#include "GUI/coregui/Models/JobItem.h" #include "GUI/coregui/Models/JobItem.h"
#include "GUI/coregui/Models/RealDataItem.h" #include "GUI/coregui/Models/RealDataItem.h"
#include "GUI/coregui/mainwindow/mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QDateTime> #include <QDateTime>
#include <QDir> #include <QDir>
...@@ -65,6 +66,11 @@ void information(QWidget* parent, const QString& title, const QString& text, ...@@ -65,6 +66,11 @@ void information(QWidget* parent, const QString& title, const QString& text,
messageBox->exec(); messageBox->exec();
} }
void information(const QString& title, const QString& text, const QString& detailedText)
{
information(MainWindow::instance(), title, text, detailedText);
}
void warning(QWidget* parent, const QString& title, const QString& text, void warning(QWidget* parent, const QString& title, const QString& text,
const QString& detailedText) const QString& detailedText)
{ {
...@@ -80,6 +86,11 @@ void warning(QWidget* parent, const QString& title, const QString& text, ...@@ -80,6 +86,11 @@ void warning(QWidget* parent, const QString& title, const QString& text,
messageBox->exec(); messageBox->exec();
} }
void warning(const QString& title, const QString& text, const QString& detailedText)
{
warning(MainWindow::instance(), title, text, detailedText);
}
bool question(QWidget* parent, const QString& title, const QString& text, bool question(QWidget* parent, const QString& title, const QString& text,
const QString& detailedText, const QString& yesText, const QString& noText) const QString& detailedText, const QString& yesText, const QString& noText)
{ {
......
...@@ -42,11 +42,18 @@ private: ...@@ -42,11 +42,18 @@ private:
void information(QWidget* parent, const QString& title, const QString& text, void information(QWidget* parent, const QString& title, const QString& text,
const QString& detailedText = ""); const QString& detailedText = "");
void information(const QString& title, const QString& text, const QString& detailedText = "");
void warning(QWidget* parent, const QString& title, const QString& text, void warning(QWidget* parent, const QString& title, const QString& text,
const QString& detailedText = ""); const QString& detailedText = "");
void warning(const QString& title, const QString& text, const QString& detailedText = "");
bool question(QWidget* parent, const QString& title, const QString& text, bool question(QWidget* parent, const QString& title, const QString& text,
const QString& detailedText = "", const QString& yesText = "&Yes", const QString& detailedText = "", const QString& yesText = "&Yes",
const QString& noText = "&No"); const QString& noText = "&No");
bool okToDelete(QWidget* parent, const QString& title, const QString& text, bool okToDelete(QWidget* parent, const QString& title, const QString& text,
const QString& detailedText = ""); const QString& detailedText = "");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment