mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Merge branch 'bettertopicinfo' into 'master'
[OpenMW-CS] Improve TopicInfo editing See merge request OpenMW/openmw!2616
This commit is contained in:
commit
9c5b25cde4
@ -328,6 +328,7 @@ CSMWorld::Data::Data(ToUTF8::FromType encoding, bool fsStrict, const Files::Path
|
||||
mTopicInfos.addColumn(new RecordStateColumn<Info>);
|
||||
mTopicInfos.addColumn(new FixedRecordTypeColumn<Info>(UniversalId::Type_TopicInfo));
|
||||
mTopicInfos.addColumn(new TopicColumn<Info>(false));
|
||||
mTopicInfos.addColumn(new ResponseColumn<Info>);
|
||||
mTopicInfos.addColumn(new ActorColumn<Info>);
|
||||
mTopicInfos.addColumn(new RaceColumn<Info>);
|
||||
mTopicInfos.addColumn(new ClassColumn<Info>);
|
||||
@ -339,7 +340,6 @@ CSMWorld::Data::Data(ToUTF8::FromType encoding, bool fsStrict, const Files::Path
|
||||
mTopicInfos.addColumn(new PcFactionColumn<Info>);
|
||||
mTopicInfos.addColumn(new PcRankColumn<Info>);
|
||||
mTopicInfos.addColumn(new SoundFileColumn<Info>);
|
||||
mTopicInfos.addColumn(new ResponseColumn<Info>);
|
||||
// Result script
|
||||
mTopicInfos.addColumn(new NestedParentColumn<Info>(
|
||||
Columns::ColumnId_InfoList, ColumnBase::Flag_Dialogue | ColumnBase::Flag_Dialogue_List));
|
||||
|
@ -18,6 +18,13 @@ bool CSVWorld::DragDropUtils::canAcceptData(const QDropEvent& event, CSMWorld::C
|
||||
return data != nullptr && data->holdsType(type);
|
||||
}
|
||||
|
||||
bool CSVWorld::DragDropUtils::isTopicOrJournal(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
|
||||
{
|
||||
const CSMWorld::TableMimeData* data = getTableMimeData(event);
|
||||
return data != nullptr
|
||||
&& (data->holdsType(CSMWorld::UniversalId::Type_Topic) || data->holdsType(CSMWorld::UniversalId::Type_Journal));
|
||||
}
|
||||
|
||||
bool CSVWorld::DragDropUtils::isInfo(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
|
||||
{
|
||||
const CSMWorld::TableMimeData* data = getTableMimeData(event);
|
||||
|
@ -20,6 +20,8 @@ namespace CSVWorld
|
||||
bool canAcceptData(const QDropEvent& event, CSMWorld::ColumnBase::Display type);
|
||||
///< Checks whether the \a event contains a valid CSMWorld::TableMimeData that holds the \a type
|
||||
|
||||
bool isTopicOrJournal(const QDropEvent& event, CSMWorld::ColumnBase::Display type);
|
||||
|
||||
bool isInfo(const QDropEvent& event, CSMWorld::ColumnBase::Display type);
|
||||
///< Info types can be dragged to sort the info table
|
||||
|
||||
|
@ -53,7 +53,8 @@ void CSVWorld::DragRecordTable::dragMoveEvent(QDragMoveEvent* event)
|
||||
{
|
||||
QModelIndex index = indexAt(event->pos());
|
||||
if (CSVWorld::DragDropUtils::canAcceptData(*event, getIndexDisplayType(index))
|
||||
|| CSVWorld::DragDropUtils::isInfo(*event, getIndexDisplayType(index)))
|
||||
|| CSVWorld::DragDropUtils::isInfo(*event, getIndexDisplayType(index))
|
||||
|| CSVWorld::DragDropUtils::isTopicOrJournal(*event, getIndexDisplayType(index)))
|
||||
{
|
||||
if (index.flags() & Qt::ItemIsEditable)
|
||||
{
|
||||
@ -86,6 +87,14 @@ void CSVWorld::DragRecordTable::dropEvent(QDropEvent* event)
|
||||
{
|
||||
emit moveRecordsFromSameTable(event);
|
||||
}
|
||||
if (CSVWorld::DragDropUtils::isTopicOrJournal(*event, display))
|
||||
{
|
||||
const CSMWorld::TableMimeData* tableMimeData = CSVWorld::DragDropUtils::getTableMimeData(*event);
|
||||
for (auto universalId : tableMimeData->getData())
|
||||
{
|
||||
emit createNewInfoRecord(universalId.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CSMWorld::ColumnBase::Display CSVWorld::DragRecordTable::getIndexDisplayType(const QModelIndex& index) const
|
||||
|
@ -57,6 +57,7 @@ namespace CSVWorld
|
||||
|
||||
signals:
|
||||
void moveRecordsFromSameTable(QDropEvent* event);
|
||||
void createNewInfoRecord(const std::string& id);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,12 @@ void CSVWorld::InfoCreator::reset()
|
||||
GenericCreator::reset();
|
||||
}
|
||||
|
||||
void CSVWorld::InfoCreator::setText(const std::string& text)
|
||||
{
|
||||
QString qText = QString::fromStdString(text);
|
||||
mTopic->setText(qText);
|
||||
}
|
||||
|
||||
std::string CSVWorld::InfoCreator::getErrors() const
|
||||
{
|
||||
// We ignore errors from GenericCreator here, because they can never happen in an InfoCreator.
|
||||
@ -138,6 +144,11 @@ void CSVWorld::InfoCreator::focus()
|
||||
mTopic->setFocus();
|
||||
}
|
||||
|
||||
void CSVWorld::InfoCreator::callReturnPressed()
|
||||
{
|
||||
emit inputReturnPressed();
|
||||
}
|
||||
|
||||
void CSVWorld::InfoCreator::topicChanged()
|
||||
{
|
||||
update();
|
||||
|
@ -47,6 +47,8 @@ namespace CSVWorld
|
||||
|
||||
void reset() override;
|
||||
|
||||
void setText(const std::string& text);
|
||||
|
||||
std::string getErrors() const override;
|
||||
///< Return formatted error descriptions for the current state of the creator. if an empty
|
||||
/// string is returned, there is no error.
|
||||
@ -54,6 +56,10 @@ namespace CSVWorld
|
||||
/// Focus main input widget
|
||||
void focus() override;
|
||||
|
||||
public slots:
|
||||
|
||||
void callReturnPressed();
|
||||
|
||||
private slots:
|
||||
|
||||
void topicChanged();
|
||||
|
@ -269,6 +269,8 @@ CSVWorld::Table::Table(const CSMWorld::UniversalId& id, bool createAndDelete, bo
|
||||
{
|
||||
mProxyModel = new CSMWorld::InfoTableProxyModel(id.getType(), this);
|
||||
connect(this, &CSVWorld::DragRecordTable::moveRecordsFromSameTable, this, &CSVWorld::Table::moveRecords);
|
||||
connect(this, &CSVWorld::DragRecordTable::createNewInfoRecord, this,
|
||||
&CSVWorld::Table::createRecordsDirectlyRequest);
|
||||
}
|
||||
else if (isLtexTable)
|
||||
{
|
||||
|
@ -121,6 +121,8 @@ namespace CSVWorld
|
||||
|
||||
void createRequest();
|
||||
|
||||
void createRecordsDirectlyRequest(const std::string& id);
|
||||
|
||||
void cloneRequest(const CSMWorld::UniversalId&);
|
||||
|
||||
void touchRequest(const std::vector<CSMWorld::UniversalId>& ids);
|
||||
|
@ -8,9 +8,12 @@
|
||||
#include <QStackedLayout>
|
||||
#include <QStatusBar>
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include <apps/opencs/view/world/extendedcommandconfigurator.hpp>
|
||||
|
||||
#include "creator.hpp"
|
||||
#include "infocreator.hpp"
|
||||
|
||||
void CSVWorld::TableBottomBox::updateSize()
|
||||
{
|
||||
@ -255,6 +258,20 @@ void CSVWorld::TableBottomBox::createRequest()
|
||||
mCreator->focus();
|
||||
}
|
||||
|
||||
void CSVWorld::TableBottomBox::createRecordsDirectlyRequest(const std::string& id)
|
||||
{
|
||||
if (InfoCreator* creator = dynamic_cast<InfoCreator*>(mCreator))
|
||||
{
|
||||
creator->reset();
|
||||
creator->setText(id);
|
||||
creator->callReturnPressed();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(Debug::Warning) << "Creating a record directly failed.";
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::TableBottomBox::cloneRequest(const std::string& id, const CSMWorld::UniversalId::Type type)
|
||||
{
|
||||
mCreator->reset();
|
||||
|
@ -107,6 +107,7 @@ namespace CSVWorld
|
||||
void noMorePosition();
|
||||
|
||||
void createRequest();
|
||||
void createRecordsDirectlyRequest(const std::string& id);
|
||||
void cloneRequest(const std::string& id, const CSMWorld::UniversalId::Type type);
|
||||
void touchRequest(const std::vector<CSMWorld::UniversalId>&);
|
||||
|
||||
|
@ -104,6 +104,8 @@ CSVWorld::TableSubView::TableSubView(
|
||||
connect(this, qOverload<const std::string&, const CSMWorld::UniversalId::Type>(&TableSubView::cloneRequest),
|
||||
mBottom, &TableBottomBox::cloneRequest);
|
||||
|
||||
connect(mTable, &Table::createRecordsDirectlyRequest, mBottom, &TableBottomBox::createRecordsDirectlyRequest);
|
||||
|
||||
connect(mTable, &Table::touchRequest, mBottom, &TableBottomBox::touchRequest);
|
||||
|
||||
connect(mTable, &Table::extendedDeleteConfigRequest, mBottom, &TableBottomBox::extendedDeleteConfigRequest);
|
||||
|
Loading…
x
Reference in New Issue
Block a user