diff --git a/Modules/Qmitk/QmitkFileDialog.cpp b/Modules/Qmitk/QmitkFileDialog.cpp index 122b517b1e..a73d482e38 100644 --- a/Modules/Qmitk/QmitkFileDialog.cpp +++ b/Modules/Qmitk/QmitkFileDialog.cpp @@ -1,244 +1,214 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //#define _USE_MATH_DEFINES #include // MITK #include #include // STL Headers #include //microservices #include #include #include //QT #include #include #include #include // Test imports, delete later #include class DummyReader : public mitk::AbstractFileReader { public: DummyReader(const DummyReader& other) : mitk::AbstractFileReader(other) { } DummyReader(const std::string& extension, int priority) : mitk::AbstractFileReader(extension, "This is a dummy description") { m_Priority = priority; //std::list options; m_Options.push_front(std::make_pair("isANiceGuy", true)); m_Options.push_front(std::make_pair("canFly", false)); m_Options.push_front(std::make_pair("isAwesome", true)); m_Options.push_front(std::make_pair("hasOptions", true)); m_Options.push_front(std::make_pair("has more Options", true)); m_Options.push_front(std::make_pair("has maaaaaaaany Options", true)); m_ServiceReg = this->RegisterService(); } ~DummyReader() { if (m_ServiceReg) m_ServiceReg.Unregister(); } using mitk::AbstractFileReader::Read; virtual std::list< itk::SmartPointer > Read(const std::istream& /*stream*/, mitk::DataStorage* /*ds*/ = 0) { std::list result; return result; } virtual void SetOptions(const std::list< mitk::FileServiceOption >& options ) { m_Options = options; //m_Registration.SetProperties(GetServiceProperties()); } private: DummyReader* Clone() const { return new DummyReader(*this); } us::ServiceRegistration m_ServiceReg; }; // End of internal dummy reader const std::string QmitkFileDialog::VIEW_ID = "org.mitk.views.QmitkFileDialog"; // // // // // // // // // QmitkFileDialog::QmitkFileDialog(QWidget* parent, Qt::WindowFlags f): QFileDialog(parent, f) { this->setOption(QFileDialog::DontUseNativeDialog); this->setFileMode(QFileDialog::ExistingFile); DummyReader* dr = new DummyReader(".xsfd", 1000); CreateQtPartControl(this); } QmitkFileDialog::~QmitkFileDialog() { } //////////////////// INITIALIZATION ///////////////////// void QmitkFileDialog::CreateQtPartControl(QWidget *parent) { // cast own layout to gridLayout QGridLayout *layout = (QGridLayout*)this->layout(); // creat groupbox for options QGroupBox *box = new QGroupBox(this); box->setTitle("Options:"); box->setVisible(true); m_BoxLayout = new QGridLayout(box); box->setLayout(m_BoxLayout); layout->addWidget(box,4,0,1,3); this->CreateConnections(); // m_context = us::getmodulecontext(); } void QmitkFileDialog::CreateConnections() { connect( this, SIGNAL(currentChanged( const QString &)), this, SLOT(DisplayOptions( QString)) ); connect( this, SIGNAL(fileSelected( const QString &)), this, SLOT(ProcessSelectedFile()) ); } /////////////////////////// OPTIONS /////////////////////////////// void QmitkFileDialog::DisplayOptions(QString path) { std::string extension = path.toStdString(); extension.erase(0, extension.find_last_of('.')); ClearOptionsBox(); us::ModuleContext* context = us::GetModuleContext(); mitk::FileReaderManager manager; mitk::IFileReader* reader = manager.GetReader(extension); if (reader == NULL) { // MITK_WARN << "Did not find ReaderService for registered Extension. This should be looked into by a developer."; return; } std::list< mitk::FileServiceOption > options = reader->GetOptions(); int i = 0; while (options.size() > 0) { QCheckBox *checker = new QCheckBox(this); checker->setText( options.front().first.c_str() ); checker->setChecked( options.front().second ); options.pop_front(); m_BoxLayout->addWidget(checker, i / 4, i % 4); i++; } } void QmitkFileDialog::ClearOptionsBox() { if ( m_BoxLayout != NULL ) { QLayoutItem* item; while ( ( item = m_BoxLayout->takeAt( 0 ) ) != NULL ) { delete item->widget(); delete item; } } } -void QmitkFileDialog::ProcessSelectedFile() -{ - std::string file = this->selectedFiles().front().toStdString(); - std::string extension = file; - extension.erase(0, extension.find_last_of('.')); - - m_Options = GetSelectedOptions(); - // We are not looking for specific Options here, which is okay, since the dialog currently only shows the - // reader with the highest priority. Better behaviour required, if we want selectable readers. - - m_FileReader = m_FileReaderManager.GetReader(extension); - m_FileReader->SetOptions(m_Options); -} - std::list< mitk::FileServiceOption > QmitkFileDialog::GetSelectedOptions() { std::list result; if ( m_BoxLayout != NULL ) { QLayoutItem* item; while ( ( item = m_BoxLayout->takeAt( 0 ) ) != NULL ) { QCheckBox* checker = dynamic_cast (item->widget()); if (checker) { mitk::FileServiceOption option = std::make_pair( checker->text().toStdString() , checker->isChecked() ); result.push_back(option); } delete item->widget(); delete item; } } return result; } - -mitk::IFileReader* QmitkFileDialog::GetReader() -{ - return this->m_FileReader; -} - -std::list< mitk::BaseData::Pointer > QmitkFileDialog::GetBaseData() -{ - if (m_FileReader == NULL ) - { - MITK_WARN << "Tried go get BaseData while no FileReader was selected in Dialog. Returning empty list."; - std::list< mitk::BaseData::Pointer > emptyList; - return emptyList; - } - return m_FileReader->Read(this->selectedFiles().front().toStdString()); -} \ No newline at end of file diff --git a/Modules/Qmitk/QmitkFileDialog.h b/Modules/Qmitk/QmitkFileDialog.h index 14a8944110..bbc5d3991a 100644 --- a/Modules/Qmitk/QmitkFileDialog.h +++ b/Modules/Qmitk/QmitkFileDialog.h @@ -1,98 +1,94 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QmitkFileDialog_H_INCLUDED #define _QmitkFileDialog_H_INCLUDED #include "QmitkExports.h" #include //QT headers #include #include #include //Microservices #include "usServiceReference.h" #include "usModuleContext.h" #include "usServiceEvent.h" #include "usServiceInterface.h" // MITK #include #include /** * \ingroup QmitkModule * * \brief */ class QMITK_EXPORT QmitkFileDialog :public QFileDialog { //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT private: //us::ModuleContext* m_Context; ///** \brief a filter to further narrow down the list of results*/ //std::string m_Filter; ///** \brief The name of the ServiceInterface that this class should list */ //std::string m_Interface; ///** \brief The name of the ServiceProperty that will be displayed in the list to represent the service */ //std::string m_NamingProperty; public: static const std::string VIEW_ID; QmitkFileDialog(QWidget* p = 0, Qt::WindowFlags f1 = 0); virtual ~QmitkFileDialog(); /** \brief This method is part of the widget and needs not to be called separately. */ virtual void CreateQtPartControl(QWidget *parent); /** \brief This method is part of the widget and needs not to be called separately. (Creation of the connections of main and control widget.)*/ virtual void CreateConnections(); virtual std::list< mitk::FileServiceOption > GetSelectedOptions(); - virtual mitk::IFileReader* GetReader(); - - virtual std::list< mitk::BaseData::Pointer > GetBaseData(); - signals: public slots: virtual void DisplayOptions(QString path); protected slots: - virtual void ProcessSelectedFile(); + virtual void ProcessSelectedFile() = 0; protected: QGridLayout* m_BoxLayout; mitk::IFileReader* m_FileReader; std::list m_Options; mitk::FileReaderManager m_FileReaderManager; virtual void ClearOptionsBox(); //Ui::QmitkFileDialogControls* m_Controls; ///< member holding the UI elements of this widget }; #endif // _QmitkFileDialog_H_INCLUDED diff --git a/Modules/Qmitk/QmitkFileOpenDialog.cpp b/Modules/Qmitk/QmitkFileOpenDialog.cpp new file mode 100644 index 0000000000..0f431e010d --- /dev/null +++ b/Modules/Qmitk/QmitkFileOpenDialog.cpp @@ -0,0 +1,79 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +//#define _USE_MATH_DEFINES +#include + +// MITK +#include +#include + +// STL Headers +#include + +//microservices +#include +#include +#include + +//QT +#include +#include +#include +#include + +// Test imports, delete later +#include + +const std::string QmitkFileOpenDialog::VIEW_ID = "org.mitk.views.QmitkFileOpenDialog"; + +QmitkFileOpenDialog::QmitkFileOpenDialog(QWidget* parent, Qt::WindowFlags f): QmitkFileDialog(parent, f) +{ +} + +QmitkFileOpenDialog::~QmitkFileOpenDialog() +{ +} + +void QmitkFileOpenDialog::ProcessSelectedFile() +{ + std::string file = this->selectedFiles().front().toStdString(); + std::string extension = file; + extension.erase(0, extension.find_last_of('.')); + + m_Options = GetSelectedOptions(); + // We are not looking for specific options here, which is okay, since the dialog currently only shows the + // reader with the highest priority. Better behaviour required, if we want selectable readers. + + m_FileReader = m_FileReaderManager.GetReader(extension); + m_FileReader->SetOptions(m_Options); +} + +mitk::IFileReader* QmitkFileOpenDialog::GetReader() +{ + return this->m_FileReader; +} + +std::list< mitk::BaseData::Pointer > QmitkFileOpenDialog::GetBaseData() +{ + if (m_FileReader == NULL ) + { + MITK_WARN << "Tried go get BaseData while no FileReader was selected in Dialog. Returning empty list."; + std::list< mitk::BaseData::Pointer > emptyList; + return emptyList; + } + return m_FileReader->Read(this->selectedFiles().front().toStdString()); +} \ No newline at end of file diff --git a/Modules/Qmitk/QmitkFileDialog.h b/Modules/Qmitk/QmitkFileOpenDialog.h similarity index 66% copy from Modules/Qmitk/QmitkFileDialog.h copy to Modules/Qmitk/QmitkFileOpenDialog.h index 14a8944110..32f239b2f3 100644 --- a/Modules/Qmitk/QmitkFileDialog.h +++ b/Modules/Qmitk/QmitkFileOpenDialog.h @@ -1,98 +1,86 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef _QmitkFileDialog_H_INCLUDED -#define _QmitkFileDialog_H_INCLUDED +#ifndef _QmitkFileOpenDialog_H_INCLUDED +#define _QmitkFileOpenDialog_H_INCLUDED #include "QmitkExports.h" #include //QT headers #include -#include #include //Microservices #include "usServiceReference.h" #include "usModuleContext.h" #include "usServiceEvent.h" #include "usServiceInterface.h" // MITK +#include #include #include /** * \ingroup QmitkModule * * \brief */ -class QMITK_EXPORT QmitkFileDialog :public QFileDialog +class QMITK_EXPORT QmitkFileOpenDialog :public QmitkFileDialog { //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT private: //us::ModuleContext* m_Context; ///** \brief a filter to further narrow down the list of results*/ //std::string m_Filter; ///** \brief The name of the ServiceInterface that this class should list */ //std::string m_Interface; ///** \brief The name of the ServiceProperty that will be displayed in the list to represent the service */ //std::string m_NamingProperty; public: static const std::string VIEW_ID; - QmitkFileDialog(QWidget* p = 0, Qt::WindowFlags f1 = 0); - virtual ~QmitkFileDialog(); - - /** \brief This method is part of the widget and needs not to be called separately. */ - virtual void CreateQtPartControl(QWidget *parent); - /** \brief This method is part of the widget and needs not to be called separately. (Creation of the connections of main and control widget.)*/ - virtual void CreateConnections(); - - virtual std::list< mitk::FileServiceOption > GetSelectedOptions(); + QmitkFileOpenDialog(QWidget* p = 0, Qt::WindowFlags f1 = 0); + virtual ~QmitkFileOpenDialog(); virtual mitk::IFileReader* GetReader(); virtual std::list< mitk::BaseData::Pointer > GetBaseData(); signals: public slots: - virtual void DisplayOptions(QString path); - protected slots: virtual void ProcessSelectedFile(); protected: - QGridLayout* m_BoxLayout; mitk::IFileReader* m_FileReader; std::list m_Options; mitk::FileReaderManager m_FileReaderManager; - virtual void ClearOptionsBox(); - - //Ui::QmitkFileDialogControls* m_Controls; ///< member holding the UI elements of this widget + //Ui::QmitkFileOpenDialogControls* m_Controls; ///< member holding the UI elements of this widget }; -#endif // _QmitkFileDialog_H_INCLUDED +#endif // _QmitkFileOpenDialog_H_INCLUDED diff --git a/Modules/Qmitk/QmitkFileDialog.cpp b/Modules/Qmitk/QmitkFileSaveDialog.cpp similarity index 88% copy from Modules/Qmitk/QmitkFileDialog.cpp copy to Modules/Qmitk/QmitkFileSaveDialog.cpp index 122b517b1e..2d7cc1e210 100644 --- a/Modules/Qmitk/QmitkFileDialog.cpp +++ b/Modules/Qmitk/QmitkFileSaveDialog.cpp @@ -1,244 +1,244 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //#define _USE_MATH_DEFINES -#include +#include // MITK #include #include // STL Headers #include //microservices #include #include #include //QT #include #include #include #include // Test imports, delete later #include class DummyReader : public mitk::AbstractFileReader { public: DummyReader(const DummyReader& other) : mitk::AbstractFileReader(other) { } DummyReader(const std::string& extension, int priority) : mitk::AbstractFileReader(extension, "This is a dummy description") { m_Priority = priority; //std::list options; m_Options.push_front(std::make_pair("isANiceGuy", true)); m_Options.push_front(std::make_pair("canFly", false)); m_Options.push_front(std::make_pair("isAwesome", true)); m_Options.push_front(std::make_pair("hasOptions", true)); m_Options.push_front(std::make_pair("has more Options", true)); m_Options.push_front(std::make_pair("has maaaaaaaany Options", true)); m_ServiceReg = this->RegisterService(); } ~DummyReader() { if (m_ServiceReg) m_ServiceReg.Unregister(); } using mitk::AbstractFileReader::Read; virtual std::list< itk::SmartPointer > Read(const std::istream& /*stream*/, mitk::DataStorage* /*ds*/ = 0) { std::list result; return result; } virtual void SetOptions(const std::list< mitk::FileServiceOption >& options ) { m_Options = options; //m_Registration.SetProperties(GetServiceProperties()); } private: DummyReader* Clone() const { return new DummyReader(*this); } us::ServiceRegistration m_ServiceReg; }; // End of internal dummy reader -const std::string QmitkFileDialog::VIEW_ID = "org.mitk.views.QmitkFileDialog"; +const std::string QmitkFileSaveDialog::VIEW_ID = "org.mitk.views.QmitkFileSaveDialog"; // // // // // // // // // -QmitkFileDialog::QmitkFileDialog(QWidget* parent, Qt::WindowFlags f): QFileDialog(parent, f) +QmitkFileSaveDialog::QmitkFileSaveDialog(QWidget* parent, Qt::WindowFlags f): QFileDialog(parent, f) { this->setOption(QFileDialog::DontUseNativeDialog); this->setFileMode(QFileDialog::ExistingFile); DummyReader* dr = new DummyReader(".xsfd", 1000); CreateQtPartControl(this); } -QmitkFileDialog::~QmitkFileDialog() +QmitkFileSaveDialog::~QmitkFileSaveDialog() { } //////////////////// INITIALIZATION ///////////////////// -void QmitkFileDialog::CreateQtPartControl(QWidget *parent) +void QmitkFileSaveDialog::CreateQtPartControl(QWidget *parent) { // cast own layout to gridLayout QGridLayout *layout = (QGridLayout*)this->layout(); // creat groupbox for options QGroupBox *box = new QGroupBox(this); box->setTitle("Options:"); box->setVisible(true); m_BoxLayout = new QGridLayout(box); box->setLayout(m_BoxLayout); layout->addWidget(box,4,0,1,3); this->CreateConnections(); // m_context = us::getmodulecontext(); } -void QmitkFileDialog::CreateConnections() +void QmitkFileSaveDialog::CreateConnections() { connect( this, SIGNAL(currentChanged( const QString &)), this, SLOT(DisplayOptions( QString)) ); connect( this, SIGNAL(fileSelected( const QString &)), this, SLOT(ProcessSelectedFile()) ); } /////////////////////////// OPTIONS /////////////////////////////// -void QmitkFileDialog::DisplayOptions(QString path) +void QmitkFileSaveDialog::DisplayOptions(QString path) { std::string extension = path.toStdString(); extension.erase(0, extension.find_last_of('.')); ClearOptionsBox(); us::ModuleContext* context = us::GetModuleContext(); mitk::FileReaderManager manager; mitk::IFileReader* reader = manager.GetReader(extension); if (reader == NULL) { // MITK_WARN << "Did not find ReaderService for registered Extension. This should be looked into by a developer."; return; } std::list< mitk::FileServiceOption > options = reader->GetOptions(); int i = 0; while (options.size() > 0) { QCheckBox *checker = new QCheckBox(this); checker->setText( options.front().first.c_str() ); checker->setChecked( options.front().second ); options.pop_front(); m_BoxLayout->addWidget(checker, i / 4, i % 4); i++; } } -void QmitkFileDialog::ClearOptionsBox() +void QmitkFileSaveDialog::ClearOptionsBox() { if ( m_BoxLayout != NULL ) { QLayoutItem* item; while ( ( item = m_BoxLayout->takeAt( 0 ) ) != NULL ) { delete item->widget(); delete item; } } } -void QmitkFileDialog::ProcessSelectedFile() +void QmitkFileSaveDialog::ProcessSelectedFile() { std::string file = this->selectedFiles().front().toStdString(); std::string extension = file; extension.erase(0, extension.find_last_of('.')); m_Options = GetSelectedOptions(); // We are not looking for specific Options here, which is okay, since the dialog currently only shows the // reader with the highest priority. Better behaviour required, if we want selectable readers. m_FileReader = m_FileReaderManager.GetReader(extension); m_FileReader->SetOptions(m_Options); } -std::list< mitk::FileServiceOption > QmitkFileDialog::GetSelectedOptions() +std::list< mitk::FileServiceOption > QmitkFileSaveDialog::GetSelectedOptions() { std::list result; if ( m_BoxLayout != NULL ) { QLayoutItem* item; while ( ( item = m_BoxLayout->takeAt( 0 ) ) != NULL ) { QCheckBox* checker = dynamic_cast (item->widget()); if (checker) { mitk::FileServiceOption option = std::make_pair( checker->text().toStdString() , checker->isChecked() ); result.push_back(option); } delete item->widget(); delete item; } } return result; } -mitk::IFileReader* QmitkFileDialog::GetReader() +mitk::IFileReader* QmitkFileSaveDialog::GetReader() { return this->m_FileReader; } -std::list< mitk::BaseData::Pointer > QmitkFileDialog::GetBaseData() +std::list< mitk::BaseData::Pointer > QmitkFileSaveDialog::GetBaseData() { if (m_FileReader == NULL ) { MITK_WARN << "Tried go get BaseData while no FileReader was selected in Dialog. Returning empty list."; std::list< mitk::BaseData::Pointer > emptyList; return emptyList; } return m_FileReader->Read(this->selectedFiles().front().toStdString()); } \ No newline at end of file diff --git a/Modules/Qmitk/QmitkFileDialog.h b/Modules/Qmitk/QmitkFileSaveDialog.h similarity index 85% copy from Modules/Qmitk/QmitkFileDialog.h copy to Modules/Qmitk/QmitkFileSaveDialog.h index 14a8944110..0bb9dd6983 100644 --- a/Modules/Qmitk/QmitkFileDialog.h +++ b/Modules/Qmitk/QmitkFileSaveDialog.h @@ -1,98 +1,98 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ -#ifndef _QmitkFileDialog_H_INCLUDED -#define _QmitkFileDialog_H_INCLUDED +#ifndef _QmitkFileSaveDialog_H_INCLUDED +#define _QmitkFileSaveDialog_H_INCLUDED #include "QmitkExports.h" #include //QT headers #include #include #include //Microservices #include "usServiceReference.h" #include "usModuleContext.h" #include "usServiceEvent.h" #include "usServiceInterface.h" // MITK #include #include /** * \ingroup QmitkModule * * \brief */ -class QMITK_EXPORT QmitkFileDialog :public QFileDialog +class QMITK_EXPORT QmitkFileSaveDialog :public QFileDialog { //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT private: //us::ModuleContext* m_Context; ///** \brief a filter to further narrow down the list of results*/ //std::string m_Filter; ///** \brief The name of the ServiceInterface that this class should list */ //std::string m_Interface; ///** \brief The name of the ServiceProperty that will be displayed in the list to represent the service */ //std::string m_NamingProperty; public: static const std::string VIEW_ID; - QmitkFileDialog(QWidget* p = 0, Qt::WindowFlags f1 = 0); - virtual ~QmitkFileDialog(); + QmitkFileSaveDialog(QWidget* p = 0, Qt::WindowFlags f1 = 0); + virtual ~QmitkFileSaveDialog(); /** \brief This method is part of the widget and needs not to be called separately. */ virtual void CreateQtPartControl(QWidget *parent); /** \brief This method is part of the widget and needs not to be called separately. (Creation of the connections of main and control widget.)*/ virtual void CreateConnections(); virtual std::list< mitk::FileServiceOption > GetSelectedOptions(); virtual mitk::IFileReader* GetReader(); virtual std::list< mitk::BaseData::Pointer > GetBaseData(); signals: public slots: virtual void DisplayOptions(QString path); protected slots: virtual void ProcessSelectedFile(); protected: QGridLayout* m_BoxLayout; mitk::IFileReader* m_FileReader; std::list m_Options; mitk::FileReaderManager m_FileReaderManager; virtual void ClearOptionsBox(); - //Ui::QmitkFileDialogControls* m_Controls; ///< member holding the UI elements of this widget + //Ui::QmitkFileSaveDialogControls* m_Controls; ///< member holding the UI elements of this widget }; -#endif // _QmitkFileDialog_H_INCLUDED +#endif // _QmitkFileSaveDialog_H_INCLUDED diff --git a/Modules/Qmitk/files.cmake b/Modules/Qmitk/files.cmake index 98f5aa8615..cfba7f5055 100644 --- a/Modules/Qmitk/files.cmake +++ b/Modules/Qmitk/files.cmake @@ -1,68 +1,72 @@ set(CPP_FILES QmitkApplicationCursor.cpp QmitkEnums.h QmitkCustomVariants.h QmitkDataStorageComboBox.cpp QmitkDataStorageListModel.cpp QmitkDataStorageTableModel.cpp QmitkDataStorageTreeModel.cpp QmitkEventAdapter.cpp QmitkFileDialog.cpp +QmitkFileOpenDialog.cpp +QmitkFileSaveDialog.cpp QmitkLevelWindowPresetDefinitionDialog.cpp QmitkLevelWindowRangeChangeDialog.cpp QmitkLevelWindowWidgetContextMenu.cpp QmitkLevelWindowWidget.cpp QmitkLineEditLevelWindowWidget.cpp QmitkMemoryUsageIndicatorView.cpp QmitkNodeDescriptor.cpp QmitkNodeDescriptorManager.cpp QmitkRenderWindowMenu.cpp QmitkProgressBar.cpp QmitkPropertiesTableEditor.cpp QmitkPropertiesTableModel.cpp QmitkPropertyDelegate.cpp QmitkRegisterClasses.cpp QmitkRenderingManager.cpp QmitkRenderingManagerFactory.cpp QmitkRenderWindow.cpp QmitkServiceListWidget.cpp QmitkSliderLevelWindowWidget.cpp QmitkStdMultiWidget.cpp QmitkMouseModeSwitcher.cpp ) set(MOC_H_FILES QmitkDataStorageComboBox.h QmitkDataStorageTableModel.h QmitkFileDialog.h +QmitkFileOpenDialog.h +QmitkFileSaveDialog.h QmitkLevelWindowPresetDefinitionDialog.h QmitkLevelWindowRangeChangeDialog.h QmitkLevelWindowWidgetContextMenu.h QmitkLevelWindowWidget.h QmitkLineEditLevelWindowWidget.h QmitkMemoryUsageIndicatorView.h QmitkNodeDescriptor.h QmitkNodeDescriptorManager.h QmitkRenderWindowMenu.h QmitkProgressBar.h QmitkPropertiesTableEditor.h QmitkPropertyDelegate.h QmitkRenderingManager.h QmitkRenderWindow.h QmitkServiceListWidget.h QmitkSliderLevelWindowWidget.h QmitkStdMultiWidget.h QmitkMouseModeSwitcher.h ) set(UI_FILES QmitkLevelWindowPresetDefinition.ui QmitkLevelWindowWidget.ui QmitkLevelWindowRangeChange.ui QmitkMemoryUsageIndicator.ui QmitkServiceListWidgetControls.ui ) set(QRC_FILES Qmitk.qrc ) diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp index f7dc4550cc..cf4d6b084a 100644 --- a/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkFileOpenAction.cpp @@ -1,130 +1,130 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkFileOpenAction.h" #include "internal/org_mitk_gui_qt_application_Activator.h" #include #include #include #include -#include +#include #include #include #include #include #include #include #include class QmitkFileOpenActionPrivate { public: QmitkFileOpenActionPrivate() : m_PrefServiceTracker(mitk::PluginActivator::GetContext()) {} void init ( berry::IWorkbenchWindow::Pointer window, QmitkFileOpenAction* action ) { m_PrefServiceTracker.open(); m_Window = window; action->setParent(static_cast(m_Window.Lock()->GetShell()->GetControl())); action->setText("&Open..."); action->setToolTip("Open data files (images, surfaces,...)"); QObject::connect(action, SIGNAL(triggered(bool)), action, SLOT(Run())); } berry::IPreferences::Pointer GetPreferences() const { berry::IPreferencesService* prefService = m_PrefServiceTracker.getService(); if (prefService) { return prefService->GetSystemPreferences()->Node("/General"); } return berry::IPreferences::Pointer(0); } QString getLastFileOpenPath() const { berry::IPreferences::Pointer prefs = GetPreferences(); if(prefs.IsNotNull()) { return QString::fromStdString(prefs->Get("LastFileOpenPath", "")); } return QString(); } void setLastFileOpenPath(const QString& path) const { berry::IPreferences::Pointer prefs = GetPreferences(); if(prefs.IsNotNull()) { prefs->Put("LastFileOpenPath", path.toStdString()); prefs->Flush(); } } berry::IWorkbenchWindow::WeakPtr m_Window; ctkServiceTracker m_PrefServiceTracker; }; QmitkFileOpenAction::QmitkFileOpenAction(berry::IWorkbenchWindow::Pointer window) : QAction(0), d(new QmitkFileOpenActionPrivate) { d->init(window, this); } QmitkFileOpenAction::QmitkFileOpenAction(const QIcon & icon, berry::IWorkbenchWindow::Pointer window) : QAction(0), d(new QmitkFileOpenActionPrivate) { d->init(window, this); this->setIcon(icon); } QmitkFileOpenAction::~QmitkFileOpenAction() { } void QmitkFileOpenAction::Run() { // Ask the user for a list of files to open - QmitkFileDialog dialog; + QmitkFileOpenDialog dialog; //QmitkFileDialog dialog; dialog.setFilter(mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); //dialog.show(); dialog.exec(); // QStringList fileNames = dialog.getOpenFileName(); //QStringList fileNames = QmitkFileDialog::getOpenFileNames(NULL, "Open", //d->getLastFileOpenPath(), // mitk::CoreObjectFactory::GetInstance()->GetFileExtensions()); //if (fileNames.empty()) return; //d->setLastFileOpenPath(fileNames.front()); //mitk::WorkbenchUtil::LoadFiles(fileNames, d->m_Window.Lock()); }