summaryrefslogtreecommitdiffstats
path: root/krename/krenameimpl.h
blob: aa8850fa1f605c17ef0a541b87ef76629aff1c08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/***************************************************************************
                          krenameimpl.h  -  description
                             -------------------
    begin                : Die Mai 20 2003
    copyright            : (C) 2003 by Dominik Seichter
    email                : domseichter@web.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KRENAMEIMPL_H
#define KRENAMEIMPL_H

// Own includes
#include "batchrenamer.h"
#include "krenamedcop.h"

class HelpDialog;
class HelpDialogData;
class KAction;
class KComboBox;
class KJanusWidget;
class KMyHistoryCombo;
class KMyListBox;
class KMyListView;
class KMenuBar;
class KPopupMenu;
class KPushButton;
class KToggleAction;
class KURL;
class KURLRequester;
class KIntNumInput;
class MyHelpCombo;
class MyLabel;
class Plugin;
class PluginLoader;
class TQButtonGroup;
class TQCheckBox;
class TQGroupBox;
class TQFileInfo;
class TQFrame;
class TQHBoxLayout;
class TQLabel;
class TQLineEdit;
class TQListView;
class TQPushButton;
class TQRect;
class TQWidgetStack;
class TQRadioButton;
class TQVBoxLayout;
class TQVGroupBox;
class TQWidget;

#include <kguiitem.h>
KPushButton* createButton( KGuiItem item, TQWidget* parent );

class KRenameImpl : public TQObject, public KRenameDCOP {
    Q_OBJECT
  TQ_OBJECT
    
    friend class ProfileManager;
    friend class ProfileDlg;
    friend class tabs;

    public: 
        KRenameImpl( TQWidget* p, KMenuBar* m, TQPushButton* finish );
        ~KRenameImpl();

        void setWizardMode( bool mode );
        
        /*
         * public because both get called from KRenameImpl::launch()
         */
        void updatePre();
        void addFileOrDir( const KURL & name );

        void setup( bool wizardmode );
        void changeParent( TQWidget* p, KMenuBar* m, TQPushButton* finish, TQRect r );
        static TQWidget* launch( TQRect rect, const KURL::List & list, KRenameImpl* impl = 0, bool loadprofile = true );

        /** DCOP functions we have to implement
          */
        void addFileOrDir( const TQString & name );
        const TQString fileNameTemplate() const;
        inline int counterStart() const;
  
        void setExtensionTemplate( const TQString & t );
        const TQString extensionTemplate() const;

        void setUseExtension( bool b );
        bool useExtension() const;
        
        TQStringList tokens() const;

        TQString parseString( const TQString & token, const TQString & string );
        void addDir( const TQString & name, const TQString & filter, bool recursive, bool hidden, bool dirnames );

        const TQString title( int index ) const;
        
        /** @returns true if the user has specified a profile on the commandline
         *           other wise false is returned
         */
        inline bool hasCommandlineProfile() const;

    public slots:
        void setFileNameTemplate( const TQString & t );
        void setCounterStart( int index );
                
    signals:
        void pageDone( TQWidget* page, const TQString & title );
        void showPage( int page );
        void enableFinish( bool b );

    private slots:
        void about();
        void addFile();
        bool checkErrors();
        void clearList();
        void enableControls();
        void toggleImagePreview();
        void moveUp();
        void moveDown();
        void help();
        void removeFile();
        void removeFile( int index );
        void preferences();
        void replace();
        void saveConfig();
        void start();
        void updateCount();
        void undo();
        void changeUndoScriptName();
        void pluginHelpChanged();
        void getCoordinates();
        void changeNumbers();
        void updateDots();
        void updatePreview();
        void showTokenHelp();
        void toggleName();
        void changed();
        void loadFilePlugins();
        void reloadFilePluginData();
        void manageProfiles();
        TQString easyOptions( KComboBox* combo, KMyHistoryCombo* custom );
        void slotEasy1();
        void slotEasy2();
        void slotEasy3();
        void slotEasy4();

        /** Update the preview only if the passed
         *  plugin is enabled for use.
         */
        void updatePluginPreview( Plugin* p );

    private:
        static int numRealTimePreview;

        /** Change the GUI mode according to the current setting of m_wizard
          */
        void changeGUIMode();
        
        /** Returns COPY if optionCopy is checked, RENAME if optionRename is checked
          * ...
          */
        int currentRenameMode();
        
        void loadConfig();
        void fillStructures( BatchRenamer* b, bool preview );
        bool setupBatchRenamer( BatchRenamer* b, bool preview );
        void splitFilename( TQFileInfo* fi, TQString* base, TQString* extension );

        void setupActions();
        void setupPage1();
        void setupPage2();
        void setupPage3();
        void setupPage4();
        void setupTab1();
        void setupFileTab1();
        void setupFileTab2();
        void setupPages();
        void updateHist();
        void parseCommandline();
        void addTitle( TQWidget* p, TQVBoxLayout* tqlayout, TQString title );

        TQValueList<manualchanges> changes;
        void refreshColumnMode();
        void parseWizardMode();
        void getHelpDialogString( TQLineEdit* edit );
        
    protected:
        TQWidget* parent;
        KMenuBar* menuBar;
        KPopupMenu* mnuSort;
        KAction* loadPlugins;
        
        TQPushButton* finishButton;

        PluginLoader* plugin;

        TQWidgetStack* fileTab;
        
        TQWidget* page_1;
        TQWidget* page_2;
        KJanusWidget* page_3;
        TQWidget* page_4;

        bool m_wizard;
        bool m_loadplugins;
        bool m_switching;
        bool m_autosize;
        int m_hist;
        int m_index;
        int m_step;
	bool m_reset;

        bool m_hasCommandlineProfile;

        KPushButton* buttonUp;
        KPushButton* buttonDown;
        KPushButton* buttonUp2;
        KPushButton* buttonDown2;
        KPushButton* buttonAdd;
        KPushButton* buttonRemove;
        KPushButton* buttonRemoveAll;
        KPushButton* buttonReplace;
        KPushButton* buttonEasyReplace;
        KPushButton* buttonHelp;
        KPushButton* buttonMove;
        KPushButton* buttonCoord;
        KPushButton* buttonNumber;
        
        KPushButton* buttonEasy1;
        KPushButton* buttonEasy2;
        KPushButton* buttonEasy3;
        KPushButton* buttonEasy4;
        KComboBox* comboSort;
        
        TQLabel* description;
        TQLabel* description2;
        TQLabel* description3;
        TQLabel* description4;

        TQLabel* labelTemplate;
        TQLabel* labelHelp;
        TQLabel* labelCount;
        TQLabel* labelPoint;

        KMyListBox* fileList;
        KMyListView* preview;
        TQButtonGroup* groupOptions;

        TQRadioButton* optionCopy;
        TQRadioButton* optionMove;
        TQRadioButton* optionRename;
        TQRadioButton* optionLink;

        TQGroupBox* groupExtension;
        TQVGroupBox* groupUndo;

        KMyHistoryCombo* dirname;
        KURLRequester* urlrequester;
        KURLRequester* undorequester;
        KMyHistoryCombo* filename;
        KMyHistoryCombo* extemplate;

        TQCheckBox* checkName;
        TQCheckBox* checkExtension;
        TQCheckBox* checkOverwrite;
        TQCheckBox* checkPreview;
        TQCheckBox* checkUndoScript;

        KComboBox* comboExtension;

        MyHelpCombo* comboHelp;
        HelpDialog* helpDialog;
        HelpDialogData* helpDialogData;

        BatchRenamer* b;
        TQValueList<int> skip;
        TQValueList<replacestrings> rep;

        // ==========
        // Easy mode:
        // ==========
        
        KComboBox* comboKRenamePrefix;
        KComboBox* comboKRenameSuffix;
        KComboBox* comboKRenameFilename;
        KComboBox* comboKRenameExtension;
        
        KMyHistoryCombo* comboPrefix;
        KMyHistoryCombo* comboSuffix;        
        KMyHistoryCombo* comboCustom;
        KMyHistoryCombo* comboCustomExtension;
        
        KIntNumInput* spinStart;
        KIntNumInput* spinNull;        
        
        // ===========
        // Layout:
        // ===========

        TQHBoxLayout* pageLayout;
        TQVBoxLayout* pageLayout_2;
        TQVBoxLayout* pageLayout_3;
        TQVBoxLayout* pageLayout_4;

        TQHBoxLayout* tabLayout_0;
        TQHBoxLayout* tabLayout_1;
        TQHBoxLayout* tabLayout_2;
        TQVBoxLayout* tabLayout_3;
        TQVBoxLayout* groupAdvancedExtensionLayout;
        TQVBoxLayout* groupOptionsLayout;
        TQHBoxLayout* groupDirLayout;
        TQVBoxLayout* groupNumberLayout;
        TQHBoxLayout* groupExtensionLayout;

        // page1
        TQHBoxLayout* Layout2;
        TQVBoxLayout* Layout3;
        TQHBoxLayout* Layout4;
        TQVBoxLayout* Layout5;

        // page4
        TQVBoxLayout* Layout10;
        TQHBoxLayout* Layout15;
        TQVBoxLayout* Layout16;
        TQHBoxLayout* Layout22;
        TQVBoxLayout* Layout23;

        // tab
        TQHBoxLayout* Layout100;
        TQHBoxLayout* Layout101;
};


int KRenameImpl::counterStart() const
{
    return m_index;
}

bool KRenameImpl::hasCommandlineProfile() const
{
    return m_hasCommandlineProfile;
}

#endif