[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [skrooge] /: BUG:345719
From: Stephane Mankowski <stephane () mankowski ! fr>
Date: 2015-03-31 20:54:09
Message-ID: E1Yd3An-0002Vy-Mp () scm ! kde ! org
[Download RAW message or body]
Git commit c0270dfbbf0bd211684d4713a6ec825ffd75a4fb by Stephane Mankowski.
Committed on 31/03/2015 at 20:53.
Pushed by smankowski into branch 'master'.
BUG:345719
Enhance fast search/filter on lists
M +1 -0 CHANGELOG
M +2 -0 TODO
M +3 -0 skgbasegui/skgfilteredtableview.ui
M +15 -3 skgbasegui/skgsortfilterproxymodel.cpp
M +2 -2 skgbasemodeler/skgservices.cpp
M +20 -0 tests/skgbasemodelertest/skgtestbase.cpp
http://commits.kde.org/skrooge/c0270dfbbf0bd211684d4713a6ec825ffd75a4fb
diff --git a/CHANGELOG b/CHANGELOG
index 33b2357..3ecd2af 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@ skrooge (1.11.0)
*Correction bug 345580: Share without tax should not be split
*Correction bug 345654: Btn Add grayed after entering values information
*Correction bug 345661: Selecting multiple operations: amount is not -----
+ *Correction bug 345719: Enhance fast search/filter on lists
*Correction: "Search" and "Report" do not work on properties of suboperations
*Correction: Bad tooltips in "Report" for expand and collapse
*Correction: Support invalid OFX file having debit with positive amount
diff --git a/TODO b/TODO
index a0fefe1..d6377c2 100644
--- a/TODO
+++ b/TODO
@@ -84,6 +84,8 @@ Also I'm sure it would be helpful to make better, more rich rules.
146:P1: New function to restaure the previous backup
+147:P1: Attribute for creation date on operation
+
Current Sprint
--------------
084:P1: [Space] key to point operations, since space is standard checkbox key?
diff --git a/skgbasegui/skgfilteredtableview.ui b/skgbasegui/skgfilteredtableview.ui
index 620820f..c5cb2e2 100644
--- a/skgbasegui/skgfilteredtableview.ui
+++ b/skgbasegui/skgfilteredtableview.ui
@@ -100,6 +100,9 @@
<property name="focusPolicy">
<enum>Qt::WheelFocus</enum>
</property>
+ <property name="toolTip">
+ <string><html><head/><body><p>If you just put a word \
or series of words in the search box, the application will filter the table to keep \
all lines having these words (logical operator AND). </p><p>If you want \
to add (logical operator OR) some line, you must prefix you word by \
&quot;+&quot;.</p><p>If you want to remove (logical operator NOT) \
some line, you must prefix you word by &quot;-&quot;.</p><p>If \
you want to search only on one column, you must prefix you word by the column name \
like: col1:word.</p><p>Searching is case-insensitive. So table, Table, \
and TABLE are all the same. </p><p>If you want to search for a phrase or \
something that contains spaces, you must put it in quotes, like: &quot;yes, this \
is a phrase&quot;.</p><p>Examples:</p><p>+val1 +val2 \
=&gt; Keep lines containing val1 OR val2</p><p>+val1 -val2 =&gt; \
Keep lines containing val1 but NOT val2</p><p>&quot;abc def&quot; \
=&gt; Keep lines containing the sentense &quot;abc def&quot; \
</p><p>abc:def =&gt; Keep lines having a column name starting by abc \
and containing def</p></body></html></string> + </property>
</widget>
</item>
<item>
diff --git a/skgbasegui/skgsortfilterproxymodel.cpp \
b/skgbasegui/skgsortfilterproxymodel.cpp index 8fac253..9c12558 100644
--- a/skgbasegui/skgsortfilterproxymodel.cpp
+++ b/skgbasegui/skgsortfilterproxymodel.cpp
@@ -213,6 +213,14 @@ bool SKGSortFilterProxyModel::filterAcceptsRowWords(int \
source_row, const QModel int nbwords = iWords.count();
for (int w = 0; output && w < nbwords; ++w) {
QString word = iWords.at(w);
+ QString att;
+
+ // Check if the word follows the format attribut:value
+ int pos = word.indexOf(':');
+ if (pos != -1) {
+ att = word.left(pos);
+ word = word.right(word.count() - pos - 1);
+ }
// Is this word validated by at least one column ?
output = false;
@@ -220,9 +228,13 @@ bool SKGSortFilterProxyModel::filterAcceptsRowWords(int \
source_row, const QModel for (int i = 0; !output && i < nbcol; ++i) {
QModelIndex index0 = model->index(source_row, i, source_parent);
if (index0.isValid()) {
- output = model->data(index0).toString().contains(word , \
Qt::CaseInsensitive);
- if (!output) {
- output = model->data(index0, \
Qt::UserRole).toString().contains(word , Qt::CaseInsensitive); + \
// Check if the header validates the attribut + if (att.isEmpty() \
|| model->headerData(i, Qt::Horizontal).toString().startsWith(att, \
Qt::CaseInsensitive)) { + // Check if the value validate the \
attribute + output = \
model->data(index0).toString().contains(word , Qt::CaseInsensitive); + \
if (!output) { + output = model->data(index0, \
Qt::UserRole).toString().contains(word , Qt::CaseInsensitive); + \
} }
}
}
diff --git a/skgbasemodeler/skgservices.cpp b/skgbasemodeler/skgservices.cpp
index 87183ad..ade344f 100644
--- a/skgbasemodeler/skgservices.cpp
+++ b/skgbasemodeler/skgservices.cpp
@@ -54,8 +54,8 @@ QList< SKGServices::SKGSearchCriteria > \
SKGServices::stringToSearchCriterias(con QList< SKGServices::SKGSearchCriteria > \
output;
QStringList words = SKGServices::splitCSVLine(iString, ' ', true);
- int nbwords = words.count();
+ int nbwords = words.count();
SKGServices::SKGSearchCriteria criteria;
criteria.mode = '+';
bool atLeastOnePlus = false;
@@ -347,7 +347,7 @@ QStringList SKGServices::splitCSVLine(const QString& iString, \
const QChar& iSepa if (isInBlock) {
item += c;
}
- } else if ((c == '\"' || c == '\'') && item.count() == 0 && \
iCoteDefineBlock) { + } else if ((c == '\"' || c == '\'') && \
iCoteDefineBlock) { if (cote == ' ') {
cote = c; // Set the real cote char
}
diff --git a/tests/skgbasemodelertest/skgtestbase.cpp \
b/tests/skgbasemodelertest/skgtestbase.cpp index 320c999..9e58c9d 100644
--- a/tests/skgbasemodelertest/skgtestbase.cpp
+++ b/tests/skgbasemodelertest/skgtestbase.cpp
@@ -394,6 +394,10 @@ int main(int argc, char** argv)
SKGTEST("STR:splitCSVLine", parameters[0], "A");
SKGTEST("STR:splitCSVLine", parameters[1], "\"B\";\"C\"");
+ parameters = SKGServices::splitCSVLine("+123 -\"abc def\"", ' ', true);
+ SKGTEST("STR:splitCSVLine count", parameters.count(), 2);
+ SKGTEST("STR:splitCSVLine", parameters[0], "+123");
+ SKGTEST("STR:splitCSVLine", parameters[1], "-abc def");
SKGTEST("STR:splitCSVLine words", SKGServices::splitCSVLine("w1 w2", ' ', \
true).count(), 2);
SKGTEST("STR:splitCSVLine words", SKGServices::splitCSVLine("\"w1 w1\"", ' \
', true).count(), 1); @@ -435,6 +439,22 @@ int main(int argc, char** argv)
SKGTEST("STR:stringToSearchCriterias words count", \
criterias[1].words.count(), 1);
SKGTEST("STR:stringToSearchCriterias word", criterias[1].words[0], "abc");
+ criterias = SKGServices::stringToSearchCriterias("\"abc def ghi\" \"123 \
456\""); + SKGTEST("STR:stringToSearchCriterias count", criterias.count(), 1);
+ SKGTEST("STR:stringToSearchCriterias mode", criterias[0].mode, '+');
+ SKGTEST("STR:stringToSearchCriterias words count", \
criterias[0].words.count(), 2); + SKGTEST("STR:stringToSearchCriterias word", \
criterias[0].words[0], "abc def ghi"); + SKGTEST("STR:stringToSearchCriterias \
word", criterias[0].words[1], "123 456"); +
+ criterias = SKGServices::stringToSearchCriterias("-payee:\"abc def : ghi\" \
+amount:25"); + SKGTEST("STR:stringToSearchCriterias count", \
criterias.count(), 2); + SKGTEST("STR:stringToSearchCriterias mode", \
criterias[0].mode, '+'); + SKGTEST("STR:stringToSearchCriterias words count", \
criterias[0].words.count(), 1); + SKGTEST("STR:stringToSearchCriterias word", \
criterias[0].words[0], "amount:25"); + SKGTEST("STR:stringToSearchCriterias \
mode", criterias[1].mode, '-'); + SKGTEST("STR:stringToSearchCriterias words \
count", criterias[1].words.count(), 1); + SKGTEST("STR:stringToSearchCriterias \
word", criterias[1].words[0], "payee:abc def : ghi"); +
SKGStringListList table;
table.push_back(QStringList() << "Person" << "Salary" << "Age");
table.push_back(QStringList() << "John" << "58000" << "33");
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic