Skip to content
Snippets Groups Projects
Commit 4a4f5b6b authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

corr

parent 6fd7a6e4
No related branches found
No related tags found
1 merge request!2359Use same tree view with delegate for datafiles, samples, and instruments. Also move some code between GUI/View directories. Restore Py wrappers lost in previous MR.
......@@ -69,6 +69,8 @@ QVariant DatafilesQModel::data(const QModelIndex& index, int role) const
DatafileItem* DatafilesQModel::itemForIndex(const QModelIndex& index) const
{
if (!index.isValid() || index.row() >= (int)m_model->size() || index.row() < 0)
return nullptr;
return m_model->dfileItemAt(index.row());
}
......
......@@ -163,7 +163,18 @@ QSize DatafilesSelector::minimumSizeHint() const
DatafileItem* DatafilesSelector::currentDatafileItem()
{
return m_qmodel->itemForIndex(currentDatafileIndex());
const QModelIndex i = m_qview->selectionModel()->currentIndex();
if (!m_qview->selectionModel()->isSelected(i))
return nullptr;
return m_qmodel->itemForIndex(i);
}
QModelIndex DatafilesSelector::currentDatafileIndex() const
{
const QModelIndex i = m_qview->selectionModel()->currentIndex();
if (!m_qview->selectionModel()->isSelected(i))
return {};
return i;
}
void DatafilesSelector::setCurrentDatafileItem(const DatafileItem* item)
......@@ -181,13 +192,6 @@ void DatafilesSelector::restoreSelection()
m_data_frames->setStackedItem(currentDatafileItem()->dataItem());
}
QModelIndex DatafilesSelector::currentDatafileIndex() const
{
if (!m_qview->selectionModel()->isSelected(m_qview->selectionModel()->currentIndex()))
return {};
return m_qview->selectionModel()->currentIndex();
}
QList<QAction*> DatafilesSelector::getOverlayActions(const QModelIndex& index, bool asHover)
{
if (m_qmodel->isHeadline(index))
......@@ -197,7 +201,7 @@ QList<QAction*> DatafilesSelector::getOverlayActions(const QModelIndex& index, b
if (!asHover)
return {};
auto* item = m_qmodel->itemForIndex(index);
const DatafileItem* item = m_qmodel->itemForIndex(index);
if (item == nullptr)
return {};
......@@ -228,7 +232,7 @@ void DatafilesSelector::onSelectionChanged()
void DatafilesSelector::onContextMenuRequest(const QPoint& point)
{
auto* dfile_item = m_qmodel->itemForIndex(m_qview->indexAt(point));
DatafileItem* dfile_item = m_qmodel->itemForIndex(m_qview->indexAt(point));
updateActionEnabling(dfile_item);
QMenu menu;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment