summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/ofileselector_p.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp
index e2af32b..488dee2 100644
--- a/microkde/ofileselector_p.cpp
+++ b/microkde/ofileselector_p.cpp
@@ -64,329 +64,330 @@ void OFileViewInterface::activate( const QString& ) {
64} 64}
65void OFileViewInterface::ok() { 65void OFileViewInterface::ok() {
66 emit selector()->ok(); 66 emit selector()->ok();
67} 67}
68void OFileViewInterface::cancel() { 68void OFileViewInterface::cancel() {
69 emit selector()->cancel(); 69 emit selector()->cancel();
70} 70}
71void OFileViewInterface::closeMe() { 71void OFileViewInterface::closeMe() {
72 emit selector()->closeMe(); 72 emit selector()->closeMe();
73} 73}
74void OFileViewInterface::fileSelected( const QString& str) { 74void OFileViewInterface::fileSelected( const QString& str) {
75 emit selector()->fileSelected( str); 75 emit selector()->fileSelected( str);
76} 76}
77void OFileViewInterface::fileSelected( const DocLnk& lnk) { 77void OFileViewInterface::fileSelected( const DocLnk& lnk) {
78 emit selector()->fileSelected( lnk ); 78 emit selector()->fileSelected( lnk );
79} 79}
80void OFileViewInterface::setCurrentFileName( const QString& str ) { 80void OFileViewInterface::setCurrentFileName( const QString& str ) {
81 selector()->m_lneEdit->setText( str ); 81 selector()->m_lneEdit->setText( str );
82} 82}
83QString OFileViewInterface::currentFileName()const{ 83QString OFileViewInterface::currentFileName()const{
84 return selector()->m_lneEdit->text(); 84 return selector()->m_lneEdit->text();
85} 85}
86QString OFileViewInterface::startDirectory()const{ 86QString OFileViewInterface::startDirectory()const{
87 return selector()->m_startDir; 87 return selector()->m_startDir;
88} 88}
89 89
90 90
91ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 91ODocumentFileView::ODocumentFileView( OFileSelector* selector )
92 : OFileViewInterface( selector ) { 92 : OFileViewInterface( selector ) {
93 m_selector = 0; 93 m_selector = 0;
94 setName( i18n("Documents") ); 94 setName( i18n("Documents") );
95} 95}
96ODocumentFileView::~ODocumentFileView() { 96ODocumentFileView::~ODocumentFileView() {
97 97
98} 98}
99QString ODocumentFileView::selectedName()const { 99QString ODocumentFileView::selectedName()const {
100 if (!m_selector) 100 if (!m_selector)
101 return QString::null; 101 return QString::null;
102 102
103 return m_selector->selected()->file(); 103 return m_selector->selected()->file();
104} 104}
105QString ODocumentFileView::selectedPath()const { 105QString ODocumentFileView::selectedPath()const {
106 return QPEApplication::documentDir(); 106 return QPEApplication::documentDir();
107} 107}
108QString ODocumentFileView::directory()const { 108QString ODocumentFileView::directory()const {
109 return selectedPath(); 109 return selectedPath();
110} 110}
111void ODocumentFileView::reread() { 111void ODocumentFileView::reread() {
112 if (!m_selector) 112 if (!m_selector)
113 return; 113 return;
114 114
115 m_selector->setNewVisible( showNew() ); 115 m_selector->setNewVisible( showNew() );
116 m_selector->setCloseVisible( showClose() ); 116 m_selector->setCloseVisible( showClose() );
117 m_selector->filter = currentMimeType().join(";"); 117 m_selector->filter = currentMimeType().join(";");
118 m_selector->reread(); 118 m_selector->reread();
119} 119}
120int ODocumentFileView::fileCount()const { 120int ODocumentFileView::fileCount()const {
121 if (!m_selector) 121 if (!m_selector)
122 return -1; 122 return -1;
123 123
124 return m_selector->fileCount(); 124 return m_selector->fileCount();
125} 125}
126 126
127DocLnk ODocumentFileView::selectedDocument()const { 127DocLnk ODocumentFileView::selectedDocument()const {
128 if (!m_selector) 128 if (!m_selector)
129 return DocLnk(); 129 return DocLnk();
130 DocLnk lnk = *m_selector->selected(); 130 DocLnk lnk = *m_selector->selected();
131 return lnk; 131 return lnk;
132} 132}
133 133
134QWidget* ODocumentFileView::widget( QWidget* parent ) { 134QWidget* ODocumentFileView::widget( QWidget* parent ) {
135 if (!m_selector ) { 135 if (!m_selector ) {
136 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 136 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
137 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), 137 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ),
138 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 138 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
139 QObject::connect(m_selector, SIGNAL(closeMe() ), 139 QObject::connect(m_selector, SIGNAL(closeMe() ),
140 selector(), SIGNAL(closeMe() ) ); 140 selector(), SIGNAL(closeMe() ) );
141 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), 141 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ),
142 selector(), SIGNAL(newSelected(const DocLnk& ) ) ); 142 selector(), SIGNAL(newSelected(const DocLnk& ) ) );
143 } 143 }
144 144
145 return m_selector; 145 return m_selector;
146} 146}
147 147
148/* 148/*
149 * This is the file system view used 149 * This is the file system view used
150 * we use a QListView + QListViewItems for it 150 * we use a QListView + QListViewItems for it
151 */ 151 */
152 152
153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
154 const QString& path, const QString& date, 154 const QString& path, const QString& date,
155 const QString& size, const QString& dir, 155 const QString& size, const QString& dir,
156 bool isLocked, bool isDir ) 156 bool isLocked, bool isDir )
157 : QListViewItem( view ) 157 : QListViewItem( view )
158{ 158{
159 159
160 QString kind; 160 QString kind = "dir";;
161 QString _path = path; 161 QString _path = path;
162 if ( isDir ) 162 if ( !isDir ){
163 kind = "dir"; 163 int arrow = path.findRev( "." ,-1);
164 else 164 if (arrow > 0 ) {
165 kind = "file"; 165 kind = path.mid(arrow+1);
166 }
167 }
166 setPixmap(0, pixmap ); 168 setPixmap(0, pixmap );
167 int arrow = path.find( "->" ); 169 int arrow = path.find( "->" );
168 if (arrow > 0 ) { 170 if (arrow > 0 ) {
169 kind += path.mid( arrow );
170 _path = path.left(arrow); 171 _path = path.left(arrow);
171 } 172 }
172 setText(1, _path ); 173 setText(1, _path );
173 setText(2, size ); 174 setText(2, size );
174 setText(3, date ); 175 setText(3, date );
175 setText(4, kind ); 176 setText(4, kind );
176 m_isDir = isDir; 177 m_isDir = isDir;
177 m_dir = dir; 178 m_dir = dir;
178 m_locked = isLocked; 179 m_locked = isLocked;
179} 180}
180OFileSelectorItem::~OFileSelectorItem() { 181OFileSelectorItem::~OFileSelectorItem() {
181 182
182} 183}
183bool OFileSelectorItem::isLocked()const { 184bool OFileSelectorItem::isLocked()const {
184 return m_locked; 185 return m_locked;
185} 186}
186QString OFileSelectorItem::directory()const { 187QString OFileSelectorItem::directory()const {
187 return m_dir; 188 return m_dir;
188} 189}
189bool OFileSelectorItem::isDir()const { 190bool OFileSelectorItem::isDir()const {
190 return m_isDir; 191 return m_isDir;
191} 192}
192QString OFileSelectorItem::path()const { 193QString OFileSelectorItem::path()const {
193 return text( 1 ); 194 return text( 1 );
194} 195}
195QString OFileSelectorItem::key( int id, bool )const { 196QString OFileSelectorItem::key( int id, bool )const {
196 QString ke; 197 QString ke;
197 if( id == 0 || id == 1 ){ // name 198 if( id == 0 || id == 1 ){ // name
198 if( m_isDir ){ 199 if( m_isDir ){
199 ke.append("0" ); 200 ke.append("0" );
200 ke.append( text(1) ); 201 ke.append( text(1) );
201 }else{ 202 }else{
202 ke.append("1" ); 203 ke.append("1" );
203 ke.append( text(1) ); 204 ke.append( text(1) );
204 } 205 }
205 return ke; 206 return ke;
206 } else if ( id == 2 ) { 207 } else if ( id == 2 ) {
207 QString sort = "00000000"; 208 QString sort = "00000000";
208 sort = sort.left( 9-text( 2 ).length()) + text( 2 ); 209 sort = sort.left( 9-text( 2 ).length()) + text( 2 );
209 return sort; 210 return sort;
210 211
211 } else 212 } else
212 return text( id ); 213 return text( id );
213 214
214} 215}
215 216
216OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, 217OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
217 OFileSelector* sel) 218 OFileSelector* sel)
218 : QWidget( parent ), m_sel( sel ) { 219 : QWidget( parent ), m_sel( sel ) {
219 m_all = false; 220 m_all = false;
220 QVBoxLayout* lay = new QVBoxLayout( this ); 221 QVBoxLayout* lay = new QVBoxLayout( this );
221 m_currentDir = startDir; 222 m_currentDir = startDir;
222 223
223 /* 224 /*
224 * now we add a special bar 225 * now we add a special bar
225 * One Button For Up 226 * One Button For Up
226 * Home 227 * Home
227 * Doc 228 * Doc
228 * And a dropdown menu with FileSystems 229 * And a dropdown menu with FileSystems
229 * FUTURE: one to change dir with lineedit 230 * FUTURE: one to change dir with lineedit
230 * Bookmarks 231 * Bookmarks
231 * Create Dir 232 * Create Dir
232 */ 233 */
233 QHBox* box = new QHBox(this ); 234 QHBox* box = new QHBox(this );
234 box->setBackgroundMode( PaletteButton ); 235 box->setBackgroundMode( PaletteButton );
235 box->setSpacing( 0 ); 236 box->setSpacing( 0 );
236 237
237 QToolButton *btn = new QToolButton( box ); 238 QToolButton *btn = new QToolButton( box );
238 btn->setIconSet( Resource::loadPixmap("up") ); 239 btn->setIconSet( Resource::loadPixmap("up") );
239 connect(btn, SIGNAL(clicked() ), 240 connect(btn, SIGNAL(clicked() ),
240 this, SLOT( cdUP() ) ); 241 this, SLOT( cdUP() ) );
241 242
242 btn = new QToolButton( box ); 243 btn = new QToolButton( box );
243 btn->setIconSet( Resource::loadPixmap("home") ); 244 btn->setIconSet( Resource::loadPixmap("home") );
244 connect(btn, SIGNAL(clicked() ), 245 connect(btn, SIGNAL(clicked() ),
245 this, SLOT( cdHome() ) ); 246 this, SLOT( cdHome() ) );
246 247
247 btn = new QToolButton( box ); 248 btn = new QToolButton( box );
248 btn->setIconSet( Resource::loadPixmap("DocsIcon") ); 249 btn->setIconSet( Resource::loadPixmap("DocsIcon") );
249 connect(btn, SIGNAL(clicked() ), 250 connect(btn, SIGNAL(clicked() ),
250 this, SLOT(cdDoc() ) ); 251 this, SLOT(cdDoc() ) );
251 252
252 m_btnNew = new QToolButton( box ); 253 m_btnNew = new QToolButton( box );
253 m_btnNew->setIconSet( Resource::loadPixmap("new") ); 254 m_btnNew->setIconSet( Resource::loadPixmap("new") );
254 connect(m_btnNew, SIGNAL(clicked() ), 255 connect(m_btnNew, SIGNAL(clicked() ),
255 this, SLOT(slotNew() ) ); 256 this, SLOT(slotNew() ) );
256 257
257 258
258 m_btnClose = new QToolButton( box ); 259 m_btnClose = new QToolButton( box );
259 m_btnClose->setIconSet( Resource::loadPixmap("close") ); 260 m_btnClose->setIconSet( Resource::loadPixmap("close") );
260 connect(m_btnClose, SIGNAL(clicked() ), 261 connect(m_btnClose, SIGNAL(clicked() ),
261 selector(), SIGNAL(closeMe() ) ); 262 selector(), SIGNAL(closeMe() ) );
262 263
263 btn = new QToolButton( box ); 264 btn = new QToolButton( box );
264 btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); 265 btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") );
265 266
266 /* let's fill device parts */ 267 /* let's fill device parts */
267 QPopupMenu* pop = new QPopupMenu(this); 268 QPopupMenu* pop = new QPopupMenu(this);
268 connect(pop, SIGNAL( activated(int) ), 269 connect(pop, SIGNAL( activated(int) ),
269 this, SLOT(slotFSActivated(int) ) ); 270 this, SLOT(slotFSActivated(int) ) );
270 271
271 StorageInfo storage; 272 StorageInfo storage;
272 const QList<FileSystem> &fs = storage.fileSystems(); 273 const QList<FileSystem> &fs = storage.fileSystems();
273 QListIterator<FileSystem> it(fs); 274 QListIterator<FileSystem> it(fs);
274 for ( ; it.current(); ++it ) { 275 for ( ; it.current(); ++it ) {
275 const QString disk = (*it)->name(); 276 const QString disk = (*it)->name();
276 const QString path = (*it)->path(); 277 const QString path = (*it)->path();
277 m_dev.insert( disk, path ); 278 m_dev.insert( disk, path );
278 pop->insertItem( disk ); 279 pop->insertItem( disk );
279 } 280 }
280 m_fsPop = pop; 281 m_fsPop = pop;
281 282
282 283
283 btn->setPopup( pop ); 284 btn->setPopup( pop );
284 btn->setPopupDelay ( 0 ); 285 btn->setPopupDelay ( 0 );
285 lay->addWidget( box ); 286 lay->addWidget( box );
286 287
287 m_view = new QListView( this ); 288 m_view = new QListView( this );
288 289
289 m_view->installEventFilter(this); 290 m_view->installEventFilter(this);
290 291
291 QPEApplication::setStylusOperation( m_view->viewport(), 292 QPEApplication::setStylusOperation( m_view->viewport(),
292 QPEApplication::RightOnHold); 293 QPEApplication::RightOnHold);
293 m_view->addColumn(" " ); 294 m_view->addColumn(" " );
294 m_view->addColumn(i18n("Name"), 135 ); 295 m_view->addColumn(i18n("Name"), 150 );
295 m_view->addColumn(i18n("Size"), -1 ); 296 m_view->addColumn(i18n("Size"), -1 );
296 m_view->addColumn(i18n("Date"), 60 ); 297 m_view->addColumn(i18n("Date"), -1 );
297 m_view->addColumn(i18n("Mime Type"), -1 ); 298 m_view->addColumn(i18n("Mime Type"), -1 );
298 299
299 300
300 m_view->setSorting( 1 ); 301 m_view->setSorting( 1 );
301 m_view->setAllColumnsShowFocus( TRUE ); 302 m_view->setAllColumnsShowFocus( TRUE );
302 303
303 lay->addWidget( m_view, 1000 ); 304 lay->addWidget( m_view, 1000 );
304 connectSlots(); 305 connectSlots();
305} 306}
306OFileViewFileListView::~OFileViewFileListView() { 307OFileViewFileListView::~OFileViewFileListView() {
307} 308}
308void OFileViewFileListView::slotNew() { 309void OFileViewFileListView::slotNew() {
309 DocLnk lnk; 310 DocLnk lnk;
310 emit selector()->newSelected( lnk ); 311 emit selector()->newSelected( lnk );
311} 312}
312OFileSelectorItem* OFileViewFileListView::currentItem()const{ 313OFileSelectorItem* OFileViewFileListView::currentItem()const{
313 QListViewItem* item = m_view->currentItem(); 314 QListViewItem* item = m_view->currentItem();
314 if (!item ) 315 if (!item )
315 return 0l; 316 return 0l;
316 317
317 return static_cast<OFileSelectorItem*>(item); 318 return static_cast<OFileSelectorItem*>(item);
318} 319}
319void OFileViewFileListView::reread( bool all ) { 320void OFileViewFileListView::reread( bool all ) {
320 m_view->clear(); 321 m_view->clear();
321 322
322 if (selector()->showClose() ) 323 if (selector()->showClose() )
323 m_btnClose->show(); 324 m_btnClose->show();
324 else 325 else
325 m_btnClose->hide(); 326 m_btnClose->hide();
326 327
327 if (selector()->showNew() ) 328 if (selector()->showNew() )
328 m_btnNew->show(); 329 m_btnNew->show();
329 else 330 else
330 m_btnNew->hide(); 331 m_btnNew->hide();
331 332
332 m_mimes = selector()->currentMimeType(); 333 m_mimes = selector()->currentMimeType();
333 m_all = all; 334 m_all = all;
334 335
335 QDir dir( m_currentDir ); 336 QDir dir( m_currentDir );
336 if (!dir.exists() ) 337 if (!dir.exists() )
337 return; 338 return;
338 topLevelWidget()->setCaption( dir.path() ); 339 topLevelWidget()->setCaption( dir.path() );
339 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 340 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
340 int filter; 341 int filter;
341 if (m_all ) 342 if (m_all )
342 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 343 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
343 else 344 else
344 filter = QDir::Files | QDir::Dirs | QDir::All; 345 filter = QDir::Files | QDir::Dirs | QDir::All;
345 dir.setFilter( filter ); 346 dir.setFilter( filter );
346 347
347 // now go through all files 348 // now go through all files
348 const QFileInfoList *list = dir.entryInfoList(); 349 const QFileInfoList *list = dir.entryInfoList();
349 if (!list) { 350 if (!list) {
350 cdUP(); 351 cdUP();
351 return; 352 return;
352 } 353 }
353 QFileInfoListIterator it( *list ); 354 QFileInfoListIterator it( *list );
354 QFileInfo *fi; 355 QFileInfo *fi;
355 while( (fi=it.current() ) ){ 356 while( (fi=it.current() ) ){
356 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ 357 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
357 ++it; 358 ++it;
358 continue; 359 continue;
359 } 360 }
360 361
361 /* 362 /*
362 * It is a symlink we try to resolve it now but don't let us attack by DOS 363 * It is a symlink we try to resolve it now but don't let us attack by DOS
363 * 364 *
364 */ 365 */
365 if( fi->isSymLink() ){ 366 if( fi->isSymLink() ){
366 qDebug("SYMLINK "); 367 qDebug("SYMLINK ");
367 QString file = fi->readLink(); 368 QString file = fi->readLink();
368 for( int i = 0; i<=5; i++) { // 5 tries to prevent dos 369 for( int i = 0; i<=5; i++) { // 5 tries to prevent dos
369 QFileInfo info( file ); 370 QFileInfo info( file );
370 qDebug("FILE %s ", file.latin1()); 371 qDebug("FILE %s ", file.latin1());
371 if( !info.exists() ){ 372 if( !info.exists() ){
372 addSymlink( fi, TRUE ); 373 addSymlink( fi, TRUE );
373 break; 374 break;
374 }else if( info.isDir() ){ 375 }else if( info.isDir() ){
375 addDir( fi, TRUE ); 376 addDir( fi, TRUE );
376 break; 377 break;
377 }else if( info.isFile() ){ 378 }else if( info.isFile() ){
378 addFile( fi, TRUE ); 379 addFile( fi, TRUE );
379 break; 380 break;
380 }else if( info.isSymLink() ){ 381 }else if( info.isSymLink() ){
381 file = info.readLink() ; 382 file = info.readLink() ;
382 break; 383 break;
383 }else if( i == 4){ // couldn't resolve symlink add it as symlink 384 }else if( i == 4){ // couldn't resolve symlink add it as symlink
384 addSymlink( fi ); 385 addSymlink( fi );
385 } 386 }
386 } // off for loop for symlink resolving 387 } // off for loop for symlink resolving
387 }else if( fi->isDir() ) 388 }else if( fi->isDir() )
388 addDir( fi ); 389 addDir( fi );
389 else if( fi->isFile() ) 390 else if( fi->isFile() )
390 addFile( fi ); 391 addFile( fi );
391 392
392 ++it; 393 ++it;