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
|
/****************************************************************************
**
** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "mainwindow.h"
#include "qfileiconview.h"
#include "../dirview/dirview.h"
#include <ntqsplitter.h>
#include <ntqprogressbar.h>
#include <ntqlabel.h>
#include <ntqstatusbar.h>
#include <ntqtoolbar.h>
#include <ntqcombobox.h>
#include <ntqpixmap.h>
#include <ntqtoolbutton.h>
#include <ntqdir.h>
#include <ntqfileinfo.h>
static const char* cdtoparent_xpm[]={
"15 13 3 1",
". c None",
"* c #000000",
"a c #ffff99",
"..*****........",
".*aaaaa*.......",
"***************",
"*aaaaaaaaaaaaa*",
"*aaaa*aaaaaaaa*",
"*aaa***aaaaaaa*",
"*aa*****aaaaaa*",
"*aaaa*aaaaaaaa*",
"*aaaa*aaaaaaaa*",
"*aaaa******aaa*",
"*aaaaaaaaaaaaa*",
"*aaaaaaaaaaaaa*",
"***************"};
static const char* newfolder_xpm[] = {
"15 14 4 1",
" c None",
". c #000000",
"+ c #FFFF00",
"@ c #FFFFFF",
" . ",
" ",
" . ",
" . . ",
" .... . . . ",
" .+@+@. . . ",
".......... . .",
".@+@+@+@+@.. ",
".+@+@+@+@+. . ",
".@+@+@+@+@. . ",
".+@+@+@+@+. ",
".@+@+@+@+@. ",
".+@+@+@+@+. ",
"........... "};
FileMainWindow::FileMainWindow()
: TQMainWindow()
{
setup();
}
void FileMainWindow::show()
{
TQMainWindow::show();
}
void FileMainWindow::setup()
{
TQSplitter *splitter = new TQSplitter( this );
dirlist = new DirectoryView( splitter, "dirlist", TRUE );
dirlist->addColumn( "Name" );
dirlist->addColumn( "Type" );
Directory *root = new Directory( dirlist, "/" );
root->setOpen( TRUE );
splitter->setResizeMode( dirlist, TQSplitter::KeepSize );
fileview = new TQtFileIconView( "/", splitter );
fileview->setSelectionMode( TQIconView::Extended );
setCentralWidget( splitter );
TQToolBar *toolbar = new TQToolBar( this, "toolbar" );
setRightJustification( TRUE );
(void)new TQLabel( tr( " Path: " ), toolbar );
pathCombo = new TQComboBox( TRUE, toolbar );
pathCombo->setAutoCompletion( TRUE );
toolbar->setStretchableWidget( pathCombo );
connect( pathCombo, SIGNAL( activated( const TQString & ) ),
this, SLOT ( changePath( const TQString & ) ) );
toolbar->addSeparator();
TQPixmap pix;
pix = TQPixmap( cdtoparent_xpm );
upButton = new TQToolButton( pix, "One directory up", TQString::null,
this, SLOT( cdUp() ), toolbar, "cd up" );
pix = TQPixmap( newfolder_xpm );
mkdirButton = new TQToolButton( pix, "New Folder", TQString::null,
this, SLOT( newFolder() ), toolbar, "new folder" );
connect( dirlist, SIGNAL( folderSelected( const TQString & ) ),
fileview, SLOT ( setDirectory( const TQString & ) ) );
connect( fileview, SIGNAL( directoryChanged( const TQString & ) ),
this, SLOT( directoryChanged( const TQString & ) ) );
connect( fileview, SIGNAL( startReadDir( int ) ),
this, SLOT( slotStartReadDir( int ) ) );
connect( fileview, SIGNAL( readNextDir() ),
this, SLOT( slotReadNextDir() ) );
connect( fileview, SIGNAL( readDirDone() ),
this, SLOT( slotReadDirDone() ) );
setDockEnabled( DockLeft, FALSE );
setDockEnabled( DockRight, FALSE );
label = new TQLabel( statusBar() );
statusBar()->addWidget( label, 2, TRUE );
progress = new TQProgressBar( statusBar() );
statusBar()->addWidget( progress, 1, TRUE );
connect( fileview, SIGNAL( enableUp() ),
this, SLOT( enableUp() ) );
connect( fileview, SIGNAL( disableUp() ),
this, SLOT( disableUp() ) );
connect( fileview, SIGNAL( enableMkdir() ),
this, SLOT( enableMkdir() ) );
connect( fileview, SIGNAL( disableMkdir() ),
this, SLOT( disableMkdir() ) );
}
void FileMainWindow::setPathCombo()
{
TQString dir = caption();
int i = 0;
bool found = FALSE;
for ( i = 0; i < pathCombo->count(); ++i ) {
if ( pathCombo->text( i ) == dir) {
found = TRUE;
break;
}
}
if ( found )
pathCombo->setCurrentItem( i );
else {
pathCombo->insertItem( dir );
pathCombo->setCurrentItem( pathCombo->count() - 1 );
}
}
void FileMainWindow::directoryChanged( const TQString &dir )
{
setCaption( dir );
setPathCombo();
}
void FileMainWindow::slotStartReadDir( int dirs )
{
label->setText( tr( " Reading Directory..." ) );
progress->reset();
progress->setTotalSteps( dirs );
}
void FileMainWindow::slotReadNextDir()
{
int p = progress->progress();
progress->setProgress( ++p );
}
void FileMainWindow::slotReadDirDone()
{
label->setText( tr( " Reading Directory Done." ) );
progress->setProgress( progress->totalSteps() );
}
void FileMainWindow::cdUp()
{
TQDir dir = fileview->currentDir();
dir.cd( ".." );
fileview->setDirectory( dir );
}
void FileMainWindow::newFolder()
{
fileview->newDirectory();
}
void FileMainWindow::changePath( const TQString &path )
{
if ( TQFileInfo( path ).exists() )
fileview->setDirectory( path );
else
setPathCombo();
}
void FileMainWindow::enableUp()
{
upButton->setEnabled( TRUE );
}
void FileMainWindow::disableUp()
{
upButton->setEnabled( FALSE );
}
void FileMainWindow::enableMkdir()
{
mkdirButton->setEnabled( TRUE );
}
void FileMainWindow::disableMkdir()
{
mkdirButton->setEnabled( FALSE );
}
|