KRename – powerful batch renamer
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.

krenameimpl.h 9.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. /***************************************************************************
  2. krenameimpl.h - description
  3. -------------------
  4. begin : Die Mai 20 2003
  5. copyright : (C) 2003 by Dominik Seichter
  6. email : domseichter@web.de
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #ifndef KRENAMEIMPL_H
  17. #define KRENAMEIMPL_H
  18. // Own includes
  19. #include "batchrenamer.h"
  20. #include "krenamedcop.h"
  21. class HelpDialog;
  22. class HelpDialogData;
  23. class TDEAction;
  24. class KComboBox;
  25. class KJanusWidget;
  26. class KMyHistoryCombo;
  27. class KMyListBox;
  28. class KMyListView;
  29. class KMenuBar;
  30. class TDEPopupMenu;
  31. class KPushButton;
  32. class TDEToggleAction;
  33. class KURL;
  34. class KURLRequester;
  35. class KIntNumInput;
  36. class MyHelpCombo;
  37. class MyLabel;
  38. class Plugin;
  39. class PluginLoader;
  40. class TQButtonGroup;
  41. class TQCheckBox;
  42. class TQGroupBox;
  43. class TQFileInfo;
  44. class TQFrame;
  45. class TQHBoxLayout;
  46. class TQLabel;
  47. class TQLineEdit;
  48. class TQListView;
  49. class TQPushButton;
  50. class TQRect;
  51. class TQWidgetStack;
  52. class TQRadioButton;
  53. class TQVBoxLayout;
  54. class TQVGroupBox;
  55. class TQWidget;
  56. #include <kguiitem.h>
  57. KPushButton* createButton( KGuiItem item, TQWidget* parent );
  58. class KRenameImpl : public TQObject, public KRenameDCOP {
  59. Q_OBJECT
  60. friend class ProfileManager;
  61. friend class ProfileDlg;
  62. friend class tabs;
  63. public:
  64. KRenameImpl( TQWidget* p, KMenuBar* m, TQPushButton* finish );
  65. ~KRenameImpl();
  66. void setWizardMode( bool mode );
  67. /*
  68. * public because both get called from KRenameImpl::launch()
  69. */
  70. void updatePre();
  71. void addFileOrDir( const KURL & name );
  72. void setup( bool wizardmode );
  73. void changeParent( TQWidget* p, KMenuBar* m, TQPushButton* finish, TQRect r );
  74. static TQWidget* launch( TQRect rect, const KURL::List & list, KRenameImpl* impl = 0, bool loadprofile = true );
  75. /** DCOP functions we have to implement
  76. */
  77. void addFileOrDir( const TQString & name );
  78. const TQString fileNameTemplate() const;
  79. inline int counterStart() const;
  80. void setExtensionTemplate( const TQString & t );
  81. const TQString extensionTemplate() const;
  82. void setUseExtension( bool b );
  83. bool useExtension() const;
  84. TQStringList tokens() const;
  85. TQString parseString( const TQString & token, const TQString & string );
  86. void addDir( const TQString & name, const TQString & filter, bool recursive, bool hidden, bool dirnames );
  87. const TQString title( int index ) const;
  88. /** @returns true if the user has specified a profile on the commandline
  89. * other wise false is returned
  90. */
  91. inline bool hasCommandlineProfile() const;
  92. public slots:
  93. void setFileNameTemplate( const TQString & t );
  94. void setCounterStart( int index );
  95. signals:
  96. void pageDone( TQWidget* page, const TQString & title );
  97. void showPage( int page );
  98. void enableFinish( bool b );
  99. private slots:
  100. void about();
  101. void addFile();
  102. bool checkErrors();
  103. void clearList();
  104. void enableControls();
  105. void toggleImagePreview();
  106. void moveUp();
  107. void moveDown();
  108. void help();
  109. void removeFile();
  110. void removeFile( int index );
  111. void preferences();
  112. void replace();
  113. void saveConfig();
  114. void start();
  115. void updateCount();
  116. void undo();
  117. void changeUndoScriptName();
  118. void pluginHelpChanged();
  119. void getCoordinates();
  120. void changeNumbers();
  121. void updateDots();
  122. void updatePreview();
  123. void showTokenHelp();
  124. void toggleName();
  125. void changed();
  126. void loadFilePlugins();
  127. void reloadFilePluginData();
  128. void manageProfiles();
  129. TQString easyOptions( KComboBox* combo, KMyHistoryCombo* custom );
  130. void slotEasy1();
  131. void slotEasy2();
  132. void slotEasy3();
  133. void slotEasy4();
  134. /** Update the preview only if the passed
  135. * plugin is enabled for use.
  136. */
  137. void updatePluginPreview( Plugin* p );
  138. private:
  139. static int numRealTimePreview;
  140. /** Change the GUI mode according to the current setting of m_wizard
  141. */
  142. void changeGUIMode();
  143. /** Returns COPY if optionCopy is checked, RENAME if optionRename is checked
  144. * ...
  145. */
  146. int currentRenameMode();
  147. void loadConfig();
  148. void fillStructures( BatchRenamer* b, bool preview );
  149. bool setupBatchRenamer( BatchRenamer* b, bool preview );
  150. void splitFilename( TQFileInfo* fi, TQString* base, TQString* extension );
  151. void setupActions();
  152. void setupPage1();
  153. void setupPage2();
  154. void setupPage3();
  155. void setupPage4();
  156. void setupTab1();
  157. void setupFileTab1();
  158. void setupFileTab2();
  159. void setupPages();
  160. void updateHist();
  161. void parseCommandline();
  162. void addTitle( TQWidget* p, TQVBoxLayout* layout, TQString title );
  163. TQValueList<manualchanges> changes;
  164. void refreshColumnMode();
  165. void parseWizardMode();
  166. void getHelpDialogString( TQLineEdit* edit );
  167. protected:
  168. TQWidget* parent;
  169. KMenuBar* menuBar;
  170. TDEPopupMenu* mnuSort;
  171. TDEAction* loadPlugins;
  172. TQPushButton* finishButton;
  173. PluginLoader* plugin;
  174. TQWidgetStack* fileTab;
  175. TQWidget* page_1;
  176. TQWidget* page_2;
  177. KJanusWidget* page_3;
  178. TQWidget* page_4;
  179. bool m_wizard;
  180. bool m_loadplugins;
  181. bool m_switching;
  182. bool m_autosize;
  183. int m_hist;
  184. int m_index;
  185. int m_step;
  186. bool m_reset;
  187. bool m_hasCommandlineProfile;
  188. KPushButton* buttonUp;
  189. KPushButton* buttonDown;
  190. KPushButton* buttonUp2;
  191. KPushButton* buttonDown2;
  192. KPushButton* buttonAdd;
  193. KPushButton* buttonRemove;
  194. KPushButton* buttonRemoveAll;
  195. KPushButton* buttonReplace;
  196. KPushButton* buttonEasyReplace;
  197. KPushButton* buttonHelp;
  198. KPushButton* buttonMove;
  199. KPushButton* buttonCoord;
  200. KPushButton* buttonNumber;
  201. KPushButton* buttonEasy1;
  202. KPushButton* buttonEasy2;
  203. KPushButton* buttonEasy3;
  204. KPushButton* buttonEasy4;
  205. KComboBox* comboSort;
  206. TQLabel* description;
  207. TQLabel* description2;
  208. TQLabel* description3;
  209. TQLabel* description4;
  210. TQLabel* labelTemplate;
  211. TQLabel* labelHelp;
  212. TQLabel* labelCount;
  213. TQLabel* labelPoint;
  214. KMyListBox* fileList;
  215. KMyListView* preview;
  216. TQButtonGroup* groupOptions;
  217. TQRadioButton* optionCopy;
  218. TQRadioButton* optionMove;
  219. TQRadioButton* optionRename;
  220. TQRadioButton* optionLink;
  221. TQGroupBox* groupExtension;
  222. TQVGroupBox* groupUndo;
  223. KMyHistoryCombo* dirname;
  224. KURLRequester* urlrequester;
  225. KURLRequester* undorequester;
  226. KMyHistoryCombo* filename;
  227. KMyHistoryCombo* extemplate;
  228. TQCheckBox* checkName;
  229. TQCheckBox* checkExtension;
  230. TQCheckBox* checkOverwrite;
  231. TQCheckBox* checkPreview;
  232. TQCheckBox* checkUndoScript;
  233. KComboBox* comboExtension;
  234. MyHelpCombo* comboHelp;
  235. HelpDialog* helpDialog;
  236. HelpDialogData* helpDialogData;
  237. BatchRenamer* b;
  238. TQValueList<int> skip;
  239. TQValueList<replacestrings> rep;
  240. // ==========
  241. // Easy mode:
  242. // ==========
  243. KComboBox* comboKRenamePrefix;
  244. KComboBox* comboKRenameSuffix;
  245. KComboBox* comboKRenameFilename;
  246. KComboBox* comboKRenameExtension;
  247. KMyHistoryCombo* comboPrefix;
  248. KMyHistoryCombo* comboSuffix;
  249. KMyHistoryCombo* comboCustom;
  250. KMyHistoryCombo* comboCustomExtension;
  251. KIntNumInput* spinStart;
  252. KIntNumInput* spinNull;
  253. // ===========
  254. // Layout:
  255. // ===========
  256. TQHBoxLayout* pageLayout;
  257. TQVBoxLayout* pageLayout_2;
  258. TQVBoxLayout* pageLayout_3;
  259. TQVBoxLayout* pageLayout_4;
  260. TQHBoxLayout* tabLayout_0;
  261. TQHBoxLayout* tabLayout_1;
  262. TQHBoxLayout* tabLayout_2;
  263. TQVBoxLayout* tabLayout_3;
  264. TQVBoxLayout* groupAdvancedExtensionLayout;
  265. TQVBoxLayout* groupOptionsLayout;
  266. TQHBoxLayout* groupDirLayout;
  267. TQVBoxLayout* groupNumberLayout;
  268. TQHBoxLayout* groupExtensionLayout;
  269. // page1
  270. TQHBoxLayout* Layout2;
  271. TQVBoxLayout* Layout3;
  272. TQHBoxLayout* Layout4;
  273. TQVBoxLayout* Layout5;
  274. // page4
  275. TQVBoxLayout* Layout10;
  276. TQHBoxLayout* Layout15;
  277. TQVBoxLayout* Layout16;
  278. TQHBoxLayout* Layout22;
  279. TQVBoxLayout* Layout23;
  280. // tab
  281. TQHBoxLayout* Layout100;
  282. TQHBoxLayout* Layout101;
  283. };
  284. int KRenameImpl::counterStart() const
  285. {
  286. return m_index;
  287. }
  288. bool KRenameImpl::hasCommandlineProfile() const
  289. {
  290. return m_hasCommandlineProfile;
  291. }
  292. #endif