• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

akonadi/clients

mainwidget.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of Akonadi.
00003 
00004     Copyright (c) 2008 Bruno Virlet <bvirlet@kdemail.net>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019     USA.
00020 */
00021 
00022 #include "mainwidget.h"
00023 #include "mainwindow.h"
00024 
00025 #include <QtGui/QSortFilterProxyModel>
00026 
00027 MainWidget::MainWidget( MainWindow* parent )
00028     : QWidget( parent ), mMainWindow( parent )
00029 {
00030     // Layout
00031     QHBoxLayout *layout = new QHBoxLayout( this );
00032     QSplitter *topSplitter = new QSplitter( Qt::Vertical, this );
00033     layout->addWidget( topSplitter );
00034     QSplitter *splitter = new QSplitter( Qt::Horizontal,  this );
00035     topSplitter->addWidget( splitter );
00036 
00037     /*
00038      * Views
00039      */
00040     // Calendar listview
00041     mCollectionList = new Akonadi::CollectionView();
00042     splitter->addWidget( mCollectionList );
00043 
00044     // Event listview
00045     mIncidenceList = new QTreeView( this );
00046     mIncidenceList->setDragEnabled( this );
00047     mIncidenceList->setRootIsDecorated( false );
00048     splitter->addWidget( mIncidenceList );
00049 
00050     // Event view
00051     mIncidenceViewer = new Akonadi::KCalItemBrowser( this );
00052     topSplitter->addWidget( mIncidenceViewer );
00053 
00054 
00055     /*
00056      * Models
00057      */
00058     // Calendar model
00059     mCollectionModel = new Akonadi::CollectionModel( this );
00060     mCollectionProxyModel = new Akonadi::CollectionFilterProxyModel( this );
00061     mCollectionProxyModel->setSourceModel( mCollectionModel );
00062     mCollectionProxyModel->addMimeTypeFilter( QString::fromLatin1( "text/calendar" ) );
00063 
00064     // display collections sorted
00065     QSortFilterProxyModel *sortModel = new QSortFilterProxyModel( this );
00066     sortModel->setDynamicSortFilter( true );
00067     sortModel->setSortCaseSensitivity( Qt::CaseInsensitive );
00068     sortModel->setSourceModel( mCollectionProxyModel );
00069 
00070     // Calendar view (list of incidences)
00071     mIncidenceModel = new Akonadi::KCalModel( this );
00072 
00073     /*
00074      * Connexion between views and models
00075      */
00076     mIncidenceList->setModel( mIncidenceModel );
00077     mCollectionList->setModel( sortModel );
00078 
00079     /*
00080      * React to user orders
00081      */
00082     connect( mCollectionList, SIGNAL(clicked(const Akonadi::Collection&)),
00083              SLOT(collectionClicked(const Akonadi::Collection&)) );
00084     connect( mIncidenceList, SIGNAL(clicked(QModelIndex)), SLOT(itemActivated(QModelIndex)) );
00085 }
00086 
00087 void MainWidget::collectionClicked( const Akonadi::Collection& collection )
00088 {
00089     mIncidenceModel->setCollection( collection );
00090 }
00091 
00092 void MainWidget::itemActivated( const QModelIndex& index )
00093 {
00094     const Akonadi::Item item = mIncidenceModel->itemForIndex( index );
00095     mIncidenceViewer->setItem( item );
00096 }
00097 

akonadi/clients

Skip menu "akonadi/clients"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal