diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 70d96aa031..20057d8aae 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -4,9 +4,9 @@ #include #include +#include #include #include -#include #include "columnbase.hpp" #include "universalid.hpp" @@ -36,7 +36,7 @@ namespace CSMWorld std::vector mUniversalId; QStringList mObjectsFormats; const CSMDoc::Document& mDocument; - const CSVWorld::DragRecordTable* mTableOfDragStart; + CSVWorld::DragRecordTable* mTableOfDragStart; QModelIndex mIndexAtDragStart; public: @@ -63,10 +63,14 @@ namespace CSMWorld const CSMDoc::Document* getDocumentPtr() const; UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const; - - void setIndexAtDragStart(QModelIndex index) {mIndexAtDragStart = index;} - - void setTableOfDragStart(const CSVWorld::DragRecordTable* table) {mTableOfDragStart = table;} + + void setIndexAtDragStart(QModelIndex index) { mIndexAtDragStart = index; } + + void setTableOfDragStart(CSVWorld::DragRecordTable* table) { mTableOfDragStart = table; } + + const QModelIndex getIndexAtDragStart() const { return mIndexAtDragStart; } + + const CSVWorld::DragRecordTable* getTableOfDragStart() const { return mTableOfDragStart; } static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index 040c3604de..d99544c5ce 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -9,8 +9,11 @@ #include "recordfilterbox.hpp" +#include + #include #include +#include CSVFilter::FilterBox::FilterBox(CSMWorld::Data& data, QWidget* parent) : QWidget(parent) @@ -42,8 +45,20 @@ void CSVFilter::FilterBox::dropEvent(QDropEvent* event) return; std::vector universalIdData = mime->getData(); + QModelIndex index = mime->getIndexAtDragStart(); + const CSVWorld::DragRecordTable* dragTable = mime->getTableOfDragStart(); - emit recordDropped(universalIdData, event->proposedAction()); + std::string searchString = ""; + if (index.isValid() && dragTable) + searchString = dragTable->model()->data(index).toString().toStdString(); + Log(Debug::Warning) << "Data: " << searchString; + + std::string searchColumn = ""; + if (index.isValid() && dragTable) + searchColumn = dragTable->model()->headerData(index.column(), Qt::Horizontal).toString().toStdString(); + Log(Debug::Warning) << "Header: " << searchColumn; + + emit recordDropped(universalIdData, event->proposedAction(), searchString, searchColumn); } void CSVFilter::FilterBox::dragEnterEvent(QDragEnterEvent* event) diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index d8baabd874..78692e908b 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -50,7 +50,8 @@ namespace CSVFilter signals: void recordFilterChanged(std::shared_ptr filter); - void recordDropped(std::vector& types, Qt::DropAction action); + void recordDropped(std::vector& types, Qt::DropAction action, + const std::string& searchString, const std::string& searchColumn); }; } diff --git a/apps/opencs/view/world/dragrecordtable.cpp b/apps/opencs/view/world/dragrecordtable.cpp index 1ffcd271dc..0d822de793 100644 --- a/apps/opencs/view/world/dragrecordtable.cpp +++ b/apps/opencs/view/world/dragrecordtable.cpp @@ -16,7 +16,7 @@ #include "dragdroputils.hpp" -void CSVWorld::DragRecordTable::startDragFromTable(const CSVWorld::DragRecordTable& table, QModelIndex index) +void CSVWorld::DragRecordTable::startDragFromTable(CSVWorld::DragRecordTable& table, QModelIndex index) { std::vector records = table.getDraggedRecords(); if (records.empty()) diff --git a/apps/opencs/view/world/dragrecordtable.hpp b/apps/opencs/view/world/dragrecordtable.hpp index 614ff5e408..9e124a1ef0 100644 --- a/apps/opencs/view/world/dragrecordtable.hpp +++ b/apps/opencs/view/world/dragrecordtable.hpp @@ -42,7 +42,7 @@ namespace CSVWorld void setEditLock(bool locked); protected: - void startDragFromTable(const DragRecordTable& table, QModelIndex index); + void startDragFromTable(DragRecordTable& table, QModelIndex index); void dragEnterEvent(QDragEnterEvent* event) override; diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index e6f2df938e..c656411967 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -150,7 +150,8 @@ void CSVWorld::TableSubView::cloneRequest(const CSMWorld::UniversalId& toClone) emit cloneRequest(toClone.getId(), toClone.getType()); } -void CSVWorld::TableSubView::createFilterRequest(std::vector& types, Qt::DropAction action) +void CSVWorld::TableSubView::createFilterRequest(std::vector& types, Qt::DropAction action, + const std::string& searchString, const std::string& searchColumn) { std::vector>> filterSource; @@ -173,7 +174,15 @@ void CSVWorld::TableSubView::createFilterRequest(std::vectorcreateFilterRequest(filterSource, action); + if (!filterSource.empty()) + mFilterBox->createFilterRequest(filterSource, action); + else if (searchString != "") + { + std::vector testVector; + testVector.emplace_back(searchColumn); + filterSource.emplace_back(searchString, testVector); + mFilterBox->createFilterRequest(filterSource, action); + } } bool CSVWorld::TableSubView::eventFilter(QObject* object, QEvent* event) diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index b24b3c4623..45e1c26154 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -61,7 +61,8 @@ namespace CSVWorld void editRequest(const CSMWorld::UniversalId& id, const std::string& hint); void cloneRequest(const CSMWorld::UniversalId& toClone); - void createFilterRequest(std::vector& types, Qt::DropAction action); + void createFilterRequest(std::vector& types, Qt::DropAction action, + const std::string& searchString, const std::string& searchColumn); void toggleOptions(); public slots: