Page MenuHomePhabricator

datamanager_qmitk.patch

Authored By
zelzer
Sep 23 2009, 2:23 PM
Size
6 KB
Referenced Files
None
Subscribers
None

datamanager_qmitk.patch

Index: mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDataManagerView.cpp
===================================================================
--- mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDataManagerView.cpp (revision 19086)
+++ mitk/Modules/Bundles/org.mitk.gui.qt.datamanager/src/internal/QmitkDataManagerView.cpp (working copy)
@@ -526,4 +526,4 @@
{
if(obj == m_NodePropertiesTableEditor)
m_NodePropertiesTableEditor = 0;
-}
\ No newline at end of file
+}
Index: mitk/CoreUI/Qmitk/QmitkPropertiesTableModel.cpp
===================================================================
--- mitk/CoreUI/Qmitk/QmitkPropertiesTableModel.cpp (revision 19086)
+++ mitk/CoreUI/Qmitk/QmitkPropertiesTableModel.cpp (working copy)
@@ -64,11 +64,14 @@
// there are also read only property items -> do not allow editing them
if(index.data(Qt::EditRole).isValid())
flags |= Qt::ItemIsEditable;
+
+ if(index.data(Qt::CheckStateRole).isValid())
+ flags |= Qt::ItemIsUserCheckable;
}
if (index.column() == PROPERTY_ACTIVE_COLUMN)
{
- flags |= Qt::ItemIsEditable;
+ flags |= Qt::ItemIsUserCheckable;
}
return flags;
@@ -132,10 +135,8 @@
else if(mitk::BoolProperty* boolProp = dynamic_cast<mitk::BoolProperty*>(baseProp))
{
- if(role == Qt::DisplayRole)
- data.setValue<bool>( boolProp->GetValue() );
- else if(role == Qt::EditRole)
- data.setValue<bool>( boolProp->GetValue() );
+ if(role == Qt::CheckStateRole)
+ data = boolProp->GetValue() ? Qt::Checked : Qt::Unchecked;
}
else if (mitk::StringProperty* stringProp = dynamic_cast<mitk::StringProperty*>(baseProp))
@@ -190,11 +191,8 @@
// enabled/disabled value
else if(index.column() == PROPERTY_ACTIVE_COLUMN)
{
- if(role == Qt::DisplayRole)
- data.setValue<bool>(m_SelectedProperties[index.row()].second.second);
-
- else if(role == Qt::EditRole)
- data.setValue<bool>(m_SelectedProperties[index.row()].second.second);
+ if (role == Qt::CheckStateRole)
+ data = (m_SelectedProperties[index.row()].second.second) ? Qt::Checked : Qt::Unchecked;
}
return data;
@@ -276,7 +274,8 @@
bool QmitkPropertiesTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
- if (index.isValid() && !m_SelectedProperties.empty() && index.row() < (int)(m_SelectedProperties.size()) && role == Qt::EditRole)
+ if (index.isValid() && !m_SelectedProperties.empty() && index.row() < (int)(m_SelectedProperties.size())
+ && (role == Qt::EditRole || Qt::CheckStateRole))
{
// block all events now!
m_BlockEvents = true;
@@ -306,7 +305,7 @@
else if(mitk::BoolProperty* boolProp = dynamic_cast<mitk::BoolProperty*>(baseProp))
{
- boolProp->SetValue(value.value<bool>());
+ boolProp->SetValue(value.toInt() == Qt::Checked ? true : false);
m_PropertyList->InvokeEvent(itk::ModifiedEvent());
m_PropertyList->Modified();
@@ -368,7 +367,7 @@
// enabled/disabled value
else if(index.column() == PROPERTY_ACTIVE_COLUMN)
{
- bool active = value.value<bool>();
+ bool active = value.toInt() == Qt::Checked;
std::string propertyName = m_SelectedProperties[index.row()].first;
m_PropertyList->SetEnabled(propertyName, active);
Index: mitk/CoreUI/Qmitk/QmitkDataStorageTableModel.cpp
===================================================================
--- mitk/CoreUI/Qmitk/QmitkDataStorageTableModel.cpp (revision 19086)
+++ mitk/CoreUI/Qmitk/QmitkDataStorageTableModel.cpp (working copy)
@@ -88,10 +88,14 @@
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
// name & visibility is editable
- if (index.column() == 0 || index.column() == 2)
+ if (index.column() == 0)
{
flags |= Qt::ItemIsEditable;
}
+ else if (index.column() == 2)
+ {
+ flags |= Qt::ItemIsUserCheckable;
+ }
return flags;
}
@@ -182,14 +186,10 @@
// get visible property of mitk::BaseData
bool visibility = false;
- if(node->GetVisibility(visibility, 0))
+ if(node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole)
{
- if (role == Qt::DisplayRole || role == Qt::EditRole)
- {
- data = visibility;
- } // role == Qt::DisplayRole
-
- } // node->GetVisibility(visibility, 0)
+ data = (visibility ? Qt::Checked : Qt::Unchecked);
+ } // node->GetVisibility(visibility, 0) && role == Qt::CheckStateRole
} // index.column() == 2
@@ -377,7 +377,7 @@
{
bool noErr = false;
- if (index.isValid() && role == Qt::EditRole)
+ if (index.isValid() && (role == Qt::EditRole || role == Qt::CheckStateRole))
{
// any change events produced here should not be caught in this class
// --> set m_BlockEvents to true
@@ -391,7 +391,7 @@
}
else if(index.column() == 2)
{
- node->SetBoolProperty("visible", value.toBool());
+ node->SetBoolProperty("visible", (value.toInt() == Qt::Checked ? true : false));
mitk::RenderingManager::GetInstance()->RequestUpdateAll();
}
Index: mitk/CoreUI/Qmitk/QmitkPropertiesTableEditor.cpp
===================================================================
--- mitk/CoreUI/Qmitk/QmitkPropertiesTableEditor.cpp (revision 19086)
+++ mitk/CoreUI/Qmitk/QmitkPropertiesTableEditor.cpp (working copy)
@@ -117,6 +117,7 @@
m_NodePropertiesTableView->setSelectionMode( QAbstractItemView::SingleSelection );
m_NodePropertiesTableView->setSelectionBehavior( QAbstractItemView::SelectItems );
+ m_NodePropertiesTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked | QAbstractItemView::EditKeyPressed);
m_NodePropertiesTableView->verticalHeader()->hide();
m_NodePropertiesTableView->setItemDelegate(new QmitkPropertyDelegate(this));
m_NodePropertiesTableView->setAlternatingRowColors(true);
Index: mitk/CoreUI/Qmitk/QmitkPropertyDelegate.cpp
===================================================================
--- mitk/CoreUI/Qmitk/QmitkPropertyDelegate.cpp (revision 19086)
+++ mitk/CoreUI/Qmitk/QmitkPropertyDelegate.cpp (working copy)
@@ -1,3 +1,5 @@
+#define NOMINMAX
+
#include "QmitkPropertyDelegate.h"
#include "QmitkCustomVariants.h"
@@ -94,6 +96,8 @@
{
QSpinBox* spinBox = new QSpinBox(parent);
spinBox->setSingleStep(1);
+ spinBox->setMinimum(std::numeric_limits<int>::min());
+ spinBox->setMaximum(std::numeric_limits<int>::max());
return spinBox;
}
// see qt documentation. cast is correct, it would be obsolete if we

File Metadata

Mime Type
text/plain
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
309
Default Alt Text
datamanager_qmitk.patch (6 KB)

Event Timeline

patch for better(?) editing behaviour