|
|
|
|
@ -2,82 +2,66 @@ |
|
|
|
|
#define __KMFOLDERTREE |
|
|
|
|
|
|
|
|
|
#include <qwidget.h> |
|
|
|
|
#include <qlistview.h> |
|
|
|
|
#include <qtimer.h> |
|
|
|
|
#include <qheader.h> |
|
|
|
|
|
|
|
|
|
#include <klocale.h> |
|
|
|
|
#include <kpopupmenu.h> |
|
|
|
|
#include <kfoldertree.h> |
|
|
|
|
|
|
|
|
|
// Fixme! A temporary dependency
|
|
|
|
|
#include "kmheaders.h" // For KMHeaderToFolderDrag & KMPaintInfo |
|
|
|
|
|
|
|
|
|
#include "kmheaders.h" |
|
|
|
|
#include "kmfolder.h" |
|
|
|
|
|
|
|
|
|
class QDropEvent; |
|
|
|
|
class QPixmap; |
|
|
|
|
class QPainter; |
|
|
|
|
class KMFolderImap; |
|
|
|
|
class KMFolderTree; |
|
|
|
|
class CryptPlugWrapperList; |
|
|
|
|
|
|
|
|
|
class KMFolderTreeItem : public QListViewItem |
|
|
|
|
class KMFolderTreeItem : public KFolderTreeItem |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
KMFolder* folder; |
|
|
|
|
QString unread; |
|
|
|
|
KMPaintInfo *mPaintInfo; |
|
|
|
|
|
|
|
|
|
/** Construct the root item */ |
|
|
|
|
KMFolderTreeItem( QListView *parent, |
|
|
|
|
KMPaintInfo *aPaintInfo ) |
|
|
|
|
: QListViewItem( parent, i18n("Mail") ), |
|
|
|
|
folder( 0 ), |
|
|
|
|
unread( QString::null ), |
|
|
|
|
mPaintInfo( aPaintInfo ) |
|
|
|
|
/** Construct a root item _without_ folder */ |
|
|
|
|
KMFolderTreeItem( KFolderTree *parent, |
|
|
|
|
QString name ) |
|
|
|
|
: KFolderTreeItem( parent, name ), mFolder( 0 ) |
|
|
|
|
{} |
|
|
|
|
KMFolderTreeItem( QListView *parent, |
|
|
|
|
KMFolder* folder, |
|
|
|
|
KMPaintInfo *aPaintInfo ) |
|
|
|
|
: QListViewItem( parent, i18n("Mail") ), |
|
|
|
|
folder( folder ), |
|
|
|
|
unread( QString::null ), |
|
|
|
|
mPaintInfo( aPaintInfo ) |
|
|
|
|
|
|
|
|
|
/** Construct a root item _with_ folder */
|
|
|
|
|
KMFolderTreeItem( KFolderTree *parent, QString name, |
|
|
|
|
KMFolder* folder ) |
|
|
|
|
: KFolderTreeItem( parent, name, folder->protocol() ), mFolder( folder ) |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
/** Construct a child item */ |
|
|
|
|
KMFolderTreeItem( QListViewItem* parent, |
|
|
|
|
KMFolder* folder, |
|
|
|
|
KMPaintInfo *aPaintInfo ) |
|
|
|
|
: QListViewItem( parent, (folder) ? folder->label() : QString::null ), |
|
|
|
|
folder( folder ), |
|
|
|
|
unread( QString::null ), |
|
|
|
|
mPaintInfo( aPaintInfo ) |
|
|
|
|
KMFolderTreeItem( KFolderTreeItem* parent, QString name, |
|
|
|
|
KMFolder* folder ) |
|
|
|
|
: KFolderTreeItem( parent, folder->protocol(), name ), mFolder( folder ) |
|
|
|
|
{} |
|
|
|
|
|
|
|
|
|
virtual ~KMFolderTreeItem(); |
|
|
|
|
|
|
|
|
|
void paintCell( QPainter * p, const QColorGroup & cg, |
|
|
|
|
int column, int width, int align );
|
|
|
|
|
/** gets the recursive unread-count */ |
|
|
|
|
virtual int countUnreadRecursive(); |
|
|
|
|
|
|
|
|
|
virtual QString key( int, bool ) const; |
|
|
|
|
/** associated folder */ |
|
|
|
|
KMFolder* folder() { return mFolder; } |
|
|
|
|
|
|
|
|
|
virtual int compare( QListViewItem * i, int col, bool ascending ) const;
|
|
|
|
|
/** dnd */ |
|
|
|
|
virtual bool acceptDrag(QDropEvent* ) const; |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
KMFolder* mFolder; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
|
|
#define KMFolderTreeInherited QListView |
|
|
|
|
class KMFolderTree : public QListView |
|
|
|
|
class KMFolderTree : public KFolderTree |
|
|
|
|
{ |
|
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
virtual void drawContentsOffset( QPainter * p, int ox, int oy, |
|
|
|
|
int cx, int cy, int cw, int ch ); |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
KMFolderTree( CryptPlugWrapperList * cryptPlugList, |
|
|
|
|
QWidget *parent=0, const char *name=0 ); |
|
|
|
|
virtual ~KMFolderTree(); |
|
|
|
|
|
|
|
|
|
/** Save config options */ |
|
|
|
|
void writeConfig(); |
|
|
|
|
@ -86,7 +70,7 @@ public: |
|
|
|
|
virtual void reload(bool openFolders = false); |
|
|
|
|
|
|
|
|
|
/** Recusively add folders in a folder directory to a listview item. */ |
|
|
|
|
virtual void addDirectory( KMFolderDir *fdir, QListViewItem* parent ); |
|
|
|
|
virtual void addDirectory( KMFolderDir *fdir, KMFolderTreeItem* parent ); |
|
|
|
|
|
|
|
|
|
/** Find index of given folder. Returns -1 if not found */ |
|
|
|
|
virtual QListViewItem* indexOfFolder(const KMFolder*); |
|
|
|
|
@ -105,9 +89,6 @@ public: |
|
|
|
|
/** Read color options and set palette. */ |
|
|
|
|
void readColorConfig(void); |
|
|
|
|
|
|
|
|
|
/** Ensure that there is only one selected item */ |
|
|
|
|
virtual void setSelected( QListViewItem *, bool ); |
|
|
|
|
|
|
|
|
|
/** Remove information about not existing folders from the config file */ |
|
|
|
|
void cleanupConfigFile(); |
|
|
|
|
|
|
|
|
|
@ -124,18 +105,6 @@ public: |
|
|
|
|
/** toggles the unread and total columns on/off */ |
|
|
|
|
void toggleColumn(int column, bool openFolders = false); |
|
|
|
|
|
|
|
|
|
/** returns true when the column is active */ |
|
|
|
|
bool isUnreadActive() { return unreadIsActive; } |
|
|
|
|
bool isTotalActive() { return totalIsActive; } |
|
|
|
|
|
|
|
|
|
/** returns the current column number (section) */ |
|
|
|
|
int getUnreadColumnNumber() { return header()->mapToSection(unreadIndex); } |
|
|
|
|
int getTotalColumnNumber() { return header()->mapToSection(totalIndex); } |
|
|
|
|
|
|
|
|
|
/** returns the current column number (section) */ |
|
|
|
|
int getUnreadColumIndex() { return unreadIndex; } |
|
|
|
|
int getTotalColumnIndex() { return totalIndex; } |
|
|
|
|
|
|
|
|
|
signals: |
|
|
|
|
/** The selected folder has changed */ |
|
|
|
|
void folderSelected(KMFolder*); |
|
|
|
|
@ -149,28 +118,35 @@ signals: |
|
|
|
|
/** Messages have been dropped onto a folder with Ctrl */ |
|
|
|
|
void folderDropCopy(KMFolder*); |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
/** open ancestors and ensure item is visible */ |
|
|
|
|
void prepareItem( 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(); |
|
|
|
|
|
|
|
|
|
/** Remove all items associated with the given IMAP account */ |
|
|
|
|
void slotAccountDeleted(KMFolderImap*); |
|
|
|
|
|
|
|
|
|
/** Select the item and switch to the folder */ |
|
|
|
|
void doFolderSelected(QListViewItem*); |
|
|
|
|
|
|
|
|
|
/** autoscroll support */ |
|
|
|
|
void startAutoScroll(); |
|
|
|
|
void stopAutoScroll(); |
|
|
|
|
|
|
|
|
|
protected slots: |
|
|
|
|
// void slotRMB(int, int);
|
|
|
|
|
/** called by the folder-manager when the list of folders changed */ |
|
|
|
|
@ -203,6 +179,12 @@ protected slots: |
|
|
|
|
void slotToggleUnreadColumn(); |
|
|
|
|
void slotToggleTotalColumn(); |
|
|
|
|
|
|
|
|
|
void autoScroll(); |
|
|
|
|
|
|
|
|
|
/** right and middle mouse button */ |
|
|
|
|
void rightButtonPressed( QListViewItem *, const QPoint &, int); |
|
|
|
|
void mouseButtonPressed( int btn, QListViewItem *, const QPoint &, int); |
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
|
/** Catch palette changes */ |
|
|
|
|
virtual bool event(QEvent *e); |
|
|
|
|
@ -218,7 +200,6 @@ protected: |
|
|
|
|
bool readIsListViewItemOpen(KMFolderTreeItem *fti); |
|
|
|
|
void writeIsListViewItemOpen(KMFolderTreeItem *fti); |
|
|
|
|
|
|
|
|
|
KMFolderNodeList mList; |
|
|
|
|
QTimer mUpdateTimer; |
|
|
|
|
static QPixmap *pixDir, *pixNode, *pixPlain, *pixFld, *pixFull, *pixIn, |
|
|
|
|
*pixOut, *pixTr, *pixSent; |
|
|
|
|
@ -226,7 +207,7 @@ protected: |
|
|
|
|
/** We need out own root, otherwise the @ref QListView will create
|
|
|
|
|
its own root of type @ref QListViewItem, hence no overriding |
|
|
|
|
paintBranches and no backing pixmap */ |
|
|
|
|
QListViewItem *root; |
|
|
|
|
KMFolderTreeItem *root; |
|
|
|
|
|
|
|
|
|
/** Drag and drop methods */ |
|
|
|
|
void contentsDragEnterEvent( QDragEnterEvent *e ); |
|
|
|
|
@ -245,42 +226,35 @@ protected: |
|
|
|
|
QListViewItem *dropItem; |
|
|
|
|
KMFolderTreeItem *mLastItem; |
|
|
|
|
QTimer autoopen_timer; |
|
|
|
|
KMPaintInfo mPaintInfo; |
|
|
|
|
|
|
|
|
|
// filter some rmb-events
|
|
|
|
|
// bool eventFilter(QObject*, QEvent*);
|
|
|
|
|
bool eventFilter(QObject*, QEvent*); |
|
|
|
|
|
|
|
|
|
virtual void drawContentsOffset( QPainter * p, int ox, int oy, |
|
|
|
|
int cx, int cy, int cw, int ch ); |
|
|
|
|
|
|
|
|
|
/** open ancestors and ensure item is visible */ |
|
|
|
|
void prepareItem( KMFolderTreeItem* ); |
|
|
|
|
|
|
|
|
|
/** connect all signals */ |
|
|
|
|
void connectSignals(); |
|
|
|
|
|
|
|
|
|
// ########### The Trolls may move this Drag and drop stuff to QScrollView
|
|
|
|
|
private: |
|
|
|
|
QTimer autoscroll_timer; |
|
|
|
|
int autoscroll_time; |
|
|
|
|
int autoscroll_accel; |
|
|
|
|
CryptPlugWrapperList * mCryptPlugList; |
|
|
|
|
|
|
|
|
|
/** unread and total column */ |
|
|
|
|
bool unreadIsActive; |
|
|
|
|
bool totalIsActive; |
|
|
|
|
QListViewItemIterator mUpdateIterator; |
|
|
|
|
int unreadIndex; |
|
|
|
|
int totalIndex; |
|
|
|
|
|
|
|
|
|
/** popup for unread/total */ |
|
|
|
|
KPopupMenu* mPopup; |
|
|
|
|
int mUnreadPop; |
|
|
|
|
int mTotalPop; |
|
|
|
|
|
|
|
|
|
// actions for D'n'D from Headers to Folder
|
|
|
|
|
int mActionWhenDnD; |
|
|
|
|
int mActionWhenShiftDnD; |
|
|
|
|
int mActionWhenCtrlDnD; |
|
|
|
|
QTimer autoscroll_timer; |
|
|
|
|
int autoscroll_time; |
|
|
|
|
int autoscroll_accel; |
|
|
|
|
CryptPlugWrapperList * mCryptPlugList; |
|
|
|
|
|
|
|
|
|
public slots: |
|
|
|
|
void startAutoScroll(); |
|
|
|
|
void stopAutoScroll(); |
|
|
|
|
protected slots: |
|
|
|
|
void autoScroll(); |
|
|
|
|
void rightButtonPressed( QListViewItem *, const QPoint &, int); |
|
|
|
|
void mouseButtonPressed( int btn, QListViewItem *, const QPoint &, int); |
|
|
|
|
/** total column */ |
|
|
|
|
QListViewItemIterator mUpdateIterator; |
|
|
|
|
|
|
|
|
|
/** popup for unread/total */ |
|
|
|
|
KPopupMenu* mPopup; |
|
|
|
|
int mUnreadPop; |
|
|
|
|
int mTotalPop; |
|
|
|
|
|
|
|
|
|
/** show popup after D'n'D? */ |
|
|
|
|
bool mShowPopupAfterDnD; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
|
|