diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index e689c6a3f..e04333608 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -26,6 +26,7 @@ namespace CSMWorld enum Display { + Display_None, //Do not use Display_String, //CONCRETE TYPES STARTS HERE diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index ee37dfce6..b56c9c8c2 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -64,6 +64,7 @@ std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const return mUniversalId; } + bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const { for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) @@ -121,165 +122,325 @@ bool CSMWorld::TableMimeData::fromDocument (const CSMDoc::Document& document) co return &document == &mDocument; } -CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) const +CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) { switch (type) { case CSMWorld::ColumnBase::Display_Race: return CSMWorld::UniversalId::Type_Race; - break; + case CSMWorld::ColumnBase::Display_Skill: return CSMWorld::UniversalId::Type_Skill; - break; + case CSMWorld::ColumnBase::Display_Class: return CSMWorld::UniversalId::Type_Class; - break; + case CSMWorld::ColumnBase::Display_Faction: return CSMWorld::UniversalId::Type_Faction; - break; + case CSMWorld::ColumnBase::Display_Sound: return CSMWorld::UniversalId::Type_Sound; - break; + case CSMWorld::ColumnBase::Display_Region: return CSMWorld::UniversalId::Type_Region; - break; + case CSMWorld::ColumnBase::Display_Birthsign: return CSMWorld::UniversalId::Type_Birthsign; - break; + case CSMWorld::ColumnBase::Display_Spell: return CSMWorld::UniversalId::Type_Spell; - break; + case CSMWorld::ColumnBase::Display_Cell: return CSMWorld::UniversalId::Type_Cell; - break; + case CSMWorld::ColumnBase::Display_Referenceable: return CSMWorld::UniversalId::Type_Referenceable; - break; + case CSMWorld::ColumnBase::Display_Activator: return CSMWorld::UniversalId::Type_Activator; - break; + case CSMWorld::ColumnBase::Display_Potion: return CSMWorld::UniversalId::Type_Potion; - break; + case CSMWorld::ColumnBase::Display_Apparatus: return CSMWorld::UniversalId::Type_Apparatus; - break; + case CSMWorld::ColumnBase::Display_Armor: return CSMWorld::UniversalId::Type_Armor; - break; + case CSMWorld::ColumnBase::Display_Book: return CSMWorld::UniversalId::Type_Book; - break; + case CSMWorld::ColumnBase::Display_Clothing: return CSMWorld::UniversalId::Type_Clothing; - break; + case CSMWorld::ColumnBase::Display_Container: return CSMWorld::UniversalId::Type_Container; - break; + case CSMWorld::ColumnBase::Display_Creature: return CSMWorld::UniversalId::Type_Creature; - break; + case CSMWorld::ColumnBase::Display_Door: return CSMWorld::UniversalId::Type_Door; - break; + case CSMWorld::ColumnBase::Display_Ingredient: return CSMWorld::UniversalId::Type_Ingredient; - break; + case CSMWorld::ColumnBase::Display_CreatureLevelledList: return CSMWorld::UniversalId::Type_CreatureLevelledList; - break; + case CSMWorld::ColumnBase::Display_ItemLevelledList: return CSMWorld::UniversalId::Type_ItemLevelledList; - break; + case CSMWorld::ColumnBase::Display_Light: return CSMWorld::UniversalId::Type_Light; - break; + case CSMWorld::ColumnBase::Display_Lockpick: return CSMWorld::UniversalId::Type_Lockpick; - break; + case CSMWorld::ColumnBase::Display_Miscellaneous: return CSMWorld::UniversalId::Type_Miscellaneous; - break; + case CSMWorld::ColumnBase::Display_Npc: return CSMWorld::UniversalId::Type_Npc; - break; + case CSMWorld::ColumnBase::Display_Probe: return CSMWorld::UniversalId::Type_Probe; - break; + case CSMWorld::ColumnBase::Display_Repair: return CSMWorld::UniversalId::Type_Repair; - break; + case CSMWorld::ColumnBase::Display_Static: return CSMWorld::UniversalId::Type_Static; - break; + case CSMWorld::ColumnBase::Display_Weapon: return CSMWorld::UniversalId::Type_Weapon; - break; + case CSMWorld::ColumnBase::Display_Reference: return CSMWorld::UniversalId::Type_Reference; - break; + case CSMWorld::ColumnBase::Display_Filter: return CSMWorld::UniversalId::Type_Filter; - break; + case CSMWorld::ColumnBase::Display_Topic: return CSMWorld::UniversalId::Type_Topic; - break; + case CSMWorld::ColumnBase::Display_Journal: return CSMWorld::UniversalId::Type_Journal; - break; + case CSMWorld::ColumnBase::Display_TopicInfo: return CSMWorld::UniversalId::Type_TopicInfo; - break; + case CSMWorld::ColumnBase::Display_JournalInfo: return CSMWorld::UniversalId::Type_JournalInfo; - break; + case CSMWorld::ColumnBase::Display_Scene: return CSMWorld::UniversalId::Type_Scene; - break; + case CSMWorld::ColumnBase::Display_Script: return CSMWorld::UniversalId::Type_Script; - break; + default: return CSMWorld::UniversalId::Type_None; - break; + } } -// kate: indent-mode cstyle; indent-width 4; replace-tabs on; + +CSMWorld::ColumnBase::Display CSMWorld::TableMimeData::convertEnums (CSMWorld::UniversalId::Type type) +{ + switch (type) + { + case CSMWorld::UniversalId::Type_Race: + return CSMWorld::ColumnBase::Display_Race; + + + case CSMWorld::UniversalId::Type_Skill: + return CSMWorld::ColumnBase::Display_Skill; + + + case CSMWorld::UniversalId::Type_Class: + return CSMWorld::ColumnBase::Display_Class; + + + case CSMWorld::UniversalId::Type_Faction: + return CSMWorld::ColumnBase::Display_Faction; + + + case CSMWorld::UniversalId::Type_Sound: + return CSMWorld::ColumnBase::Display_Sound; + + + case CSMWorld::UniversalId::Type_Region: + return CSMWorld::ColumnBase::Display_Region; + + + case CSMWorld::UniversalId::Type_Birthsign: + return CSMWorld::ColumnBase::Display_Birthsign; + + + case CSMWorld::UniversalId::Type_Spell: + return CSMWorld::ColumnBase::Display_Spell; + + + case CSMWorld::UniversalId::Type_Cell: + return CSMWorld::ColumnBase::Display_Cell; + + + case CSMWorld::UniversalId::Type_Referenceable: + return CSMWorld::ColumnBase::Display_Referenceable; + + + case CSMWorld::UniversalId::Type_Activator: + return CSMWorld::ColumnBase::Display_Activator; + + + case CSMWorld::UniversalId::Type_Potion: + return CSMWorld::ColumnBase::Display_Potion; + + + case CSMWorld::UniversalId::Type_Apparatus: + return CSMWorld::ColumnBase::Display_Apparatus; + + + case CSMWorld::UniversalId::Type_Armor: + return CSMWorld::ColumnBase::Display_Armor; + + + case CSMWorld::UniversalId::Type_Book: + return CSMWorld::ColumnBase::Display_Book; + + + case CSMWorld::UniversalId::Type_Clothing: + return CSMWorld::ColumnBase::Display_Clothing; + + + case CSMWorld::UniversalId::Type_Container: + return CSMWorld::ColumnBase::Display_Container; + + + case CSMWorld::UniversalId::Type_Creature: + return CSMWorld::ColumnBase::Display_Creature; + + + case CSMWorld::UniversalId::Type_Door: + return CSMWorld::ColumnBase::Display_Door; + + + case CSMWorld::UniversalId::Type_Ingredient: + return CSMWorld::ColumnBase::Display_Ingredient; + + + case CSMWorld::UniversalId::Type_CreatureLevelledList: + return CSMWorld::ColumnBase::Display_CreatureLevelledList; + + + case CSMWorld::UniversalId::Type_ItemLevelledList: + return CSMWorld::ColumnBase::Display_ItemLevelledList; + + + case CSMWorld::UniversalId::Type_Light: + return CSMWorld::ColumnBase::Display_Light; + + + case CSMWorld::UniversalId::Type_Lockpick: + return CSMWorld::ColumnBase::Display_Lockpick; + + + case CSMWorld::UniversalId::Type_Miscellaneous: + return CSMWorld::ColumnBase::Display_Miscellaneous; + + + case CSMWorld::UniversalId::Type_Npc: + return CSMWorld::ColumnBase::Display_Npc; + + + case CSMWorld::UniversalId::Type_Probe: + return CSMWorld::ColumnBase::Display_Probe; + + + case CSMWorld::UniversalId::Type_Repair: + return CSMWorld::ColumnBase::Display_Repair; + + + case CSMWorld::UniversalId::Type_Static: + return CSMWorld::ColumnBase::Display_Static; + + + case CSMWorld::UniversalId::Type_Weapon: + return CSMWorld::ColumnBase::Display_Weapon; + + + case CSMWorld::UniversalId::Type_Reference: + return CSMWorld::ColumnBase::Display_Reference; + + + case CSMWorld::UniversalId::Type_Filter: + return CSMWorld::ColumnBase::Display_Filter; + + + case CSMWorld::UniversalId::Type_Topic: + return CSMWorld::ColumnBase::Display_Topic; + + + case CSMWorld::UniversalId::Type_Journal: + return CSMWorld::ColumnBase::Display_Journal; + + + case CSMWorld::UniversalId::Type_TopicInfo: + return CSMWorld::ColumnBase::Display_TopicInfo; + + + case CSMWorld::UniversalId::Type_JournalInfo: + return CSMWorld::ColumnBase::Display_JournalInfo; + + + case CSMWorld::UniversalId::Type_Scene: + return CSMWorld::ColumnBase::Display_Scene; + + + case CSMWorld::UniversalId::Type_Script: + return CSMWorld::ColumnBase::Display_Script; + + + default: + return CSMWorld::ColumnBase::Display_None; + } +} \ No newline at end of file diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 010a18acb..7687f3555 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -50,12 +50,14 @@ namespace CSMWorld UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const; + static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); + static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type); + private: std::vector mUniversalId; QStringList mObjectsFormats; const CSMDoc::Document& mDocument; - CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const; }; } #endif // TABLEMIMEDATA_H \ No newline at end of file diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 708d45032..cc1578bdd 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -2,6 +2,8 @@ #include "editwidget.hpp" #include +#include +#include #include "../../model/world/data.hpp" @@ -56,3 +58,146 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s { textChanged (text()); } + +void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource, + Qt::DropAction action) +{ + const unsigned count = filterSource.size(); + bool multipleElements = false; + + switch (count) //setting multipleElements; + { + case 0: //empty + return; //nothing to do here + + case 1: //only single + multipleElements = false; + break; + + default: + multipleElements = true; + break; + } + + Qt::KeyboardModifiers key = QApplication::keyboardModifiers(); + QString oldContent (text()); + + bool replaceMode = false; + std::string orAnd; + + switch (key) //setting replaceMode and string used to glue expressions + { + case Qt::ShiftModifier: + orAnd = "!or("; + replaceMode = false; + break; + + case Qt::ControlModifier: + orAnd = "!and("; + replaceMode = false; + break; + + default: + replaceMode = true; + break; + } + + if (oldContent.isEmpty() || !oldContent.contains (QRegExp ("^!.*$", Qt::CaseInsensitive))) //if line edit is empty or it does not contain one shot filter go into replace mode + { + replaceMode = true; + } + + if (!replaceMode) + { + oldContent.remove ('!'); + } + + std::stringstream ss; + + if (multipleElements) + { + if (replaceMode) + { + ss<<"!or("; + } else { + ss << orAnd << oldContent.toStdString() << ','; + } + + for (unsigned i = 0; i < count; ++i) + { + ss<4) + { + clear(); + insert (QString::fromUtf8(ss.str().c_str())); + } +} + +std::string CSVFilter::EditWidget::generateFilter (std::pair< std::string, std::vector< std::string > >& seekedString) const +{ + const unsigned columns = seekedString.second.size(); + + bool multipleColumns = false; + switch (columns) + { + case 0: //empty + return ""; //no column to filter + + case 1: //one column to look for + multipleColumns = false; + break; + + default: + multipleColumns = true; + break; + } + + std::stringstream ss; + if (multipleColumns) + { + ss<<"or("; + for (unsigned i = 0; i < columns; ++i) + { + ss<<"string("<<'"'< #include +#include #include "../../model/filter/parser.hpp" #include "../../model/filter/node.hpp" @@ -33,6 +34,9 @@ namespace CSVFilter void filterChanged (boost::shared_ptr filter); + private: + std::string generateFilter(std::pair >& seekedString) const; + private slots: void textChanged (const QString& text); @@ -42,6 +46,11 @@ namespace CSVFilter void filterRowsRemoved (const QModelIndex& parent, int start, int end); void filterRowsInserted (const QModelIndex& parent, int start, int end); + + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); + + void useFilterRequest(const std::string& idOfFilter); }; } diff --git a/apps/opencs/view/filter/filterbox.cpp b/apps/opencs/view/filter/filterbox.cpp index 273170884..a33288025 100644 --- a/apps/opencs/view/filter/filterbox.cpp +++ b/apps/opencs/view/filter/filterbox.cpp @@ -2,9 +2,12 @@ #include "filterbox.hpp" #include +#include #include "recordfilterbox.hpp" +#include + CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) : QWidget (parent) { @@ -21,4 +24,27 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent) connect (recordFilterBox, SIGNAL (filterChanged (boost::shared_ptr)), this, SIGNAL (recordFilterChanged (boost::shared_ptr))); -} \ No newline at end of file + + connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), + recordFilterBox, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction))); + + connect(this, SIGNAL(useFilterRequest(const std::string&)), recordFilterBox, SIGNAL(useFilterRequest(const std::string&))); + setAcceptDrops(true); +} + +void CSVFilter::FilterBox::dropEvent (QDropEvent* event) +{ + std::vector data = dynamic_cast (event->mimeData())->getData(); + + emit recordDropped(data, event->proposedAction()); +} + +void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event) +{ + event->acceptProposedAction(); +} + +void CSVFilter::FilterBox::dragMoveEvent (QDragMoveEvent* event) +{ + event->accept(); +} diff --git a/apps/opencs/view/filter/filterbox.hpp b/apps/opencs/view/filter/filterbox.hpp index 2524fa0a3..3817d5e70 100644 --- a/apps/opencs/view/filter/filterbox.hpp +++ b/apps/opencs/view/filter/filterbox.hpp @@ -1,9 +1,13 @@ #ifndef CSV_FILTER_FILTERBOX_H #define CSV_FILTER_FILTERBOX_H +#include + #include +#include #include "../../model/filter/node.hpp" +#include "../../model/world/universalid.hpp" namespace CSMWorld { @@ -16,6 +20,12 @@ namespace CSVFilter { Q_OBJECT + void dragEnterEvent (QDragEnterEvent* event); + + void dropEvent (QDropEvent* event); + + void dragMoveEvent(QDragMoveEvent *event); + public: FilterBox (CSMWorld::Data& data, QWidget *parent = 0); @@ -23,8 +33,13 @@ namespace CSVFilter signals: void recordFilterChanged (boost::shared_ptr filter); + void recordDropped (std::vector& types, Qt::DropAction action); + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); + void useFilterRequest(const std::string& idOfFilter); }; } #endif + diff --git a/apps/opencs/view/filter/recordfilterbox.cpp b/apps/opencs/view/filter/recordfilterbox.cpp index c405177b0..2a1a1407f 100644 --- a/apps/opencs/view/filter/recordfilterbox.cpp +++ b/apps/opencs/view/filter/recordfilterbox.cpp @@ -24,4 +24,9 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare connect ( editWidget, SIGNAL (filterChanged (boost::shared_ptr)), this, SIGNAL (filterChanged (boost::shared_ptr))); + + connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), + editWidget, SLOT(createFilterRequest(std::vector > >&, Qt::DropAction))); + + connect(this, SIGNAL(useFilterRequest(const std::string&)), editWidget, SLOT(useFilterRequest(const std::string&))); } diff --git a/apps/opencs/view/filter/recordfilterbox.hpp b/apps/opencs/view/filter/recordfilterbox.hpp index 057d69518..3638dc6c3 100644 --- a/apps/opencs/view/filter/recordfilterbox.hpp +++ b/apps/opencs/view/filter/recordfilterbox.hpp @@ -4,6 +4,7 @@ #include #include +#include #include @@ -27,6 +28,9 @@ namespace CSVFilter signals: void filterChanged (boost::shared_ptr filter); + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); + void useFilterRequest(const std::string& idOfFilter); }; } diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index f1d89e22c..edf3bc6de 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -471,7 +472,20 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); - drag->exec(); + + Qt::DropActions action = Qt::IgnoreAction; + switch (QApplication::keyboardModifiers()) + { + case Qt::ControlModifier: + action = Qt::CopyAction; + break; + + case Qt::ShiftModifier: + action = Qt::MoveAction; + break; + } + + drag->exec(action); } } @@ -485,6 +499,11 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) { QModelIndex index = indexAt (event->pos()); + if (!index.isValid()) + { + return; + } + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); if (mime->fromDocument (mDocument)) { @@ -496,7 +515,7 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) CSMWorld::UniversalId record (mime->returnMatching (display)); std::auto_ptr command (new CSMWorld::ModifyCommand - (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + (*mProxyModel, index, QVariant (QString::fromUtf8 (record.getId().c_str())))); mUndoStack.push (command.release()); } @@ -507,3 +526,21 @@ void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) { event->accept(); } + +std::vector CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const +{ + const int count = mModel->columnCount(); + + std::vector titles; + for (int i = 0; i < count; ++i) + { + CSMWorld::ColumnBase::Display columndisplay = static_cast + (mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + + if (display == columndisplay) + { + titles.push_back(mModel->headerData (i, Qt::Horizontal).toString().toStdString()); + } + } + return titles; +} \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index ff08db06f..615a31b4d 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -8,6 +8,7 @@ #include #include "../../model/filter/node.hpp" +#include "../../model/world/columnbase.hpp" namespace CSMDoc { class Document; @@ -63,10 +64,9 @@ namespace CSVWorld void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); - void dragMoveEvent(QDragMoveEvent *event); + void dropEvent(QDropEvent *event); public: @@ -82,6 +82,8 @@ namespace CSVWorld void updateEditorSetting (const QString &settingName, const QString &settingValue); + std::vector getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const; + signals: void editRequest (int row); diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index d379db51a..e330d4775 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -2,8 +2,10 @@ #include "tablesubview.hpp" #include +#include #include "../../model/doc/document.hpp" +#include "../../model/world/tablemimedata.hpp" #include "../filter/filterbox.hpp" #include "table.hpp" @@ -43,6 +45,9 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D mTable->tableSizeUpdate(); mTable->selectionSizeUpdate(); + mTable->viewport()->installEventFilter(this); + mBottom->installEventFilter(this); + filterBox->installEventFilter(this); if (mBottom->canCreateAndDelete()) { @@ -60,6 +65,14 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D connect (filterBox, SIGNAL (recordFilterChanged (boost::shared_ptr)), mTable, SLOT (recordFilterChanged (boost::shared_ptr))); + + connect(filterBox, SIGNAL(recordDropped(std::vector&, Qt::DropAction)), + this, SLOT(createFilterRequest(std::vector&, Qt::DropAction))); + + connect(this, SIGNAL(useFilterRequest(const std::string&)), filterBox, SIGNAL(useFilterRequest(const std::string&))); + + connect(this, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction)), + filterBox, SIGNAL(createFilterRequest(std::vector > >&, Qt::DropAction))); } void CSVWorld::TableSubView::setEditLock (bool locked) @@ -87,3 +100,33 @@ void CSVWorld::TableSubView::cloneRequest(const CSMWorld::UniversalId& toClone) { emit cloneRequest(toClone.getId(), toClone.getType()); } + +void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::UniversalId>& types, Qt::DropAction action) +{ + std::vector > > filterSource; + + for (std::vector::iterator it = types.begin(); it != types.end(); ++it) + { + std::pair > pair( //splited long line + std::make_pair(it->getId(), mTable->getColumnsWithDisplay(CSMWorld::TableMimeData::convertEnums(it->getType())))); + + filterSource.push_back(pair); + } + emit createFilterRequest(filterSource, action); +} + +bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event) +{ + if (event->type() == QEvent::Drop) + { + QDropEvent* drop = dynamic_cast(event); + const CSMWorld::TableMimeData* data = dynamic_cast(drop->mimeData()); + bool handled = data->holdsType(CSMWorld::UniversalId::Type_Filter); + if (handled) + { + emit useFilterRequest(data->returnMatching(CSMWorld::UniversalId::Type_Filter).getId()); + } + return handled; + } + return false; +} \ No newline at end of file diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index d728dc2f3..1f67e0262 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -3,6 +3,8 @@ #include "../doc/subview.hpp" +#include + class QModelIndex; namespace CSMWorld @@ -39,14 +41,22 @@ namespace CSVWorld virtual void setStatusBar (bool show); + protected: + bool eventFilter(QObject* object, QEvent *event); + signals: void cloneRequest(const std::string&, const CSMWorld::UniversalId::Type); + void createFilterRequest(std::vector > >& filterSource, + Qt::DropAction action); + void useFilterRequest(const std::string& idOfFilter); private slots: void editRequest (int row); void cloneRequest (const CSMWorld::UniversalId& toClone); + void createFilterRequest(std::vector< CSMWorld::UniversalId >& types, + Qt::DropAction action); }; } diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index ba0e1d056..265069dc4 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -176,7 +176,7 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot else slot = mCharacterManager.getCurrentCharacter()->updateSlot (slot, profile); - std::ofstream stream (slot->mPath.string().c_str()); + std::ofstream stream (slot->mPath.string().c_str(), std::ios::binary); ESM::ESMWriter writer; diff --git a/components/esm/esmwriter.cpp b/components/esm/esmwriter.cpp index ff7bd765d..91f123eb7 100644 --- a/components/esm/esmwriter.cpp +++ b/components/esm/esmwriter.cpp @@ -120,7 +120,7 @@ namespace ESM mStream->seekp(rec.position); mCounting = false; - write (reinterpret_cast (&rec.size), sizeof(int)); + write (reinterpret_cast (&rec.size), sizeof(uint32_t)); mCounting = true; mStream->seekp(0, std::ios::end);