kmail

kmfolderdia.h
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 <tqvaluevector.h>
00038 
00039 class TQCheckBox;
00040 class TQPushButton;
00041 class TQLineEdit;
00042 class TQListBox;
00043 class TQComboBox;
00044 class KMFolder;
00045 class KMFolderTreeItem;
00046 class KMFolderDir;
00047 class KIntNumInput;
00048 class TDEIconButton;
00049 class KEditListBox;
00050 namespace KPIM { class IdentityCombo; }
00051 class KMFolderDialog;
00052 class KMFolderTree;
00053 template <typename T> class TQGuardedPtr;
00054 class TemplatesConfiguration;
00055 class KPushButton;
00056 
00057 namespace KMail {
00058   class FolderRequester;
00070 class FolderDiaTab : public TQWidget
00071 {
00072   Q_OBJECT
00073   
00074 public:
00075    FolderDiaTab( TQWidget *parent=0, const char* name=0 )
00076      : TQWidget( parent, name ) {}
00077 
00078   virtual void load() = 0;
00079 
00084   virtual bool save() = 0;
00085 
00086   enum AccepStatus { Accepted, Canceled, Delayed };
00091   virtual AccepStatus accept() {
00092     return save() ? Accepted : Canceled;
00093   }
00094 
00095 signals:
00098   void readyForAccept();
00099 
00102   void cancelAccept();
00103 
00105   void changed(bool);
00106 };
00107 
00112 class FolderDiaGeneralTab : public FolderDiaTab
00113 {
00114   Q_OBJECT
00115   
00116 
00117 public:
00118   FolderDiaGeneralTab( KMFolderDialog* dlg,
00119                        const TQString& aName,
00120                        TQWidget* parent, const char* name = 0 );
00121 
00122   virtual void load();
00123   virtual bool save();
00124 
00125 private slots:
00126   void slotChangeIcon( TQString icon );
00127   /*
00128    * is called if the folder dropdown changes
00129    * then we update the other items to reflect the capabilities
00130    */
00131   void slotFolderNameChanged( const TQString& );
00132   void slotFolderContentsSelectionChanged( int );
00133 
00134 private:
00135   void initializeWithValuesFromFolder( KMFolder* folder );
00136 
00137 private:
00138   TQComboBox *mShowSenderReceiverComboBox;
00139   TQComboBox *mContentsComboBox;
00140   TQComboBox *mIncidencesForComboBox;
00141   TQCheckBox *mAlarmsBlockedCheckBox;
00142   TQCheckBox *mSharedSeenFlagsCheckBox;
00143   TQLabel      *mNormalIconLabel;
00144   TDEIconButton *mNormalIconButton;
00145   TQLabel      *mUnreadIconLabel;
00146   TDEIconButton *mUnreadIconButton;
00147   TQCheckBox   *mIconsCheckBox;
00148   TQCheckBox   *mNewMailCheckBox;
00149   TQCheckBox   *mNotifyOnNewMailCheckBox;
00150   TQCheckBox   *mKeepRepliesInSameFolderCheckBox;
00151   KLineEdit   *mNameEdit;
00152 
00153   KPIM::IdentityCombo *mIdentityComboBox;
00154 
00155   KMFolderDialog* mDlg;
00156   bool mIsLocalSystemFolder;
00157   bool mIsResourceFolder;
00158 };
00159 
00164 class FolderDiaTemplatesTab : public FolderDiaTab
00165 {
00166   Q_OBJECT
00167   
00168 
00169 public:
00170   FolderDiaTemplatesTab( KMFolderDialog *dlg, TQWidget *parent );
00171 
00172   virtual void load();
00173   virtual bool save();
00174 
00175 public slots:
00176   void slotEmitChanged(); // do nothing for now
00177 
00178   void slotCopyGlobal();
00179 
00180 private:
00181   void initializeWithValuesFromFolder( KMFolder* folder );
00182 
00183 private:
00184   TQCheckBox* mCustom;
00185   TemplatesConfiguration* mWidget;
00186   KPushButton* mCopyGlobal;
00187   KMFolder* mFolder;
00188   uint mIdentity;
00189 
00190   KMFolderDialog* mDlg;
00191   bool mIsLocalSystemFolder;
00192 };
00193 
00194 } // end of namespace KMail
00195 
00199 class KMFolderDialog : public KDialogBase
00200 {
00201   Q_OBJECT
00202   
00203 
00204 public:
00205   KMFolderDialog( KMFolder *folder, KMFolderDir *aFolderDir,
00206           KMFolderTree* parent, const TQString& caption,
00207                   const TQString& name = TQString() );
00208 
00209   KMFolder* folder() const { return mFolder; }
00210   void setFolder( KMFolder* folder );
00211   // Was mFolder just created? (This only makes sense from save())
00212   // If Apply is clicked, or OK proceeeds half-way, then next time "new folder" will be false.
00213   bool isNewFolder() const { return mIsNewFolder; }
00214 
00215   KMFolderDir* folderDir() const { return mFolderDir; }
00216   typedef TQValueList<TQGuardedPtr<KMFolder> > FolderList;
00217 
00218   KMFolder* parentFolder() const { return mParentFolder; }
00219 
00220   KMFolderTree* folderTree() const { return mFolderTree; }
00221 
00222 protected slots:
00223   void slotChanged( bool );
00224   virtual void slotOk();
00225   virtual void slotApply();
00226 
00227   void slotReadyForAccept();
00228   void slotCancelAccept();
00229 
00230 private:
00231   void addTab( KMail::FolderDiaTab* tab );
00232 
00233 private:
00234   // Can be 0 initially when creating a folder, but will be set by save() in the first tab.
00235   TQGuardedPtr<KMFolder> mFolder;
00236   TQGuardedPtr<KMFolderDir> mFolderDir;
00237   TQGuardedPtr<KMFolder> mParentFolder;
00238 
00239   bool mIsNewFolder; // if true, save() did set mFolder.
00240 
00241   TQValueVector<KMail::FolderDiaTab*> mTabs;
00242   int mDelayedSavingTabs; // this should go into a base class one day
00243   KMFolderTree* mFolderTree;
00244 };
00245 
00246 #endif /*__KMFOLDERDIA*/
00247