Branch 'kolab/integration/4.13.0' - 6 commits - korganizer/akonadicollectionview.cpp korganizer/views

Christian Mollekopf mollekopf at kolabsys.com
Wed Oct 15 09:39:34 CEST 2014


 korganizer/akonadicollectionview.cpp                           |   44 +++++-----
 korganizer/views/collectionview/calendardelegate.cpp           |   17 ++-
 korganizer/views/collectionview/controller.cpp                 |   32 +++----
 korganizer/views/collectionview/controller.h                   |    4 
 korganizer/views/collectionview/quickview.cpp                  |    8 -
 korganizer/views/collectionview/reparentingmodel.cpp           |   33 ++++---
 korganizer/views/collectionview/reparentingmodel.h             |    1 
 korganizer/views/collectionview/tests/reparentingmodeltest.cpp |   29 ++++++
 8 files changed, 103 insertions(+), 65 deletions(-)

New commits:
commit 2c96a55b177c3c0d0a780290b0e935d9e040ee28
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Wed Oct 15 09:25:48 2014 +0200

    ReparentingModel: Fixed filtering in model
    
    dataChanged still needs to be emitted (because the data changed), and we can't
    use the move signals since QSortFilterProxyModel doesn't handle them.

diff --git a/korganizer/views/collectionview/reparentingmodel.cpp b/korganizer/views/collectionview/reparentingmodel.cpp
index e0625c8..15049e9 100644
--- a/korganizer/views/collectionview/reparentingmodel.cpp
+++ b/korganizer/views/collectionview/reparentingmodel.cpp
@@ -592,6 +592,7 @@ void ReparentingModel::onSourceDataChanged(QModelIndex begin, QModelIndex end)
     for (int row = begin.row(); row <= end.row(); row++) {
         mNodeManager->updateSourceIndex(sourceModel()->index(row, begin.column(), begin.parent()));
     }
+    emit dataChanged(mapFromSource(begin), mapFromSource(end));
 }
 
 void ReparentingModel::onSourceModelAboutToBeReset()
@@ -715,12 +716,18 @@ void ReparentingModel::reparentSourceNodes(const Node::Ptr &proxyNode)
         if (proxyNode->adopts(n->sourceIndex)) {
             //kDebug() << "reparenting" << n->data(Qt::DisplayRole).toString() << "from" << n->parent->data(Qt::DisplayRole).toString()
             //         << "to" << proxyNode->data(Qt::DisplayRole).toString();
-            const int oldRow = row(n);
+
+            //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();
+            beginRemoveRows(index(n->parent), oldRow, oldRow);
+            //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();
-            beginMoveRows(index(n->parent), oldRow, oldRow,
-                          index(proxyNode.data()), newRow);
+            beginInsertRows(index(proxyNode.data()), newRow, newRow);
             proxyNode->reparent(n);
-            endMoveRows();
+            endInsertRows();
             Q_ASSERT(validateNode(n));
         }
     }
diff --git a/korganizer/views/collectionview/tests/reparentingmodeltest.cpp b/korganizer/views/collectionview/tests/reparentingmodeltest.cpp
index bfb8820..22fd2d8 100644
--- a/korganizer/views/collectionview/tests/reparentingmodeltest.cpp
+++ b/korganizer/views/collectionview/tests/reparentingmodeltest.cpp
@@ -174,6 +174,7 @@ private Q_SLOTS:
     void testInvalidLayoutChanged();
     void testAddRemoveNodeByNodeManager();
     void testRemoveNodeByNodeManagerWithDataChanged();
+    void testDataChanged();
 };
 
 void ReparentingModelTest::testPopulation()
@@ -746,8 +747,27 @@ void ReparentingModelTest::testRemoveNodeByNodeManagerWithDataChanged()
     QVERIFY(!getIndex("personfolder", reparentingModel).isValid());
 }
 
+void ReparentingModelTest::testDataChanged()
+{
+    QStandardItemModel sourceModel;
+    QStandardItem *item = new QStandardItem(QLatin1String("folder"));
+    sourceModel.appendRow(item);
+    ReparentingModel reparentingModel;
+    reparentingModel.setNodeManager(ReparentingModel::NodeManager::Ptr(new DummyNodeManager(reparentingModel)));
+    reparentingModel.setSourceModel(&sourceModel);
+    ModelSignalSpy spy(reparentingModel);
+
+    QTest::qWait(0);
+
+    //Trigger data changed
+    item->setStatusTip(QLatin1String("sldkfjlfsj"));
+
+    QTest::qWait(0);
+
+    QCOMPARE(spy.mSignals, QStringList() << QLatin1String("dataChanged"));
+}
 
 QTEST_MAIN(ReparentingModelTest)
 
 #include "reparentingmodeltest.moc"
-    
+


commit f5ab940aea77c97a438a2b51304802aa8efa0dc7
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Wed Oct 15 00:28:22 2014 +0200

    CollectionFilter: QModelIndex::child doesn't work on an invalid index

diff --git a/korganizer/akonadicollectionview.cpp b/korganizer/akonadicollectionview.cpp
index 80368f9..6eb2908 100644
--- a/korganizer/akonadicollectionview.cpp
+++ b/korganizer/akonadicollectionview.cpp
@@ -347,7 +347,8 @@ class CollectionFilter : public QSortFilterProxyModel
 
   protected:
     virtual bool filterAcceptsRow(int row, const QModelIndex &sourceParent) const {
-        const QModelIndex sourceIndex = sourceParent.child(row, 0);
+        const QModelIndex sourceIndex = sourceModel()->index(row, 0, sourceParent);
+        Q_ASSERT(sourceIndex.isValid());
         const Akonadi::Collection &col = sourceIndex.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
         CollectionIdentificationAttribute *attr = col.attribute<CollectionIdentificationAttribute>();
         //We filter the user folders because we insert person nodes for user folders.


commit 1f5a8fac797026bc25cd5deebf438132d1289c69
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Tue Oct 14 10:17:44 2014 +0200

    ReparentingModel: Simplified and clearer update mechanism.
    
    Instead of replacing the complete node, which was just a workaround to the
    reparentingmodel not knowing anything about the personnode, we delegate that
    work to the node itself.

diff --git a/korganizer/views/collectionview/controller.cpp b/korganizer/views/collectionview/controller.cpp
index d30a640..d91497e 100644
--- a/korganizer/views/collectionview/controller.cpp
+++ b/korganizer/views/collectionview/controller.cpp
@@ -216,6 +216,11 @@ bool PersonNode::isDuplicateOf(const QModelIndex& sourceIndex)
     return (sourceIndex.data(PersonRole).value<Person>().uid == mPerson.uid);
 }
 
