kmail
favoritefolderview.h
00001 /* 00002 Copyright (c) 2007 Volker Krause <vkrause@kde.org> 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef KMAIL_FAVORITEFOLDERVIEW_H 00020 #define KMAIL_FAVORITEFOLDERVIEW_H 00021 00022 #include "kmfoldertree.h" 00023 00024 namespace KMail { 00025 00026 class FavoriteFolderView; 00027 00028 class FavoriteFolderViewItem : public KMFolderTreeItem 00029 { 00030 Q_OBJECT 00031 public: 00032 FavoriteFolderViewItem( FavoriteFolderView *parent, const QString & name, KMFolder* folder ); 00033 00034 protected: 00035 bool useTopLevelIcon() const { return false; } 00036 int iconSize() const { return 22; } 00037 00038 private slots: 00039 void updateCount(); 00040 void nameChanged(); 00041 00042 private: 00043 QString mOldName; 00044 }; 00045 00046 class FavoriteFolderView : public FolderTreeBase 00047 { 00048 Q_OBJECT 00049 00050 public: 00051 FavoriteFolderView( KMMainWidget *mainWidget, QWidget *parent = 0 ); 00052 ~FavoriteFolderView(); 00053 00054 void readConfig(); 00055 void writeConfig(); 00056 00057 KMFolderTreeItem* addFolder( KMFolder *folder, const QString &name = QString::null, 00058 QListViewItem *after = 0 ); 00059 00060 public slots: 00061 void folderTreeSelectionChanged( KMFolder *folder ); 00062 void checkMail(); 00063 00064 protected: 00065 bool acceptDrag(QDropEvent* e) const; 00066 void contentsDragEnterEvent( QDragEnterEvent *e ); 00067 void readColorConfig(); 00068 00069 private: 00070 static QString prettyName( KMFolderTreeItem* fti ); 00071 KMFolderTreeItem* findFolderTreeItem( KMFolder* folder ) const; 00072 00073 private slots: 00074 void selectionChanged(); 00075 void itemClicked( QListViewItem *item ); 00076 void folderRemoved( KMFolder *folder ); 00077 void dropped( QDropEvent *e, QListViewItem *after ); 00078 void contextMenu( QListViewItem *item, const QPoint &point ); 00079 void removeFolder(); 00080 void initializeFavorites(); 00081 void renameFolder(); 00082 void addFolder(); 00083 void notifyInstancesOnChange(); 00084 00085 private: 00086 KMFolderTreeItem* mContextMenuItem; 00087 static QValueList<FavoriteFolderView*> mInstances; 00088 bool mReadingConfig; 00089 }; 00090 00091 } 00092 00093 #endif