forked from mirror/openmw-tes3mp
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:
|
signals:
|
||||||
|
|
||||||
void done();
|
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
|
/// \brief Base class for Creator factory
|
||||||
|
|
|
@ -101,9 +101,12 @@ void CSVWorld::GenericCreator::create()
|
||||||
{
|
{
|
||||||
if (!mLocked)
|
if (!mLocked)
|
||||||
{
|
{
|
||||||
|
std::string id = getId();
|
||||||
|
|
||||||
mUndoStack.push (new CSMWorld::CreateCommand (
|
mUndoStack.push (new CSMWorld::CreateCommand (
|
||||||
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), getId()));
|
dynamic_cast<CSMWorld::IdTable&> (*mData.getTableModel (mListId)), id));
|
||||||
|
|
||||||
emit done();
|
emit done();
|
||||||
|
emit requestFocus (id);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -283,3 +283,11 @@ void CSVWorld::Table::selectionSizeUpdate()
|
||||||
{
|
{
|
||||||
selectionSizeChanged (selectionModel()->selectedRows().size());
|
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 selectionSizeUpdate();
|
||||||
|
|
||||||
|
void requestFocus (const std::string& id);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,9 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
|
||||||
mLayout->addWidget (mCreator);
|
mLayout->addWidget (mCreator);
|
||||||
|
|
||||||
connect (mCreator, SIGNAL (done()), this, SLOT (createRequestDone()));
|
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)
|
void CSVWorld::TableBottomBox::setEditLock (bool locked)
|
||||||
|
|
|
@ -55,6 +55,12 @@ namespace CSVWorld
|
||||||
///
|
///
|
||||||
/// \note The BotomBox does not partake in the deletion of records.
|
/// \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:
|
private slots:
|
||||||
|
|
||||||
void createRequestDone();
|
void createRequestDone();
|
||||||
|
|
|
@ -41,6 +41,9 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
|
|
||||||
if (mBottom->canCreateAndDelete())
|
if (mBottom->canCreateAndDelete())
|
||||||
connect (mTable, SIGNAL (createRequest()), mBottom, SLOT (createRequest()));
|
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)
|
void CSVWorld::TableSubView::setEditLock (bool locked)
|
||||||
|
|
Loading…
Reference in a new issue