From 829345257c13c1991eab1a9bd008a674c2987a8f Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Sat, 24 Sep 2016 10:36:00 -0400 Subject: [PATCH 1/3] Allow disabled nested tables to be scrollable --- apps/opencs/view/world/dialoguesubview.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 0a79aac2b..b6e8f3766 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -583,8 +583,13 @@ void CSVWorld::EditWidget::remake(int row) table->resizeColumnsToContents(); if (!editable) { + // Make table look disabled without actually disabling. + // This allows user to scroll through table without + // being able to edit items. table->setEditTriggers(QAbstractItemView::NoEditTriggers); - table->setEnabled(false); + table->setSelectionMode(QAbstractItemView::NoSelection); + table->setFocusPolicy(Qt::NoFocus); + table->setStyleSheet("background-color: whitesmoke"); } int rows = mTable->rowCount(mTable->index(row, i)); From b59694c4f0b53e768c95e08778182fd0047cbe2b Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Sun, 25 Sep 2016 06:31:28 -0400 Subject: [PATCH 2/3] Set tooltip for read-only nested tables --- apps/opencs/view/world/dialoguesubview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index b6e8f3766..93be48dc9 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -583,13 +583,13 @@ void CSVWorld::EditWidget::remake(int row) table->resizeColumnsToContents(); if (!editable) { - // Make table look disabled without actually disabling. - // This allows user to scroll through table without - // being able to edit items. + // Disallow table editing, selection, and focus. + // This allows user to scroll through table but not edit items. + // Disabling table doesn't allow user to scroll. table->setEditTriggers(QAbstractItemView::NoEditTriggers); table->setSelectionMode(QAbstractItemView::NoSelection); table->setFocusPolicy(Qt::NoFocus); - table->setStyleSheet("background-color: whitesmoke"); + table->setToolTip("Currently read-only"); } int rows = mTable->rowCount(mTable->index(row, i)); From 8f47ed17dfcb046e3f7de861364f396ef85d69e8 Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Thu, 29 Sep 2016 20:42:44 -0400 Subject: [PATCH 3/3] Show nested tables only when they are editable --- apps/opencs/view/world/dialoguesubview.cpp | 53 +++++++++------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index 93be48dc9..03d83f7da 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -578,40 +578,31 @@ void CSVWorld::EditWidget::remake(int row) fixedRows = true; } - NestedTable* table = - new NestedTable(mDocument, id, mNestedModels.back(), this, editable, fixedRows); - table->resizeColumnsToContents(); - if (!editable) + // Create and display nested table only if it's editable. + if (editable) { - // Disallow table editing, selection, and focus. - // This allows user to scroll through table but not edit items. - // Disabling table doesn't allow user to scroll. - table->setEditTriggers(QAbstractItemView::NoEditTriggers); - table->setSelectionMode(QAbstractItemView::NoSelection); - table->setFocusPolicy(Qt::NoFocus); - table->setToolTip("Currently read-only"); - } - - int rows = mTable->rowCount(mTable->index(row, i)); - int rowHeight = (rows == 0) ? table->horizontalHeader()->height() : table->rowHeight(0); - int tableMaxHeight = (5 * rowHeight) - + table->horizontalHeader()->height() + 2 * table->frameWidth(); - table->setMinimumHeight(tableMaxHeight); - - QLabel* label = - new QLabel (mTable->headerData (i, Qt::Horizontal, Qt::DisplayRole).toString(), mMainWidget); - - label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); - if(!editable) - label->setEnabled(false); + NestedTable* table = + new NestedTable(mDocument, id, mNestedModels.back(), this, editable, fixedRows); + table->resizeColumnsToContents(); + + int rows = mTable->rowCount(mTable->index(row, i)); + int rowHeight = (rows == 0) ? table->horizontalHeader()->height() : table->rowHeight(0); + int headerHeight = table->horizontalHeader()->height(); + int tableMaxHeight = (5 * rowHeight) + headerHeight + (2 * table->frameWidth()); + table->setMinimumHeight(tableMaxHeight); + + QString headerText = mTable->headerData (i, Qt::Horizontal, Qt::DisplayRole).toString(); + QLabel* label = new QLabel (headerText, mMainWidget); + label->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); - tablesLayout->addWidget(label); - tablesLayout->addWidget(table); + tablesLayout->addWidget(label); + tablesLayout->addWidget(table); - connect(table, - SIGNAL(editRequest(const CSMWorld::UniversalId &, const std::string &)), - this, - SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &))); + connect(table, + SIGNAL(editRequest(const CSMWorld::UniversalId &, const std::string &)), + this, + SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &))); + } } else if (!(flags & CSMWorld::ColumnBase::Flag_Dialogue_List)) {