Branch 'dev/fix_quickview' - 4 commits - korganizer/akonadicollectionview.cpp korganizer/views

Sandro Knauß knauss at kolabsys.com
Wed Nov 26 13:18:35 CET 2014


 korganizer/akonadicollectionview.cpp                 |    4 +--
 korganizer/views/collectionview/calendardelegate.cpp |    4 ---
 korganizer/views/collectionview/controller.cpp       |   24 ++++++++++++-------
 korganizer/views/collectionview/reparentingmodel.cpp |   14 ++++++++---
 korganizer/views/collectionview/reparentingmodel.h   |    1 
 5 files changed, 31 insertions(+), 16 deletions(-)

New commits:
commit 5d89dfd19c0c95f7313641424cfaec9265b6884f
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Nov 26 12:45:35 2014 +0100

    either show removefromlist or addfavorite but not both

diff --git a/korganizer/views/collectionview/calendardelegate.cpp b/korganizer/views/collectionview/calendardelegate.cpp
index 6633c93..263bdde 100644
--- a/korganizer/views/collectionview/calendardelegate.cpp
+++ b/korganizer/views/collectionview/calendardelegate.cpp
@@ -115,9 +115,7 @@ QList<StyledCalendarDelegate::Action> StyledCalendarDelegate::getActions(const Q
             if (hover) {
                 if (enabled != Qt::Checked) {
                     buttons << Enable;
-                }
-                //The remove button should not be available for person subfolders
-                if (!isChildOfPersonCollection(index)) {
+                } else if (!isChildOfPersonCollection(index)) {    //The remove button should not be available for person subfolders
                     buttons << RemoveFromList;
                 }
             } else {


commit 94e5f163b4e1196a05f6f0f24443ed4b3178f201
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Nov 26 12:42:49 2014 +0100

    Fixing reparentingmodel
    
    Make sure that the correct line is deleted and that the model is in good
    shape also after removing the line. To be able to use modeltest.

diff --git a/korganizer/views/collectionview/reparentingmodel.cpp b/korganizer/views/collectionview/reparentingmodel.cpp
index 15049e9..5a3e3fe 100644
--- a/korganizer/views/collectionview/reparentingmodel.cpp
+++ b/korganizer/views/collectionview/reparentingmodel.cpp
@@ -61,7 +61,7 @@ bool ReparentingModel::Node::operator==(const ReparentingModel::Node &node) cons
     return (this == &node);
 }
 
-void ReparentingModel::Node::reparent(ReparentingModel::Node *node)
+ReparentingModel::Node::Ptr ReparentingModel::Node::searchNode(ReparentingModel::Node *node)
 {
     Node::Ptr nodePtr;
     if (node->parent) {
@@ -79,6 +79,13 @@ void ReparentingModel::Node::reparent(ReparentingModel::Node *node)
     } else {
         nodePtr = Node::Ptr(node);
     }
+
+    return nodePtr;
+}
+
+void ReparentingModel::Node::reparent(ReparentingModel::Node *node)
+{
+    Node::Ptr nodePtr = searchNode(node);
     addChild(nodePtr);
 }
 
@@ -719,14 +726,15 @@ void ReparentingModel::reparentSourceNodes(const Node::Ptr &proxyNode)
 
             //WARNING: While a beginMoveRows/endMoveRows would be more suitable, QSortFilterProxyModel can't deal with that. Therefore we
             //cannot use them.
-            const int oldRow = n->sourceIndex.row();
+            const int oldRow = n->row();
             beginRemoveRows(index(n->parent), oldRow, oldRow);
+            Node::Ptr nodePtr = proxyNode->searchNode(n);
             //We lie about the row being removed already, but the view can deal with that better than if we call endRemoveRows after beginInsertRows
             endRemoveRows();
 
             const int newRow = proxyNode->children.size();
             beginInsertRows(index(proxyNode.data()), newRow, newRow);
-            proxyNode->reparent(n);
+            proxyNode->addChild(nodePtr);
             endInsertRows();
             Q_ASSERT(validateNode(n));
         }
diff --git a/korganizer/views/collectionview/reparentingmodel.h b/korganizer/views/collectionview/reparentingmodel.h
index 0f77c45..9455915 100644
--- a/korganizer/views/collectionview/reparentingmodel.h
+++ b/korganizer/views/collectionview/reparentingmodel.h
@@ -53,6 +53,7 @@ public:
         virtual void update(const Node::Ptr &node);
 
         bool isSourceNode() const;
+        Node::Ptr searchNode(Node *node);
         void reparent(Node *node);
         void addChild(const Node::Ptr &node);
         int row() const;


commit c53f24bcf297827c61ba48e761b262d86dd9ad6f
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Nov 26 13:12:33 2014 +0100

    Search for collection if a user is enabled.
    
    If a User is enabled from search, search for a matching collection is
    non was found before.
    
    KOLAB: #3967

