[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kactivities-stats] src: Ignoring link status when sortin UsedResources and LinkedResources model
From:       Ivan Čukić <ivan.cukic () kde ! org>
Date:       2016-10-24 11:37:14
Message-ID: E1bydZ4-0006BP-OZ () code ! kde ! org
[Download RAW message or body]

Git commit 83e46917592a004f8ae9aa43fc134ce365e1652c by Ivan Čukić.
Committed on 24/10/2016 at 11:34.
Pushed by ivan into branch 'master'.

Ignoring link status when sortin UsedResources and LinkedResources model

The only model that should differentiate between resources that are
linked and those that are not is the AllResources model which combines
the linked resources with those that are not linked, but were used
before.

M  +20   -6    src/resultmodel.cpp
M  +3    -2    src/resultset.h

http://commits.kde.org/kactivities-stats/83e46917592a004f8ae9aa43fc134ce365e1652c

diff --git a/src/resultmodel.cpp b/src/resultmodel.cpp
index 8128788..f576034 100644
--- a/src/resultmodel.cpp
+++ b/src/resultmodel.cpp
@@ -171,6 +171,13 @@ public:
                                 d->destinationFor(*resourcePosition));
         }
 
+        inline void debug() const
+        {
+            for (const auto& item: m_items) {
+                qDebug() << "Item: " << item;
+            }
+        }
+
     private:
         ResultModelPrivate *const d;
 
@@ -536,10 +543,15 @@ public:
 
         #define ORDER_BY(Field) member(&ResultSet::Result::Field) > Field
         #define ORDER_BY_FULL(Field)                                           \
-            cache.lowerBound(FixedItemsLessThan(cache, resource)               \
-                             && ORDER_BY(linkStatus)                           \
-                             && ORDER_BY(Field)                                \
-                             && ORDER_BY(resource))
+            (query.selection() == Terms::AllResources ?                        \
+                cache.lowerBound(FixedItemsLessThan(cache, resource)           \
+                                 && ORDER_BY(linkStatus)                       \
+                                 && ORDER_BY(Field)                            \
+                                 && ORDER_BY(resource)) :                      \
+                cache.lowerBound(FixedItemsLessThan(cache, resource)           \
+                                 && ORDER_BY(Field)                            \
+                                 && ORDER_BY(resource))                        \
+            )
 
         const auto destination =
             query.ordering() == HighScoredFirst      ? ORDER_BY_FULL(score):
@@ -694,7 +706,7 @@ public:
     {
         using boost::lower_bound;
 
-        QDBG << "ResultModelPrivate::onResultAdded "
+        QDBG << "ResultModelPrivate::onResultScoreUpdated "
              << "result added:" << resource
              << "score:" << score
              << "last:" << lastUpdate
@@ -707,7 +719,9 @@ public:
 
         ResultSet::Result::LinkStatus linkStatus
             = result ? result->linkStatus()
-                     : ResultSet::Result::NotLinked;
+            : query.selection() != Terms::UsedResources ? ResultSet::Result::Unknown
+            : query.selection() != Terms::LinkedResources ? ResultSet::Result::Linked
+            : ResultSet::Result::NotLinked;
 
         if (result) {
             // We are only updating a result we already had,
diff --git a/src/resultset.h b/src/resultset.h
index e440a40..8861ad8 100644
--- a/src/resultset.h
+++ b/src/resultset.h
@@ -240,8 +240,9 @@ inline QDebug operator<< (QDebug out, const ResultSet::Result &result)
         << (result.linkStatus() == ResultSet::Result::Linked ? "⊤" :
             result.linkStatus() == ResultSet::Result::NotLinked ? "⊥" : "?")
         << result.score()
-        << result.title()
-        << result.resource()
+        << (result.title() != result.resource() ? result.title() : QString())
+        << result.lastUpdate()
+        << result.resource().rightRef(20)
         ;
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic