From kde-commits Tue Mar 31 20:54:09 2015 From: Stephane Mankowski Date: Tue, 31 Mar 2015 20:54:09 +0000 To: kde-commits Subject: [skrooge] /: BUG:345719 Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=142783526030410 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 subopera= tions = *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 ri= ch 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/skgfilteredtab= leview.ui index 620820f..c5cb2e2 100644 --- a/skgbasegui/skgfilteredtableview.ui +++ b/skgbasegui/skgfilteredtableview.ui @@ -100,6 +100,9 @@ Qt::WheelFocus + + <html><head/><body><p>If you just = put a word or series of words in the search box, the application will filte= r the table to keep all lines having these words (logical operator AND). &l= t;/p><p>If you want to add (logical operator OR) some line, you mu= st prefix you word by &quot;+&quot;.</p><p>If you want = to remove (logical operator NOT) some line, you must prefix you word by &am= p;quot;-&quot;.</p><p>If you want to search only on one col= umn, 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 somethin= g that contains spaces, you must put it in quotes, like: &quot;yes, thi= s is a phrase&quot;.</p><p>Examples:</p><p>+val= 1 +val2 =3D&gt; Keep lines containing val1 OR val2</p><p>+v= al1 -val2 =3D&gt; Keep lines containing val1 but NOT val2</p><= p>&quot;abc def&quot; =3D&gt; Keep lines containing the sent= ense &quot;abc def&quot; </p><p>abc:def =3D&gt; Kee= p lines having a column name starting by abc and containing def</p>&l= t;/body></html> + diff --git a/skgbasegui/skgsortfilterproxymodel.cpp b/skgbasegui/skgsortfil= terproxymodel.cpp index 8fac253..9c12558 100644 --- a/skgbasegui/skgsortfilterproxymodel.cpp +++ b/skgbasegui/skgsortfilterproxymodel.cpp @@ -213,6 +213,14 @@ bool SKGSortFilterProxyModel::filterAcceptsRowWords(in= t source_row, const QModel int nbwords =3D iWords.count(); for (int w =3D 0; output && w < nbwords; ++w) { QString word =3D iWords.at(w); + QString att; + + // Check if the word follows the format attribut:value + int pos =3D word.indexOf(':'); + if (pos !=3D -1) { + att =3D word.left(pos); + word =3D word.right(word.count() - pos - 1); + } = // Is this word validated by at least one column ? output =3D false; @@ -220,9 +228,13 @@ bool SKGSortFilterProxyModel::filterAcceptsRowWords(in= t source_row, const QModel for (int i =3D 0; !output && i < nbcol; ++i) { QModelIndex index0 =3D model->index(source_row, i, source_= parent); if (index0.isValid()) { - output =3D model->data(index0).toString().contains(wor= d , Qt::CaseInsensitive); - if (!output) { - output =3D model->data(index0, Qt::UserRole).toStr= ing().contains(word , Qt::CaseInsensitive); + // Check if the header validates the attribut + if (att.isEmpty() || model->headerData(i, Qt::Horizont= al).toString().startsWith(att, Qt::CaseInsensitive)) { + // Check if the value validate the attribute + output =3D model->data(index0).toString().contains= (word , Qt::CaseInsensitive); + if (!output) { + output =3D model->data(index0, Qt::UserRole).t= oString().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::stri= ngToSearchCriterias(con QList< SKGServices::SKGSearchCriteria > output; = QStringList words =3D SKGServices::splitCSVLine(iString, ' ', true); - int nbwords =3D words.count(); = + int nbwords =3D words.count(); SKGServices::SKGSearchCriteria criteria; criteria.mode =3D '+'; bool atLeastOnePlus =3D false; @@ -347,7 +347,7 @@ QStringList SKGServices::splitCSVLine(const QString& iS= tring, const QChar& iSepa if (isInBlock) { item +=3D c; } - } else if ((c =3D=3D '\"' || c =3D=3D '\'') && item.count() =3D= =3D 0 && iCoteDefineBlock) { + } else if ((c =3D=3D '\"' || c =3D=3D '\'') && iCoteDefineBlock)= { if (cote =3D=3D ' ') { cote =3D c; // Set the real cote char } diff --git a/tests/skgbasemodelertest/skgtestbase.cpp b/tests/skgbasemodele= rtest/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 =3D 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].wo= rds.count(), 1); SKGTEST("STR:stringToSearchCriterias word", criterias[1].words[0],= "abc"); = + criterias =3D 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].wo= rds.count(), 2); + SKGTEST("STR:stringToSearchCriterias word", criterias[0].words[0],= "abc def ghi"); + SKGTEST("STR:stringToSearchCriterias word", criterias[0].words[1],= "123 456"); + + criterias =3D SKGServices::stringToSearchCriterias("-payee:\"abc d= ef : ghi\" +amount:25"); + SKGTEST("STR:stringToSearchCriterias count", criterias.count(), 2); + SKGTEST("STR:stringToSearchCriterias mode", criterias[0].mode, '+'= ); + SKGTEST("STR:stringToSearchCriterias words count", criterias[0].wo= rds.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].wo= rds.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");