kmail Library API Documentation

kmfoldertree.h

00001 /* -*- mode: C++ -*-
00002    This file is part of the KDE libraries
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00016    Boston, MA 02111-1307, USA.
00017 */
00018 #ifndef __KMFOLDERTREE
00019 #define __KMFOLDERTREE
00020 
00021 #include "kmheaders.h"
00022 #include "kmfolder.h"
00023 
00024 #include <klocale.h>
00025 #include <kpopupmenu.h>
00026 #include <kfoldertree.h>
00027 #include <kiconloader.h>
00028 
00029 #include <qwidget.h>
00030 #include <qtimer.h>
00031 #include <qheader.h>
00032 
00033 class QDropEvent;
00034 class QPixmap;
00035 class QPainter;
00036 class KMFolderImap;
00037 class KMFolderTree;
00038 class KMMainWidget;
00039 class KMAccount;
00040 template <typename T> class QGuardedPtr;
00041 
00042 namespace KMail {
00043   class QuotaInfo;
00044 }
00045 
00046 namespace {
00047   class ItemToolTip;
00048 }
00049 
00050 class KMFolderTreeItem : public QObject, public KFolderTreeItem
00051 
00052 {
00053   Q_OBJECT
00054 public:
00056   KMFolderTreeItem( KFolderTree *parent, const QString & name,
00057                     KFolderTreeItem::Protocol protocol=KFolderTreeItem::NONE );
00058 
00060   KMFolderTreeItem( KFolderTree *parent, const QString & name,
00061                     KMFolder* folder );
00062 
00064   KMFolderTreeItem( KFolderTreeItem* parent, const QString & name,
00065                     KMFolder* folder );
00066   virtual ~KMFolderTreeItem();
00067 
00068   QPixmap normalIcon(int size=16) const;
00069   QPixmap unreadIcon(int size=16) const;
00070 
00071   void setNeedsRepaint( bool value ) { mNeedsRepaint = value; }
00072   bool needsRepaint() const { return mNeedsRepaint; }
00073 
00075   KMFolder* folder() const { return mFolder; }
00076   QListViewItem* parent() const { return KFolderTreeItem::parent(); }
00077 
00080   void adjustUnreadCount( int newUnreadCount );
00081 
00083   virtual bool acceptDrag(QDropEvent* ) const;
00084 
00085   QString toolTip( int column ) const;
00086 
00087 signals:
00089   void iconChanged( KMFolderTreeItem * );
00091   void nameChanged( KMFolderTreeItem * );
00092 
00093 public slots:
00094   void properties();
00095   void slotRepaint();
00096   void slotNameChanged() { emit nameChanged( this ); }
00097 
00098 
00099 protected:
00100   void init();
00101   KMFolder* mFolder;
00102 private:
00103   bool mNeedsRepaint;
00104 };
00105 
00106 //==========================================================================
00107 
00108 class KMFolderTree : public KFolderTree
00109 {
00110   Q_OBJECT
00111 
00112 public:
00113   KMFolderTree( KMMainWidget *mainWidget, QWidget *parent=0,
00114         const char *name=0 );
00115 
00117   void writeConfig();
00118 
00120   virtual void reload(bool openFolders = false);
00121 
00123   virtual void addDirectory( KMFolderDir *fdir, KMFolderTreeItem* parent );
00124 
00126   virtual QListViewItem* indexOfFolder( const KMFolder* folder ) const
00127   {
00128      if ( mFolderToItem.contains( folder ) )
00129        return mFolderToItem[ folder ];
00130      else
00131        return 0;
00132   }
00133   
00135   void createFolderList( QStringList *str,
00136                          QValueList<QGuardedPtr<KMFolder> > *folders,
00137                          bool localFolders=true,
00138                          bool imapFolders=true,
00139                          bool dimapFolders=true,
00140                          bool searchFolders=false,
00141                          bool includeNoContent=true,
00142                          bool includeNoChildren=true );
00143 
00145   virtual void readConfig(void);
00146 
00148   void readColorConfig(void);
00149 
00151   void cleanupConfigFile();
00152 
00154   void nextUnreadFolder(bool confirm);
00155 
00157   bool checkUnreadFolder(KMFolderTreeItem* ftl, bool confirm);
00158 
00159   KMFolder *currentFolder() const;
00160 
00161   enum ColumnMode {unread=15, total=16};
00162 
00164   void toggleColumn(int column, bool openFolders = false);
00165 
00168   virtual void updatePopup() const;
00169 
00171   KMMainWidget * mainWidget() const { return mMainWidget; }
00172 
00174   void showFolder( KMFolder* );
00175 
00176   void insertIntoFolderToItemMap( const KMFolder *folder, KMFolderTreeItem* item )
00177   {
00178     mFolderToItem.insert( folder, item );
00179   }
00180 
00181   void removeFromFolderToItemMap( const KMFolder *folder )
00182   {
00183     mFolderToItem.remove( folder );
00184   }
00185 
00187   enum MenuAction {
00188     CopyMessage,
00189     MoveMessage,
00190     CopyFolder,
00191     MoveFolder
00192   };
00193   
00195   void folderToPopupMenu( MenuAction action, QObject *receiver, KMMenuToFolder *, 
00196       QPopupMenu *menu, QListViewItem *start = 0 );
00197   
00198 signals:
00200   void folderSelected(KMFolder*);
00201 
00203   void folderSelectedUnread( KMFolder * );
00204 
00206   void folderDrop(KMFolder*);
00207 
00209   void folderDropCopy(KMFolder*);
00210 
00212   void columnsChanged();
00213 
00215   void iconChanged( KMFolderTreeItem * );
00216 
00218   void nameChanged( KMFolderTreeItem * );
00219 
00220 public slots:
00222   void nextUnreadFolder();
00223 
00225   void prevUnreadFolder();
00226 
00228   void incCurrentFolder();
00229 
00231   void decCurrentFolder();
00232 
00234   void selectCurrentFolder();
00235 
00237   void delayedUpdate();
00238 
00240   void slotAccountRemoved(KMAccount*);
00241 
00243   void doFolderSelected(QListViewItem*);
00244 
00250   void slotResetFolderList( QListViewItem* item = 0, bool startList = true );
00251 
00252   void slotReceivedQuotaInfo( KMFolder* folder, KIO::Job* job,
00253                               const KMail::QuotaInfo& info );
00254 
00255 
00256 protected slots:
00257   //  void slotRMB(int, int);
00259   void doFolderListChanged();
00260 
00262   void slotFolderRemoved(KMFolder *);
00263 
00265   void refresh();
00266 
00268   void addChildFolder();
00269 
00271   void openFolder();
00272 
00274   void slotFolderExpanded( QListViewItem * item );
00275 
00277   void slotFolderCollapsed( QListViewItem * item );
00278 
00280   void slotRenameFolder( QListViewItem * item, int col, const QString& text);
00281 
00283   void slotUpdateCounts(KMFolder * folder);
00284   void slotUpdateCounts(KMFolderImap * folder, bool success = true);
00285   void slotUpdateOneCount();
00286 
00288   void slotToggleUnreadColumn();
00289   void slotToggleTotalColumn();
00290 
00291   void slotContextMenuRequested( QListViewItem *, const QPoint & );
00292 
00294   void slotCheckMail();
00295 
00296   void slotNewMessageToMailingList();
00297 
00299   virtual void moveSelectedToFolder( int menuId );
00301   virtual void copySelectedToFolder( int menuId );
00302 
00303 protected:
00305   virtual bool event(QEvent *e);
00306 
00307   virtual void contentsMouseReleaseEvent(QMouseEvent* me);
00308 
00310   virtual void updateUnreadAll( );
00311 
00312   virtual void resizeEvent(QResizeEvent*);
00313 
00315   bool readIsListViewItemOpen(KMFolderTreeItem *fti);
00316   void writeIsListViewItemOpen(KMFolderTreeItem *fti);
00317 
00318   QTimer mUpdateTimer;
00319 
00321   void contentsDragEnterEvent( QDragEnterEvent *e );
00322   void contentsDragMoveEvent( QDragMoveEvent *e );
00323   void contentsDragLeaveEvent( QDragLeaveEvent *e );
00324   void contentsDropEvent( QDropEvent *e );
00325 
00327   QListViewItem *oldCurrent, *oldSelected;
00328   QListViewItem *dropItem;
00329   KMFolderTreeItem *mLastItem;
00330   QTimer autoopen_timer;
00331 
00332   // filter some rmb-events
00333   bool eventFilter(QObject*, QEvent*);
00334 
00336   void prepareItem( KMFolderTreeItem* );
00337 
00339   void connectSignals();
00340 
00342   void moveOrCopyCurrentFolder( KMFolder* destination, bool move=false );
00343 
00344 private:
00346   QListViewItemIterator mUpdateIterator;
00347 
00349   KPopupMenu* mPopup;
00350   int mUnreadPop;
00351   int mTotalPop;
00352 
00354   bool mShowPopupAfterDnD;
00355   KMMainWidget *mMainWidget;
00356   bool mReloading;
00357   QMap<const KMFolder*, KMFolderTreeItem*> mFolderToItem;
00358 
00360   KMMenuToFolder mMenuToFolder;
00361   ItemToolTip *mToolTip;
00362 };
00363 
00364 #endif
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 4 14:42:23 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003