diff --git a/korganizer/views/collectionview/controller.cpp b/korganizer/views/collectionview/controller.cpp
index b3ccea2..731e902 100644
--- a/korganizer/views/collectionview/controller.cpp
+++ b/korganizer/views/collectionview/controller.cpp
@@ -652,27 +652,31 @@ void Controller::onPersonCollectionsFetched(KJob* job)
 void Controller::addPerson(const Person &person)
 {
     kDebug() << person.uid << person.name << person.rootCollection;
+    Person p = person;
 
     if (person.rootCollection == -1) {
         Baloo::PIM::CollectionQuery query;
         query.setNamespace(QStringList() << QLatin1String("usertoplevel"));
-        query.pathMatches(QLatin1String("/Other Users/")+person.uid);
-        query.setLimit(200);
+        query.pathMatches(QLatin1String("/Other Users/")+p.uid);
+        query.setLimit(2);
         Baloo::PIM::ResultIterator it = query.exec();
         Akonadi::Collection::List collections;
         while (it.next()) {
             collections << Akonadi::Collection(it.id());
         }
-        kDebug() << "Found collections " << collections.size() << "for" << person.name;
-        //TODO: use the found collection and update attribute
+        kDebug() << "Found collections " << collections.size() << "for" << p.name;
+        if (collections.size() == 1) {
+            kDebug() << "Set rootCollection=" << collections.at(0).id();
+            p.rootCollection = collections.at(0).id();
+        }
     }
 
-    PersonNode *personNode = new PersonNode(*mPersonModel, person);
+    PersonNode *personNode = new PersonNode(*mPersonModel, p);
     personNode->setChecked(true);
     mPersonModel->addNode(ReparentingModel::Node::Ptr(personNode));
 
-    if (person.rootCollection > -1) {
-        setCollectionState(Akonadi::Collection(person.rootCollection), Referenced, true);
+    if (p.rootCollection > -1) {
+        setCollectionState(Akonadi::Collection(p.rootCollection), Referenced, true);
     } else {
         kDebug() << "well this only a ldap search object without a collection";
         //TODO: use freebusy data into calendar


commit 655cd1a73a232fcf0b65b26b77fa6df1f4563f26
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Nov 26 12:57:08 2014 +0100

    get the correct collection for collection/Person node
    * use the collection that is assosated with the currect index for quickview
    * we need the correct collection also for enable the correcdt collection
      for the saarch of personal calendars.
    
    KOLAB: #3934

diff --git a/korganizer/akonadicollectionview.cpp b/korganizer/akonadicollectionview.cpp
index 19e3eae..5d27815 100644
--- a/korganizer/akonadicollectionview.cpp
+++ b/korganizer/akonadicollectionview.cpp
@@ -1076,12 +1076,12 @@ void AkonadiCollectionView::onAction(const QModelIndex &index, int a)
                 person = i.data(PersonRole);
             }
             if (person.isValid()) {
-                Quickview *quickview = new Quickview(person.value<Person>(), Akonadi::Collection(person.value<Person>().rootCollection));
+                Quickview *quickview = new Quickview(person.value<Person>(), CalendarSupport::collectionFromIndex(index));
                 quickview->setAttribute(Qt::WA_DeleteOnClose, true);
                 quickview->show();
             } else {
                 kWarning() << "No valid person found for" << index;
-                Quickview *quickview = new Quickview(Person(), index.data(CollectionRole).value<Akonadi::Collection>());
+                Quickview *quickview = new Quickview(Person(), CalendarSupport::collectionFromIndex(index));
                 quickview->setAttribute(Qt::WA_DeleteOnClose, true);
                 quickview->show();
             }
diff --git a/korganizer/views/collectionview/controller.cpp b/korganizer/views/collectionview/controller.cpp
index 0500b60..b3ccea2 100644
--- a/korganizer/views/collectionview/controller.cpp
+++ b/korganizer/views/collectionview/controller.cpp
@@ -88,7 +88,7 @@ QVariant CollectionNode::data(int role) const
     if (role == IsSearchResultRole) {
         return isSearchNode;
     }
-    if (role == CollectionRole) {
+    if (role == CollectionRole || role == Akonadi::EntityTreeModel::CollectionRole) {
         return QVariant::fromValue(mCollection);
     }
     if (role == NodeTypeRole) {
@@ -182,6 +182,10 @@ QVariant PersonNode::data(int role) const
     if (role == NodeTypeRole) {
         return PersonNodeRole;
     }
+    if (role == CollectionRole || role == Akonadi::EntityTreeModel::CollectionRole) {
+        return QVariant::fromValue(Akonadi::Collection(mPerson.rootCollection));
+    }
+
     return QVariant();
 }
 




More information about the commits mailing list