+void PersonNode::update(const Node::Ptr &node)
+{
+    mPerson = node.staticCast<PersonNode>()->mPerson;
+}
+
 Person PersonNodeManager::person(const QModelIndex &sourceIndex)
 {
     Person person;
diff --git a/korganizer/views/collectionview/controller.h b/korganizer/views/collectionview/controller.h
index 9eb38f9..af786aa 100644
--- a/korganizer/views/collectionview/controller.h
+++ b/korganizer/views/collectionview/controller.h
@@ -104,6 +104,7 @@ private:
     virtual bool setData(const QVariant& variant, int role);
     virtual bool adopts(const QModelIndex& sourceIndex);
     virtual bool isDuplicateOf(const QModelIndex& sourceIndex);
+    virtual void update(const Node::Ptr &node);
 
     Person mPerson;
     Qt::CheckState mCheckState;
diff --git a/korganizer/views/collectionview/reparentingmodel.cpp b/korganizer/views/collectionview/reparentingmodel.cpp
index 5ef1c89..e0625c8 100644
--- a/korganizer/views/collectionview/reparentingmodel.cpp
+++ b/korganizer/views/collectionview/reparentingmodel.cpp
@@ -117,6 +117,11 @@ bool ReparentingModel::Node::isDuplicateOf(const QModelIndex& /* sourceIndex */)
     return false;
 }
 
+void ReparentingModel::Node::update(const Node::Ptr &/* node */)
+{
+
+}
+
 bool ReparentingModel::Node::isSourceNode() const
 {
     return mIsSourceNode;
@@ -278,17 +283,8 @@ void ReparentingModel::updateNode(const ReparentingModel::Node::Ptr &node)
 {
     Q_FOREACH(const ReparentingModel::Node::Ptr &existing, mProxyNodes) {
         if (*existing == *node) {
-            node->parent = existing->parent;
-            node->children = existing->children;
-            Q_FOREACH(ReparentingModel::Node::Ptr child, existing->children) {
-                child->parent = node.data();
-            }
-            node->sourceIndex = existing->sourceIndex;
-            int r = row(existing.data());
-            mProxyNodes.replace(mProxyNodes.indexOf(existing), node);
-            existing->parent->children.replace(r, node);
-            const QModelIndex i = index(node.data());
-            Q_ASSERT(i.row() == r);
+            existing->update(node);
+            const QModelIndex i = index(existing.data());
             emit dataChanged(i, i);
             return;
         }
diff --git a/korganizer/views/collectionview/reparentingmodel.h b/korganizer/views/collectionview/reparentingmodel.h
index ff66a4b..0f77c45 100644
--- a/korganizer/views/collectionview/reparentingmodel.h
+++ b/korganizer/views/collectionview/reparentingmodel.h
@@ -50,6 +50,7 @@ public:
         virtual bool setData(const QVariant &variant, int role);
         virtual bool adopts(const QModelIndex &sourceIndex);
         virtual bool isDuplicateOf(const QModelIndex &sourceIndex);
+        virtual void update(const Node::Ptr &node);
 
         bool isSourceNode() const;
         void reparent(Node *node);
diff --git a/korganizer/views/collectionview/tests/reparentingmodeltest.cpp b/korganizer/views/collectionview/tests/reparentingmodeltest.cpp
index 6fb5526..bfb8820 100644
--- a/korganizer/views/collectionview/tests/reparentingmodeltest.cpp
+++ b/korganizer/views/collectionview/tests/reparentingmodeltest.cpp
@@ -76,6 +76,13 @@ private:
         return sourceIndex.data().toString().contains(mParent);
     }
 
+    void update(const Node::Ptr &node)
+    {
+        mName = node.staticCast<DummyNode>()->mName;
+        mData = node.staticCast<DummyNode>()->mData;
+    }
+
+
     QString mName;
     QString mData;
 };
@@ -743,4 +750,4 @@ void ReparentingModelTest::testRemoveNodeByNodeManagerWithDataChanged()
 QTEST_MAIN(ReparentingModelTest)
 
 #include "reparentingmodeltest.moc"
-    
\ No newline at end of file
+    


commit add7bfada9565b3b66db5edbee82eeec837ef94a
Merge: 8d91eb0 4a8d069
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Tue Oct 14 08:32:15 2014 +0200

    Merge remote-tracking branch 'kolab/kolab/integration/4.13.0' into kolab/integration/4.13.0
    
    Conflicts:
    	korganizer/views/collectionview/controller.cpp

diff --cc korganizer/views/collectionview/controller.cpp
index 8f7808c,d2b903f..d30a640
--- a/korganizer/views/collectionview/controller.cpp
+++ b/korganizer/views/collectionview/controller.cpp
@@@ -230,32 -233,36 +228,36 @@@ Person PersonNodeManager::person(const 
              person.ou = QString::fromUtf8(attr->ou());
              person.uid = col.name();
              person.rootCollection = col.id();
- 
-             model.addNode(ReparentingModel::Node::Ptr(new PersonNode(model, person)));
          }
      }
+     return person;
  }
  
- void PersonNodeManager::checkSourceIndexRemoval(const QModelIndex &sourceIndex)
+ void PersonNodeManager::checkSourceIndex(const QModelIndex &sourceIndex)
  {
-     const Akonadi::Collection col = sourceIndex.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
-     // kDebug() << col.displayName() << col.enabled();
-     if (col.isValid()) {
-         CollectionIdentificationAttribute *attr = col.attribute<CollectionIdentificationAttribute>();
-         if (attr && attr->collectionNamespace() == "usertoplevel") {
-             kDebug() << "Found user folder, removing person node " << col.displayName();
-             Person person;
-             person.name = col.displayName();
-             person.mail = QString::fromUtf8(attr->mail());
-             person.ou = QString::fromUtf8(attr->ou());
-             person.uid = col.name();
-             person.rootCollection = col.id();
-             model.removeNode(PersonNode(model, person));
-         }
+     const Person &p = person(sourceIndex);
+     if (p.rootCollection > -1) {
 -        model.addNode(ReparentingModel::Node::Ptr(new PersonNode(model, p, sourceIndex)));
++        model.addNode(ReparentingModel::Node::Ptr(new PersonNode(model, p)));
+     }
+ }
+ 
+ void PersonNodeManager::updateSourceIndex(const QModelIndex &sourceIndex)
+ {
+     const Person &p = person(sourceIndex);
+     if (p.rootCollection > -1) {
 -        model.updateNode(ReparentingModel::Node::Ptr(new PersonNode(model, p, sourceIndex)));
++        model.updateNode(ReparentingModel::Node::Ptr(new PersonNode(model, p)));
      }
  }
  
  
+ void PersonNodeManager::checkSourceIndexRemoval(const QModelIndex &sourceIndex)
+ {
+     const Person &p = person(sourceIndex);
+     if (p.rootCollection > -1) {
 -        model.removeNode(PersonNode(model, p, sourceIndex));
++        model.removeNode(PersonNode(model, p));
+     }
+ }
+ 
  CollectionSearchJob::CollectionSearchJob(const QString& searchString, QObject* parent)
      : KJob(parent),
      mSearchString(searchString)


commit 8d91eb02ce32c8eae149978b1d6b5f1093099511
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Mon Oct 13 22:36:10 2014 +0200

    Korganizer: Add quickview for person collections
    
    KOLAB: #3054

diff --git a/korganizer/CMakeLists.txt b/korganizer/CMakeLists.txt
index b1e0bb3..5c7645e 100644
--- a/korganizer/CMakeLists.txt
+++ b/korganizer/CMakeLists.txt
@@ -176,6 +176,7 @@ set(korganizerprivate_LIB_SRCS
     views/collectionview/reparentingmodel.cpp
     views/collectionview/controller.cpp
     views/collectionview/calendardelegate.cpp
+    views/collectionview/quickview.cpp
     calendarview.cpp
     datechecker.cpp
     datenavigator.cpp
@@ -224,6 +225,7 @@ set(korganizerprivate_LIB_SRCS
     publishdialog_base.ui
     searchdialog_base.ui
     timescaleedit_base.ui
+    views/collectionview/quickview.ui
   )
 
   qt4_add_resources(korganizerprivate_LIB_SRCS
diff --git a/korganizer/akonadicollectionview.cpp b/korganizer/akonadicollectionview.cpp
index c562255..8723710 100644
--- a/korganizer/akonadicollectionview.cpp
+++ b/korganizer/akonadicollectionview.cpp
@@ -33,6 +33,8 @@
 #include "koglobals.h"
 #include "views/collectionview/reparentingmodel.h"
 #include "views/collectionview/calendardelegate.h"
+#include "views/collectionview/quickview.h"
+
 
 #include <calendarsupport/kcalprefs.h>
 #include <calendarsupport/utils.h>
@@ -349,8 +351,8 @@ class CollectionFilter : public QSortFilterProxyModel
         const Akonadi::Collection &col = sourceIndex.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
         CollectionIdentificationAttribute *attr = col.attribute<CollectionIdentificationAttribute>();
         //We filter the user folders because we insert person nodes for user folders.
-        if (attr && ((attr->collectionNamespace() == "usertoplevel") || (attr->collectionNamespace() == "usertoplevel"))
-                || (col.name().contains(QLatin1String("Other Users")))) {
+        if ( (attr && attr->collectionNamespace().startsWith("user"))
+                || col.name().contains(QLatin1String("Other Users"))) {
             return false;
         }
         return true;
@@ -1018,41 +1020,61 @@ void AkonadiCollectionView::onAction(const QModelIndex &index, int a)
     const StyledCalendarDelegate::Action action = static_cast<StyledCalendarDelegate::Action>(a);
     switch (action) {
         case StyledCalendarDelegate::AddToList: {
-            const Akonadi::Collection col = index.data(CollectionRole).value<Akonadi::Collection>();
-            if (col.isValid()) {
-                mController->setCollectionState(col, Controller::Referenced);
+            const QVariant var = index.data(PersonRole);
+            if (var.isValid()) {
+                mController->addPerson(var.value<Person>());
             } else {
-                const QVariant var = index.data(PersonRole);
-                if (var.isValid()) {
-                    mController->addPerson(var.value<Person>());
+                const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
+                if (col.isValid()) {
+                    mController->setCollectionState(col, Controller::Referenced);
                 }
             }
         }
         break;
         case StyledCalendarDelegate::RemoveFromList: {
-            const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
-            if (col.isValid()) {
-                mController->setCollectionState(col, Controller::Disabled);
+            const QVariant var = index.data(PersonRole);
+            if (var.isValid()) {
+                kDebug() << "person";
+                mController->removePerson(var.value<Person>());
             } else {
-                const QVariant var = index.data(PersonRole);
-                if (var.isValid()) {
-                    mController->removePerson(var.value<Person>());
+                const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
+                if (col.isValid()) {
+                    mController->setCollectionState(col, Controller::Disabled);
                 }
             }
         }
         break;
         case StyledCalendarDelegate::Enable: {
-            const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
-            if (col.isValid()) {
-                mController->setCollectionState(col, Controller::Enabled);
+            const QVariant var = index.data(PersonRole);
+            if (var.isValid()) {
+                mController->setCollectionState(Akonadi::Collection(var.value<Person>().rootCollection), Controller::Enabled, true);
             } else {
-                const QVariant var = index.data(PersonRole);
-                if (var.isValid()) {
-                    mController->setCollectionState(Akonadi::Collection(var.value<Person>().rootCollection), Controller::Enabled, true);
+                const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
+                if (col.isValid()) {
+                    mController->setCollectionState(col, Controller::Enabled);
                 }
             }
         }
         break;
+        case StyledCalendarDelegate::Quickview: {
+            QVariant person = index.data(PersonRole);
+            QModelIndex i = index;
+            while (!person.isValid()) {
+                i = i.parent();
+                if (!i.isValid()) {
+                    break;
+                }
+                person = i.data(PersonRole);
+            }
+            if (person.isValid()) {
+                Quickview *quickview = new Quickview(person.value<Person>(), Akonadi::Collection(person.value<Person>().rootCollection));
+                quickview->setAttribute(Qt::WA_DeleteOnClose, true);
+                quickview->show();
+            } else {
+                kWarning() << "No valid person found for" << index;
+            }
+        }
+        break;
     }
 }
 
diff --git a/korganizer/views/collectionview/calendardelegate.cpp b/korganizer/views/collectionview/calendardelegate.cpp
index ee29a3e..e5d9eda 100644
--- a/korganizer/views/collectionview/calendardelegate.cpp
+++ b/korganizer/views/collectionview/calendardelegate.cpp
@@ -35,6 +35,7 @@ StyledCalendarDelegate::StyledCalendarDelegate(QObject * parent)
     mPixmap.insert(Enable, KIconLoader().loadIcon(QLatin1String("bookmarks"), KIconLoader::Small));
     mPixmap.insert(RemoveFromList, KIconLoader().loadIcon(QLatin1String("list-remove"), KIconLoader::Small));
     mPixmap.insert(AddToList, KIconLoader().loadIcon(QLatin1String("list-add"), KIconLoader::Small));
+    mPixmap.insert(Quickview, KIconLoader().loadIcon(QLatin1String("quickview"), KIconLoader::Small));
 }
 
 StyledCalendarDelegate::~StyledCalendarDelegate()
@@ -85,6 +86,14 @@ static bool isChildOfPersonCollection(const QModelIndex &index)
     return false;
 }
 
+static bool isPersonNode(const QModelIndex &index)
+{
+    if (index.data(NodeTypeRole).toInt() == PersonNodeRole) {
+        return true;
+    }
+    return false;
+}
+
 QList<StyledCalendarDelegate::Action> StyledCalendarDelegate::getActions(const QStyleOptionViewItem &option, const QModelIndex &index) const
 {
     const bool isSearchResult = index.data(IsSearchResultRole).toBool();
@@ -111,6 +120,9 @@ QList<StyledCalendarDelegate::Action> StyledCalendarDelegate::getActions(const Q
             }
         }
     }
+    if (isPersonNode(index)) {
+        buttons << Quickview;
+    }
     return buttons;
 }
 
@@ -181,14 +193,11 @@ bool StyledCalendarDelegate::editorEvent(QEvent *event,
 
         QMouseEvent *me = static_cast<QMouseEvent*>(event);
 
-        if (enableButtonRect(option.rect, 1).contains(me->pos())) {
-            button = 1;
-        }
-        if (enableButtonRect(option.rect, 2).contains(me->pos())) {
-            button = 2;
-        }
-        if (enableButtonRect(option.rect, 3).contains(me->pos())) {
-            button = 3;
+        for (int i = 1; i < 4; i++) {
+            if (enableButtonRect(option.rect, i).contains(me->pos())) {
+                button = i;
+                break;
+            }
         }
         if (me->button() != Qt::LeftButton || button < 0) {
             return QStyledItemDelegate::editorEvent(event, model, option, index);
@@ -206,11 +215,13 @@ bool StyledCalendarDelegate::editorEvent(QEvent *event,
     QStyleOptionViewItem opt = option;
     opt.state |= QStyle::State_MouseOver;
 
-    const Action a = getActions(opt, index).at(button - 1);
-    // kDebug() << "Button clicked: " << a;
-    emit action(index, a);
-
-    return true;
+    QList<StyledCalendarDelegate::Action> actions = getActions(opt, index);
+    if (actions.count() >= button) {
+        const Action a = actions.at(button - 1);
+        emit action(index, a);
+        return true;
+    }
+    return QStyledItemDelegate::editorEvent(event, model, option, index);
 }
 
 QSize StyledCalendarDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
diff --git a/korganizer/views/collectionview/calendardelegate.h b/korganizer/views/collectionview/calendardelegate.h
index 788a1d3..0be37f6 100644
--- a/korganizer/views/collectionview/calendardelegate.h
+++ b/korganizer/views/collectionview/calendardelegate.h
@@ -35,7 +35,8 @@ public:
     enum Action {
         AddToList,
         RemoveFromList,
-        Enable
+        Enable,
+        Quickview
     };
 
 Q_SIGNALS:
diff --git a/korganizer/views/collectionview/quickview.cpp b/korganizer/views/collectionview/quickview.cpp
new file mode 100644
index 0000000..bfb7ce3
--- /dev/null
+++ b/korganizer/views/collectionview/quickview.cpp
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+//http://stackoverflow.com/questions/18831242/qt-start-editing-of-cell-after-one-click
+
+#include "quickview.h"
+#include "ui_quickview.h"
+
+#include <KCalCore/Event>
+#include <KCalCore/FreeBusy>
+#include <KCalCore/MemoryCalendar>
+#include <akonadi/entitydisplayattribute.h>
+#include <akonadi/changerecorder.h>
+#include <akonadi/itemfetchscope.h>
+
+#include <calendarviews/agenda/agendaview.h>
+#include <calendarviews/agenda/viewcalendar.h>
+#include <calendarsupport/calendarsingleton.h>
+
+#include <freebusymodel/freebusycalendar.h>
+
+#include <KDebug>
+#include <KSystemTimeZones>
+#include <KCheckableProxyModel>
+
+class FreebusyViewCalendar : public EventViews::ViewCalendar
+{
+public:
+    virtual ~FreebusyViewCalendar() {};
+    virtual bool isValid(const KCalCore::Incidence::Ptr &incidence) const
+    {
+        return incidence->uid().startsWith(QLatin1String("fb-"));
+    }
+
+    virtual QString displayName(const KCalCore::Incidence::Ptr &incidence) const
+    {
+        Q_UNUSED(incidence);
+        return i18n("Freebusycalendar from %1").arg(name);
+    }
+
+    virtual QColor resourceColor(const KCalCore::Incidence::Ptr &incidence) const
+    {
+        bool ok = false;
+        int status = incidence->customProperty("FREEBUSY", "STATUS").toInt(&ok);
+
+        if (!ok) {
+            return QColor("#555");
+        }
+
+        switch (status) {
+        case KCalCore::FreeBusyPeriod::Busy:
+            return QColor("#f00");
+        case KCalCore::FreeBusyPeriod::BusyTentative:
+        case KCalCore::FreeBusyPeriod::BusyUnavailable:
+            return QColor("#f70");
+        case KCalCore::FreeBusyPeriod::Free:
+            return QColor("#0f0");
+        default:
+            return QColor("#555");
+        }
+    }
+
+    virtual QString iconForIncidence(const KCalCore::Incidence::Ptr &incidence) const
+    {
+        return QString();
+    }
+
+    virtual KCalCore::Calendar::Ptr getCalendar() const
+    {
+        return mCalendar;
+    }
+
+    KCalCore::Calendar::Ptr mCalendar;
+    QString name;
+};
+
+Quickview::Quickview(const Person &person, const Akonadi::Collection &col)
+    : KDialog()
+    , mUi(new Ui_quickview)
+    , mPerson(person)
+    , mCollection(col)
+    , mDayRange(7)
+{
+    QWidget *w = new QWidget( this );
+    mUi->setupUi( w );
+    setMainWidget( w );
+
+    mAgendaView = new EventViews::AgendaView(QDate(), QDate(), false,  false);
+
+    //show fbcalendar for person in quickview
+    if (!person.mail.isEmpty()) {
+        FreeBusyItemModel *model = new FreeBusyItemModel(this);
+        FreeBusyCalendar *fbCal = new FreeBusyCalendar(this);
+        FreebusyViewCalendar *fbCalendar = new FreebusyViewCalendar();
+        KCalCore::Attendee::Ptr attendee(new KCalCore::Attendee(person.name,  person.mail));
+        FreeBusyItem::Ptr freebusy( new FreeBusyItem( attendee, this ));
+
+        fbCal->setModel(model);
+        model->addItem(freebusy);
+        fbCalendar->mCalendar = fbCal->calendar();
+        fbCalendar->name = attendee->fullName();
+        mAgendaView->addCalendar(EventViews::ViewCalendar::Ptr(fbCalendar));
+    }
+
+    if (mCollection.isValid()) {
+        //create etm for mCollection
+        Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder(this);
+        Akonadi::ItemFetchScope scope;
+        QStringList allMimeTypes;
+
+        allMimeTypes << KCalCore::Event::eventMimeType() << KCalCore::Todo::todoMimeType()
+                     << KCalCore::Journal::journalMimeType();
+
+        scope.fetchFullPayload(true);
+        scope.fetchAttribute<Akonadi::EntityDisplayAttribute>();
+
+        monitor->setCollectionMonitored(mCollection);
+        monitor->fetchCollection(true);
+        monitor->setItemFetchScope(scope);
+        monitor->setAllMonitored(true);
+
+        foreach(const QString &mimetype, allMimeTypes) {
+            monitor->setMimeTypeMonitored(mimetype, true);
+        }
+
+        Akonadi::ETMCalendar::Ptr calendar = Akonadi::ETMCalendar::Ptr(new Akonadi::ETMCalendar(monitor));
+
+        calendar->setCollectionFilteringEnabled(false);
+        mAgendaView->setCalendar(calendar);
+    }
+    mUi->calender->addWidget( mAgendaView );
+
+    connect(mUi->mTodayBtn, SIGNAL(clicked(bool)), SLOT(onTodayClicked()));
+    connect(mUi->mNextBtn, SIGNAL(clicked(bool)), SLOT(onNextClicked()));
+    connect(mUi->mPreviousBtn, SIGNAL(clicked(bool)), SLOT(onPreviousClicked()));
+
+    onTodayClicked();
+}
+
+Quickview::~Quickview()
+{
+    delete mUi;
+}
+
+void Quickview::onNextClicked()
+{
+    QDate start = mAgendaView->startDate().addDays(mDayRange);
+    mAgendaView->showDates(start, start.addDays(mDayRange-1));
+}
+
+void Quickview::onPreviousClicked()
+{
+    QDate start = mAgendaView->startDate().addDays(-mDayRange);
+    mAgendaView->showDates(start, start.addDays(mDayRange-1));
+}
+
+void Quickview::onTodayClicked()
+{
+    QDate start = QDate::currentDate();
+    start = start.addDays(-QDate::currentDate().dayOfWeek()+1);
+    mAgendaView->showDates(start, start.addDays(mDayRange-1));
+}
+
+
+#include "quickview.moc"
diff --git a/korganizer/views/collectionview/quickview.h b/korganizer/views/collectionview/quickview.h
new file mode 100644
index 0000000..d296887
--- /dev/null
+++ b/korganizer/views/collectionview/quickview.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License or (at your option) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef KORG_QUICKVIEW_H
+#define KORG_QUICKVIEW_H
+
+#include "controller.h"
+
+#include <calendarviews/agenda/viewcalendar.h>
+
+#include <KCalCore/FreeBusy>
+#include <KDialog>
+
+#include <QStringList>
+#include <QStringListModel>
+
+class  Ui_quickview;
+
+namespace EventViews
+{
+    class AgendaView;
+}
+
+class Quickview : public KDialog
+{
+    Q_OBJECT
+public:
+    Quickview(const Person &person, const Akonadi::Collection &col);
+    virtual ~Quickview();
+
+private slots:
+    void onTodayClicked();
+    void onNextClicked();
+    void onPreviousClicked();
+
+private:
+    Ui_quickview *mUi;
+    EventViews::AgendaView *mAgendaView;
+    Person mPerson;
+    Akonadi::Collection mCollection;
+    int mDayRange;
+};
+
+#endif // QUICKVIEW_H
diff --git a/korganizer/views/collectionview/quickview.ui b/korganizer/views/collectionview/quickview.ui
new file mode 100644
index 0000000..8854b60
--- /dev/null
+++ b/korganizer/views/collectionview/quickview.ui
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>quickview</class>
+ <widget class="QWidget" name="quickview">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>552</width>
+    <height>566</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QPushButton" name="mDayBtn">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string>Day</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="mWeekBtn">
+       <property name="text">
+        <string>Week</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="mMothBtn">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string>Month</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="mAgendaBtn">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string>Agenda</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="mPreviousBtn">
+       <property name="enabled">
+        <bool>true</bool>
+       </property>
+       <property name="text">
+        <string><</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="mTodayBtn">
+       <property name="enabled">
+        <bool>true</bool>
+       </property>
+       <property name="text">
+        <string>Today</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="mNextBtn">
+       <property name="enabled">
+        <bool>true</bool>
+       </property>
+       <property name="text">
+        <string>></string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="calender">
+     <property name="sizeConstraint">
+      <enum>QLayout::SetDefaultConstraint</enum>
+     </property>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>


commit 2cfb1a7726b26798f48112d19124623eec99cced
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Mon Oct 13 16:20:36 2014 +0200

    Revert "Korganizer: Add quickview for person collections"
    
    This reverts commit e252dae1d9ef3d07ebd3fee788142f3f6a85f89e.

diff --git a/korganizer/CMakeLists.txt b/korganizer/CMakeLists.txt
index 5c7645e..b1e0bb3 100644
--- a/korganizer/CMakeLists.txt
+++ b/korganizer/CMakeLists.txt
@@ -176,7 +176,6 @@ set(korganizerprivate_LIB_SRCS
     views/collectionview/reparentingmodel.cpp
     views/collectionview/controller.cpp
     views/collectionview/calendardelegate.cpp
-    views/collectionview/quickview.cpp
     calendarview.cpp
     datechecker.cpp
     datenavigator.cpp
@@ -225,7 +224,6 @@ set(korganizerprivate_LIB_SRCS
     publishdialog_base.ui
     searchdialog_base.ui
     timescaleedit_base.ui
-    views/collectionview/quickview.ui
   )
 
   qt4_add_resources(korganizerprivate_LIB_SRCS
diff --git a/korganizer/akonadicollectionview.cpp b/korganizer/akonadicollectionview.cpp
index 0de456e..c562255 100644
--- a/korganizer/akonadicollectionview.cpp
+++ b/korganizer/akonadicollectionview.cpp
@@ -33,8 +33,6 @@
 #include "koglobals.h"
 #include "views/collectionview/reparentingmodel.h"
 #include "views/collectionview/calendardelegate.h"
-#include "views/collectionview/quickview.h"
-
 
 #include <calendarsupport/kcalprefs.h>
 #include <calendarsupport/utils.h>
@@ -351,8 +349,8 @@ class CollectionFilter : public QSortFilterProxyModel
         const Akonadi::Collection &col = sourceIndex.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
         CollectionIdentificationAttribute *attr = col.attribute<CollectionIdentificationAttribute>();
         //We filter the user folders because we insert person nodes for user folders.
-        if ( (attr && attr->collectionNamespace().startsWith("user"))
-                || col.name().contains(QLatin1String("Other Users"))) {
+        if (attr && ((attr->collectionNamespace() == "usertoplevel") || (attr->collectionNamespace() == "usertoplevel"))
+                || (col.name().contains(QLatin1String("Other Users")))) {
             return false;
         }
         return true;
@@ -1020,7 +1018,7 @@ void AkonadiCollectionView::onAction(const QModelIndex &index, int a)
     const StyledCalendarDelegate::Action action = static_cast<StyledCalendarDelegate::Action>(a);
     switch (action) {
         case StyledCalendarDelegate::AddToList: {
-            const Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
+            const Akonadi::Collection col = index.data(CollectionRole).value<Akonadi::Collection>();
             if (col.isValid()) {
                 mController->setCollectionState(col, Controller::Referenced);
             } else {
@@ -1055,25 +1053,6 @@ void AkonadiCollectionView::onAction(const QModelIndex &index, int a)
             }
         }
         break;
-        case StyledCalendarDelegate::Quickview: {
-            QVariant person = index.data(PersonRole);
-            Akonadi::Collection col = CalendarSupport::collectionFromIndex(index);
-            QModelIndex i = index;
-            while (!person.isValid()) {
-                i = i.parent();
-                if (!i.isValid()) {
-                    break;
-                }
-                person = i.data(PersonRole);
-            }
-            if (person.isValid()) {
-                Quickview *quickview = new Quickview(person.value<Person>(), col);
-                quickview->show();
-            } else {
-                kWarning() << "No valid person found for" << index;
-            }
-        }
-        break;
     }
 }
 
diff --git a/korganizer/views/collectionview/calendardelegate.cpp b/korganizer/views/collectionview/calendardelegate.cpp
index e77c9c1..ee29a3e 100644
--- a/korganizer/views/collectionview/calendardelegate.cpp
+++ b/korganizer/views/collectionview/calendardelegate.cpp
@@ -28,7 +28,6 @@
 #include <calendarsupport/utils.h>
 #include <kohelper.h>
 #include "controller.h"
-#include <akonadi/collectionidentificationattribute.h>
 
 StyledCalendarDelegate::StyledCalendarDelegate(QObject * parent)
     : QStyledItemDelegate(parent)
@@ -36,7 +35,6 @@ StyledCalendarDelegate::StyledCalendarDelegate(QObject * parent)
     mPixmap.insert(Enable, KIconLoader().loadIcon(QLatin1String("bookmarks"), KIconLoader::Small));
     mPixmap.insert(RemoveFromList, KIconLoader().loadIcon(QLatin1String("list-remove"), KIconLoader::Small));
     mPixmap.insert(AddToList, KIconLoader().loadIcon(QLatin1String("list-add"), KIconLoader::Small));
-    mPixmap.insert(Quickview, KIconLoader().loadIcon(QLatin1String("quickview"), KIconLoader::Small));
 }
 
 StyledCalendarDelegate::~StyledCalendarDelegate()
@@ -96,11 +94,6 @@ QList<StyledCalendarDelegate::Action> StyledCalendarDelegate::getActions(const Q
     // kDebug() << index.data().toString() << enabled;
 
     QList<Action> buttons;
-
-    CollectionIdentificationAttribute *attr = col.attribute<CollectionIdentificationAttribute>();
-    if (attr && attr->collectionNamespace().startsWith("user")) {
-        buttons << Quickview;
-    }
     if (isSearchResult) {
         buttons << AddToList;
     } else {
@@ -188,11 +181,14 @@ bool StyledCalendarDelegate::editorEvent(QEvent *event,
 
         QMouseEvent *me = static_cast<QMouseEvent*>(event);
 
-        for (int i = 1; i < 4; i++) {
-            if (enableButtonRect(option.rect, i).contains(me->pos())) {
-                button = i;
-                break;
-            }
+        if (enableButtonRect(option.rect, 1).contains(me->pos())) {
+            button = 1;
+        }
+        if (enableButtonRect(option.rect, 2).contains(me->pos())) {
+            button = 2;
+        }
+        if (enableButtonRect(option.rect, 3).contains(me->pos())) {
+            button = 3;
         }
         if (me->button() != Qt::LeftButton || button < 0) {
             return QStyledItemDelegate::editorEvent(event, model, option, index);
@@ -210,13 +206,11 @@ bool StyledCalendarDelegate::editorEvent(QEvent *event,
     QStyleOptionViewItem opt = option;
     opt.state |= QStyle::State_MouseOver;
 
-    QList<StyledCalendarDelegate::Action> actions = getActions(opt, index);
-    if (actions.count() >= button) {
-        const Action a = actions.at(button - 1);
-        emit action(index, a);
-        return true;
-    }
-    return QStyledItemDelegate::editorEvent(event, model, option, index);
+    const Action a = getActions(opt, index).at(button - 1);
+    // kDebug() << "Button clicked: " << a;
+    emit action(index, a);
+
+    return true;
 }
 
 QSize StyledCalendarDelegate::sizeHint( const QStyleOptionViewItem &option, const QModelIndex &index ) const
diff --git a/korganizer/views/collectionview/calendardelegate.h b/korganizer/views/collectionview/calendardelegate.h
index 0be37f6..788a1d3 100644
--- a/korganizer/views/collectionview/calendardelegate.h
+++ b/korganizer/views/collectionview/calendardelegate.h
@@ -35,8 +35,7 @@ public:
     enum Action {
         AddToList,
         RemoveFromList,
-        Enable,
-        Quickview
+        Enable
     };
 
 Q_SIGNALS:
diff --git a/korganizer/views/collectionview/controller.cpp b/korganizer/views/collectionview/controller.cpp
index 7c83a3c..8f7808c 100644
--- a/korganizer/views/collectionview/controller.cpp
+++ b/korganizer/views/collectionview/controller.cpp
@@ -111,17 +111,15 @@ bool CollectionNode::isDuplicateOf(const QModelIndex& sourceIndex)
 }
 
 
-PersonNode::PersonNode(ReparentingModel& personModel, const Person& person, const QModelIndex &colIndex)
+PersonNode::PersonNode(ReparentingModel& personModel, const Person& person)
 :   Node(personModel),
     mPerson(person),
     mCheckState(Qt::Unchecked),
-    isSearchNode(false),
-    mCollectionIndex(colIndex)
+    isSearchNode(false)
 {
 
 }
 
-
 PersonNode::~PersonNode()
 {
 
@@ -182,12 +180,7 @@ QVariant PersonNode::data(int role) const
     if (role == NodeTypeRole) {
         return PersonNodeRole;
     }
-
-    if (mCollectionIndex.isValid()) {
-        return mCollectionIndex.data(role);
-    } else {
-        return QVariant();
-    }
+    return QVariant();
 }
 
 bool PersonNode::setData(const QVariant& value, int role)
@@ -220,7 +213,7 @@ bool PersonNode::adopts(const QModelIndex& sourceIndex)
 
 bool PersonNode::isDuplicateOf(const QModelIndex& sourceIndex)
 {
-    return (sourceIndex.data(PersonRole).value<Person>().uid == mPerson.uid);
+    return (sourceIndex.data(PersonRole).value<Person>().name == mPerson.name);
 }
 
 void PersonNodeManager::checkSourceIndex(const QModelIndex &sourceIndex)
@@ -238,7 +231,7 @@ void PersonNodeManager::checkSourceIndex(const QModelIndex &sourceIndex)
             person.uid = col.name();
             person.rootCollection = col.id();
 
-            model.addNode(ReparentingModel::Node::Ptr(new PersonNode(model, person, sourceIndex)));
+            model.addNode(ReparentingModel::Node::Ptr(new PersonNode(model, person)));
         }
     }
 }
@@ -257,7 +250,7 @@ void PersonNodeManager::checkSourceIndexRemoval(const QModelIndex &sourceIndex)
             person.ou = QString::fromUtf8(attr->ou());
             person.uid = col.name();
             person.rootCollection = col.id();
-            model.removeNode(PersonNode(model, person, sourceIndex));
+            model.removeNode(PersonNode(model, person));
         }
     }
 }
@@ -656,7 +649,7 @@ void Controller::onCollectionsFound(KJob* job)
 void Controller::onPersonsFound(const QList<Person> &persons)
 {
     Q_FOREACH(const Person &p, persons) {
-        PersonNode *personNode = new PersonNode(*mSearchModel, p, QModelIndex());
+        PersonNode *personNode = new PersonNode(*mSearchModel, p);
         personNode->isSearchNode = true;
         //toggled by the checkbox, results in person getting added to main model
         // connect(&personNode->emitter, SIGNAL(enabled(bool, Person)), this, SLOT(onPersonEnabled(bool, Person)));
@@ -666,7 +659,7 @@ void Controller::onPersonsFound(const QList<Person> &persons)
 
 void Controller::onPersonUpdate(const Person &person)
 {
-    PersonNode *personNode = new PersonNode(*mSearchModel, person, QModelIndex());
+    PersonNode *personNode = new PersonNode(*mSearchModel, person);
     personNode->isSearchNode = true;
     mSearchModel->updateNode(ReparentingModel::Node::Ptr(personNode));
 }
@@ -762,7 +755,7 @@ void Controller::addPerson(const Person &person)
         //TODO: use the found collection and update attribute
     }
 
-    PersonNode *personNode = new PersonNode(*mPersonModel, person, QModelIndex());
+    PersonNode *personNode = new PersonNode(*mPersonModel, person);
     personNode->setChecked(true);
     mPersonModel->addNode(ReparentingModel::Node::Ptr(personNode));
 
@@ -777,7 +770,7 @@ void Controller::addPerson(const Person &person)
 void Controller::removePerson(const Person &person)
 {
     kDebug() << person.uid << person.name << person.rootCollection;
-    mPersonModel->removeNode(PersonNode(*mPersonModel, person, QModelIndex()));
+    mPersonModel->removeNode(PersonNode(*mPersonModel, person));
 
     if (person.rootCollection > -1) {
         setCollectionState(Akonadi::Collection(person.rootCollection), Disabled, true);
diff --git a/korganizer/views/collectionview/controller.h b/korganizer/views/collectionview/controller.h
index 0f404a0..916078e 100644
--- a/korganizer/views/collectionview/controller.h
+++ b/korganizer/views/collectionview/controller.h
@@ -89,7 +89,7 @@ public:
 class PersonNode : public ReparentingModel::Node
 {
 public:
-    PersonNode(ReparentingModel &personModel, const Person &person, const QModelIndex &colIndex);
+    PersonNode(ReparentingModel &personModel, const Person &person);
     virtual ~PersonNode();
     virtual bool operator==(const Node &) const;
 
@@ -107,7 +107,6 @@ private:
 
     Person mPerson;
     Qt::CheckState mCheckState;
-    QModelIndex mCollectionIndex;
 };
 
 class CollectionNode : public ReparentingModel::Node
diff --git a/korganizer/views/collectionview/quickview.cpp b/korganizer/views/collectionview/quickview.cpp
deleted file mode 100644
index f9a7963..0000000
--- a/korganizer/views/collectionview/quickview.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2014  Sandro Knauß <knauss at kolabsys.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License or (at your option) version 3 or any later version
- * accepted by the membership of KDE e.V. (or its successor approved
- * by the membership of KDE e.V.), which shall act as a proxy
- * defined in Section 14 of version 3 of the license.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-//http://stackoverflow.com/questions/18831242/qt-start-editing-of-cell-after-one-click
-
-#include "quickview.h"
-#include "ui_quickview.h"
-
-#include <KCalCore/Event>
-#include <KCalCore/FreeBusy>
-#include <KCalCore/MemoryCalendar>
-#include <akonadi/entitydisplayattribute.h>
-#include <akonadi/changerecorder.h>
-#include <akonadi/itemfetchscope.h>
-
-#include <calendarviews/agenda/agendaview.h>
-#include <calendarviews/agenda/viewcalendar.h>
-#include <calendarsupport/calendarsingleton.h>
-
-#include <freebusymodel/freebusycalendar.h>
-
-#include <KDebug>
-#include <KSystemTimeZones>
-#include <KCheckableProxyModel>
-
-class FreebusyViewCalendar : public EventViews::ViewCalendar
-{
-public:
-    virtual ~FreebusyViewCalendar() {};
-    virtual bool isValid(const KCalCore::Incidence::Ptr &incidence) const
-    {
-        return incidence->uid().startsWith(QLatin1String("fb-"));
-    }
-
-    virtual QString displayName(const KCalCore::Incidence::Ptr &incidence) const
-    {
-        Q_UNUSED(incidence);
-        return i18n("Freebusycalendar from %1").arg(name);
-    }
-
-    virtual QColor resourceColor(const KCalCore::Incidence::Ptr &incidence) const
-    {
-        bool ok = false;
-        int status = incidence->customProperty("FREEBUSY", "STATUS").toInt(&ok);
-
-        if (!ok) {
-            return QColor("#555");
-        }
-
-        switch (status) {
-        case KCalCore::FreeBusyPeriod::Busy:
-            return QColor("#f00");
-        case KCalCore::FreeBusyPeriod::BusyTentative:
-        case KCalCore::FreeBusyPeriod::BusyUnavailable:
-            return QColor("#f70");
-        case KCalCore::FreeBusyPeriod::Free:
-            return QColor("#0f0");
-        default:
-            return QColor("#555");
-        }
-    }
-
-    virtual QString iconForIncidence(const KCalCore::Incidence::Ptr &incidence) const
-    {
-        return QString();
-    }
-
-    virtual KCalCore::Calendar::Ptr getCalendar() const
-    {
-        return mCalendar;
-    }
-
-    KCalCore::Calendar::Ptr mCalendar;
-    QString name;
-};
-
-Quickview::Quickview(const Person &person, const Akonadi::Collection &col)
-    : mPerson(person)
-    , mCollection(col)
-    , mDayRange(7)
-{
-    mUi = new Ui_quickview;
-
-    QWidget *w = new QWidget( this );
-    mUi->setupUi( w );
-    setMainWidget( w );
-
-    mAgendaView = new EventViews::AgendaView(QDate(), QDate(), false,  false);
-
-    //show fbcalendar for person in quickview
-    if (!person.mail.isEmpty()) {
-        FreeBusyItemModel *model = new FreeBusyItemModel(this);
-        FreeBusyCalendar *fbCal = new FreeBusyCalendar(this);
-        FreebusyViewCalendar *fbCalendar = new FreebusyViewCalendar();
-        KCalCore::Attendee::Ptr attendee(new KCalCore::Attendee(person.name,  person.mail));
-        FreeBusyItem::Ptr freebusy( new FreeBusyItem( attendee, this ));
-
-        fbCal->setModel(model);
-        model->addItem(freebusy);
-        fbCalendar->mCalendar = fbCal->calendar();
-        fbCalendar->name = attendee->fullName();
-        mAgendaView->addCalendar(EventViews::ViewCalendar::Ptr(fbCalendar));
-    }
-
-    if (mCollection.isValid()) {
-        //create etm for mCollection
-        Akonadi::ChangeRecorder *monitor = new Akonadi::ChangeRecorder(this);
-        Akonadi::ItemFetchScope scope;
-        QStringList allMimeTypes;
-
-        allMimeTypes << KCalCore::Event::eventMimeType() << KCalCore::Todo::todoMimeType()
-                     << KCalCore::Journal::journalMimeType();
-
-        scope.fetchFullPayload(true);
-        scope.fetchAttribute<Akonadi::EntityDisplayAttribute>();
-
-        monitor->setCollectionMonitored(mCollection);
-        monitor->fetchCollection(true);
-        monitor->setItemFetchScope(scope);
-        monitor->setAllMonitored(true);
-
-        foreach(const QString &mimetype, allMimeTypes) {
-            monitor->setMimeTypeMonitored(mimetype, true);
-        }
-
-        Akonadi::ETMCalendar::Ptr calendar = Akonadi::ETMCalendar::Ptr(new Akonadi::ETMCalendar(monitor));
-
-        calendar->setCollectionFilteringEnabled(false);
-        mAgendaView->setCalendar(calendar);
-    }
-    mUi->calender->addWidget( mAgendaView );
-
-    connect(mUi->mTodayBtn, SIGNAL(clicked(bool)), SLOT(onTodayClicked()));
-    connect(mUi->mNextBtn, SIGNAL(clicked(bool)), SLOT(onNextClicked()));
-    connect(mUi->mPreviousBtn, SIGNAL(clicked(bool)), SLOT(onPreviousClicked()));
-
-    onTodayClicked();
-}
-
-Quickview::~Quickview()
-{
-
-}
-
-void Quickview::onNextClicked()
-{
-    QDate start = mAgendaView->startDate().addDays(mDayRange);
-    mAgendaView->showDates(start, start.addDays(mDayRange-1));
-}
-
-void Quickview::onPreviousClicked()
-{
-    QDate start = mAgendaView->startDate().addDays(-mDayRange);
-    mAgendaView->showDates(start, start.addDays(mDayRange-1));
-}
-
-void Quickview::onTodayClicked()
-{
-    QDate start = QDate::currentDate();
-    start = start.addDays(-QDate::currentDate().dayOfWeek()+1);
-    mAgendaView->showDates(start, start.addDays(mDayRange-1));
-}
-
-
-#include "quickview.moc"
diff --git a/korganizer/views/collectionview/quickview.h b/korganizer/views/collectionview/quickview.h
deleted file mode 100644
index d296887..0000000
--- a/korganizer/views/collectionview/quickview.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2014  Sandro Knauß <knauss at kolabsys.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License or (at your option) version 3 or any later version
- * accepted by the membership of KDE e.V. (or its successor approved
- * by the membership of KDE e.V.), which shall act as a proxy
- * defined in Section 14 of version 3 of the license.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef KORG_QUICKVIEW_H
-#define KORG_QUICKVIEW_H
-
-#include "controller.h"
-
-#include <calendarviews/agenda/viewcalendar.h>
-
-#include <KCalCore/FreeBusy>
-#include <KDialog>
-
-#include <QStringList>
-#include <QStringListModel>
-
-class  Ui_quickview;
-
-namespace EventViews
-{
-    class AgendaView;
-}
-
-class Quickview : public KDialog
-{
-    Q_OBJECT
-public:
-    Quickview(const Person &person, const Akonadi::Collection &col);
-    virtual ~Quickview();
-
-private slots:
-    void onTodayClicked();
-    void onNextClicked();
-    void onPreviousClicked();
-
-private:
-    Ui_quickview *mUi;
-    EventViews::AgendaView *mAgendaView;
-    Person mPerson;
-    Akonadi::Collection mCollection;
-    int mDayRange;
-};
-
-#endif // QUICKVIEW_H
diff --git a/korganizer/views/collectionview/quickview.ui b/korganizer/views/collectionview/quickview.ui
deleted file mode 100644
index 8854b60..0000000
--- a/korganizer/views/collectionview/quickview.ui
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>quickview</class>
- <widget class="QWidget" name="quickview">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>552</width>
-    <height>566</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Form</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="QPushButton" name="mDayBtn">
-       <property name="enabled">
-        <bool>false</bool>
-       </property>
-       <property name="text">
-        <string>Day</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="mWeekBtn">
-       <property name="text">
-        <string>Week</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="mMothBtn">
-       <property name="enabled">
-        <bool>false</bool>
-       </property>
-       <property name="text">
-        <string>Month</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="mAgendaBtn">
-       <property name="enabled">
-        <bool>false</bool>
-       </property>
-       <property name="text">
-        <string>Agenda</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="mPreviousBtn">
-       <property name="enabled">
-        <bool>true</bool>
-       </property>
-       <property name="text">
-        <string><</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="mTodayBtn">
-       <property name="enabled">
-        <bool>true</bool>
-       </property>
-       <property name="text">
-        <string>Today</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="mNextBtn">
-       <property name="enabled">
-        <bool>true</bool>
-       </property>
-       <property name="text">
-        <string>></string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="calender">
-     <property name="sizeConstraint">
-      <enum>QLayout::SetDefaultConstraint</enum>
-     </property>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>




More information about the commits mailing list