summaryrefslogtreecommitdiffstats
path: root/kdat/KDatMainWindow.h
blob: 34772dc2d10b859de6969d6b4eedf6152c0067b2 (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
// KDat - a tar-based DAT archiver
// Copyright (C) 1998-2000  Sean Vyain, svyain@mail.tds.net
// Copyright (C) 2001-2002  Lawrence Widman, kdat@cardiothink.com
//
// 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.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

#ifndef KDat_h
#define KDat_h

#include <tdemainwindow.h>
#include <kdialog.h>
#include <tqpushbutton.h>
#include <tqlabel.h>

class KMenuBar;
class TQSplitter;
class KStatusBar;
class TDEToolBar;
class KTreeView;
class KTreeViewItem;

class TQPixmap;
class TQPopupMenu;

class Archive;
class ArchiveInfoWidget;
class BackupProfile;
class BackupProfileInfoWidget;
class BackupProfileRootNode;
class File;
class FileInfoWidget;
class Node;
class RootNode;
class Tape;
class TapeDriveNode;
class TapeFileInfoWidget;
class TapeInfoWidget;

/**
 * @short The KDat main window.  Everything happens from here.
 */
class KDatMainWindow : public TDEMainWindow {
    TQ_OBJECT
  

private:
    bool                     _destroyed;
    KMenuBar*                _menu;
    TQPopupMenu*              _fileMenu;
    TQPopupMenu*              _editMenu;
    TDEToolBar*                _toolbar;
    KStatusBar*              _statusBar;
    TQSplitter*               _panner;
    KTreeView*               _tree;
    TQPopupMenu*              _tapeDriveMenu;
    TQPopupMenu*              _archiveMenu;
    TQPopupMenu*              _mountedArchiveMenu;
    TQPopupMenu*              _mountedTapeFileMenu;
    TQPopupMenu*              _localFileMenu;
    TQPopupMenu*              _tapeMenu;
    TQPopupMenu*              _backupProfileRootMenu;
    TQPopupMenu*              _backupProfileMenu;
    ArchiveInfoWidget*       _archiveInfo;
    BackupProfileInfoWidget* _backupProfileInfo;
    TapeFileInfoWidget*      _tapeFileInfo;
    TapeInfoWidget*          _tapeInfo;
    FileInfoWidget*          _fileInfo;
    RootNode*                _rootNode;
    TapeDriveNode*           _tapeDriveNode;
    BackupProfileRootNode*   _backupProfileRootNode;

    static KDatMainWindow* _instance;

    void doVerify( bool restore = FALSE );
    void setTapePresent( bool tapePresent, bool eject = TRUE );
    int calcBackupSize( const TQString& workingDir, bool local, const TQStringList& files,
                        bool incremental, const TQString& snapshot, bool removeSnapshot );

    KDatMainWindow();
   
    // 2002-01-24 LEW
    // used in calcBackupSize() to see whether user cancelled the on-going 
    // backup to tape.  
    KDialog*                 _backupdialog;
    TQPushButton*             _cancel;
    TQPushButton*             _continue;
    TQLabel*                  _lbl;
    int                      stop_flag;  
    void create_backup_dialog();
    // 2002-01-24 LEW

private slots:
    void localExpanding( KTreeViewItem* item, bool& allow );
    void localExpanded( int index );
    void localCollapsed( int index );
    void localSelected( int index );
    void localHighlighted( int index );
    void localPopupMenu( int index, const TQPoint& p );

    void fileBackup();
    void fileRestore();
    void fileVerify();
    void fileMountTape();
    void fileIndexTape();
    void fileDeleteArchive();
    void fileDeleteIndex();
    void fileFormatTape();
    void fileNewBackupProfile();
    void fileDeleteBackupProfile();
    void fileQuit();
    void editPreferences();
    void help();

    void slotTapeDevice();
    void slotTapeMounted();
    void slotTapeUnmounted();

    // 2002-01-24 LEW    
    void backupCancel();
    void backupContinue();
    // 2002-01-24 LEW

protected:
    virtual void readProperties( TDEConfig* config );
    virtual void saveProperties( TDEConfig* config );
    
public:
    /**
     * Destroy the KDat main window.
     */
    ~KDatMainWindow();

    /**
     * Get a reference to the single instance of the KDat main window.
     *
     * @return A pointer to the KDat main window.
     */
    static KDatMainWindow* getInstance();

    /**
     * Display the tape drive node popup menu.
     * 
     * @param p The upper left corner of the menu.
     */
    void popupTapeDriveMenu( const TQPoint& p );

    /**
     * Display the archive node popup menu.
     *
     * @param p The upper left corner of the menu.
     */
    void popupArchiveMenu( const TQPoint& p );

    /**
     * Display the mounted archive node popup menu.
     *
     * @param p The upper left corner of the menu.
     */
    void popupMountedArchiveMenu( const TQPoint& p );

    /**
     * Display the mounted tape file node popup menu.
     *
     * @param p The upper left corner of the menu.
     */
    void popupMountedTapeFileMenu( const TQPoint& p );

    /**
     * Display the local file node popup menu.
     *
     * @param p The upper left corner of the menu.
     */
    void popupLocalFileMenu( const TQPoint& p );

    /**
     * Display the tape index node popup menu.
     *
     * @param p The upper left corner of the menu.
     */
    void popupTapeMenu( const TQPoint& p );

    /**
     * Display the backup profile root node popup menu.
     *
     * @param p The upper left corner of the menu.
     */
    void popupBackupProfileRootMenu( const TQPoint& p );

    /**
     * Display the backup profile node popup menu.
     *
     * @param p The upper left corner of the menu.
     */
    void popupBackupProfileMenu( const TQPoint& p );

    /**
     * Hide all of the info viewers.
     */
    void hideInfo();

    /**
     * Display the tape info widget for the given tape.
     *
     * @param tape The tape index to display.
     */
    void showTapeInfo( Tape* tape );

    /**
     * Display the archive info widget for the given archive.
     *
     * @param archive The archive to display.
     */
    void showArchiveInfo( Archive* archive );

    /**
     * Display the tape file info widget for the given file.
     *
     * @param file The file to display.
     */
    void showTapeFileInfo( File* file );

    /**
     * Display the backup profile info widget for the given backup profile.
     *
     * @param backupProfile The backup profile to display.
     */
    void showBackupProfileInfo( BackupProfile* backupProfile );

    /**
     * Display the local file info widget for the given file.
     *
     * @param file The full path name of the file to display.
     */
    void showFileInfo( const TQString & name );

    /**
     * Make sure that the user interface is consistent for the given mounted
     * tape.  This method mostly just enables or disables GUI objects based on
     * the currently mounted tape, and selections.
     *
     * @param tape The currently mounted tape. May be NULL.
     */
    void configureUI( Tape* tape );

    /**
     * Get a list of all the files selected for backup.
     *
     * @param files This list will be filled with the selected files.
     */
    void getBackupFiles( TQStringList& files );

    /**
     * Set the list of all the files selected for backup.
     *
     * @param files This list will become the selection.
     */
    void setBackupFiles( const TQStringList& files );

public slots:
    /**
     * Display a text message in the status bar.
     *
     * @param msg The message to display.
     */
    void status( const TQString & msg );
    
    /**
     * Initialize the KDat main window before displaying.
     */
    virtual void show();

};

#endif