mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Merge remote-tracking branch 'cc9cii/windows-save-fix' into openmw-29
This commit is contained in:
commit
b0ae5b8ab7
15 changed files with 509 additions and 49 deletions
|
@ -26,6 +26,7 @@ namespace CSMWorld
|
|||
|
||||
enum Display
|
||||
{
|
||||
Display_None, //Do not use
|
||||
Display_String,
|
||||
|
||||
//CONCRETE TYPES STARTS HERE
|
||||
|
|
|
@ -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<UniversalId>::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;
|
||||
}
|
||||
}
|
|
@ -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<UniversalId> mUniversalId;
|
||||
QStringList mObjectsFormats;
|
||||
const CSMDoc::Document& mDocument;
|
||||
|
||||
CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const;
|
||||
};
|
||||
}
|
||||
#endif // TABLEMIMEDATA_H
|
|
@ -2,6 +2,8 @@
|
|||
#include "editwidget.hpp"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QString>
|
||||
#include <QApplication>
|
||||
|
||||
#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<<generateFilter (filterSource[i]);
|
||||
|
||||
if (i+1 != count)
|
||||
{
|
||||
ss<<", ";
|
||||
}
|
||||
}
|
||||
|
||||
ss<<')';
|
||||
} else {
|
||||
if (!replaceMode)
|
||||
{
|
||||
ss << orAnd << oldContent.toStdString() <<',';
|
||||
} else {
|
||||
ss<<'!';
|
||||
}
|
||||
|
||||
ss << generateFilter (filterSource[0]);
|
||||
|
||||
if (!replaceMode)
|
||||
{
|
||||
ss<<')';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ss.str().length() >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("<<'"'<<seekedString.second[i]<<'"'<<','<<'"'<<seekedString.first<<'"'<<')';
|
||||
if (i+1 != columns)
|
||||
ss<<',';
|
||||
}
|
||||
ss<<')';
|
||||
} else {
|
||||
ss<<"string"<<'('<<'"'<<seekedString.second[0]<<"\","<<'"'<<seekedString.first<<"\")";
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void CSVFilter::EditWidget::useFilterRequest (const std::string& idOfFilter)
|
||||
{
|
||||
clear();
|
||||
insert(QString::fromUtf8(idOfFilter.c_str()));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <QLineEdit>
|
||||
#include <QPalette>
|
||||
#include <qt4/QtCore/qnamespace.h>
|
||||
|
||||
#include "../../model/filter/parser.hpp"
|
||||
#include "../../model/filter/node.hpp"
|
||||
|
@ -33,6 +34,9 @@ namespace CSVFilter
|
|||
|
||||
void filterChanged (boost::shared_ptr<CSMFilter::Node> filter);
|
||||
|
||||
private:
|
||||
std::string generateFilter(std::pair<std::string, std::vector<std::string> >& 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<std::pair<std::string, std::vector<std::string> > >& filterSource,
|
||||
Qt::DropAction action);
|
||||
|
||||
void useFilterRequest(const std::string& idOfFilter);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
#include "filterbox.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QDragEnterEvent>
|
||||
|
||||
#include "recordfilterbox.hpp"
|
||||
|
||||
#include <apps/opencs/model/world/tablemimedata.hpp>
|
||||
|
||||
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<CSMFilter::Node>)),
|
||||
this, SIGNAL (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)));
|
||||
}
|
||||
|
||||
connect(this, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)),
|
||||
recordFilterBox, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, 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<CSMWorld::UniversalId> data = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData())->getData();
|
||||
|
||||
emit recordDropped(data, event->proposedAction());
|
||||
}
|
||||
|
||||
void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
|
||||
void CSVFilter::FilterBox::dragMoveEvent (QDragMoveEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
#ifndef CSV_FILTER_FILTERBOX_H
|
||||
#define CSV_FILTER_FILTERBOX_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QWidget>
|
||||
#include <qt4/QtCore/qnamespace.h>
|
||||
|
||||
#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<CSMFilter::Node> filter);
|
||||
void recordDropped (std::vector<CSMWorld::UniversalId>& types, Qt::DropAction action);
|
||||
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
|
||||
Qt::DropAction action);
|
||||
void useFilterRequest(const std::string& idOfFilter);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -24,4 +24,9 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare
|
|||
connect (
|
||||
editWidget, SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)),
|
||||
this, SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)));
|
||||
|
||||
connect(this, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)),
|
||||
editWidget, SLOT(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)));
|
||||
|
||||
connect(this, SIGNAL(useFilterRequest(const std::string&)), editWidget, SLOT(useFilterRequest(const std::string&)));
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <QWidget>
|
||||
#include <qt4/QtCore/qnamespace.h>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
|
@ -27,6 +28,9 @@ namespace CSVFilter
|
|||
signals:
|
||||
|
||||
void filterChanged (boost::shared_ptr<CSMFilter::Node> filter);
|
||||
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
|
||||
Qt::DropAction action);
|
||||
void useFilterRequest(const std::string& idOfFilter);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QHeaderView>
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QString>
|
||||
|
@ -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<const CSMWorld::TableMimeData*> (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<CSMWorld::ModifyCommand> 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<std::string> CSVWorld::Table::getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const
|
||||
{
|
||||
const int count = mModel->columnCount();
|
||||
|
||||
std::vector<std::string> titles;
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
CSMWorld::ColumnBase::Display columndisplay = static_cast<CSMWorld::ColumnBase::Display>
|
||||
(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;
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
#include <QtGui/qevent.h>
|
||||
|
||||
#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<std::string> getColumnsWithDisplay(CSMWorld::ColumnBase::Display display) const;
|
||||
|
||||
signals:
|
||||
|
||||
void editRequest (int row);
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
#include "tablesubview.hpp"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QEvent>
|
||||
|
||||
#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<CSMFilter::Node>)),
|
||||
mTable, SLOT (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)));
|
||||
|
||||
connect(filterBox, SIGNAL(recordDropped(std::vector<CSMWorld::UniversalId>&, Qt::DropAction)),
|
||||
this, SLOT(createFilterRequest(std::vector<CSMWorld::UniversalId>&, Qt::DropAction)));
|
||||
|
||||
connect(this, SIGNAL(useFilterRequest(const std::string&)), filterBox, SIGNAL(useFilterRequest(const std::string&)));
|
||||
|
||||
connect(this, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)),
|
||||
filterBox, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, 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<std::pair<std::string, std::vector<std::string> > > filterSource;
|
||||
|
||||
for (std::vector<CSMWorld::UniversalId>::iterator it = types.begin(); it != types.end(); ++it)
|
||||
{
|
||||
std::pair<std::string, std::vector<std::string> > 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<QDropEvent*>(event);
|
||||
const CSMWorld::TableMimeData* data = dynamic_cast<const CSMWorld::TableMimeData*>(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;
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "../doc/subview.hpp"
|
||||
|
||||
#include <qt4/QtCore/qnamespace.h>
|
||||
|
||||
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<std::pair<std::string, std::vector<std::string> > >& 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);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace ESM
|
|||
mStream->seekp(rec.position);
|
||||
|
||||
mCounting = false;
|
||||
write (reinterpret_cast<const char*> (&rec.size), sizeof(int));
|
||||
write (reinterpret_cast<const char*> (&rec.size), sizeof(uint32_t));
|
||||
mCounting = true;
|
||||
|
||||
mStream->seekp(0, std::ios::end);
|
||||
|
|
Loading…
Reference in a new issue