kmail

kmfolderdia.h

Go to the documentation of this file.
00001 // -*- mode: C++; c-file-style: "gnu" -*-
00032 #ifndef __KMFOLDERDIA
00033 #define __KMFOLDERDIA
00034 
00035 #include <kdialogbase.h>
00036 #include "configuredialog_p.h"
00037 #include <qvaluevector.h>
00038 
00039 class QCheckBox;
00040 class QPushButton;
00041 class QLineEdit;
00042 class QListBox;
00043 class QComboBox;
00044 class KMFolder;
00045 class KMFolderTreeItem;
00046 class KMFolderDir;
00047 class KIntNumInput;
00048 class KIconButton;
00049 class KEditListBox;
00050 namespace KPIM { class IdentityCombo; }
00051 class KMFolderDialog;
00052 class KMFolderTree;
00053 template <typename T> class QGuardedPtr;
00054 class TemplatesConfiguration;
00055 class KPushButton;
00056 
00057 namespace KMail {
00058   class FolderRequester;
00070 class FolderDiaTab : public QWidget
00071 {
00072   Q_OBJECT
00073 public:
00074    FolderDiaTab( QWidget *parent=0, const char* name=0 )
00075      : QWidget( parent, name ) {}
00076 
00077   virtual void load() = 0;
00078 
00083   virtual bool save() = 0;
00084 
00085   enum AcceptStatus { Accepted, Canceled, Delayed };
00090   virtual AcceptStatus accept() {
00091     return save() ? Accepted : Canceled;
00092   }
00093 
00094 signals:
00097   void readyForAccept();
00098 
00101   void cancelAccept();
00102 
00104   void changed(bool);
00105 };
00106 
00111 class FolderDiaGeneralTab : public FolderDiaTab
00112 {
00113   Q_OBJECT
00114 
00115 public:
00116   FolderDiaGeneralTab( KMFolderDialog* dlg,
00117                        const QString& aName,
00118                        QWidget* parent, const char* name = 0 );
00119 
00120   virtual void load();
00121   virtual bool save();
00122 
00123 private slots:
00124   void slotChangeIcon( QString icon );
00125   /*
00126    * is called if the folder dropdown changes
00127    * then we update the other items to reflect the capabilities
00128    */
00129   void slotFolderNameChanged( const QString& );
00130   void slotFolderContentsSelectionChanged( int );
00131 
00132 private:
00133   void initializeWithValuesFromFolder( KMFolder* folder );
00134 
00135 private:
00136   QComboBox *mShowSenderReceiverComboBox;
00137   QComboBox *mContentsComboBox;
00138   QComboBox *mIncidencesForComboBox;
00139   QCheckBox *mAlarmsBlockedCheckBox;
00140   QLabel      *mNormalIconLabel;
00141   KIconButton *mNormalIconButton;
00142   QLabel      *mUnreadIconLabel;
00143   KIconButton *mUnreadIconButton;
00144   QCheckBox   *mIconsCheckBox;
00145   QCheckBox   *mNewMailCheckBox;
00146   QCheckBox   *mNotifyOnNewMailCheckBox;
00147   QCheckBox   *mKeepRepliesInSameFolderCheckBox;
00148   KLineEdit   *mNameEdit;
00149 
00150   KPIM::IdentityCombo *mIdentityComboBox;
00151 
00152   KMFolderDialog* mDlg;
00153   bool mIsLocalSystemFolder;
00154 };
00155 
00160 class FolderDiaTemplatesTab : public FolderDiaTab
00161 {
00162   Q_OBJECT
00163 
00164 public:
00165   FolderDiaTemplatesTab( KMFolderDialog *dlg, QWidget *parent );
00166 
00167   virtual void load();
00168   virtual bool save();
00169 
00170 public slots:
00171   void slotEmitChanged(); // do nothing for now
00172 
00173   void slotCopyGlobal();
00174 
00175 private:
00176   void initializeWithValuesFromFolder( KMFolder* folder );
00177 
00178 private:
00179   QCheckBox* mCustom;
00180   TemplatesConfiguration* mWidget;
00181   KPushButton* mCopyGlobal;
00182   KMFolder* mFolder;
00183   uint mIdentity;
00184 
00185   KMFolderDialog* mDlg;
00186   bool mIsLocalSystemFolder;
00187 };
00188 
00189 } // end of namespace KMail
00190 
00194 class KMFolderDialog : public KDialogBase
00195 {
00196   Q_OBJECT
00197 
00198 public:
00199   KMFolderDialog( KMFolder *folder, KMFolderDir *aFolderDir,
00200           KMFolderTree* parent, const QString& caption,
00201                   const QString& name = QString::null );
00202 
00203   KMFolder* folder() const { return mFolder; }
00204   void setFolder( KMFolder* folder );
00205   // Was mFolder just created? (This only makes sense from save())
00206   // If Apply is clicked, or OK proceeeds half-way, then next time "new folder" will be false.
00207   bool isNewFolder() const { return mIsNewFolder; }
00208 
00209   KMFolderDir* folderDir() const { return mFolderDir; }
00210   typedef QValueList<QGuardedPtr<KMFolder> > FolderList;
00211 
00212   KMFolder* parentFolder() const { return mParentFolder; }
00213 
00214   KMFolderTree* folderTree() const { return mFolderTree; }
00215 
00216 protected slots:
00217   void slotChanged( bool );
00218   virtual void slotOk();
00219   virtual void slotApply();
00220 
00221   void slotReadyForAccept();
00222   void slotCancelAccept();
00223 
00224 private:
00225   void addTab( KMail::FolderDiaTab* tab );
00226 
00227 private:
00228   // Can be 0 initially when creating a folder, but will be set by save() in the first tab.
00229   QGuardedPtr<KMFolder> mFolder;
00230   QGuardedPtr<KMFolderDir> mFolderDir;
00231   QGuardedPtr<KMFolder> mParentFolder;
00232 
00233   bool mIsNewFolder; // if true, save() did set mFolder.
00234 
00235   QValueVector<KMail::FolderDiaTab*> mTabs;
00236   int mDelayedSavingTabs; // this should go into a base class one day
00237   KMFolderTree* mFolderTree;
00238 };
00239 
00240 #endif /*__KMFOLDERDIA*/
00241