Commit 2dee1799 authored by Jean-Loup Haberbusch's avatar Jean-Loup Haberbusch

Merge branch '56-new-way-to-open-directory' into 'develop'

Resolve "New way to open DICOM volumes (or other type of directory component) in imp"

Closes #56

See merge request !128
parents a163515a 9077f373
/*****************************************************************************
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
......@@ -59,6 +59,10 @@ DicomDialog::DicomDialog(QList<DicomDialogEntry*> elements): QDialog() {
ui.tableWidget->setItem(row, column++, new QTableWidgetItem(item->getSeriesName()));
row++;
}
// To get checkbox checked if there is only one study in list
if (elements.size() == 1) {
ui.tableWidget->itemAt(0, 0)->setCheckState(Qt::Checked);
}
ui.tableWidget->resizeColumnsToContents();
......
/*****************************************************************************
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
......@@ -68,7 +68,6 @@ ImpMainWindow::ImpMainWindow() : MainWindow("imp") {
// initialize architecture
updateActionStates();
updateOpenDirectoryMenu();
// now add the different viewers
setCentralViewer(MedicalImageViewer::getInstance());
......@@ -111,10 +110,9 @@ void ImpMainWindow::aboutToShow() {
void ImpMainWindow::refresh() {
MainWindow::refresh();
// update Data directory menu
updateOpenDirectoryMenu();
// update all the action states
updateActionStates();
// update menu
updateRecentDocumentsMenu();
}
......@@ -229,10 +227,12 @@ void ImpMainWindow::initMenuBar() {
fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(fileOpen);
fileOpenDataDirectoryMenu = new QMenu(tr("Open &Data Directory..."));
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fileOpenDataDirectoryMenu->setEnabled(false);
fileMenu->addMenu(fileOpenDataDirectoryMenu);
openDataDirectoryMenuBuilder(fileMenu);
// fileOpenDataDirectoryMenu = new QMenu(tr("Open &Data Directory..."));
// fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
// fileOpenDataDirectoryMenu->setEnabled(false);
// fileMenu->addMenu(fileOpenDataDirectoryMenu);
fileMenu->addAction(fileClose);
fileMenu->addAction(fileCloseAll);
......@@ -423,32 +423,9 @@ void ImpMainWindow::resetWindows() {
move(0, 0);
}
// ------------------------ updateDataDirectoryMenu ----------------------------
void ImpMainWindow::updateOpenDirectoryMenu() {
unsigned int nrOfDataDirectoryManager = 0;
disconnect(fileOpenDataDirectoryMenu, SIGNAL(triggered(QAction*)), this, SLOT(openDirectory(QAction*)));
fileOpenDataDirectoryMenu->clear();
fileOpenDataDirectoryMenu->setEnabled(false);
foreach (QString name, ExtensionManager::getDataDirectoryExtNames()) {
nrOfDataDirectoryManager++;
QAction* openDirectory = new QAction(name, this);
openDirectory->setStatusTip(tr(QString("Opens data directory for " + name).toStdString().c_str()));
openDirectory->setWhatsThis(tr(QString("Opens data directory for " + name).toStdString().c_str()));
fileOpenDataDirectoryMenu->addAction(openDirectory);
}
if (nrOfDataDirectoryManager > 0) {
fileOpenDataDirectoryMenu->setEnabled(true);
connect(fileOpenDataDirectoryMenu, SIGNAL(triggered(QAction*)), this, SLOT(openDirectory(QAction*)));
}
}
// ------------- openDataDirectory -----------------
void ImpMainWindow::openDirectory(QAction* emitter) {
QString pluginName = emitter->text().replace("&", "");
void ImpMainWindow::openDicomDirectory(QString plugin) {
QString pluginName = plugin;
statusBar()->showMessage(tr(QString("Opening " + pluginName + " directory...").toStdString().c_str()));
......@@ -569,7 +546,7 @@ void ImpMainWindow::editSettings() {
}
// check if there are anything to change in the data directory menu (for data directory manager)
updateOpenDirectoryMenu();
ImpMainWindow::openDataDirectoryMenuBuilder(fileMenu);
}
// ------------- setApplicationConsole -----------------
......@@ -623,7 +600,60 @@ void ImpMainWindow::saveHistoryAsSCXML() {
Application::saveHistoryAsSXML();
}
// ------------------------- openDataDirectoryMenuBuilder ---------------------------
void ImpMainWindow::openDataDirectoryMenuBuilder(QMenu * fm) {
QStringList dirExt = ExtensionManager::getDataDirectoryExtNames();
QString dirExtName;
if (dirExt.size() > 1) {
if (fileOpenDataDirectoryMenu == nullptr){
fileOpenDataDirectoryMenu = new QMenu("Open Data Directory");
fm->addMenu(fileOpenDataDirectoryMenu);
} else {
disconnect(fileOpenDataDirectoryMenu,0,0,0);
fileOpenDataDirectoryMenu->clear();
}
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
foreach (dirExtName, dirExt) {
QAction* openDirectory = new QAction(dirExtName, this);
openDirectory->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
openDirectory->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
connect(openDirectory, &QAction::triggered, this, [=]() {this->openDicomDirectory(dirExtName);});
fileOpenDataDirectoryMenu->addAction(openDirectory);
}
} else if (dirExt.size() == 1) {
QAction* openDirectoryAct;
dirExtName = dirExt.at(0);
int indexAction = 0;
bool updateAction = false;
foreach (QAction * action, fileMenu->actions()) {
if (action->text().contains(" Directory")) {
action->destroyed();
updateAction = true;
break;
}
indexAction++;
}
if (!updateAction) {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
fm->addAction(openDirectoryAct);
} else {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
}
openDirectoryAct->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
openDirectoryAct->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
connect(openDirectoryAct, &QAction::triggered, this, [=]() {this->openDicomDirectory(dirExtName);});
openDirectoryAct->setIcon(QPixmap(":/fileOpen"));
} else {
fileOpenDataDirectoryMenu = new QMenu("No plugins loaded to Open Data Directory");
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fileOpenDataDirectoryMenu->setEnabled(false);
fm->addMenu(fileOpenDataDirectoryMenu);
}
}
/*****************************************************************************
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
......@@ -80,7 +80,7 @@ public slots:
/// @name file menu slot
///@{
/// open a data directory, "called" from the fileOpenDataDirectoryMenu
void openDirectory(QAction*);
void openDicomDirectory(QString plugin);
///@}
/// @name viewers' slot
......@@ -122,11 +122,15 @@ protected:
/// update the viewer's menu
void updateViewMenu();
/// Build the open data directory menu
void openDataDirectoryMenuBuilder(QMenu *);
/** @name Extension and ComponentPlugin attributes */
///@{
/// update the data directory menu depending on registered plugins
void updateOpenDirectoryMenu();
/// update the recent document menu
void updateRecentDocumentsMenu();
///@}
......@@ -161,7 +165,7 @@ private:
///@{
/** file_menu contains all items of the menubar entry "File" */
QMenu* fileMenu;
QMenu* fileOpenDataDirectoryMenu;
QMenu* fileOpenDataDirectoryMenu = nullptr;
QAction* fileOpen;
QAction* fileClose;
QAction* fileCloseAll;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment