forked from teamnwah/openmw-tes3coop
automatically scroll table to the position of a newly created record
This commit is contained in:
parent
82958e6514
commit
661b290c49
7 changed files with 30 additions and 1 deletions
|
@ -29,6 +29,10 @@ namespace CSVWorld
|
|||
signals:
|
||||
|
||||
void done();
|
||||
|
||||
void requestFocus (const std::string& id);
|
||||
///< Request owner of this creator to focus the just created \a id. The owner may
|
||||
/// ignore this request.
|
||||
};
|
||||
|
||||
/// \brief Base class for Creator factory
|
||||
|
|
|
@ -101,9 +101,12 @@ void CSVWorld::GenericCreator::create()
|
|||
{
|
||||
if (!mLocked)
|
||||
{
|
||||
std::string id = getId();
|
||||
|
||||
mUndoStack.push (new CSMWorld::CreateCommand (
|
||||
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), getId()));
|
||||
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id));
|
||||
|
||||
emit done();
|
||||
emit requestFocus (id);
|
||||
}
|
||||
}
|
|
@ -282,4 +282,12 @@ void CSVWorld::Table::tableSizeUpdate()
|
|||
void CSVWorld::Table::selectionSizeUpdate()
|
||||
{
|
||||
selectionSizeChanged (selectionModel()->selectedRows().size());
|
||||
}
|
||||
|
||||
void CSVWorld::Table::requestFocus (const std::string& id)
|
||||
{
|
||||
QModelIndex index = mProxyModel->getModelIndex (id, 0);
|
||||
|
||||
if (index.isValid())
|
||||
scrollTo (index, QAbstractItemView::PositionAtTop);
|
||||
}
|
|
@ -83,6 +83,8 @@ namespace CSVWorld
|
|||
|
||||
void selectionSizeUpdate();
|
||||
|
||||
void requestFocus (const std::string& id);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,9 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
|
|||
mLayout->addWidget (mCreator);
|
||||
|
||||
connect (mCreator, SIGNAL (done()), this, SLOT (createRequestDone()));
|
||||
|
||||
connect (mCreator, SIGNAL (requestFocus (const std::string&)),
|
||||
this, SIGNAL (requestFocus (const std::string&)));
|
||||
}
|
||||
|
||||
void CSVWorld::TableBottomBox::setEditLock (bool locked)
|
||||
|
|
|
@ -55,6 +55,12 @@ namespace CSVWorld
|
|||
///
|
||||
/// \note The BotomBox does not partake in the deletion of records.
|
||||
|
||||
signals:
|
||||
|
||||
void requestFocus (const std::string& id);
|
||||
///< Request owner of this box to focus the just created \a id. The owner may
|
||||
/// ignore this request.
|
||||
|
||||
private slots:
|
||||
|
||||
void createRequestDone();
|
||||
|
|
|
@ -41,6 +41,9 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
|||
|
||||
if (mBottom->canCreateAndDelete())
|
||||
connect (mTable, SIGNAL (createRequest()), mBottom, SLOT (createRequest()));
|
||||
|
||||
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
||||
mTable, SLOT (requestFocus (const std::string&)));
|
||||
}
|
||||
|
||||
void CSVWorld::TableSubView::setEditLock (bool locked)
|
||||
|
|
Loading…
Reference in a new issue