Commit 7479ff50 authored by jcfr's avatar jcfr

STYLE: Remove obsolete use of Qt4 QHeaderView API

See https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide#Obsolete_Code_RemovalCo-authored-by: Jean-Christophe Fillion-Robin's avatarJean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Co-authored-by: phcerdan's avatarPablo Hernandez-Cerdan <pablo.hernandez.cerdan@outlook.com>

From: Pablo Hernandez-Cerdan <pablo.hernandez.cerdan@outlook.com>

git-svn-id: http://svn.slicer.org/Slicer4/trunk@28002 3bd1e089-480b-0410-8dfb-8563597acbee
parent 98171a61
......@@ -59,13 +59,8 @@ qSlicerDataDialogPrivate::qSlicerDataDialogPrivate(QWidget* _parent)
ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(
Qt::Horizontal, this->FileWidget);
// Copy the previous behavior of the header into the new checkable header view
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
headerView->setClickable(previousHeaderView->isClickable());
headerView->setMovable(previousHeaderView->isMovable());
#else
headerView->setSectionsClickable(previousHeaderView->sectionsClickable());
headerView->setSectionsMovable(previousHeaderView->sectionsMovable());
#endif
headerView->setHighlightSections(previousHeaderView->highlightSections());
headerView->setStretchLastSection(previousHeaderView->stretchLastSection());
// Propagate to top-level items only (depth = 1),no need to go deeper
......@@ -75,15 +70,9 @@ qSlicerDataDialogPrivate::qSlicerDataDialogPrivate(QWidget* _parent)
this->FileWidget->setHorizontalHeader(headerView);
headerView->setStretchLastSection(false);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
headerView->setResizeMode(FileColumn, QHeaderView::Stretch);
headerView->setResizeMode(TypeColumn, QHeaderView::ResizeToContents);
headerView->setResizeMode(OptionsColumn, QHeaderView::ResizeToContents);
#else
headerView->setSectionResizeMode(FileColumn, QHeaderView::Stretch);
headerView->setSectionResizeMode(TypeColumn, QHeaderView::ResizeToContents);
headerView->setSectionResizeMode(OptionsColumn, QHeaderView::ResizeToContents);
#endif
this->FileWidget->sortItems(-1, Qt::AscendingOrder);
......
......@@ -171,13 +171,8 @@ qSlicerSaveDataDialogPrivate::qSlicerSaveDataDialogPrivate(QWidget* parentWidget
QHeaderView* previousHeaderView = this->FileWidget->horizontalHeader();
ctkCheckableHeaderView* headerView = new ctkCheckableHeaderView(Qt::Horizontal, this->FileWidget);
// Copy the previous behavior of the header into the new checkable header view
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
headerView->setClickable(previousHeaderView->isClickable());
headerView->setMovable(previousHeaderView->isMovable());
#else
headerView->setSectionsClickable(previousHeaderView->sectionsClickable());
headerView->setSectionsMovable(previousHeaderView->sectionsMovable());
#endif
headerView->setHighlightSections(previousHeaderView->highlightSections());
headerView->setStretchLastSection(previousHeaderView->stretchLastSection());
// Propagate to top-level items only (depth = 1),no need to go deeper
......
......@@ -63,15 +63,9 @@ void qMRMLColorTableViewPrivate::init()
q->setSelectionBehavior(QAbstractItemView::SelectRows);
q->horizontalHeader()->setStretchLastSection(false);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
q->horizontalHeader()->setResizeMode(colorModel->colorColumn(), QHeaderView::ResizeToContents);
q->horizontalHeader()->setResizeMode(colorModel->labelColumn(), QHeaderView::Stretch);
q->horizontalHeader()->setResizeMode(colorModel->opacityColumn(), QHeaderView::ResizeToContents);
#else
q->horizontalHeader()->setSectionResizeMode(colorModel->colorColumn(), QHeaderView::ResizeToContents);
q->horizontalHeader()->setSectionResizeMode(colorModel->labelColumn(), QHeaderView::Stretch);
q->horizontalHeader()->setSectionResizeMode(colorModel->opacityColumn(), QHeaderView::ResizeToContents);
#endif
q->setItemDelegate(new qMRMLItemDelegate(q));
}
......
......@@ -77,12 +77,6 @@ void qMRMLNodeAttributeTableViewPrivate::init()
q, SLOT(storeSelectedAttributeTableItem(QTableWidgetItem*,QTableWidgetItem*)));
this->setMessage(QString());
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
// Set up initial look of node attributes table
this->NodeAttributesTable->horizontalHeader()->setResizeMode(
QHeaderView::ResizeToContents);
#endif
}
// --------------------------------------------------------------------------
......
......@@ -471,11 +471,7 @@ void qMRMLAnnotationTreeView::hideScene()
// set the column widths
for (int i = 0; i < this->header()->count(); ++i)
{
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
this->header()->setResizeMode(i, QHeaderView::ResizeToContents);
#else
this->header()->setSectionResizeMode(i, QHeaderView::ResizeToContents);
#endif
}
}
......
......@@ -187,13 +187,8 @@ void qSlicerDataModuleWidget::setup()
d->TransformMRMLTreeView->sceneModel()->setIDColumn(1);
d->TransformMRMLTreeView->sceneModel()->setHorizontalHeaderLabels(QStringList() << "Nodes" << "IDs");
d->TransformMRMLTreeView->header()->setStretchLastSection(false);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
d->TransformMRMLTreeView->header()->setResizeMode(0, QHeaderView::Stretch);
d->TransformMRMLTreeView->header()->setResizeMode(1, QHeaderView::ResizeToContents);
#else
d->TransformMRMLTreeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
d->TransformMRMLTreeView->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
#endif
connect( d->TransformMRMLTreeView, SIGNAL(currentNodeChanged(vtkMRMLNode*)),
this, SLOT(onCurrentNodeChanged(vtkMRMLNode*)) );
......@@ -232,13 +227,8 @@ void qSlicerDataModuleWidget::setup()
d->AllNodesMRMLTreeView->sceneModel()->setIDColumn(1);
d->AllNodesMRMLTreeView->sceneModel()->setHorizontalHeaderLabels(QStringList() << "Nodes" << "IDs");
d->AllNodesMRMLTreeView->header()->setStretchLastSection(false);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
d->AllNodesMRMLTreeView->header()->setResizeMode(0, QHeaderView::Stretch);
d->AllNodesMRMLTreeView->header()->setResizeMode(1, QHeaderView::ResizeToContents);
#else
d->AllNodesMRMLTreeView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
d->AllNodesMRMLTreeView->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
#endif
// Edit properties
connect( d->AllNodesMRMLTreeView, SIGNAL(editNodeRequested(vtkMRMLNode*)),
......
......@@ -133,11 +133,7 @@ void qSlicerSimpleMarkupsWidget::setup()
d->MarkupsFiducialTableWidget->setColumnCount( FIDUCIAL_COLUMNS );
d->MarkupsFiducialTableWidget->setHorizontalHeaderLabels( QStringList() << "Label" << "X" << "Y" << "Z" );
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
d->MarkupsFiducialTableWidget->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
#else
d->MarkupsFiducialTableWidget->horizontalHeader()->setSectionResizeMode( QHeaderView::Stretch );
#endif
d->MarkupsFiducialTableWidget->setContextMenuPolicy( Qt::CustomContextMenu );
d->MarkupsFiducialTableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); // only select rows rather than cells
......
......@@ -112,15 +112,9 @@ void qSlicerSceneViewsModuleWidgetPrivate::setupUi(qSlicerWidget* widget)
this->SceneViewTableWidget->setHorizontalHeaderLabels(QStringList() << "Thumbnail" << "Description" << "Actions");
this->SceneViewTableWidget->horizontalHeader()->hide();
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
this->SceneViewTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
this->SceneViewTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
this->SceneViewTableWidget->horizontalHeader()->setResizeMode(SCENE_VIEW_DESCRIPTION_COLUMN, QHeaderView::Stretch);
#else
this->SceneViewTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
this->SceneViewTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
this->SceneViewTableWidget->horizontalHeader()->setSectionResizeMode(SCENE_VIEW_DESCRIPTION_COLUMN, QHeaderView::Stretch);
#endif
// background of text browser widget is painted by the widget, and images has no background
// either, so it is easier to just disable selection
......
......@@ -98,22 +98,14 @@ void qMRMLSegmentationConversionParametersWidgetPrivate::init()
q, SLOT(applyConversion()));
// Set up initial look of the tables
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
this->PathsTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#else
this->PathsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
this->PathsTable->horizontalHeader()->setStretchLastSection(1);
this->PathsTable->setSelectionMode(QAbstractItemView::SingleSelection);
this->PathsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
this->PathsColumnLabels << "Cost" << "Path";
this->PathsTable->setColumnCount(this->PathsColumnLabels.size());
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
this->ParametersTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#else
this->ParametersTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
this->ParametersTable->horizontalHeader()->setStretchLastSection(1);
this->ParametersColumnLabels << "Name" << "Value";
this->ParametersTable->setColumnCount(this->ParametersColumnLabels.size());
......
......@@ -141,11 +141,7 @@ void qMRMLSegmentsTableViewPrivate::init()
this->SegmentsTable->horizontalHeaderItem(
this->columnIndex("Visible"))->setIcon(QIcon(":/Icons/Small/SlicerVisibleInvisible.png") );
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
this->SegmentsTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#else
this->SegmentsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
this->SegmentsTable->horizontalHeader()->setStretchLastSection(1);
// Select rows
......
......@@ -170,19 +170,11 @@ void qMRMLSubjectHierarchyTreeViewPrivate::init()
// Set up headers
q->header()->setStretchLastSection(false);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
q->header()->setResizeMode(this->Model->nameColumn(), QHeaderView::Stretch);
q->header()->setResizeMode(this->Model->visibilityColumn(), QHeaderView::ResizeToContents);
q->header()->setResizeMode(this->Model->colorColumn(), QHeaderView::ResizeToContents);
q->header()->setResizeMode(this->Model->transformColumn(), QHeaderView::ResizeToContents);
q->header()->setResizeMode(this->Model->idColumn(), QHeaderView::ResizeToContents);
#else
q->header()->setSectionResizeMode(this->Model->nameColumn(), QHeaderView::Stretch);
q->header()->setSectionResizeMode(this->Model->visibilityColumn(), QHeaderView::ResizeToContents);
q->header()->setSectionResizeMode(this->Model->colorColumn(), QHeaderView::ResizeToContents);
q->header()->setSectionResizeMode(this->Model->transformColumn(), QHeaderView::ResizeToContents);
q->header()->setSectionResizeMode(this->Model->idColumn(), QHeaderView::ResizeToContents);
#endif
// Set generic MRML item delegate
q->setItemDelegate(new qMRMLItemDelegate(q));
......
......@@ -3,8 +3,6 @@ import qt
import vtk
import logging
from packaging import version
from ctk import ctkDICOMObjectListWidget, ctkDICOMDatabase, ctkDICOMIndexer, ctkDICOMBrowser, ctkPopupWidget, ctkExpandButton
import slicer
from slicer.util import VTKObservationMixin
......@@ -1112,13 +1110,6 @@ class DICOMPluginSelector(qt.QWidget):
return selectedPlugins
def _setSectionResizeMode(header, *args, **kwargs):
if version.parse(qt.Qt.qVersion()) < version.parse("5.0.0"):
header.setResizeMode(*args, **kwargs)
else:
header.setSectionResizeMode(*args, **kwargs)
class DICOMLoadableTable(qt.QTableWidget):
"""Implement the Qt code for a table of
selectable slicer data to be made from
......@@ -1141,10 +1132,10 @@ class DICOMLoadableTable(qt.QTableWidget):
self.setColumnCount(3)
self.setHorizontalHeaderLabels(['DICOM Data', 'Reader', 'Warnings'])
self.setSelectionBehavior(qt.QTableView.SelectRows)
_setSectionResizeMode(self.horizontalHeader(), qt.QHeaderView.Stretch)
_setSectionResizeMode(self.horizontalHeader(), 0, qt.QHeaderView.ResizeToContents)
_setSectionResizeMode(self.horizontalHeader(), 1, qt.QHeaderView.Stretch)
_setSectionResizeMode(self.horizontalHeader(), 2, qt.QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(qt.QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(0, qt.QHeaderView.ResizeToContents)
self.horizontalHeader().setSectionResizeMode(1, qt.QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(2, qt.QHeaderView.Stretch)
def addLoadableRow(self, loadable, row, reader):
self.insertRow(row)
......@@ -1235,9 +1226,9 @@ class DICOMHeaderWidget(qt.QTableWidget):
def configure(self):
self.setColumnCount(2)
self.setHorizontalHeaderLabels(['Tag', 'Value'])
_setSectionResizeMode(self.horizontalHeader(), qt.QHeaderView.Stretch)
_setSectionResizeMode(self.horizontalHeader(), 0, qt.QHeaderView.Stretch)
_setSectionResizeMode(self.horizontalHeader(), 1, qt.QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(qt.QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(0, qt.QHeaderView.Stretch)
self.horizontalHeader().setSectionResizeMode(1, qt.QHeaderView.Stretch)
def setHeader(self, dcmFile=None):
#TODO: this method never gets called. Should be called when clicking on items from the SeriesTable
......
......@@ -128,11 +128,7 @@ void qSlicerDICOMTagEditorWidgetPrivate::setupUi(QWidget *qSlicerDICOMTagEditorW
this->TagsTable = new QTableWidget(qSlicerDICOMTagEditorWidget);
this->TagsTable->setColumnCount(2);
this->TagsTable->horizontalHeader()->setVisible(false);
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
this->TagsTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#else
this->TagsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#endif
this->TagsTable->verticalHeader()->setVisible(false);
this->TagsTable->horizontalHeader()->setStretchLastSection(true);
this->TagsTable->setSelectionMode(QAbstractItemView::NoSelection);
......
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