mirror of
https://github.com/OpenMW/openmw.git
synced 2025-05-21 14:11:28 +00:00
Merge remote-tracking branch 'artemutin/longStringEditor'
This commit is contained in:
commit
8f0d7ec1ec
2 changed files with 24 additions and 3 deletions
|
@ -5,14 +5,17 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
|
#include "../../model/world/idtablebase.hpp"
|
||||||
|
#include "../../model/world/columns.hpp"
|
||||||
|
|
||||||
CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent)
|
CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent)
|
||||||
: QLineEdit (parent), mParser (data)
|
: QLineEdit (parent), mParser (data), mIsEmpty(true)
|
||||||
{
|
{
|
||||||
mPalette = palette();
|
mPalette = palette();
|
||||||
connect (this, SIGNAL (textChanged (const QString&)), this, SLOT (textChanged (const QString&)));
|
connect (this, SIGNAL (textChanged (const QString&)), this, SLOT (textChanged (const QString&)));
|
||||||
|
|
||||||
QAbstractItemModel *model = data.getTableModel (CSMWorld::UniversalId::Type_Filters);
|
const CSMWorld::IdTableBase *model =
|
||||||
|
static_cast<const CSMWorld::IdTableBase *> (data.getTableModel (CSMWorld::UniversalId::Type_Filters));
|
||||||
|
|
||||||
connect (model, SIGNAL (dataChanged (const QModelIndex &, const QModelIndex&)),
|
connect (model, SIGNAL (dataChanged (const QModelIndex &, const QModelIndex&)),
|
||||||
this, SLOT (filterDataChanged (const QModelIndex &, const QModelIndex&)),
|
this, SLOT (filterDataChanged (const QModelIndex &, const QModelIndex&)),
|
||||||
|
@ -23,10 +26,23 @@ CSVFilter::EditWidget::EditWidget (CSMWorld::Data& data, QWidget *parent)
|
||||||
connect (model, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
connect (model, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||||
this, SLOT (filterRowsInserted (const QModelIndex&, int, int)),
|
this, SLOT (filterRowsInserted (const QModelIndex&, int, int)),
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
|
mStateColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Modification);
|
||||||
|
mDescColumnIndex = model->findColumnIndex(CSMWorld::Columns::ColumnId_Description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVFilter::EditWidget::textChanged (const QString& text)
|
void CSVFilter::EditWidget::textChanged (const QString& text)
|
||||||
{
|
{
|
||||||
|
//no need to parse and apply filter if it was empty and now is empty too.
|
||||||
|
//e.g. - we modifiing content of filter with already opened some other (big) tables.
|
||||||
|
if (text.length() == 0){
|
||||||
|
if (mIsEmpty)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
mIsEmpty = true;
|
||||||
|
}else
|
||||||
|
mIsEmpty = false;
|
||||||
|
|
||||||
if (mParser.parse (text.toUtf8().constData()))
|
if (mParser.parse (text.toUtf8().constData()))
|
||||||
{
|
{
|
||||||
setPalette (mPalette);
|
setPalette (mPalette);
|
||||||
|
@ -45,7 +61,9 @@ void CSVFilter::EditWidget::textChanged (const QString& text)
|
||||||
void CSVFilter::EditWidget::filterDataChanged (const QModelIndex& topLeft,
|
void CSVFilter::EditWidget::filterDataChanged (const QModelIndex& topLeft,
|
||||||
const QModelIndex& bottomRight)
|
const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
textChanged (text());
|
for (int i = topLeft.column(); i <= bottomRight.column(); ++i)
|
||||||
|
if (i != mStateColumnIndex && i != mDescColumnIndex)
|
||||||
|
textChanged (text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVFilter::EditWidget::filterRowsRemoved (const QModelIndex& parent, int start, int end)
|
void CSVFilter::EditWidget::filterRowsRemoved (const QModelIndex& parent, int start, int end)
|
||||||
|
|
|
@ -25,6 +25,9 @@ namespace CSVFilter
|
||||||
|
|
||||||
CSMFilter::Parser mParser;
|
CSMFilter::Parser mParser;
|
||||||
QPalette mPalette;
|
QPalette mPalette;
|
||||||
|
bool mIsEmpty;
|
||||||
|
int mStateColumnIndex;
|
||||||
|
int mDescColumnIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue