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 class KMFolderTreeItem : public QObject, public KFolderTreeItem
00043 
00044 {
00045   Q_OBJECT
00046 public:
00048   KMFolderTreeItem( KFolderTree *parent, const QString & name,
00049                     KFolderTreeItem::Protocol protocol=KFolderTreeItem::NONE );
00050 
00052   KMFolderTreeItem( KFolderTree *parent, const QString & name,
00053                     KMFolder* folder );
00054 
00056   KMFolderTreeItem( KFolderTreeItem* parent, const QString & name,
00057                     KMFolder* folder );
00058   virtual ~KMFolderTreeItem();
00059 
00060   QPixmap normalIcon(int size=16) const;
00061   QPixmap unreadIcon(int size=16) const;
00062 
00063   void setNeedsRepaint( bool value ) { mNeedsRepaint = value; }
00064   bool needsRepaint() const { return mNeedsRepaint; }
00065 
00067   KMFolder* folder() const { return mFolder; }
00068   QListViewItem* parent() const { return KFolderTreeItem::parent(); }
00069 
00072   void adjustUnreadCount( int newUnreadCount );
00073 
00075   virtual bool acceptDrag(QDropEvent* ) const;
00076 
00077 signals:
00079   void iconChanged( KMFolderTreeItem * );
00081   void nameChanged( KMFolderTreeItem * );
00082 
00083 public slots:
00084   void properties();
00085   void slotRepaint();
00086   void slotNameChanged() { emit nameChanged( this ); }
00087 
00088 
00089 protected:
00090   void init();
00091   KMFolder* mFolder;
00092 private:
00093   bool mNeedsRepaint;
00094 };
00095 
00096 //==========================================================================
00097 
00098 class KMFolderTree : public KFolderTree
00099 {
00100   Q_OBJECT
00101 
00102 public:
00103   KMFolderTree( KMMainWidget *mainWidget, QWidget *parent=0,
00104         const char *name=0 );
00105 
00107   void writeConfig();
00108 
00110   virtual void reload(bool openFolders = false);
00111 
00113   virtual void addDirectory( KMFolderDir *fdir, KMFolderTreeItem* parent );
00114 
00116   virtual QListViewItem* indexOfFolder( const KMFolder* folder ) const
00117   {
00118      if ( mFolderToItem.contains( folder ) )
00119        return mFolderToItem[ folder ];
00120      else
00121        return 0;
00122   }
00123   
00125   void createFolderList( QStringList *str,
00126                          QValueList<QGuardedPtr<KMFolder> > *folders,
00127                          bool localFolders=true,
00128                          bool imapFolders=true,
00129                          bool dimapFolders=true,
00130                          bool searchFolders=false,
00131                          bool includeNoContent=true,
00132                          bool includeNoChildren=true );
00133 
00135   virtual void readConfig(void);
00136 
00138   void readColorConfig(void);
00139 
00141   void cleanupConfigFile();
00142 
00144   void nextUnreadFolder(bool confirm);
00145 
00147   bool checkUnreadFolder(KMFolderTreeItem* ftl, bool confirm);
00148 
00149   KMFolder *currentFolder() const;
00150 
00151   enum ColumnMode {unread=15, total=16};
00152 
00154   void toggleColumn(int column, bool openFolders = false);
00155 
00158   virtual void updatePopup() const;
00159 
00161   KMMainWidget * mainWidget() const { return mMainWidget; }
00162 
00164   void showFolder( KMFolder* );
00165 
00166   void insertIntoFolderToItemMap( const KMFolder *folder, KMFolderTreeItem* item )
00167   {
00168     mFolderToItem.insert( folder, item );
00169   }
00170 
00171   void removeFromFolderToItemMap( const KMFolder *folder )
00172   {
00173     mFolderToItem.remove( folder );
00174   }
00175   
00176 signals:
00178   void folderSelected(KMFolder*);
00179 
00181   void folderSelectedUnread( KMFolder * );
00182 
00184   void folderDrop(KMFolder*);
00185 
00187   void folderDropCopy(KMFolder*);
00188 
00190   void columnsChanged();
00191 
00193   void iconChanged( KMFolderTreeItem * );
00194 
00196   void nameChanged( KMFolderTreeItem * );
00197 
00198 public slots:
00200   void nextUnreadFolder();
00201 
00203   void prevUnreadFolder();
00204 
00206   void incCurrentFolder();
00207 
00209   void decCurrentFolder();
00210 
00212   void selectCurrentFolder();
00213 
00215   void delayedUpdate();
00216 
00218   void slotAccountRemoved(KMAccount*);
00219 
00221   void doFolderSelected(QListViewItem*);
00222 
00228   void slotResetFolderList( QListViewItem* item = 0, bool startList = true );
00229 
00230 protected slots:
00231   //  void slotRMB(int, int);
00233   void doFolderListChanged();
00234 
00236   void slotFolderRemoved(KMFolder *);
00237 
00239   void refresh();
00240 
00242   void addChildFolder();
00243 
00245   void openFolder();
00246 
00248   void slotFolderExpanded( QListViewItem * item );
00249 
00251   void slotFolderCollapsed( QListViewItem * item );
00252 
00254   void slotRenameFolder( QListViewItem * item, int col, const QString& text);
00255 
00257   void slotUpdateCounts(KMFolder * folder);
00258   void slotUpdateCounts(KMFolderImap * folder, bool success = true);
00259   void slotUpdateOneCount();
00260 
00262   void slotToggleUnreadColumn();
00263   void slotToggleTotalColumn();
00264 
00265   void slotContextMenuRequested( QListViewItem *, const QPoint & );
00266 
00268   void slotCheckMail();
00269 
00270   void slotNewMessageToMailingList();
00271 
00272 protected:
00274   virtual bool event(QEvent *e);
00275 
00276   virtual void contentsMouseReleaseEvent(QMouseEvent* me);
00277 
00279   virtual void updateUnreadAll( );
00280 
00281   virtual void resizeEvent(QResizeEvent*);
00282 
00284   bool readIsListViewItemOpen(KMFolderTreeItem *fti);
00285   void writeIsListViewItemOpen(KMFolderTreeItem *fti);
00286 
00287   QTimer mUpdateTimer;
00288 
00290   void contentsDragEnterEvent( QDragEnterEvent *e );
00291   void contentsDragMoveEvent( QDragMoveEvent *e );
00292   void contentsDragLeaveEvent( QDragLeaveEvent *e );
00293   void contentsDropEvent( QDropEvent *e );
00294 
00296   QListViewItem *oldCurrent, *oldSelected;
00297   QListViewItem *dropItem;
00298   KMFolderTreeItem *mLastItem;
00299   QTimer autoopen_timer;
00300 
00301   // filter some rmb-events
00302   bool eventFilter(QObject*, QEvent*);
00303 
00305   void prepareItem( KMFolderTreeItem* );
00306 
00308   void connectSignals();
00309 
00310 private:
00312   QListViewItemIterator mUpdateIterator;
00313 
00315   KPopupMenu* mPopup;
00316   int mUnreadPop;
00317   int mTotalPop;
00318 
00320   bool mShowPopupAfterDnD;
00321   KMMainWidget *mMainWidget;
00322   bool mReloading;
00323   QMap<const KMFolder*, KMFolderTreeItem*> mFolderToItem;
00324 };
00325 
00326 #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 Mon Apr 4 04:48:27 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003