mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 07:09:40 +00:00
Dragging Topics to TopicInfo window opens create TopicInfo BottomBox with the correct id
This commit is contained in:
parent
7f8a84f2f2
commit
0310b1cddf
11 changed files with 59 additions and 1 deletions
|
@ -18,6 +18,14 @@ 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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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,26 @@ 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);
|
||||
|
||||
/*Default system of createRequest - TODO: Modify so that user doesn't see the edit box*/
|
||||
mCreator->toggleWidgets(true);
|
||||
mLayout->setCurrentWidget(mCreator);
|
||||
setVisible(true);
|
||||
mEditMode = EditMode_Creation;
|
||||
mCreator->focus();
|
||||
}
|
||||
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…
Reference in a new issue