Skip to content

Commit

Permalink
COMP: Fix Qt4/C++98 excluding ctkDICOMQueryRetrieveWidget class
Browse files Browse the repository at this point in the history
The class makes use of "std::find_if" that is only available in c++ >= 11
  • Loading branch information
jcfr committed Nov 4, 2021
1 parent 6570866 commit 8504d1d
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,11 @@ ctk_app_option(ctkDICOMRetrieve
"Build the DICOM example application" OFF
CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)

if(CTK_QT_VERSION VERSION_GREATER "4")
ctk_app_option(ctkDICOMQueryRetrieve
"Build the DICOM example application" OFF
CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
endif()

ctk_app_option(ctkDICOMHost
"Build the DICOM application host example application" OFF
Expand Down
22 changes: 18 additions & 4 deletions Libs/DICOM/Widgets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ set(KIT_SRCS
ctkDICOMListenerWidget.h
ctkDICOMQueryResultsTabWidget.cpp
ctkDICOMQueryResultsTabWidget.h
ctkDICOMQueryRetrieveWidget.cpp
ctkDICOMQueryRetrieveWidget.h
ctkDICOMQueryWidget.cpp
ctkDICOMQueryWidget.h
ctkDICOMObjectListWidget.cpp
Expand All @@ -55,7 +53,6 @@ set(KIT_MOC_SRCS
ctkDICOMImportWidget.h
ctkDICOMObjectListWidget.h
ctkDICOMObjectModel.h
ctkDICOMQueryRetrieveWidget.h
ctkDICOMQueryWidget.h
ctkDICOMServerNodeWidget.h
ctkDICOMTableManager.h
Expand All @@ -71,14 +68,31 @@ set(KIT_UI_FORMS
Resources/UI/ctkDICOMDirectoryListWidget.ui
Resources/UI/ctkDICOMImportWidget.ui
Resources/UI/ctkDICOMListenerWidget.ui
Resources/UI/ctkDICOMQueryRetrieveWidget.ui
Resources/UI/ctkDICOMQueryWidget.ui
Resources/UI/ctkDICOMObjectListWidget.ui
Resources/UI/ctkDICOMServerNodeWidget.ui
Resources/UI/ctkDICOMTableManager.ui
Resources/UI/ctkDICOMTableView.ui
)

if(CTK_QT_VERSION VERSION_GREATER "4")
# Source files
list(APPEND KIT_SRCS
ctkDICOMQueryRetrieveWidget.cpp
ctkDICOMQueryRetrieveWidget.h
)

# Headers that should run through moc
list(APPEND KIT_MOC_SRCS
ctkDICOMQueryRetrieveWidget.h
)

# UI files - includes new widgets
list(APPEND KIT_UI_FORMS
Resources/UI/ctkDICOMQueryRetrieveWidget.ui
)
endif()

# Resources
set(KIT_resources
)
Expand Down
17 changes: 13 additions & 4 deletions Libs/DICOM/Widgets/Plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ set(PLUGIN_SRCS
ctkDICOMWidgetsAbstractPlugin.cpp
ctkDICOMWidgetsAbstractPlugin.h

ctkDICOMQueryRetrieveWidgetPlugin.cpp
ctkDICOMQueryRetrieveWidgetPlugin.h

ctkDICOMTableManagerPlugin.cpp
ctkDICOMTableManagerPlugin.h
ctkDICOMTableViewPlugin.cpp
Expand All @@ -26,7 +23,6 @@ set(PLUGIN_SRCS
set(PLUGIN_MOC_SRCS
ctkDICOMWidgetsPlugins.h

ctkDICOMQueryRetrieveWidgetPlugin.h
ctkDICOMTableManagerPlugin.h
ctkDICOMTableViewPlugin.h
)
Expand All @@ -35,6 +31,19 @@ set(PLUGIN_MOC_SRCS
set(PLUGIN_resources
)

if(CTK_QT_VERSION VERSION_GREATER "4")
# Source files
list(APPEND PLUGIN_SRCS
ctkDICOMQueryRetrieveWidgetPlugin.cpp
ctkDICOMQueryRetrieveWidgetPlugin.h
)

# Headers that should run through moc
list(APPEND PLUGIN_MOC_SRCS
ctkDICOMQueryRetrieveWidgetPlugin.h
)
endif()

# Target libraries
set(PLUGIN_target_libraries
CTKDICOMWidgets
Expand Down
4 changes: 4 additions & 0 deletions Libs/DICOM/Widgets/Plugins/ctkDICOMWidgetsPlugins.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

// CTK includes
#include "ctkDICOMWidgetsPluginsExport.h"
#ifdef HAVE_QT5
#include "ctkDICOMQueryRetrieveWidgetPlugin.h"
#endif
#include "ctkDICOMTableManagerPlugin.h"
#include "ctkDICOMTableViewPlugin.h"

Expand All @@ -50,7 +52,9 @@ class CTK_DICOM_WIDGETS_PLUGINS_EXPORT ctkDICOMWidgetsPlugins
QList<QDesignerCustomWidgetInterface*> customWidgets() const
{
QList<QDesignerCustomWidgetInterface *> plugins;
#ifdef HAVE_QT5
plugins << new ctkDICOMQueryRetrieveWidgetPlugin;
#endif
plugins << new ctkDICOMTableManagerPlugin;
plugins << new ctkDICOMTableViewPlugin;
return plugins;
Expand Down
15 changes: 13 additions & 2 deletions Libs/DICOM/Widgets/Testing/Cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(KIT ${PROJECT_NAME})

create_test_sourcelist(Tests ${KIT}CppTests.cpp
set(KITTests_SRCS
ctkDICOMAppWidgetTest1.cpp
ctkDICOMBrowserTest.cpp
ctkDICOMBrowserTest1.cpp
Expand All @@ -12,11 +12,20 @@ create_test_sourcelist(Tests ${KIT}CppTests.cpp
ctkDICOMModelTest2.cpp
ctkDICOMObjectModelTest1.cpp
ctkDICOMQueryResultsTabWidgetTest1.cpp
ctkDICOMQueryRetrieveWidgetTest1.cpp
ctkDICOMServerNodeWidgetTest1.cpp
ctkDICOMThumbnailListWidgetTest1.cpp
)

if(CTK_QT_VERSION VERSION_GREATER "4")
list(APPEND KITTests_SRCS
ctkDICOMQueryRetrieveWidgetTest1.cpp
)
endif()

create_test_sourcelist(Tests ${KIT}CppTests.cpp
${KITTests_SRCS}
)

set(Tests_MOC_CPPS
ctkDICOMBrowserTest.cpp
)
Expand Down Expand Up @@ -55,7 +64,9 @@ SIMPLE_TEST(ctkDICOMModelTest2
${CMAKE_CURRENT_BINARY_DIR}/dicom.db
${CMAKE_CURRENT_SOURCE_DIR}/../../../Core/Resources/dicom-sample.sql
)
if(CTK_QT_VERSION VERSION_GREATER "4")
SIMPLE_TEST(ctkDICOMQueryRetrieveWidgetTest1)
endif()
SIMPLE_TEST(ctkDICOMQueryResultsTabWidgetTest1)
SIMPLE_TEST(ctkDICOMThumbnailListWidgetTest1
${CMAKE_CURRENT_BINARY_DIR}/dicom.db
Expand Down
18 changes: 16 additions & 2 deletions Libs/DICOM/Widgets/ctkDICOMAppWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
#include "ctkDICOMThumbnailGenerator.h"
#include "ctkThumbnailLabel.h"
#include "ctkDICOMQueryResultsTabWidget.h"
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include "ctkDICOMQueryRetrieveWidget.h"
#endif
#include "ctkDICOMQueryWidget.h"

#include "ui_ctkDICOMAppWidget.h"
Expand All @@ -77,7 +79,9 @@ class ctkDICOMAppWidgetPrivate: public Ui_ctkDICOMAppWidget
~ctkDICOMAppWidgetPrivate();

ctkFileDialog* ImportDialog;
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
ctkDICOMQueryRetrieveWidget* QueryRetrieveWidget;
#endif

QSharedPointer<ctkDICOMDatabase> DICOMDatabase;
QSharedPointer<ctkDICOMThumbnailGenerator> ThumbnailGenerator;
Expand Down Expand Up @@ -273,8 +277,10 @@ ctkDICOMAppWidget::ctkDICOMAppWidget(QWidget* _parent):Superclass(_parent),
d->ToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

//Initialize Q/R widget
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
d->QueryRetrieveWidget = new ctkDICOMQueryRetrieveWidget();
d->QueryRetrieveWidget->setWindowModality ( Qt::ApplicationModal );
#endif

//initialize directory from settings, then listen for changes
QSettings settings;
Expand Down Expand Up @@ -308,8 +314,10 @@ ctkDICOMAppWidget::ctkDICOMAppWidget(QWidget* _parent):Superclass(_parent),
connect(d->ThumbnailsWidget, SIGNAL(doubleClicked(ctkThumbnailLabel)), this, SLOT(onThumbnailDoubleClicked(ctkThumbnailLabel)));
connect(d->ImportDialog, SIGNAL(fileSelected(QString)),this,SLOT(onImportDirectory(QString)));

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
connect(d->QueryRetrieveWidget, SIGNAL(canceled()), d->QueryRetrieveWidget, SLOT(hide()) );
connect(d->QueryRetrieveWidget, SIGNAL(canceled()), this, SLOT(onQueryRetrieveFinished()) );
#endif

connect(d->ImagePreview, SIGNAL(requestNextImage()), this, SLOT(onNextImage()));
connect(d->ImagePreview, SIGNAL(requestPreviousImage()), this, SLOT(onPreviousImage()));
Expand All @@ -325,7 +333,9 @@ ctkDICOMAppWidget::~ctkDICOMAppWidget()
{
Q_D(ctkDICOMAppWidget);

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
d->QueryRetrieveWidget->deleteLater();
#endif
d->ImportDialog->deleteLater();
}

Expand Down Expand Up @@ -421,7 +431,9 @@ void ctkDICOMAppWidget::setDatabaseDirectory(const QString& directory)

//pass DICOM database instance to Import widget
// d->ImportDialog->setDICOMDatabase(d->DICOMDatabase);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
d->QueryRetrieveWidget->setRetrieveDatabase(d->DICOMDatabase);
#endif

// update the button and let any connected slots know about the change
d->DirectoryButton->setDirectory(directory);
Expand Down Expand Up @@ -527,8 +539,12 @@ void ctkDICOMAppWidget::openQueryDialog()
{
Q_D(ctkDICOMAppWidget);

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
d->QueryRetrieveWidget->show();
d->QueryRetrieveWidget->raise();
#else
qWarning() << Q_FUNC_INFO << ": The Query Retrieve dialog is only available when building against Qt 5";
#endif

}

Expand All @@ -545,8 +561,6 @@ void ctkDICOMAppWidget::onRemoveAction()
{
Q_D(ctkDICOMAppWidget);

//d->QueryRetrieveWidget->show();
// d->QueryRetrieveWidget->raise();
std::cout << "on remove" << std::endl;
QModelIndexList selection = d->TreeView->selectionModel()->selectedIndexes();
std::cout << selection.size() << std::endl;
Expand Down
18 changes: 18 additions & 0 deletions Libs/DICOM/Widgets/ctkDICOMBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
#include "ctkDICOMBrowser.h"
#include "ctkDICOMObjectListWidget.h"
#include "ctkDICOMQueryResultsTabWidget.h"
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
#include "ctkDICOMQueryRetrieveWidget.h"
#endif
#include "ctkDICOMQueryWidget.h"
#include "ctkDICOMTableManager.h"
#include "ctkDICOMTableView.h"
Expand Down Expand Up @@ -141,7 +143,9 @@ class ctkDICOMBrowserPrivate: public Ui_ctkDICOMBrowser
ctkFileDialog* ImportDialog;
ctkDICOMMetadataDialog* MetadataDialog;

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
ctkDICOMQueryRetrieveWidget* QueryRetrieveWidget;
#endif

QSharedPointer<ctkDICOMDatabase> DICOMDatabase;
QSharedPointer<ctkDICOMIndexer> DICOMIndexer;
Expand Down Expand Up @@ -213,7 +217,9 @@ ctkDICOMBrowserPrivate::ctkDICOMBrowserPrivate(ctkDICOMBrowser* parent, QSharedP
: q_ptr(parent)
, ImportDialog(0)
, MetadataDialog(0)
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
, QueryRetrieveWidget(0)
#endif
, DICOMDatabase(database)
, DICOMIndexer( QSharedPointer<ctkDICOMIndexer>(new ctkDICOMIndexer) )
, UpdateSchemaProgress(0)
Expand Down Expand Up @@ -325,9 +331,11 @@ void ctkDICOMBrowserPrivate::init()
this->ToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

// Initialize Q/R widget
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
this->QueryRetrieveWidget = new ctkDICOMQueryRetrieveWidget();
this->QueryRetrieveWidget->setWindowModality ( Qt::ApplicationModal );
this->QueryRetrieveWidget->useProgressDialog(true);
#endif

this->dicomTableManager->setDICOMDatabase(this->DICOMDatabase.data());

Expand Down Expand Up @@ -393,8 +401,10 @@ void ctkDICOMBrowserPrivate::init()
q->connect(importDirectoryModeComboBox, SIGNAL(currentIndexChanged(int)),
q, SLOT(onImportDirectoryComboBoxCurrentIndexChanged(int)));

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
q->connect(this->QueryRetrieveWidget, SIGNAL(canceled()), this->QueryRetrieveWidget, SLOT(hide()) );
q->connect(this->QueryRetrieveWidget, SIGNAL(canceled()), q, SLOT(onQueryRetrieveFinished()) );
#endif
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -423,7 +433,9 @@ ctkDICOMBrowser::~ctkDICOMBrowser()
{
Q_D(ctkDICOMBrowser);

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
d->QueryRetrieveWidget->deleteLater();
#endif
d->ImportDialog->deleteLater();
d->MetadataDialog->deleteLater();
}
Expand Down Expand Up @@ -692,7 +704,9 @@ void ctkDICOMBrowser::setDatabaseDirectory(const QString& directory)
}

// pass DICOM database instance to Import widget
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
d->QueryRetrieveWidget->setRetrieveDatabase(d->DICOMDatabase);
#endif

// update the button and let any connected slots know about the change
bool wasBlocked = d->DirectoryButton->blockSignals(true);
Expand Down Expand Up @@ -786,9 +800,13 @@ void ctkDICOMBrowser::openQueryDialog()
{
Q_D(ctkDICOMBrowser);

#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
// QueryRetrieveWidget is a QWidget not a QDialog, so use this instead of exec
d->QueryRetrieveWidget->show();
d->QueryRetrieveWidget->raise();
#else
qWarning() << Q_FUNC_INFO << ": The Query Retrieve dialog is only available when building against Qt 5";
#endif
}

//----------------------------------------------------------------------------
Expand Down

0 comments on commit 8504d1d

Please sign in to comment.