mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:23:52 +00:00
try with the passing action
This commit is contained in:
parent
38a86b5015
commit
3ad6df1f92
9 changed files with 87 additions and 27 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
|
|
||||||
|
@ -58,7 +59,8 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s
|
||||||
textChanged (text());
|
textChanged (text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource)
|
void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource,
|
||||||
|
Qt::DropAction action)
|
||||||
{
|
{
|
||||||
const unsigned count = filterSource.size();
|
const unsigned count = filterSource.size();
|
||||||
bool multipleElements = false;
|
bool multipleElements = false;
|
||||||
|
@ -77,9 +79,34 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Qt::KeyboardModifiers key = QApplication::keyboardModifiers();
|
||||||
QString oldContent(text());
|
QString oldContent(text());
|
||||||
bool replaceMode = oldContent.isEmpty() or !oldContent.contains(QRegExp("^!.*$", Qt::CaseInsensitive));
|
|
||||||
bool orMode = true; //not orMode = andMode,
|
bool replaceMode = false;
|
||||||
|
bool orMode = true;
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case Qt::ShiftModifier:
|
||||||
|
orMode = true;
|
||||||
|
replaceMode = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Qt::ControlModifier:
|
||||||
|
orMode = false;
|
||||||
|
replaceMode = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
replaceMode = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldContent.isEmpty() ||
|
||||||
|
!oldContent.contains(QRegExp("^!.*$", Qt::CaseInsensitive)))
|
||||||
|
{
|
||||||
|
replaceMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string orAnd;
|
std::string orAnd;
|
||||||
if (orMode)
|
if (orMode)
|
||||||
|
@ -89,12 +116,12 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
|
||||||
orAnd = "and";
|
orAnd = "and";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (multipleElements) //TODO Currently only 'or' is handled, we should be able to handle 'and' as well and be able to drag records into the EditWidget already filled with the filter
|
if (multipleElements) //TODO appending to the existing filter
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (replaceMode)
|
if (replaceMode)
|
||||||
{
|
{
|
||||||
ss<<'!'<<orAnd<<'(';
|
ss<<"!or(";
|
||||||
|
|
||||||
for (unsigned i = 0; i < count; ++i)
|
for (unsigned i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
|
@ -107,16 +134,25 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
|
||||||
}
|
}
|
||||||
|
|
||||||
ss<<')';
|
ss<<')';
|
||||||
clear();
|
|
||||||
insert (QString::fromUtf8 (ss.str().c_str()));
|
if (ss.str().length() >2)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
insert (QString::fromUtf8 (ss.str().c_str()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//not handled (yet) TODO
|
//not handled (yet) TODO
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (replaceMode)
|
if (replaceMode)
|
||||||
{
|
{
|
||||||
clear();
|
std::string filter(generateFilter(filterSource[0]));
|
||||||
insert ('!' + QString::fromUtf8 (generateFilter(filterSource[0]).c_str()));
|
|
||||||
|
if (!filter.empty())
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
insert ('!' + QString::fromUtf8 (generateFilter(filterSource[0]).c_str()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//not handled (yet) TODO
|
//not handled (yet) TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include "../../model/filter/parser.hpp"
|
#include "../../model/filter/parser.hpp"
|
||||||
#include "../../model/filter/node.hpp"
|
#include "../../model/filter/node.hpp"
|
||||||
|
@ -46,7 +47,8 @@ namespace CSVFilter
|
||||||
|
|
||||||
void filterRowsInserted (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);
|
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
|
||||||
|
Qt::DropAction action);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ CSVFilter::FilterBox::FilterBox (CSMWorld::Data& data, QWidget *parent)
|
||||||
SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)),
|
SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)),
|
||||||
this, SIGNAL (recordFilterChanged (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> > >&)),
|
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> > >&)));
|
recordFilterBox, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)));
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ void CSVFilter::FilterBox::dropEvent (QDropEvent* event)
|
||||||
{
|
{
|
||||||
std::vector<CSMWorld::UniversalId> data = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData())->getData();
|
std::vector<CSMWorld::UniversalId> data = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData())->getData();
|
||||||
|
|
||||||
emit recordDropped(data);
|
emit recordDropped(data, event->proposedAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event)
|
void CSVFilter::FilterBox::dragEnterEvent (QDragEnterEvent* event)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include "../../model/filter/node.hpp"
|
#include "../../model/filter/node.hpp"
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
@ -32,8 +33,9 @@ namespace CSVFilter
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter);
|
void recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter);
|
||||||
void recordDropped (std::vector<CSMWorld::UniversalId>& types);
|
void recordDropped (std::vector<CSMWorld::UniversalId>& types, Qt::DropAction action);
|
||||||
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource);
|
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
|
||||||
|
Qt::DropAction action);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,6 @@ CSVFilter::RecordFilterBox::RecordFilterBox (CSMWorld::Data& data, QWidget *pare
|
||||||
editWidget, SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)),
|
editWidget, SIGNAL (filterChanged (boost::shared_ptr<CSMFilter::Node>)),
|
||||||
this, 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> > >&)),
|
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> > >&)));
|
editWidget, SLOT(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
@ -27,7 +28,8 @@ namespace CSVFilter
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void filterChanged (boost::shared_ptr<CSMFilter::Node> filter);
|
void filterChanged (boost::shared_ptr<CSMFilter::Node> filter);
|
||||||
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource);
|
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
|
||||||
|
Qt::DropAction action);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
#include <QApplication>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -471,7 +472,20 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event)
|
||||||
|
|
||||||
drag->setMimeData (mime);
|
drag->setMimeData (mime);
|
||||||
drag->setPixmap (QString::fromStdString (mime->getIcon()));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,11 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
SIGNAL (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)),
|
SIGNAL (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)),
|
||||||
mTable, SLOT (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)));
|
mTable, SLOT (recordFilterChanged (boost::shared_ptr<CSMFilter::Node>)));
|
||||||
|
|
||||||
connect(filterBox, SIGNAL(recordDropped(std::vector<CSMWorld::UniversalId>&)),
|
connect(filterBox, SIGNAL(recordDropped(std::vector<CSMWorld::UniversalId>&, Qt::DropAction)),
|
||||||
this, SLOT(createFilterRequest(std::vector<CSMWorld::UniversalId>&)));
|
this, SLOT(createFilterRequest(std::vector<CSMWorld::UniversalId>&, Qt::DropAction)));
|
||||||
|
|
||||||
connect(this, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<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> > >&)));
|
filterBox, SIGNAL(createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >&, Qt::DropAction)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::TableSubView::setEditLock (bool locked)
|
void CSVWorld::TableSubView::setEditLock (bool locked)
|
||||||
|
@ -95,7 +95,7 @@ void CSVWorld::TableSubView::cloneRequest(const CSMWorld::UniversalId& toClone)
|
||||||
emit cloneRequest(toClone.getId(), toClone.getType());
|
emit cloneRequest(toClone.getId(), toClone.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::UniversalId>& types)
|
void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::UniversalId>& types, Qt::DropAction action)
|
||||||
{
|
{
|
||||||
std::vector<std::pair<std::string, std::vector<std::string> > > filterSource;
|
std::vector<std::pair<std::string, std::vector<std::string> > > filterSource;
|
||||||
|
|
||||||
|
@ -106,5 +106,5 @@ void CSVWorld::TableSubView::createFilterRequest (std::vector< CSMWorld::Univers
|
||||||
|
|
||||||
filterSource.push_back(pair);
|
filterSource.push_back(pair);
|
||||||
}
|
}
|
||||||
emit createFilterRequest(filterSource);
|
emit createFilterRequest(filterSource, action);
|
||||||
}
|
}
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
|
#include <qt4/QtCore/qnamespace.h>
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
|
@ -42,13 +44,15 @@ namespace CSVWorld
|
||||||
signals:
|
signals:
|
||||||
void cloneRequest(const std::string&,
|
void cloneRequest(const std::string&,
|
||||||
const CSMWorld::UniversalId::Type);
|
const CSMWorld::UniversalId::Type);
|
||||||
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource);
|
void createFilterRequest(std::vector<std::pair<std::string, std::vector<std::string> > >& filterSource,
|
||||||
|
Qt::DropAction action);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void editRequest (int row);
|
void editRequest (int row);
|
||||||
void cloneRequest (const CSMWorld::UniversalId& toClone);
|
void cloneRequest (const CSMWorld::UniversalId& toClone);
|
||||||
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types);
|
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types,
|
||||||
|
Qt::DropAction action);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue