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

List:       kde-commits
Subject:    KDE/kdepim/korganizer
From:       Sergio Luis Martins <iamsergio () gmail ! com>
Date:       2010-11-12 9:25:16
Message-ID: 20101112092516.0EE6DAC89E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1195875 by smartins:

CalendarSearch code is duplicated in calendarviews.
Remove it.
Also removed collection selection stuff, already implemented in calendarviews.

 M  +0 -1      actionmanager.cpp  
 M  +0 -2      calendarview.cpp  
 M  +3 -195    interfaces/korganizer/baseview.cpp  
 M  +0 -38     interfaces/korganizer/baseview.h  
 M  +0 -8      koviewmanager.cpp  
 M  +0 -4      koviewmanager.h  


--- trunk/KDE/kdepim/korganizer/actionmanager.cpp #1195874:1195875
@@ -305,7 +305,6 @@
   mCollectionView->setCollectionSelectionProxyModel( checkableProxy );
 
   CalendarSupport::CollectionSelection *colSel = new CalendarSupport::CollectionSelection( \
                selectionModel );
-  BaseView::setGlobalCollectionSelection( colSel );
   EventViews::EventView::setGlobalCollectionSelection( colSel );
   KSelectionProxyModel* selectionProxy = new KSelectionProxyModel( selectionModel );
   selectionProxy->setFilterBehavior( KSelectionProxyModel::ChildrenOfExactSelection );
--- trunk/KDE/kdepim/korganizer/calendarview.cpp #1195874:1195875
@@ -2188,7 +2188,6 @@
   emit filtersUpdated( filters, pos + 1 );
 
   mCalendar->setFilter( mCurrentFilter );
-  mViewManager->setFilter( mCurrentFilter );
   updateView();
 }
 
@@ -2201,7 +2200,6 @@
   if ( newFilter != mCurrentFilter ) {
     mCurrentFilter = newFilter;
     mCalendar->setFilter( mCurrentFilter );
-    mViewManager->setFilter( mCurrentFilter );
     mViewManager->addChange( EventViews::EventView::FilterChanged );
     updateView();
   }
--- trunk/KDE/kdepim/korganizer/interfaces/korganizer/baseview.cpp #1195874:1195875
@@ -24,39 +24,19 @@
 
 #include <calendarsupport/calendar.h>
 #include <calendarsupport/calendarmodel.h>
-#include <calendarsupport/calendarsearch.h>
-#include <calendarsupport/collectionselection.h>
 #include <calendarsupport/utils.h>
 
-#include <akonadi_next/kcheckableproxymodel.h>
-#include <akonadi_next/kcolumnfilterproxymodel.h>
-
 #include <Akonadi/EntityTreeView>
 
 #include <KConfigGroup>
 #include <KRandom>
 
-#include <QItemSelectionModel>
-#include <QSortFilterProxyModel>
 #include <QVBoxLayout>
 
-
 using namespace CalendarSupport;
 using namespace Future;
 using namespace KOrg;
 
-CollectionSelection* BaseView::sGlobalCollectionSelection = 0;
-
-void BaseView::setGlobalCollectionSelection( CollectionSelection* s )
-{
-  sGlobalCollectionSelection = s;
-}
-
-CollectionSelection* BaseView::globalCollectionSelection()
-{
-  return sGlobalCollectionSelection;
-}
-
 class BaseView::Private
 {
   BaseView *const q;
@@ -66,77 +46,28 @@
       : q( qq ),
         mChanges( EventViews::EventView::IncidencesAdded |
                   EventViews::EventView::DatesChanged ),
-        calendar( 0 ),
-        customCollectionSelection( 0 ),
-        collectionSelectionModel( 0 )
+        calendar( 0 )
     {
       QByteArray cname = q->metaObject()->className();
       cname.replace( ":", "_" );
       identifier = cname + "_" + KRandom::randomString( 8 ).toLatin1();
-      calendarSearch = new CalendarSearch( q );
-      connect( calendarSearch->model(), SIGNAL( rowsInserted( const QModelIndex&, int, int ) ),
-               q, SLOT( rowsInserted( const QModelIndex&, int, int ) ) );
-      connect( calendarSearch->model(), SIGNAL( rowsAboutToBeRemoved( const QModelIndex&, int, int ) ),
-               q, SLOT( rowsAboutToBeRemoved( const QModelIndex&, int, int ) ) );
-      connect( calendarSearch->model(), SIGNAL( dataChanged( const QModelIndex&, const QModelIndex& ) ),
-               q, SLOT( dataChanged( const QModelIndex&, const QModelIndex& ) ) );
-      connect( calendarSearch->model(), SIGNAL( modelReset() ), q, SLOT( calendarReset() ) );
     }
 
     ~Private()
     {
-      delete collectionSelectionModel;
     }
 
     EventViews::EventView::Changes mChanges;
     Calendar *calendar;
-    CalendarSearch *calendarSearch;
-    CollectionSelection *customCollectionSelection;
-    KCheckableProxyModel* collectionSelectionModel;
     QByteArray identifier;
     KDateTime startDateTime;
     KDateTime endDateTime;
     KDateTime actualStartDateTime;
     KDateTime actualEndDateTime;
-    void setUpModels();
-    void reconnectCollectionSelection();
 };
 
-void BaseView::Private::setUpModels()
-{
-  delete customCollectionSelection;
-  customCollectionSelection = 0;
-  if ( collectionSelectionModel ) {
-    customCollectionSelection = new CollectionSelection( collectionSelectionModel->selectionModel() );
-    calendarSearch->setSelectionModel( collectionSelectionModel->selectionModel() );
 
-  } else {
-    calendarSearch->setSelectionModel( globalCollectionSelection()->model() );
-  }
-#if 0
-  QDialog* dlg = new QDialog( q );
-  dlg->setModal( false );
-  QVBoxLayout* layout = new QVBoxLayout( dlg );
-  EntityTreeView* testview = new EntityTreeView( dlg );
-  layout->addWidget( testview );
-  testview->setModel( calendarSearch->model() );
-  dlg->show();
-#endif
-  reconnectCollectionSelection();
-}
 
-void BaseView::Private::reconnectCollectionSelection()
-{
-  if ( q->globalCollectionSelection() )
-    q->globalCollectionSelection()->disconnect( q );
-
-  if ( customCollectionSelection )
-    customCollectionSelection->disconnect( q );
-
-  QObject::connect( q->collectionSelection(), \
SIGNAL(selectionChanged(Akonadi::Collection::List,Akonadi::Collection::List)), q, \
                SLOT(collectionSelectionChanged()) );
-}
-
-
 BaseView::BaseView( QWidget *parent )
   : QWidget( parent ), mChanger( 0 ), d( new Private( this ) )
 {
@@ -149,12 +80,10 @@
 
 void BaseView::setCalendar( Calendar *cal )
 {
-  if ( d->calendar == cal )
-    return;
+  if ( d->calendar != cal ) {
   d->calendar = cal;
-  if ( cal && d->collectionSelectionModel )
-    d->collectionSelectionModel->setSourceModel( cal->model() );
 }
+}
 
 CalPrinterBase::PrintType BaseView::printType() const
 {
@@ -166,11 +95,6 @@
   return d->calendar;
 }
 
-CalendarSearch* BaseView::calendarSearch() const
-{
-  return d->calendarSearch;
-}
-
 bool BaseView::isEventView()
 {
   return false;
@@ -215,8 +139,6 @@
   const QPair<KDateTime,KDateTime> adjusted = actualDateRange( start, end );
   d->actualStartDateTime = adjusted.first;
   d->actualEndDateTime = adjusted.second;
-  d->calendarSearch->setStartDate( d->actualStartDateTime );
-  d->calendarSearch->setEndDate( d->actualEndDateTime );
 }
 
 KDateTime BaseView::startDateTime() const
@@ -255,42 +177,11 @@
 
 void BaseView::restoreConfig( const KConfigGroup &configGroup )
 {
-  const bool useCustom = configGroup.readEntry( "UseCustomCollectionSelection", false );
-  if ( !d->collectionSelectionModel && !useCustom ) {
-    delete d->collectionSelectionModel;
-    d->collectionSelectionModel = 0;
-    d->setUpModels();
-  } else if ( useCustom ) {
-
-    if ( !d->collectionSelectionModel ) {
-      // Sort the calendar model on calendar name
-      QSortFilterProxyModel *sortProxy = new QSortFilterProxyModel( this );
-      sortProxy->setDynamicSortFilter( true );
-      sortProxy->setSortCaseSensitivity( Qt::CaseInsensitive );
-
-      if ( d->calendar ) {
-        sortProxy->setSourceModel( d->calendar->treeModel() );
-      }
-
-      // Only show the first column.
-      KColumnFilterProxyModel *columnFilterProxy = new KColumnFilterProxyModel( this );
-      columnFilterProxy->setVisibleColumn( CalendarSupport::CalendarModel::CollectionTitle );
-      columnFilterProxy->setSourceModel( sortProxy );
-
-      // Make the calendar model checkable.
-      d->collectionSelectionModel = new KCheckableProxyModel( this );
-      d->collectionSelectionModel->setSourceModel( columnFilterProxy );
-
-      d->setUpModels();
-    }
-  }
-
   doRestoreConfig( configGroup );
 }
 
 void BaseView::saveConfig( KConfigGroup &configGroup )
 {
-  configGroup.writeEntry( "UseCustomCollectionSelection", d->collectionSelectionModel != 0 );
   doSaveConfig( configGroup );
 }
 
@@ -302,44 +193,6 @@
 {
 }
 
-CollectionSelection* BaseView::collectionSelection() const
-{
-  return d->customCollectionSelection ? d->customCollectionSelection : globalCollectionSelection();
-}
-
-void BaseView::setCustomCollectionSelectionProxyModel( KCheckableProxyModel* model )
-{
-  if ( d->collectionSelectionModel == model )
-    return;
-
-  delete d->collectionSelectionModel;
-  d->collectionSelectionModel = model;
-  d->setUpModels();
-}
-
-void BaseView::collectionSelectionChanged()
-{
-
-}
-
-KCheckableProxyModel *BaseView::customCollectionSelectionProxyModel() const
-{
-  return d->collectionSelectionModel;
-}
-
-KCheckableProxyModel *BaseView::takeCustomCollectionSelectionProxyModel()
-{
-  KCheckableProxyModel* m = d->collectionSelectionModel;
-  d->collectionSelectionModel = 0;
-  d->setUpModels();
-  return m;
-}
-
-CollectionSelection *BaseView::customCollectionSelection() const
-{
-  return d->customCollectionSelection;
-}
-
 void BaseView::clearSelection()
 {
 }
@@ -361,16 +214,6 @@
   highlightJournals = false;
 }
 
