TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kmfolderdia.h 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. // -*- mode: C++; c-file-style: "gnu" -*-
  2. /**
  3. * kmfolderdia.h
  4. *
  5. * Copyright (c) 1997-2004 KMail Developers
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. *
  21. * In addition, as a special exception, the copyright holders give
  22. * permission to link the code of this program with any edition of
  23. * the TQt library by Trolltech AS, Norway (or with modified versions
  24. * of TQt that use the same license as TQt), and distribute linked
  25. * combinations including the two. You must obey the GNU General
  26. * Public License in all respects for all of the code used other than
  27. * TQt. If you modify this file, you may extend this exception to
  28. * your version of the file, but you are not obligated to do so. If
  29. * you do not wish to do so, delete this exception statement from
  30. * your version.
  31. */
  32. #ifndef __KMFOLDERDIA
  33. #define __KMFOLDERDIA
  34. #include <kdialogbase.h>
  35. #include "configuredialog_p.h"
  36. #include <tqvaluevector.h>
  37. class TQCheckBox;
  38. class TQPushButton;
  39. class TQLineEdit;
  40. class TQListBox;
  41. class TQComboBox;
  42. class KMFolder;
  43. class KMFolderTreeItem;
  44. class KMFolderDir;
  45. class KIntNumInput;
  46. class TDEIconButton;
  47. class KEditListBox;
  48. namespace KPIM { class IdentityCombo; }
  49. class KMFolderDialog;
  50. class KMFolderTree;
  51. template <typename T> class TQGuardedPtr;
  52. class TemplatesConfiguration;
  53. class KPushButton;
  54. namespace KMail {
  55. class FolderRequester;
  56. /**
  57. * This is the base class for tabs in the folder dialog.
  58. * It uses the API from ConfigModuleTab (basically: it's a widget that can load and save)
  59. * but it also adds support for delayed-saving:
  60. * when save() needs to use async jobs (e.g. TDEIO) for saving,
  61. * we need to delay the closing until after the jobs are finished,
  62. * and to cancel the saving on error.
  63. *
  64. * Feel free to rename and move this base class somewhere else if it
  65. * can be useful for other dialogs.
  66. */
  67. class FolderDiaTab : public TQWidget
  68. {
  69. Q_OBJECT
  70. public:
  71. FolderDiaTab( TQWidget *parent=0, const char* name=0 )
  72. : TQWidget( parent, name ) {}
  73. virtual void load() = 0;
  74. /// Unlike ConfigModuleTab, we return a bool from save.
  75. /// This allows to cancel closing on error.
  76. /// When called from the Apply button, the return value is ignored
  77. /// @return whether save succeeded
  78. virtual bool save() = 0;
  79. enum AccepStatus { Accepted, Canceled, Delayed };
  80. /// Called when clicking OK.
  81. /// If a module returns Delayed, the closing is cancelled for now,
  82. /// and the module can close the dialog later on (i.e. after an async
  83. /// operation like a TDEIO job).
  84. virtual AccepStatus accept() {
  85. return save() ? Accepted : Canceled;
  86. }
  87. signals:
  88. /// Emit this to tell the dialog that you're done with the async jobs,
  89. /// and that the dialog can be closed.
  90. void readyForAccept();
  91. /// Emit this, i.e. after a job had an error, to tell the dialog to cancel
  92. /// the closing.
  93. void cancelAccept();
  94. /// Called when this module was changed [not really used yet]
  95. void changed(bool);
  96. };
  97. /**
  98. * "General" tab in the folder dialog
  99. * Internal class, only used by KMFolderDialog
  100. */
  101. class FolderDiaGeneralTab : public FolderDiaTab
  102. {
  103. Q_OBJECT
  104. public:
  105. FolderDiaGeneralTab( KMFolderDialog* dlg,
  106. const TQString& aName,
  107. TQWidget* parent, const char* name = 0 );
  108. virtual void load();
  109. virtual bool save();
  110. private slots:
  111. void slotChangeIcon( TQString icon );
  112. /*
  113. * is called if the folder dropdown changes
  114. * then we update the other items to reflect the capabilities
  115. */
  116. void slotFolderNameChanged( const TQString& );
  117. void slotFolderContentsSelectionChanged( int );
  118. private:
  119. void initializeWithValuesFromFolder( KMFolder* folder );
  120. private:
  121. TQComboBox *mShowSenderReceiverComboBox;
  122. TQComboBox *mContentsComboBox;
  123. TQComboBox *mIncidencesForComboBox;
  124. TQCheckBox *mAlarmsBlockedCheckBox;
  125. TQCheckBox *mSharedSeenFlagsCheckBox;
  126. TQLabel *mNormalIconLabel;
  127. TDEIconButton *mNormalIconButton;
  128. TQLabel *mUnreadIconLabel;
  129. TDEIconButton *mUnreadIconButton;
  130. TQCheckBox *mIconsCheckBox;
  131. TQCheckBox *mNewMailCheckBox;
  132. TQCheckBox *mNotifyOnNewMailCheckBox;
  133. TQCheckBox *mKeepRepliesInSameFolderCheckBox;
  134. KLineEdit *mNameEdit;
  135. KPIM::IdentityCombo *mIdentityComboBox;
  136. KMFolderDialog* mDlg;
  137. bool mIsLocalSystemFolder;
  138. bool mIsResourceFolder;
  139. };
  140. /**
  141. * "Templates" tab in the folder dialog
  142. * Internal class, only used by KMFolderDialog
  143. */
  144. class FolderDiaTemplatesTab : public FolderDiaTab
  145. {
  146. Q_OBJECT
  147. public:
  148. FolderDiaTemplatesTab( KMFolderDialog *dlg, TQWidget *parent );
  149. virtual void load();
  150. virtual bool save();
  151. public slots:
  152. void slotEmitChanged(); // do nothing for now
  153. void slotCopyGlobal();
  154. private:
  155. void initializeWithValuesFromFolder( KMFolder* folder );
  156. private:
  157. TQCheckBox* mCustom;
  158. TemplatesConfiguration* mWidget;
  159. KPushButton* mCopyGlobal;
  160. KMFolder* mFolder;
  161. uint mIdentity;
  162. KMFolderDialog* mDlg;
  163. bool mIsLocalSystemFolder;
  164. };
  165. } // end of namespace KMail
  166. /**
  167. * Dialog for handling the properties of a mail folder
  168. */
  169. class KMFolderDialog : public KDialogBase
  170. {
  171. Q_OBJECT
  172. public:
  173. KMFolderDialog( KMFolder *folder, KMFolderDir *aFolderDir,
  174. KMFolderTree* parent, const TQString& caption,
  175. const TQString& name = TQString() );
  176. KMFolder* folder() const { return mFolder; }
  177. void setFolder( KMFolder* folder );
  178. // Was mFolder just created? (This only makes sense from save())
  179. // If Apply is clicked, or OK proceeeds half-way, then next time "new folder" will be false.
  180. bool isNewFolder() const { return mIsNewFolder; }
  181. KMFolderDir* folderDir() const { return mFolderDir; }
  182. typedef TQValueList<TQGuardedPtr<KMFolder> > FolderList;
  183. KMFolder* parentFolder() const { return mParentFolder; }
  184. KMFolderTree* folderTree() const { return mFolderTree; }
  185. protected slots:
  186. void slotChanged( bool );
  187. virtual void slotOk();
  188. virtual void slotApply();
  189. void slotReadyForAccept();
  190. void slotCancelAccept();
  191. private:
  192. void addTab( KMail::FolderDiaTab* tab );
  193. private:
  194. // Can be 0 initially when creating a folder, but will be set by save() in the first tab.
  195. TQGuardedPtr<KMFolder> mFolder;
  196. TQGuardedPtr<KMFolderDir> mFolderDir;
  197. TQGuardedPtr<KMFolder> mParentFolder;
  198. bool mIsNewFolder; // if true, save() did set mFolder.
  199. TQValueVector<KMail::FolderDiaTab*> mTabs;
  200. int mDelayedSavingTabs; // this should go into a base class one day
  201. KMFolderTree* mFolderTree;
  202. };
  203. #endif /*__KMFOLDERDIA*/