From 38a86b5015c2d126d968fc37e025c4df57770184 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 20 Feb 2014 14:13:12 +0100 Subject: [PATCH] We can handle droping multiple records --- apps/opencs/view/filter/editwidget.cpp | 68 +++++++++++++++++++++----- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/apps/opencs/view/filter/editwidget.cpp b/apps/opencs/view/filter/editwidget.cpp index 2ccef17a8..5ea99c5dc 100644 --- a/apps/opencs/view/filter/editwidget.cpp +++ b/apps/opencs/view/filter/editwidget.cpp @@ -60,20 +60,66 @@ void CSVFilter::EditWidget::filterRowsInserted (const QModelIndex& parent, int s void CSVFilter::EditWidget::createFilterRequest (std::vector< std::pair< std::string, std::vector< std::string > > >& filterSource) { - clear(); + const unsigned count = filterSource.size(); + bool multipleElements = false; - std::string filter(generateFilter(*filterSource.begin())); - insert(QString::fromUtf8(filter.c_str())); + switch (count) + { + case 0: //empty + return; //nothing to do here + + case 1: //only single + multipleElements = false; + break; + + default: + multipleElements = true; + break; + } + + QString oldContent(text()); + bool replaceMode = oldContent.isEmpty() or !oldContent.contains(QRegExp("^!.*$", Qt::CaseInsensitive)); + bool orMode = true; //not orMode = andMode, + + std::string orAnd; + if (orMode) + { + orAnd = "or"; + } else { + orAnd = "and"; + } - for (unsigned i = 0; i < filterSource.size(); ++i) //test + 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 { - std::cout<