-void BaseView::handleBackendError( const QString &errorString )
-{
-  kError() << errorString;
-}
-
-void BaseView::backendErrorOccurred()
-{
-  handleBackendError( d->calendarSearch->errorString() );
-}
-
 bool BaseView::usesFullWindow()
 {
   return false;
@@ -386,18 +229,6 @@
   return true;
 }
 
-void BaseView::incidencesAdded( const Akonadi::Item::List & )
-{
-}
-
-void BaseView::incidencesAboutToBeRemoved( const Akonadi::Item::List & )
-{
-}
-
-void BaseView::incidencesChanged( const Akonadi::Item::List& )
-{
-}
-
 void BaseView::calendarReset()
 {
 }
@@ -407,29 +238,6 @@
   return qMakePair( start, end );
 }
 
-void BaseView::dataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight )
-{
-  Q_ASSERT( topLeft.parent() == bottomRight.parent() );
-
-  incidencesChanged( itemsFromModel( d->calendarSearch->model(), topLeft.parent(),
-                     topLeft.row(), bottomRight.row() ) );
-}
-
-void BaseView::rowsInserted( const QModelIndex& parent, int start, int end )
-{
-  incidencesAdded( itemsFromModel( d->calendarSearch->model(), parent, start, end ) );
-}
-
-void BaseView::rowsAboutToBeRemoved( const QModelIndex& parent, int start, int end )
-{
-  incidencesAboutToBeRemoved( itemsFromModel( d->calendarSearch->model(), parent, start, end ) );
-}
-
-void BaseView::setFilter( KCalCore::CalFilter *filter )
-{
-  calendarSearch()->setFilter( filter );
-}
-
 void BaseView::setChanges( EventViews::EventView::Changes changes )
 {
   d->mChanges = changes;
--- trunk/KDE/kdepim/korganizer/interfaces/korganizer/baseview.h #1195874:1195875
@@ -45,9 +45,6 @@
 class KConfigGroup;
 
 namespace CalendarSupport {
-  class CalendarSearch;
-  class CollectionSelection;
-  class CollectionSelectionProxyModel;
   class Calendar;
 }
 
@@ -92,8 +89,6 @@
     */
     virtual CalendarSupport::Calendar *calendar();
 
-    CalendarSupport::CalendarSearch* calendarSearch() const;
-
     /**
       @return a list of selected events.  Most views can probably only
       select a single event at a time, but some may be able to select
@@ -192,15 +187,6 @@
      */
     virtual void saveConfig( KConfigGroup &configGroup );
 
-    virtual Future::KCheckableProxyModel *takeCustomCollectionSelectionProxyModel();
-    Future::KCheckableProxyModel *customCollectionSelectionProxyModel() const;
-    virtual void setCustomCollectionSelectionProxyModel( Future::KCheckableProxyModel* model );
-
-    CalendarSupport::CollectionSelection *customCollectionSelection() const;
-
-    static CalendarSupport::CollectionSelection* globalCollectionSelection();
-    static void setGlobalCollectionSelection( CalendarSupport::CollectionSelection* selection );
-
     /**
      * returns the view at the given widget coordinate. This is usually the view itself,
      * except for composite views, where a subview will be returned. The default implementation returns \
@p this . @@ -374,18 +360,8 @@
     void newJournalSignal( const QDate & );
 
   public:
-    /**
-     * returns the selection of collection to be used by this view (custom if set, or global otherwise)
-     */
-    CalendarSupport::CollectionSelection* collectionSelection() const;
 
     /**
-     * sets the kcal filter on the calendarSearch object, this method can be removed from here when
-     * calendarsearch stuff is removed from baseview, do we need a calendarsearch object per view?
-     */
-    void setFilter( KCalCore::CalFilter *filter );
-
-    /**
        Notifies the view that there are pending changes so a redraw is needed.
 
        @param changes Types of changes that were made
@@ -420,22 +396,9 @@
      */
     virtual QPair<KDateTime,KDateTime> actualDateRange( const KDateTime& start, const KDateTime& end ) \
const;  
-    virtual void incidencesAdded( const Akonadi::Item::List& incidences );
-    virtual void incidencesAboutToBeRemoved( const Akonadi::Item::List& incidences );
-    virtual void incidencesChanged( const Akonadi::Item::List& incidences );
-
-    virtual void handleBackendError( const QString &error );
-
   protected Q_SLOTS:
-    virtual void collectionSelectionChanged();
     virtual void calendarReset();
 
-  private Q_SLOTS:
-    void backendErrorOccurred();
-    void dataChanged( const QModelIndex& topLeft, const QModelIndex& bottomRight );
-    void rowsInserted( const QModelIndex& parent, int start, int end );
-    void rowsAboutToBeRemoved( const QModelIndex& parent, int start, int end );
-
   protected:
     CalendarSupport::IncidenceChanger *mChanger;
 
@@ -443,7 +406,6 @@
     class Private;
     Private *const d;
     friend class KOrg::BaseView::Private;
-    static CalendarSupport::CollectionSelection* sGlobalCollectionSelection;
 };
 
 }
--- trunk/KDE/kdepim/korganizer/koviewmanager.cpp #1195874:1195875
@@ -696,11 +696,3 @@
          mCurrentView == mAgendaSideBySideView  ||
         ( mAgendaViewTabs && mCurrentView == mAgendaViewTabs->currentWidget() );
 }
-
-void KOViewManager::setFilter( KCalCore::CalFilter *filter )
-{
-  if ( mMonthView ) {
-    // our only calendarsearch based view for now is month view
-    mMonthView->setFilter( filter );
-  }
-}
--- trunk/KDE/kdepim/korganizer/koviewmanager.h #1195874:1195875
@@ -134,10 +134,6 @@
     */
     RangeMode rangeMode() const { return mRangeMode; }
 
-    // sets filter on calendarsearch based views, this method can be removed from here when
-    // calendarsearch stuff is removed from baseview, do we need a calendarsearch object per view?
-    void setFilter( KCalCore::CalFilter *filter );
-
   signals:
     void configChanged();
 


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

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