Skip to content

Commit

Permalink
Update SQtree
Browse files Browse the repository at this point in the history
  • Loading branch information
issakomi committed May 31, 2024
1 parent 3f5c0d9 commit 45f0d27
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 39 deletions.
4 changes: 2 additions & 2 deletions GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ void MainWindow::toggle_meta2()
if (l.empty()) return;
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
const int t = (multiview_tab) ? 3 : 2;
sqtree->set_list_of_files(l, true);
sqtree->set_list_of_files(l, 0, true);
sqtree->read_file(l.at(0), true);
tabWidget->setCurrentIndex(t);
qApp->restoreOverrideCursor();
Expand Down Expand Up @@ -2278,7 +2278,7 @@ void MainWindow::trigger_image_dicom_meta()
}
qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
qApp->processEvents();
sqtree->set_list_of_files(l, true);
sqtree->set_list_of_files(l, 0, true);
sqtree->read_file(l.at(0), true);
const int t = (multiview_tab) ? 3 : 2;
tabWidget->setCurrentIndex(t);
Expand Down
54 changes: 18 additions & 36 deletions browser/sqtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ void SQtree::read_file_and_series(const QString & ff, const bool use_lock)
if (!fi.isFile())
{
clear_tree();
set_list_of_files(QStringList(), 0, false);
#if (defined SQTREE_LOCK_TREE && SQTREE_LOCK_TREE==1)
if (use_lock) lock0 = false;
#endif
Expand Down Expand Up @@ -1165,23 +1166,14 @@ void SQtree::read_file_and_series(const QString & ff, const bool use_lock)
}
}
//
horizontalSlider->blockSignals(true);
horizontalSlider->setMinimum(0);
if (idx >= 0)
{
list_of_files = std::move(files);
horizontalSlider->setMaximum(files_size-1);
horizontalSlider->setValue(idx);
horizontalSlider->show();
set_list_of_files(files, idx, false);
}
else
{
list_of_files = QStringList(f);
horizontalSlider->setMaximum(0);
horizontalSlider->setValue(0);
horizontalSlider->hide();
set_list_of_files(QStringList(f), 0, false);
}
horizontalSlider->blockSignals(false);
read_file(f, false);
#if (defined SQTREE_LOCK_TREE && SQTREE_LOCK_TREE==1)
if (use_lock) lock0 = false;
Expand Down Expand Up @@ -1749,18 +1741,13 @@ void SQtree::dropEvent(QDropEvent * e)
}
if (!l.empty())
{
list_of_files = QStringList(l.at(0));
horizontalSlider->blockSignals(true);
horizontalSlider->setMinimum(0);
horizontalSlider->setMaximum(0);
horizontalSlider->setValue(0);
horizontalSlider->hide();
horizontalSlider->blockSignals(false);
set_list_of_files(l, 0, false);
read_file(l.at(0), false);
}
else
{
clear_tree();
set_list_of_files(QStringList(), 0, false);
}
}
// TODO distinguish other Qt apps?
Expand Down Expand Up @@ -1801,22 +1788,25 @@ void SQtree::dropEvent(QDropEvent * e)
}
if (!l.empty())
{
set_list_of_files(l, false);
set_list_of_files(l, 0, false);
read_file(l.at(0), false);
}
else
{
clear_tree();
set_list_of_files(QStringList(), 0, false);
}
}
else
{
clear_tree();
set_list_of_files(QStringList(), 0, false);
}
}
else
{
clear_tree();
set_list_of_files(QStringList(), 0, false);
}
qApp->restoreOverrideCursor();
#if (defined SQTREE_LOCK_TREE && SQTREE_LOCK_TREE==1)
Expand Down Expand Up @@ -1858,6 +1848,7 @@ void SQtree::open_file()
lock0 = true;
#endif
clear_tree();
set_list_of_files(QStringList(), 0, false);
const QString f = QFileDialog::getOpenFileName(
this,
QString("Open File"),
Expand All @@ -1870,13 +1861,7 @@ void SQtree::open_file()
QFileInfo fi(f);
if (fi.isFile())
{
list_of_files = QStringList(f);
horizontalSlider->blockSignals(true);
horizontalSlider->setMinimum(0);
horizontalSlider->setMaximum(0);
horizontalSlider->setValue(0);
horizontalSlider->hide();
horizontalSlider->blockSignals(false);
set_list_of_files(QStringList(f), 0, false);
read_file(f, false);
}
#if (defined SQTREE_LOCK_TREE && SQTREE_LOCK_TREE==1)
Expand All @@ -1890,6 +1875,8 @@ void SQtree::open_file_and_series()
if (lock0) return;
lock0 = true;
#endif
clear_tree();
set_list_of_files(QStringList(), 0, false);
QString f = QFileDialog::getOpenFileName(
this,
QString("Open file and scan series"),
Expand All @@ -1900,21 +1887,16 @@ void SQtree::open_file_and_series()
/*| QFileDialog::DontUseNativeDialog*/
));
QFileInfo fi(f);
if (!fi.isFile())
if (fi.isFile())
{
clear_tree();
#if (defined SQTREE_LOCK_TREE && SQTREE_LOCK_TREE==1)
lock0 = false;
#endif
return;
read_file_and_series(f, false);
}
read_file_and_series(f, false);
#if (defined SQTREE_LOCK_TREE && SQTREE_LOCK_TREE==1)
lock0 = false;
#endif
}

void SQtree::set_list_of_files(const QStringList & l, const bool use_lock)
void SQtree::set_list_of_files(const QStringList & l, const int idx, const bool use_lock)
{
#if (defined SQTREE_LOCK_TREE && SQTREE_LOCK_TREE==1)
if (use_lock)
Expand All @@ -1923,12 +1905,12 @@ void SQtree::set_list_of_files(const QStringList & l, const bool use_lock)
lock0 = true;
}
#endif
list_of_files = QStringList(l);
list_of_files = l;
const size_t x = list_of_files.size();
horizontalSlider->blockSignals(true);
horizontalSlider->setMinimum(0);
horizontalSlider->setMaximum(x > 0 ? x - 1 : 0);
horizontalSlider->setValue(0);
horizontalSlider->setValue(idx);
if (x > 1) horizontalSlider->show();
else horizontalSlider->hide();
horizontalSlider->blockSignals(false);
Expand Down
2 changes: 1 addition & 1 deletion browser/sqtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Q_OBJECT
void read_file(const QString&, const bool);
void read_file_and_series(const QString&, const bool);
void clear_tree();
void set_list_of_files(const QStringList&, const bool);
void set_list_of_files(const QStringList&, const int, const bool);
void set_aliza(Aliza*);

public slots:
Expand Down

0 comments on commit 45f0d27

Please sign in to comment.