Skip to content

Commit

Permalink
BUG: Fix support of interactive mode in ctkDICOMAppWidgetTest1
Browse files Browse the repository at this point in the history
Switch to use of QCommandLineParser to ensure the "-I" is properly
parsed independently of the order of the command line argument.

Co-authored-by: Jean-Christophe Fillion-Robin <[email protected]>
  • Loading branch information
Punzo and jcfr committed Jan 13, 2024
1 parent 96c5d68 commit 7b00d52
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Libs/DICOM/Widgets/Testing/Cpp/ctkDICOMAppWidgetTest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

// Qt includes
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <QDir>
#include <QTimer>
Expand All @@ -43,7 +44,16 @@
int ctkDICOMAppWidgetTest1( int argc, char * argv [] )
{
QApplication app(argc, argv);


QCommandLineParser parser;
parser.addOption({"I", "Run in interactive mode"});
parser.addPositionalArgument("directory", "Directory to import");
parser.process(app);

QString directoryToImport = parser.positionalArguments().at(0);

qDebug() << "Importing directory " << directoryToImport;

ctkDICOMAppWidget appWidget;

QFileInfo tempFileInfo(QDir::tempPath() + QString("/ctkDICOMAppWidgetTest1-db"));
Expand All @@ -66,9 +76,9 @@ int ctkDICOMAppWidgetTest1( int argc, char * argv [] )
appWidget.openQueryDialog();

appWidget.openQueryDialog();

appWidget.setDisplayImportSummary(false);
appWidget.onImportDirectory(argv[argc -1]);
appWidget.onImportDirectory(directoryToImport);
if ( appWidget.patientsAddedDuringImport() != 1
|| appWidget.studiesAddedDuringImport() != 1
|| appWidget.seriesAddedDuringImport() != 1
Expand All @@ -78,7 +88,7 @@ int ctkDICOMAppWidgetTest1( int argc, char * argv [] )
return EXIT_FAILURE;
}

if (argc <= 2 || QString(argv[1]) != "-I")
if (!parser.isSet("I"))
{
QTimer::singleShot(200, &app, SLOT(quit()));
}
Expand Down

0 comments on commit 7b00d52

Please sign in to comment.