mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 15:41:13 -04:00
refactorisation
This commit is contained in:
parent
1c35a85adf
commit
55e9083570
@ -65,7 +65,7 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
|
|||||||
const unsigned count = filterSource.size();
|
const unsigned count = filterSource.size();
|
||||||
bool multipleElements = false;
|
bool multipleElements = false;
|
||||||
|
|
||||||
switch (count)
|
switch (count) //setting multipleElements;
|
||||||
{
|
{
|
||||||
case 0: //empty
|
case 0: //empty
|
||||||
return; //nothing to do here
|
return; //nothing to do here
|
||||||
@ -83,17 +83,17 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
|
|||||||
QString oldContent (text());
|
QString oldContent (text());
|
||||||
|
|
||||||
bool replaceMode = false;
|
bool replaceMode = false;
|
||||||
bool orMode = true;
|
std::string orAnd;
|
||||||
|
|
||||||
switch (key)
|
switch (key) //setting replaceMode and string used to glue expressions
|
||||||
{
|
{
|
||||||
case Qt::ShiftModifier:
|
case Qt::ShiftModifier:
|
||||||
orMode = true;
|
orAnd = "!or(";
|
||||||
replaceMode = false;
|
replaceMode = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::ControlModifier:
|
case Qt::ControlModifier:
|
||||||
orMode = false;
|
orAnd = "!and(";
|
||||||
replaceMode = false;
|
replaceMode = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -102,32 +102,16 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldContent.isEmpty() ||
|
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
|
||||||
!oldContent.contains (QRegExp ("^!.*$", Qt::CaseInsensitive)))
|
|
||||||
{
|
{
|
||||||
replaceMode = true;
|
replaceMode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!replaceMode)
|
if (!replaceMode)
|
||||||
{
|
{
|
||||||
int index = oldContent.indexOf ('(');
|
oldContent.remove ('!');
|
||||||
|
|
||||||
if (index != 0)
|
|
||||||
{
|
|
||||||
oldContent.remove ('!');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string orAnd;
|
|
||||||
|
|
||||||
if (orMode)
|
|
||||||
{
|
|
||||||
orAnd = "!or(";
|
|
||||||
} else {
|
|
||||||
orAnd = "!and(";
|
|
||||||
}
|
|
||||||
|
|
||||||
clear();
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
if (multipleElements)
|
if (multipleElements)
|
||||||
@ -150,29 +134,27 @@ void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::st
|
|||||||
}
|
}
|
||||||
|
|
||||||
ss<<')';
|
ss<<')';
|
||||||
|
|
||||||
if (ss.str().length() >5)
|
|
||||||
{
|
|
||||||
insert (QString::fromUtf8 (ss.str().c_str()));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!replaceMode)
|
if (!replaceMode)
|
||||||
{
|
{
|
||||||
ss << orAnd << oldContent.toStdString()<<',';
|
ss << orAnd << oldContent.toStdString() <<',';
|
||||||
} else {
|
} else {
|
||||||
ss<<'!';
|
ss<<'!';
|
||||||
}
|
}
|
||||||
|
|
||||||
ss << generateFilter (filterSource[0]);
|
ss << generateFilter (filterSource[0]);
|
||||||
|
|
||||||
if (!replaceMode)
|
if (!replaceMode)
|
||||||
{
|
{
|
||||||
ss<<')';
|
ss<<')';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ss.str().length() >4)
|
}
|
||||||
{
|
|
||||||
insert (QString::fromStdString (ss.str().c_str()));
|
if (ss.str().length() >4)
|
||||||
}
|
{
|
||||||
|
clear();
|
||||||
|
insert (QString::fromStdString (ss.str().c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user