Skip to content

Commit

Permalink
Have ModelInspectorWidget make better use of space
Browse files Browse the repository at this point in the history
By turning a few labels into lineEdits we can not only make more
more efficient use of space, but we also allow people to copy
information more easily.

Allows GammaRay to be used on low resolution screen with high DPI.

Helps solve #358
  • Loading branch information
Javier O. Cordero Pérez committed Jan 11, 2025
1 parent 161a967 commit 00dffae
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 27 deletions.
9 changes: 5 additions & 4 deletions plugins/modelinspector/modelinspectorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ static const MetaEnum::Value<Qt::ItemFlag> item_flag_table[] = {
void ModelInspectorWidget::cellDataChanged()
{
const auto cellData = m_interface->currentCellData();
ui->indexLabel->setText(cellData.row != -1
ui->indexLineEdit->setText(cellData.row != -1
? tr("Row: %1 Column: %2").arg(cellData.row).arg(cellData.column)
: tr("Invalid"));
ui->internalIdLabel->setText(cellData.internalId);
ui->internalPtrLabel->setText(cellData.internalPtr);
ui->flagsLabel->setText(MetaEnum::flagsToString(cellData.flags, item_flag_table));
ui->internalIdLineEdit->setText(cellData.internalId);
ui->internalPtrLineEdit->setText(cellData.internalPtr);
ui->flagsPlainTextEdit->selectAll();
ui->flagsPlainTextEdit->insertPlainText(MetaEnum::flagsToString(cellData.flags, item_flag_table));
}

void ModelInspectorWidget::objectRegistered(const QString &objectName)
Expand Down
128 changes: 105 additions & 23 deletions plugins/modelinspector/modelinspectorwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<item>
<widget class="QSplitter" name="mainSplitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<widget class="QSplitter" name="modelSplitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget_3">
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand All @@ -28,7 +28,7 @@
<string>Models</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
Expand All @@ -38,7 +38,7 @@
<item>
<widget class="GammaRay::DeferredTreeView" name="modelView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
<enum>Qt::ContextMenuPolicy::CustomContextMenu</enum>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
Expand All @@ -47,22 +47,22 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Selection Models</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="GammaRay::DeferredTreeView" name="selectionModelsView">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
<enum>Qt::ContextMenuPolicy::CustomContextMenu</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
Expand All @@ -75,92 +75,174 @@
</layout>
</widget>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Model Content</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="GammaRay::DeferredTreeView" name="modelContentView">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
<enum>QAbstractItemView::SelectionBehavior::SelectItems</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cell Content</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Model Index:</string>
<string>Model index:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="indexLabel">
<widget class="QLineEdit" name="indexLineEdit">
<property name="minimumSize">
<size>
<width>72</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Invalid</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Internal Id:</string>
<string>Internal id:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="internalIdLabel">
<property name="text">
<string/>
<widget class="QLineEdit" name="internalIdLineEdit">
<property name="minimumSize">
<size>
<width>72</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Internal Pointer:</string>
<string>Internal pointer:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="internalPtrLabel">
<property name="text">
<string/>
<widget class="QLineEdit" name="internalPtrLineEdit">
<property name="minimumSize">
<size>
<width>72</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="minimumSize">
<size>
<width>55</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Flags:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="flagsLabel"/>
<widget class="QPlainTextEdit" name="flagsPlainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>72</width>
<height>0</height>
</size>
</property>
<property name="acceptDrops">
<bool>false</bool>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::SizeAdjustPolicy::AdjustToContents</enum>
</property>
<property name="undoRedoEnabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="plainText">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
Expand Down

0 comments on commit 00dffae

Please sign in to comment.