summaryrefslogtreecommitdiffstats
path: root/kmail/kmfoldertree.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kmail/kmfoldertree.h
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail/kmfoldertree.h')
-rw-r--r--kmail/kmfoldertree.h350
1 files changed, 350 insertions, 0 deletions
diff --git a/kmail/kmfoldertree.h b/kmail/kmfoldertree.h
new file mode 100644
index 000000000..e24f939b3
--- /dev/null
+++ b/kmail/kmfoldertree.h
@@ -0,0 +1,350 @@
+/* -*- mode: C++ -*-
+ This file is part of the KDE libraries
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef __KMFOLDERTREE
+#define __KMFOLDERTREE
+
+#include "foldertreebase.h"
+
+#include <klocale.h>
+#include <kdepimmacros.h>
+
+#include <qguardedptr.h>
+#include <qwidget.h>
+#include <qtimer.h>
+#include <qheader.h>
+
+class QDropEvent;
+class QPixmap;
+class QPainter;
+class QPopupMenu;
+class KPopupMenu;
+class KMFolder;
+class KMFolderDir;
+class KMFolderImap;
+class KMFolderTree;
+class KMAccount;
+// duplication from kmcommands.h, to avoid the include
+typedef QMap<int,KMFolder*> KMMenuToFolder;
+template <typename T> class QGuardedPtr;
+
+class KDE_EXPORT KMFolderTreeItem : public QObject, public KFolderTreeItem
+{
+ Q_OBJECT
+public:
+ /** Construct a root item _without_ folder */
+ KMFolderTreeItem( KFolderTree *parent, const QString & name,
+ KFolderTreeItem::Protocol protocol=KFolderTreeItem::NONE );
+
+ /** Construct a root item _with_ folder */
+ KMFolderTreeItem( KFolderTree *parent, const QString & name,
+ KMFolder* folder );
+
+ /** Construct a child item */
+ KMFolderTreeItem( KFolderTreeItem* parent, const QString & name,
+ KMFolder* folder );
+ virtual ~KMFolderTreeItem();
+
+ QPixmap normalIcon( int size ) const;
+ QPixmap unreadIcon( int size ) const;
+
+ void setNeedsRepaint( bool value ) { mNeedsRepaint = value; }
+ bool needsRepaint() const { return mNeedsRepaint; }
+
+ /** associated folder */
+ KMFolder* folder() const { return mFolder; }
+ QListViewItem* parent() const { return KFolderTreeItem::parent(); }
+
+ /** Adjust the unread count from the folder and update the
+ * pixmaps accordingly. */
+ void adjustUnreadCount( int newUnreadCount );
+
+ /** dnd */
+ virtual bool acceptDrag(QDropEvent* e) const;
+
+signals:
+ /** Our icon changed */
+ void iconChanged( KMFolderTreeItem * );
+ /** Our name changed */
+ void nameChanged( KMFolderTreeItem * );
+
+public slots:
+ void properties();
+ void assignShortcut();
+ void slotShowExpiryProperties();
+ void slotIconsChanged();
+ void slotNameChanged();
+ void updateCount();
+
+protected:
+ void init();
+ KMFolder* mFolder;
+ /** Returns true when top-level/account icons should be used */
+ virtual bool useTopLevelIcon() const { return depth() == 0; }
+ /** Returns the icon size. */
+ virtual int iconSize() const { return 16; }
+
+private:
+ bool mNeedsRepaint;
+};
+
+//==========================================================================
+
+class KMFolderTree : public KMail::FolderTreeBase
+{
+ Q_OBJECT
+
+public:
+ KMFolderTree( KMMainWidget *mainWidget, QWidget *parent=0,
+ const char *name=0 );
+
+ /** Save config options */
+ void writeConfig();
+
+ /** Get/refresh the folder tree */
+ virtual void reload(bool openFolders = false);
+
+ /** Recusively add folders in a folder directory to a listview item. */
+ virtual void addDirectory( KMFolderDir *fdir, KMFolderTreeItem* parent );
+
+ /** create a folderlist */
+ void createFolderList( QStringList *str,
+ QValueList<QGuardedPtr<KMFolder> > *folders,
+ bool localFolders=true,
+ bool imapFolders=true,
+ bool dimapFolders=true,
+ bool searchFolders=false,
+ bool includeNoContent=true,
+ bool includeNoChildren=true );
+
+ /** Read config options. */
+ virtual void readConfig(void);
+
+ /** Remove information about not existing folders from the config file */
+ void cleanupConfigFile();
+
+ /** Select the next folder with unread messages */
+ void nextUnreadFolder(bool confirm);
+
+ /** Check folder for unread messages (which isn't trash)*/
+ bool checkUnreadFolder(KMFolderTreeItem* ftl, bool confirm);
+
+ KMFolder *currentFolder() const;
+
+ QValueList<QGuardedPtr<KMFolder> > selectedFolders();
+
+ enum ColumnMode {unread=15, total=16, foldersize=17};
+
+ /** toggles the unread and total columns on/off */
+ void toggleColumn(int column, bool openFolders = false);
+
+ /** Set the checked/unchecked state of the unread and total column
+ * in the popup correctly */
+ virtual void updatePopup() const;
+
+ /** Select the folder and make sure it's visible */
+ void showFolder( KMFolder* );
+
+ /** Valid actions for the folderToPopup method */
+ enum MenuAction {
+ CopyMessage,
+ MoveMessage,
+ CopyFolder,
+ MoveFolder
+ };
+
+ /** Generate a popup menu that contains all folders that can have content */
+ void folderToPopupMenu( MenuAction action, QObject *receiver, KMMenuToFolder *,
+ QPopupMenu *menu, QListViewItem *start = 0 );
+
+signals:
+ /** The selected folder has changed */
+ void folderSelected(KMFolder*);
+
+ /** The selected folder has changed to go to an unread message */
+ void folderSelectedUnread( KMFolder * );
+
+ /** unread/total/size column has changed */
+ void columnsChanged();
+
+ /** an icon of one of our folders changed */
+ void iconChanged( KMFolderTreeItem * );
+
+ /** the name of one of our folders changed */
+ void nameChanged( KMFolderTreeItem * );
+
+public slots:
+ /** Select the next folder with unread messages */
+ void nextUnreadFolder();
+
+ /** Select the previous folder with unread messages */
+ void prevUnreadFolder();
+
+ /** Increment current folder */
+ void incCurrentFolder();
+
+ /** Decrement current folder */
+ void decCurrentFolder();
+
+ /** Select the current folder */
+ void selectCurrentFolder();
+
+ /** Executes delayed update of folder tree */
+ void delayedUpdate();
+
+ /** Make sure the given account is not selected because it is gone */
+ void slotAccountRemoved(KMAccount*);
+
+ /** Select the item and switch to the folder */
+ void doFolderSelected(QListViewItem *qlvi, bool keepSelection = false);
+
+ /**
+ * Reset current folder and all childs
+ * If no item is given we take the current one
+ * If startListing is true a folder listing is started
+ */
+ void slotResetFolderList( QListViewItem* item = 0, bool startList = true );
+
+ /** Create a child folder */
+ void addChildFolder( KMFolder *folder = 0, QWidget * parent = 0 );
+
+ /** Copies the currently selected folder. */
+ void copyFolder();
+
+ /** Cuts the currently selected folder. */
+ void cutFolder();
+
+ /** Pastes a previously copied/cutted folder below the currently selected folder. */
+ void pasteFolder();
+
+protected slots:
+ // void slotRMB(int, int);
+ /** called by the folder-manager when the list of folders changed */
+ void doFolderListChanged();
+
+ /** called, when a folder has been deleted */
+ void slotFolderRemoved(KMFolder *);
+
+ /** called, when a folder has been moved or copied, successfully or not */
+ void slotFolderMoveOrCopyOperationFinished();
+
+ /** Updates the folder tree (delayed), causing a "blink" */
+ void refresh();
+
+ /** Open a folder */
+ void openFolder();
+
+ /** Expand an IMAP folder */
+ void slotFolderExpanded( QListViewItem * item );
+
+ /** Tell the folder to refresh the contents on the next expansion */
+ void slotFolderCollapsed( QListViewItem * item );
+
+ /** Check if the new name is valid and confirm the new name */
+ void slotRenameFolder( QListViewItem * item, int col, const QString& text);
+
+ /** Update the total and unread columns but delayed */
+ void slotUpdateCountsDelayed(KMFolder * folder);
+ void slotUpdateCountTimeout();
+ void slotUpdateOneCount();
+
+ /** slots for the unread/total/size-popup */
+ void slotToggleUnreadColumn();
+ void slotToggleTotalColumn();
+ void slotToggleSizeColumn();
+
+ void slotContextMenuRequested( QListViewItem *, const QPoint & );
+
+ /** Fires a new-mail-check of the account that is accociated with currentItem */
+ void slotCheckMail();
+
+ void slotNewMessageToMailingList();
+
+ /** For RMB move folder */
+ virtual void moveSelectedToFolder( int menuId );
+ /** For RMB copy folder */
+ virtual void copySelectedToFolder( int menuId );
+
+ /** Updates copy/cut/paste actions */
+ void updateCopyActions();
+
+protected:
+ virtual void contentsMousePressEvent( QMouseEvent *e );
+ virtual void contentsMouseReleaseEvent(QMouseEvent* me);
+
+ /** Updates the number of unread messages for all folders */
+ virtual void updateUnreadAll( );
+
+ virtual void resizeEvent(QResizeEvent*);
+
+ /** Read/Save open/close state indicator for an item in folderTree list view */
+ bool readIsListViewItemOpen(KMFolderTreeItem *fti);
+ void writeIsListViewItemOpen(KMFolderTreeItem *fti);
+
+ QTimer mUpdateTimer;
+
+ /** Drag and drop methods */
+ void contentsDragEnterEvent( QDragEnterEvent *e );
+ void contentsDragMoveEvent( QDragMoveEvent *e );
+ void contentsDragLeaveEvent( QDragLeaveEvent *e );
+ void contentsDropEvent( QDropEvent *e );
+ virtual QDragObject* dragObject();
+
+ /** Drag and drop variables */
+ QListViewItem *oldCurrent, *oldSelected;
+ QListViewItem *dropItem;
+ KMFolderTreeItem *mLastItem;
+ QTimer autoopen_timer;
+
+ // filter some rmb-events
+ bool eventFilter(QObject*, QEvent*);
+
+ /** open ancestors and ensure item is visible */
+ void prepareItem( KMFolderTreeItem* );
+
+ /** connect all signals */
+ void connectSignals();
+
+ /** Move or copy the folder @p source to @p destination. */
+ void moveOrCopyFolder( QValueList<QGuardedPtr<KMFolder> > sources, KMFolder* destination, bool move=false );
+
+private slots:
+ void slotAddToFavorites();
+ void slotUnhideLocalInbox();
+
+private:
+ /** total column */
+ QListViewItemIterator mUpdateIterator;
+
+ /** popup for unread/total */
+ KPopupMenu* mPopup;
+ int mUnreadPop;
+ int mTotalPop;
+ int mSizePop;
+
+ bool mReloading;
+ QValueList<QGuardedPtr<KMFolder> > mCopySourceFolders;
+ bool mCutFolder;
+
+ QTimer *mUpdateCountTimer;
+ QMap<QString,KMFolder*> mFolderToUpdateCount;
+
+ /** Map menu id into a folder */
+ KMMenuToFolder mMenuToFolder;
+};
+
+#endif