mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Show nested tables only when they are editable
This commit is contained in:
parent
b59694c4f0
commit
8f47ed17df
1 changed files with 23 additions and 32 deletions
|
@ -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");
|
||||
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);
|
||||
|
||||
connect(table,
|
||||
SIGNAL(editRequest(const CSMWorld::UniversalId &, const std::string &)),
|
||||
this,
|
||||
SIGNAL(editIdRequest(const CSMWorld::UniversalId &, const std::string &)));
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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 &)));
|
||||
}
|
||||
else if (!(flags & CSMWorld::ColumnBase::Flag_Dialogue_List))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue