• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdefile
 

tdeio/tdefile

  • tdeio
  • tdefile
tdediroperator.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000 Stephan Kulow <coolo@kde.org>
3 1999,2000,2001,2002,2003 Carsten Pfeiffer <pfeiffer@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include <unistd.h>
22
23#include <tqdir.h>
24#include <tqapplication.h>
25#include <tqdialog.h>
26#include <tqlabel.h>
27#include <tqlayout.h>
28#include <tqpushbutton.h>
29#include <tqpopupmenu.h>
30#include <tqregexp.h>
31#include <tqtimer.h>
32#include <tqvbox.h>
33
34#include <tdeaction.h>
35#include <tdeapplication.h>
36#include <kdebug.h>
37#include <kdialog.h>
38#include <kdialogbase.h>
39#include <kdirlister.h>
40#include <kinputdialog.h>
41#include <tdelocale.h>
42#include <tdemessagebox.h>
43#include <tdepopupmenu.h>
44#include <kprogress.h>
45#include <kstdaction.h>
46#include <tdeio/job.h>
47#include <tdeio/jobclasses.h>
48#include <tdeio/netaccess.h>
49#include <tdeio/previewjob.h>
50#include <tdeio/renamedlg.h>
51#include <kpropertiesdialog.h>
52#include <kservicetypefactory.h>
53#include <tdestdaccel.h>
54#include <kde_file.h>
55
56#include "config-tdefile.h"
57#include "kcombiview.h"
58#include "tdediroperator.h"
59#include "tdefiledetailview.h"
60#include "tdefileiconview.h"
61#include "tdefilepreview.h"
62#include "tdefileview.h"
63#include "tdefileitem.h"
64#include "tdefilemetapreview.h"
65
66
67template class TQPtrStack<KURL>;
68template class TQDict<KFileItem>;
69
70
71class KDirOperator::KDirOperatorPrivate
72{
73public:
74 KDirOperatorPrivate() {
75 onlyDoubleClickSelectsFiles = false;
76 progressDelayTimer = 0L;
77 dirHighlighting = false;
78 config = 0L;
79 dropOptions = 0;
80 }
81
82 ~KDirOperatorPrivate() {
83 delete progressDelayTimer;
84 }
85
86 bool dirHighlighting;
87 TQString lastURL; // used for highlighting a directory on cdUp
88 bool onlyDoubleClickSelectsFiles;
89 TQTimer *progressDelayTimer;
90 TDEActionSeparator *viewActionSeparator;
91 int dropOptions;
92
93 TDEConfig *config;
94 TQString configGroup;
95};
96
97KDirOperator::KDirOperator(const KURL& _url,
98 TQWidget *parent, const char* _name)
99 : TQWidget(parent, _name),
100 dir(0),
101 m_fileView(0),
102 progress(0)
103{
104 myPreview = 0L;
105 myMode = KFile::File;
106 m_viewKind = KFile::Simple;
107 mySorting = static_cast<TQDir::SortSpec>(TQDir::Name | TQDir::DirsFirst);
108 d = new KDirOperatorPrivate;
109
110 if (_url.isEmpty()) { // no dir specified -> current dir
111 TQString strPath = TQDir::currentDirPath();
112 strPath.append('/');
113 currUrl = KURL();
114 currUrl.setProtocol(TQString::fromLatin1("file"));
115 currUrl.setPath(strPath);
116 }
117 else {
118 currUrl = _url;
119 if ( currUrl.protocol().isEmpty() )
120 currUrl.setProtocol(TQString::fromLatin1("file"));
121
122 currUrl.addPath("/"); // make sure we have a trailing slash!
123 }
124
125 setDirLister( new KDirLister( true ) );
126
127 connect(&myCompletion, TQ_SIGNAL(match(const TQString&)),
128 TQ_SLOT(slotCompletionMatch(const TQString&)));
129
130 progress = new KProgress(this, "progress");
131 progress->adjustSize();
132 progress->move(2, height() - progress->height() -2);
133
134 d->progressDelayTimer = new TQTimer( this, "progress delay timer" );
135 connect( d->progressDelayTimer, TQ_SIGNAL( timeout() ),
136 TQ_SLOT( slotShowProgress() ));
137
138 myCompleteListDirty = false;
139
140 backStack.setAutoDelete( true );
141 forwardStack.setAutoDelete( true );
142
143 // action stuff
144 setupActions();
145 setupMenu();
146
147 setFocusPolicy(TQWidget::WheelFocus);
148
149 installEventFilter(this);
150}
151
152KDirOperator::~KDirOperator()
153{
154 resetCursor();
155 if ( m_fileView )
156 {
157 if ( d->config )
158 m_fileView->writeConfig( d->config, d->configGroup );
159
160 delete m_fileView;
161 m_fileView = 0L;
162 }
163
164 delete myPreview;
165 delete dir;
166 delete d;
167}
168
169
170void KDirOperator::setSorting( TQDir::SortSpec spec )
171{
172 if ( m_fileView )
173 m_fileView->setSorting( spec );
174 mySorting = spec;
175 updateSortActions();
176}
177
178void KDirOperator::resetCursor()
179{
180 TQApplication::restoreOverrideCursor();
181 progress->hide();
182}
183
184void KDirOperator::insertViewDependentActions()
185{
186 // If we have a new view actionCollection(), insert its actions
187 // into viewActionMenu.
188
189 if( !m_fileView )
190 return;
191
192 if ( (viewActionMenu->popupMenu()->count() == 0) || // Not yet initialized or...
193 (viewActionCollection != m_fileView->actionCollection()) ) // ...changed since.
194 {
195 if (viewActionCollection)
196 {
197 disconnect( viewActionCollection, TQ_SIGNAL( inserted( TDEAction * )),
198 this, TQ_SLOT( slotViewActionAdded( TDEAction * )));
199 disconnect( viewActionCollection, TQ_SIGNAL( removed( TDEAction * )),
200 this, TQ_SLOT( slotViewActionRemoved( TDEAction * )));
201 }
202
203 viewActionMenu->popupMenu()->clear();
204// viewActionMenu->insert( shortAction );
205// viewActionMenu->insert( detailedAction );
206// viewActionMenu->insert( actionSeparator );
207 viewActionMenu->insert( myActionCollection->action( "short view" ) );
208 viewActionMenu->insert( myActionCollection->action( "detailed view" ) );
209 viewActionMenu->insert( actionSeparator );
210 viewActionMenu->insert( showHiddenAction );
211// viewActionMenu->insert( myActionCollection->action( "single" ));
212 viewActionMenu->insert( separateDirsAction );
213 // Warning: adjust slotViewActionAdded() and slotViewActionRemoved()
214 // when you add/remove actions here!
215
216 viewActionCollection = m_fileView->actionCollection();
217 if (!viewActionCollection)
218 return;
219
220 if ( !viewActionCollection->isEmpty() )
221 {
222 viewActionMenu->insert( d->viewActionSeparator );
223
224 // first insert the normal actions, then the grouped ones
225 TQStringList groups = viewActionCollection->groups();
226 groups.prepend( TQString::null ); // actions without group
227 TQStringList::ConstIterator git = groups.begin();
228 TDEActionPtrList list;
229 TDEAction *sep = actionCollection()->action("separator");
230 for ( ; git != groups.end(); ++git )
231 {
232 if ( git != groups.begin() )
233 viewActionMenu->insert( sep );
234
235 list = viewActionCollection->actions( *git );
236 TDEActionPtrList::ConstIterator it = list.begin();
237 for ( ; it != list.end(); ++it )
238 viewActionMenu->insert( *it );
239 }
240 }
241
242 connect( viewActionCollection, TQ_SIGNAL( inserted( TDEAction * )),
243 TQ_SLOT( slotViewActionAdded( TDEAction * )));
244 connect( viewActionCollection, TQ_SIGNAL( removed( TDEAction * )),
245 TQ_SLOT( slotViewActionRemoved( TDEAction * )));
246 }
247}
248
249void KDirOperator::activatedMenu( const KFileItem *, const TQPoint& pos )
250{
251 setupMenu();
252 updateSelectionDependentActions();
253
254 actionMenu->popup( pos );
255}
256
257void KDirOperator::updateSelectionDependentActions()
258{
259 bool hasSelection = m_fileView && m_fileView->selectedItems() &&
260 !m_fileView->selectedItems()->isEmpty();
261 myActionCollection->action( "trash" )->setEnabled( hasSelection );
262 myActionCollection->action( "delete" )->setEnabled( hasSelection );
263 myActionCollection->action( "properties" )->setEnabled( hasSelection );
264}
265
266void KDirOperator::setPreviewWidget(const TQWidget *w)
267{
268 if(w != 0L)
269 m_viewKind = (m_viewKind | KFile::PreviewContents);
270 else
271 m_viewKind = (m_viewKind & ~KFile::PreviewContents);
272
273 delete myPreview;
274 myPreview = w;
275
276 TDEToggleAction *preview = static_cast<TDEToggleAction*>(myActionCollection->action("preview"));
277 preview->setEnabled( w != 0L );
278 preview->setChecked( w != 0L );
279 setView( static_cast<KFile::FileView>(m_viewKind) );
280}
281
282int KDirOperator::numDirs() const
283{
284 return m_fileView ? m_fileView->numDirs() : 0;
285}
286
287int KDirOperator::numFiles() const
288{
289 return m_fileView ? m_fileView->numFiles() : 0;
290}
291
292void KDirOperator::slotDetailedView()
293{
294 KFile::FileView view = static_cast<KFile::FileView>( (m_viewKind & ~KFile::Simple) | KFile::Detail );
295 setView( view );
296}
297
298void KDirOperator::slotSimpleView()
299{
300 KFile::FileView view = static_cast<KFile::FileView>( (m_viewKind & ~KFile::Detail) | KFile::Simple );
301 setView( view );
302}
303
304void KDirOperator::slotToggleHidden( bool show )
305{
306 dir->setShowingDotFiles( show );
307 updateDir();
308 if ( m_fileView )
309 m_fileView->listingCompleted();
310}
311
312void KDirOperator::slotSeparateDirs()
313{
314 if (separateDirsAction->isChecked())
315 {
316 KFile::FileView view = static_cast<KFile::FileView>( m_viewKind | KFile::SeparateDirs );
317 setView( view );
318 }
319 else
320 {
321 KFile::FileView view = static_cast<KFile::FileView>( m_viewKind & ~KFile::SeparateDirs );
322 setView( view );
323 }
324}
325
326void KDirOperator::slotDefaultPreview()
327{
328 m_viewKind = m_viewKind | KFile::PreviewContents;
329 if ( !myPreview ) {
330 myPreview = new KFileMetaPreview( this );
331 (static_cast<TDEToggleAction*>( myActionCollection->action("preview") ))->setChecked(true);
332 }
333
334 setView( static_cast<KFile::FileView>(m_viewKind) );
335}
336
337void KDirOperator::slotSortByName()
338{
339 int sorting = (m_fileView->sorting()) & ~TQDir::SortByMask;
340 m_fileView->setSorting( static_cast<TQDir::SortSpec>( sorting | TQDir::Name ));
341 mySorting = m_fileView->sorting();
342 caseInsensitiveAction->setEnabled( true );
343}
344
345void KDirOperator::slotSortBySize()
346{
347 int sorting = (m_fileView->sorting()) & ~TQDir::SortByMask;
348 m_fileView->setSorting( static_cast<TQDir::SortSpec>( sorting | TQDir::Size ));
349 mySorting = m_fileView->sorting();
350 caseInsensitiveAction->setEnabled( false );
351}
352
353void KDirOperator::slotSortByDate()
354{
355 int sorting = (m_fileView->sorting()) & ~TQDir::SortByMask;
356 m_fileView->setSorting( static_cast<TQDir::SortSpec>( sorting | TQDir::Time ));
357 mySorting = m_fileView->sorting();
358 caseInsensitiveAction->setEnabled( false );
359}
360
361void KDirOperator::slotSortReversed()
362{
363 if ( m_fileView )
364 m_fileView->sortReversed();
365}
366
367void KDirOperator::slotToggleDirsFirst()
368{
369 TQDir::SortSpec sorting = m_fileView->sorting();
370 if ( !KFile::isSortDirsFirst( sorting ) )
371 m_fileView->setSorting( static_cast<TQDir::SortSpec>( sorting | TQDir::DirsFirst ));
372 else
373 m_fileView->setSorting( static_cast<TQDir::SortSpec>( sorting & ~TQDir::DirsFirst));
374 mySorting = m_fileView->sorting();
375}
376
377void KDirOperator::slotToggleIgnoreCase()
378{
379 TQDir::SortSpec sorting = m_fileView->sorting();
380 if ( !KFile::isSortCaseInsensitive( sorting ) )
381 m_fileView->setSorting( static_cast<TQDir::SortSpec>( sorting | TQDir::IgnoreCase ));
382 else
383 m_fileView->setSorting( static_cast<TQDir::SortSpec>( sorting & ~TQDir::IgnoreCase));
384 mySorting = m_fileView->sorting();
385}
386
387void KDirOperator::mkdir()
388{
389 bool ok;
390 TQString where = url().pathOrURL();
391 TQString name = i18n( "New Folder" );
392 if ( url().isLocalFile() && TQFileInfo( url().path(+1) + name ).exists() )
393 name = TDEIO::RenameDlg::suggestName( url(), name );
394
395 TQString dir = KInputDialog::getText( i18n( "New Folder" ),
396 i18n( "Create new folder in:\n%1" ).arg( where ),
397 name, &ok, this);
398 if (ok)
399 mkdir( TDEIO::encodeFileName( dir ), true );
400}
401
402bool KDirOperator::mkdir( const TQString& directory, bool enterDirectory )
403{
404 // Creates "directory", relative to the current directory (currUrl).
405 // The given path may contain any number directories, existant or not.
406 // They will all be created, if possible.
407
408 bool writeOk = false;
409 bool exists = false;
410 KURL url( currUrl );
411
412 TQStringList dirs = TQStringList::split( TQDir::separator(), directory );
413 TQStringList::ConstIterator it = dirs.begin();
414
415 for ( ; it != dirs.end(); ++it )
416 {
417 url.addPath( *it );
418 exists = TDEIO::NetAccess::exists( url, false, 0 );
419 writeOk = !exists && TDEIO::NetAccess::mkdir( url, topLevelWidget() );
420 }
421
422 if ( exists ) // url was already existant
423 {
424 KMessageBox::sorry(viewWidget(), i18n("A file or folder named %1 already exists.").arg(url.pathOrURL()));
425 enterDirectory = false;
426 }
427 else if ( !writeOk ) {
428 KMessageBox::sorry(viewWidget(), i18n("You do not have permission to "
429 "create that folder." ));
430 }
431 else if ( enterDirectory ) {
432 setURL( url, true );
433 }
434
435 return writeOk;
436}
437
438TDEIO::DeleteJob * KDirOperator::del( const KFileItemList& items,
439 bool ask, bool showProgress )
440{
441 return del( items, this, ask, showProgress );
442}
443
444TDEIO::DeleteJob * KDirOperator::del( const KFileItemList& items,
445 TQWidget *parent,
446 bool ask, bool showProgress )
447{
448 if ( items.isEmpty() ) {
449 KMessageBox::information( parent,
450 i18n("You did not select a file to delete."),
451 i18n("Nothing to Delete") );
452 return 0L;
453 }
454
455 KURL::List urls;
456 TQStringList files;
457 KFileItemListIterator it( items );
458
459 for ( ; it.current(); ++it ) {
460 KURL url = (*it)->url();
461 urls.append( url );
462 if ( url.isLocalFile() )
463 files.append( url.path() );
464 else
465 files.append( url.prettyURL() );
466 }
467
468 bool doIt = !ask;
469 if ( ask ) {
470 int ret;
471 if ( items.count() == 1 ) {
472 ret = KMessageBox::warningContinueCancel( parent,
473 i18n( "<qt>Do you really want to delete\n <b>'%1'</b>?</qt>" )
474 .arg( files.first() ),
475 i18n("Delete File"),
476 KStdGuiItem::del(), "AskForDelete" );
477 }
478 else
479 ret = KMessageBox::warningContinueCancelList( parent,
480 i18n("Do you really want to delete this item?", "Do you really want to delete these %n items?", items.count() ),
481 files,
482 i18n("Delete Files"),
483 KStdGuiItem::del(), "AskForDelete" );
484 doIt = (ret == KMessageBox::Continue);
485 }
486
487 if ( doIt ) {
488 TDEIO::DeleteJob *job = TDEIO::del( urls, false, showProgress );
489 job->setWindow (topLevelWidget());
490 job->setAutoErrorHandlingEnabled( true, parent );
491 return job;
492 }
493
494 return 0L;
495}
496
497void KDirOperator::deleteSelected()
498{
499 if ( !m_fileView )
500 return;
501
502 const KFileItemList *list = m_fileView->selectedItems();
503 if ( list )
504 del( *list );
505}
506
507TDEIO::CopyJob * KDirOperator::trash( const KFileItemList& items,
508 TQWidget *parent,
509 bool ask, bool showProgress )
510{
511 if ( items.isEmpty() ) {
512 KMessageBox::information( parent,
513 i18n("You did not select a file to trash."),
514 i18n("Nothing to Trash") );
515 return 0L;
516 }
517
518 KURL::List urls;
519 TQStringList files;
520 KFileItemListIterator it( items );
521
522 for ( ; it.current(); ++it ) {
523 KURL url = (*it)->url();
524 urls.append( url );
525 if ( url.isLocalFile() )
526 files.append( url.path() );
527 else
528 files.append( url.prettyURL() );
529 }
530
531 bool doIt = !ask;
532 if ( ask ) {
533 int ret;
534 if ( items.count() == 1 ) {
535 ret = KMessageBox::warningContinueCancel( parent,
536 i18n( "<qt>Do you really want to trash\n <b>'%1'</b>?</qt>" )
537 .arg( files.first() ),
538 i18n("Trash File"),
539 KGuiItem(i18n("to trash", "&Trash"),"edittrash"), "AskForTrash" );
540 }
541 else
542 ret = KMessageBox::warningContinueCancelList( parent,
543 i18n("translators: not called for n == 1", "Do you really want to trash these %n items?", items.count() ),
544 files,
545 i18n("Trash Files"),
546 KGuiItem(i18n("to trash", "&Trash"),"edittrash"), "AskForTrash" );
547 doIt = (ret == KMessageBox::Continue);
548 }
549
550 if ( doIt ) {
551 TDEIO::CopyJob *job = TDEIO::trash( urls, showProgress );
552 job->setWindow (topLevelWidget());
553 job->setAutoErrorHandlingEnabled( true, parent );
554 return job;
555 }
556
557 return 0L;
558}
559
560void KDirOperator::trashSelected(TDEAction::ActivationReason reason, TQt::ButtonState state)
561{
562 if ( !m_fileView )
563 return;
564
565 if ( reason == TDEAction::PopupMenuActivation && ( state & ShiftButton ) ) {
566 deleteSelected();
567 return;
568 }
569
570 const KFileItemList *list = m_fileView->selectedItems();
571 if ( list )
572 trash( *list, this );
573}
574
575void KDirOperator::close()
576{
577 resetCursor();
578 pendingMimeTypes.clear();
579 myCompletion.clear();
580 myDirCompletion.clear();
581 myCompleteListDirty = true;
582 dir->stop();
583}
584
585void KDirOperator::checkPath(const TQString &, bool /*takeFiles*/) // SLOT
586{
587#if 0
588 // copy the argument in a temporary string
589 TQString text = _txt;
590 // it's unlikely to happen, that at the beginning are spaces, but
591 // for the end, it happens quite often, I guess.
592 text = text.stripWhiteSpace();
593 // if the argument is no URL (the check is quite fragil) and it's
594 // no absolute path, we add the current directory to get a correct url
595 if (text.find(':') < 0 && text[0] != '/')
596 text.insert(0, currUrl);
597
598 // in case we have a selection defined and someone patched the file-
599 // name, we check, if the end of the new name is changed.
600 if (!selection.isNull()) {
601 int position = text.findRev('/');
602 ASSERT(position >= 0); // we already inserted the current dir in case
603 TQString filename = text.mid(position + 1, text.length());
604 if (filename != selection)
605 selection = TQString::null;
606 }
607
608 KURL u(text); // I have to take care of entered URLs
609 bool filenameEntered = false;
610
611 if (u.isLocalFile()) {
612 // the empty path is kind of a hack
613 KFileItem i("", u.path());
614 if (i.isDir())
615 setURL(text, true);
616 else {
617 if (takeFiles)
618 if (acceptOnlyExisting && !i.isFile())
619 warning("you entered an invalid URL");
620 else
621 filenameEntered = true;
622 }
623 } else
624 setURL(text, true);
625
626 if (filenameEntered) {
627 filename_ = u.url();
628 emit fileSelected(filename_);
629
630 TQApplication::restoreOverrideCursor();
631
632 accept();
633 }
634#endif
635 kdDebug(tdefile_area) << "TODO KDirOperator::checkPath()" << endl;
636}
637
638void KDirOperator::setURL(const KURL& _newurl, bool clearforward)
639{
640 KURL newurl;
641
642 if ( !_newurl.isValid() )
643 newurl.setPath( TQDir::homeDirPath() );
644 else
645 newurl = _newurl;
646
647 TQString pathstr = newurl.path(+1);
648 newurl.setPath(pathstr);
649
650 // already set
651 if ( newurl.equals( currUrl, true ) )
652 return;
653
654 if ( !isReadable( newurl ) ) {
655 // maybe newurl is a file? check its parent directory
656 newurl.cd(TQString::fromLatin1(".."));
657 if ( !isReadable( newurl ) ) {
658 resetCursor();
659 KMessageBox::error(viewWidget(),
660 i18n("The specified folder does not exist "
661 "or was not readable."));
662 return;
663 }
664 }
665
666 if (clearforward) {
667 // autodelete should remove this one
668 backStack.push(new KURL(currUrl));
669 forwardStack.clear();
670 }
671
672 d->lastURL = currUrl.url(-1);
673 currUrl = newurl;
674
675 pathChanged();
676 emit urlEntered(newurl);
677
678 // enable/disable actions
679 forwardAction->setEnabled( !forwardStack.isEmpty() );
680 backAction->setEnabled( !backStack.isEmpty() );
681 upAction->setEnabled( !isRoot() );
682
683 openURL( newurl );
684}
685
686void KDirOperator::updateDir()
687{
688 dir->emitChanges();
689 if ( m_fileView )
690 m_fileView->listingCompleted();
691}
692
693void KDirOperator::rereadDir()
694{
695 pathChanged();
696 openURL( currUrl, false, true );
697}
698
699
700bool KDirOperator::openURL( const KURL& url, bool keep, bool reload )
701{
702 bool result = dir->openURL( url, keep, reload );
703 if ( !result ) // in that case, neither completed() nor canceled() will be emitted by KDL
704 slotCanceled();
705
706 return result;
707}
708
709// Protected
710void KDirOperator::pathChanged()
711{
712 if (!m_fileView)
713 return;
714
715 pendingMimeTypes.clear();
716 m_fileView->clear();
717 myCompletion.clear();
718 myDirCompletion.clear();
719
720 // it may be, that we weren't ready at this time
721 TQApplication::restoreOverrideCursor();
722
723 // when TDEIO::Job emits finished, the slot will restore the cursor
724 TQApplication::setOverrideCursor( TQt::waitCursor );
725
726 if ( !isReadable( currUrl )) {
727 KMessageBox::error(viewWidget(),
728 i18n("The specified folder does not exist "
729 "or was not readable."));
730 if (backStack.isEmpty())
731 home();
732 else
733 back();
734 }
735}
736
737void KDirOperator::slotRedirected( const KURL& newURL )
738{
739 currUrl = newURL;
740 pendingMimeTypes.clear();
741 myCompletion.clear();
742 myDirCompletion.clear();
743 myCompleteListDirty = true;
744 emit urlEntered( newURL );
745}
746
747// Code pinched from kfm then hacked
748void KDirOperator::back()
749{
750 if ( backStack.isEmpty() )
751 return;
752
753 forwardStack.push( new KURL(currUrl) );
754
755 KURL *s = backStack.pop();
756
757 setURL(*s, false);
758 delete s;
759}
760
761// Code pinched from kfm then hacked
762void KDirOperator::forward()
763{
764 if ( forwardStack.isEmpty() )
765 return;
766
767 backStack.push(new KURL(currUrl));
768
769 KURL *s = forwardStack.pop();
770 setURL(*s, false);
771 delete s;
772}
773
774KURL KDirOperator::url() const
775{
776 return currUrl;
777}
778
779void KDirOperator::cdUp()
780{
781 KURL tmp(currUrl);
782 tmp.cd(TQString::fromLatin1(".."));
783 setURL(tmp, true);
784}
785
786void KDirOperator::home()
787{
788 KURL u;
789 u.setPath( TQDir::homeDirPath() );
790 setURL(u, true);
791}
792
793void KDirOperator::clearFilter()
794{
795 dir->setNameFilter( TQString::null );
796 dir->clearMimeFilter();
797 checkPreviewSupport();
798}
799
800void KDirOperator::setNameFilter(const TQString& filter)
801{
802 dir->setNameFilter(filter);
803 checkPreviewSupport();
804}
805
806void KDirOperator::setMimeFilter( const TQStringList& mimetypes )
807{
808 dir->setMimeFilter( mimetypes );
809 checkPreviewSupport();
810}
811
812bool KDirOperator::checkPreviewSupport()
813{
814 TDEToggleAction *previewAction = static_cast<TDEToggleAction*>( myActionCollection->action( "preview" ));
815
816 bool hasPreviewSupport = false;
817 TDEConfig *kc = TDEGlobal::config();
818 TDEConfigGroupSaver cs( kc, ConfigGroup );
819 if ( kc->readBoolEntry( "Show Default Preview", true ) )
820 hasPreviewSupport = checkPreviewInternal();
821
822 previewAction->setEnabled( hasPreviewSupport );
823 return hasPreviewSupport;
824}
825
826bool KDirOperator::checkPreviewInternal() const
827{
828 TQStringList supported = TDEIO::PreviewJob::supportedMimeTypes();
829 // no preview support for directories?
830 if ( dirOnlyMode() && supported.findIndex( "inode/directory" ) == -1 )
831 return false;
832
833 TQStringList mimeTypes = dir->mimeFilters();
834 TQStringList nameFilter = TQStringList::split( " ", dir->nameFilter() );
835
836 if ( mimeTypes.isEmpty() && nameFilter.isEmpty() && !supported.isEmpty() )
837 return true;
838 else {
839 TQRegExp r;
840 r.setWildcard( true ); // the "mimetype" can be "image/*"
841
842 if ( !mimeTypes.isEmpty() ) {
843 TQStringList::Iterator it = supported.begin();
844
845 for ( ; it != supported.end(); ++it ) {
846 r.setPattern( *it );
847
848 TQStringList result = mimeTypes.grep( r );
849 if ( !result.isEmpty() ) { // matches! -> we want previews
850 return true;
851 }
852 }
853 }
854
855 if ( !nameFilter.isEmpty() ) {
856 // find the mimetypes of all the filter-patterns and
857 KServiceTypeFactory *fac = KServiceTypeFactory::self();
858 TQStringList::Iterator it1 = nameFilter.begin();
859 for ( ; it1 != nameFilter.end(); ++it1 ) {
860 if ( (*it1) == "*" ) {
861 return true;
862 }
863
864 KMimeType *mt = fac->findFromPattern( *it1 );
865 if ( !mt )
866 continue;
867 TQString mime = mt->name();
868 delete mt;
869
870 // the "mimetypes" we get from the PreviewJob can be "image/*"
871 // so we need to check in wildcard mode
872 TQStringList::Iterator it2 = supported.begin();
873 for ( ; it2 != supported.end(); ++it2 ) {
874 r.setPattern( *it2 );
875 if ( r.search( mime ) != -1 ) {
876 return true;
877 }
878 }
879 }
880 }
881 }
882
883 return false;
884}
885
886KFileView* KDirOperator::createView( TQWidget* parent, KFile::FileView view )
887{
888 KFileView* new_view = 0L;
889 bool separateDirs = KFile::isSeparateDirs( view );
890 bool preview = ( KFile::isPreviewInfo(view) || KFile::isPreviewContents( view ) );
891
892 if ( separateDirs || preview ) {
893 KCombiView *combi = 0L;
894 if (separateDirs)
895 {
896 combi = new KCombiView( parent, "combi view" );
897 combi->setOnlyDoubleClickSelectsFiles(d->onlyDoubleClickSelectsFiles);
898 }
899
900 KFileView* v = 0L;
901 if ( KFile::isSimpleView( view ) )
902 v = createView( combi, KFile::Simple );
903 else
904 v = createView( combi, KFile::Detail );
905
906 v->setOnlyDoubleClickSelectsFiles(d->onlyDoubleClickSelectsFiles);
907
908 if (combi)
909 combi->setRight( v );
910
911 if (preview)
912 {
913 KFilePreview* pView = new KFilePreview( combi ? combi : v, parent, "preview" );
914 pView->setOnlyDoubleClickSelectsFiles(d->onlyDoubleClickSelectsFiles);
915 new_view = pView;
916 }
917 else
918 new_view = combi;
919 }
920 else if ( KFile::isDetailView( view ) && !preview ) {
921 new_view = new KFileDetailView( parent, "detail view");
922 new_view->setViewName( i18n("Detailed View") );
923 }
924 else /* if ( KFile::isSimpleView( view ) && !preview ) */ {
925 KFileIconView *iconView = new KFileIconView( parent, "simple view");
926 new_view = iconView;
927 new_view->setViewName( i18n("Short View") );
928 }
929
930 new_view->widget()->setAcceptDrops(acceptDrops());
931 return new_view;
932}
933
934void KDirOperator::setAcceptDrops(bool b)
935{
936 if (m_fileView)
937 m_fileView->widget()->setAcceptDrops(b);
938 TQWidget::setAcceptDrops(b);
939}
940
941void KDirOperator::setDropOptions(int options)
942{
943 d->dropOptions = options;
944 if (m_fileView)
945 m_fileView->setDropOptions(options);
946}
947
948void KDirOperator::setView( KFile::FileView view )
949{
950 bool separateDirs = KFile::isSeparateDirs( view );
951 bool preview=( KFile::isPreviewInfo(view) || KFile::isPreviewContents( view ) );
952
953 if (view == KFile::Default) {
954 if ( KFile::isDetailView( (KFile::FileView) defaultView ) )
955 view = KFile::Detail;
956 else
957 view = KFile::Simple;
958
959 separateDirs = KFile::isSeparateDirs( static_cast<KFile::FileView>(defaultView) );
960 preview = ( KFile::isPreviewInfo( static_cast<KFile::FileView>(defaultView) ) ||
961 KFile::isPreviewContents( static_cast<KFile::FileView>(defaultView) ) )
962 && myActionCollection->action("preview")->isEnabled();
963
964 if ( preview ) { // instantiates KFileMetaPreview and calls setView()
965 m_viewKind = defaultView;
966 slotDefaultPreview();
967 return;
968 }
969 else if ( !separateDirs )
970 separateDirsAction->setChecked(true);
971 }
972
973 // if we don't have any files, we can't separate dirs from files :)
974 if ( (mode() & KFile::File) == 0 &&
975 (mode() & KFile::Files) == 0 ) {
976 separateDirs = false;
977 separateDirsAction->setEnabled( false );
978 }
979
980 m_viewKind = static_cast<int>(view) | (separateDirs ? KFile::SeparateDirs : 0);
981 view = static_cast<KFile::FileView>(m_viewKind);
982
983 KFileView *new_view = createView( this, view );
984 if ( preview ) {
985 // we keep the preview-_widget_ around, but not the KFilePreview.
986 // KFilePreview::setPreviewWidget handles the reparenting for us
987 static_cast<KFilePreview*>(new_view)->setPreviewWidget(myPreview, url());
988 }
989
990 setView( new_view );
991}
992
993
994void KDirOperator::connectView(KFileView *view)
995{
996 // TODO: do a real timer and restart it after that
997 pendingMimeTypes.clear();
998 bool listDir = true;
999
1000 if ( dirOnlyMode() )
1001 view->setViewMode(KFileView::Directories);
1002 else
1003 view->setViewMode(KFileView::All);
1004
1005 if ( myMode & KFile::Files )
1006 view->setSelectionMode( KFile::Extended );
1007 else
1008 view->setSelectionMode( KFile::Single );
1009
1010 if (m_fileView)
1011 {
1012 if ( d->config ) // save and restore the views' configuration
1013 {
1014 m_fileView->writeConfig( d->config, d->configGroup );
1015 view->readConfig( d->config, d->configGroup );
1016 }
1017
1018 // transfer the state from old view to new view
1019 view->clear();
1020 view->addItemList( *m_fileView->items() );
1021 listDir = false;
1022
1023 if ( m_fileView->widget()->hasFocus() )
1024 view->widget()->setFocus();
1025
1026 KFileItem *oldCurrentItem = m_fileView->currentFileItem();
1027 if ( oldCurrentItem ) {
1028 view->setCurrentItem( oldCurrentItem );
1029 view->setSelected( oldCurrentItem, false );
1030 view->ensureItemVisible( oldCurrentItem );
1031 }
1032
1033 const KFileItemList *oldSelected = m_fileView->selectedItems();
1034 if ( !oldSelected->isEmpty() ) {
1035 KFileItemListIterator it( *oldSelected );
1036 for ( ; it.current(); ++it )
1037 view->setSelected( it.current(), true );
1038 }
1039
1040 m_fileView->widget()->hide();
1041 delete m_fileView;
1042 }
1043
1044 else
1045 {
1046 if ( d->config )
1047 view->readConfig( d->config, d->configGroup );
1048 }
1049
1050 m_fileView = view;
1051 m_fileView->widget()->installEventFilter(this);
1052 if (m_fileView->widget()->inherits("TQScrollView"))
1053 {
1054 (static_cast<TQScrollView *>(m_fileView->widget()))->viewport()->installEventFilter(this);
1055 }
1056 m_fileView->setDropOptions(d->dropOptions);
1057 viewActionCollection = 0L;
1058 KFileViewSignaler *sig = view->signaler();
1059
1060 connect(sig, TQ_SIGNAL( activatedMenu(const KFileItem *, const TQPoint& ) ),
1061 this, TQ_SLOT( activatedMenu(const KFileItem *, const TQPoint& )));
1062 connect(sig, TQ_SIGNAL( dirActivated(const KFileItem *) ),
1063 this, TQ_SLOT( selectDir(const KFileItem*) ) );
1064 connect(sig, TQ_SIGNAL( fileSelected(const KFileItem *) ),
1065 this, TQ_SLOT( selectFile(const KFileItem*) ) );
1066 connect(sig, TQ_SIGNAL( fileHighlighted(const KFileItem *) ),
1067 this, TQ_SLOT( highlightFile(const KFileItem*) ));
1068 connect(sig, TQ_SIGNAL( sortingChanged( TQDir::SortSpec ) ),
1069 this, TQ_SLOT( slotViewSortingChanged( TQDir::SortSpec )));
1070 connect(sig, TQ_SIGNAL( dropped(const KFileItem *, TQDropEvent*, const KURL::List&) ),
1071 this, TQ_SIGNAL( dropped(const KFileItem *, TQDropEvent*, const KURL::List&)) );
1072
1073 if ( reverseAction->isChecked() != m_fileView->isReversed() )
1074 slotSortReversed();
1075
1076 updateViewActions();
1077 m_fileView->widget()->resize(size());
1078 m_fileView->widget()->show();
1079
1080 if ( listDir ) {
1081 TQApplication::setOverrideCursor( TQt::waitCursor );
1082 openURL( currUrl );
1083 }
1084 else
1085 view->listingCompleted();
1086}
1087
1088KFile::Mode KDirOperator::mode() const
1089{
1090 return myMode;
1091}
1092
1093void KDirOperator::setMode(KFile::Mode m)
1094{
1095 if (myMode == m)
1096 return;
1097
1098 myMode = m;
1099
1100 dir->setDirOnlyMode( dirOnlyMode() );
1101
1102 // reset the view with the different mode
1103 setView( static_cast<KFile::FileView>(m_viewKind) );
1104}
1105
1106void KDirOperator::setView(KFileView *view)
1107{
1108 if ( view == m_fileView ) {
1109 return;
1110 }
1111
1112 setFocusProxy(view->widget());
1113 view->setSorting( mySorting );
1114 view->setOnlyDoubleClickSelectsFiles( d->onlyDoubleClickSelectsFiles );
1115 connectView(view); // also deletes the old view
1116
1117 emit viewChanged( view );
1118}
1119
1120void KDirOperator::setDirLister( KDirLister *lister )
1121{
1122 if ( lister == dir ) // sanity check
1123 return;
1124
1125 delete dir;
1126 dir = lister;
1127
1128 dir->setAutoUpdate( true );
1129
1130 TQWidget* mainWidget = topLevelWidget();
1131 dir->setMainWindow (mainWidget);
1132 kdDebug (tdefile_area) << "mainWidget=" << mainWidget << endl;
1133
1134 connect( dir, TQ_SIGNAL( percent( int )),
1135 TQ_SLOT( slotProgress( int ) ));
1136 connect( dir, TQ_SIGNAL(started( const KURL& )), TQ_SLOT(slotStarted()));
1137 connect( dir, TQ_SIGNAL(newItems(const KFileItemList &)),
1138 TQ_SLOT(insertNewFiles(const KFileItemList &)));
1139 connect( dir, TQ_SIGNAL(completed()), TQ_SLOT(slotIOFinished()));
1140 connect( dir, TQ_SIGNAL(canceled()), TQ_SLOT(slotCanceled()));
1141 connect( dir, TQ_SIGNAL(deleteItem(KFileItem *)),
1142 TQ_SLOT(itemDeleted(KFileItem *)));
1143 connect( dir, TQ_SIGNAL(redirection( const KURL& )),
1144 TQ_SLOT( slotRedirected( const KURL& )));
1145 connect( dir, TQ_SIGNAL( clear() ), TQ_SLOT( slotClearView() ));
1146 connect( dir, TQ_SIGNAL( refreshItems( const KFileItemList& ) ),
1147 TQ_SLOT( slotRefreshItems( const KFileItemList& ) ) );
1148}
1149
1150void KDirOperator::insertNewFiles(const KFileItemList &newone)
1151{
1152 if ( newone.isEmpty() || !m_fileView )
1153 return;
1154
1155 myCompleteListDirty = true;
1156 m_fileView->addItemList( newone );
1157 emit updateInformation(m_fileView->numDirs(), m_fileView->numFiles());
1158
1159 KFileItem *item;
1160 KFileItemListIterator it( newone );
1161
1162 while ( (item = it.current()) ) {
1163 // highlight the dir we come from, if possible
1164 if ( d->dirHighlighting && item->isDir() &&
1165 item->url().url(-1) == d->lastURL ) {
1166 m_fileView->setCurrentItem( item );
1167 m_fileView->ensureItemVisible( item );
1168 }
1169
1170 ++it;
1171 }
1172
1173 TQTimer::singleShot(200, this, TQ_SLOT(resetCursor()));
1174}
1175
1176void KDirOperator::selectDir(const KFileItem *item)
1177{
1178 setURL(item->url(), true);
1179}
1180
1181void KDirOperator::itemDeleted(KFileItem *item)
1182{
1183 pendingMimeTypes.removeRef( item );
1184 if ( m_fileView )
1185 {
1186 m_fileView->removeItem( static_cast<KFileItem *>( item ));
1187 emit updateInformation(m_fileView->numDirs(), m_fileView->numFiles());
1188 }
1189}
1190
1191void KDirOperator::selectFile(const KFileItem *item)
1192{
1193 TQApplication::restoreOverrideCursor();
1194
1195 emit fileSelected( item );
1196}
1197
1198void KDirOperator::setCurrentItem( const TQString& filename )
1199{
1200 if ( m_fileView ) {
1201 const KFileItem *item = 0L;
1202
1203 if ( !filename.isNull() )
1204 item = static_cast<KFileItem *>(dir->findByName( filename ));
1205
1206 m_fileView->clearSelection();
1207 if ( item ) {
1208 m_fileView->setCurrentItem( item );
1209 m_fileView->setSelected( item, true );
1210 m_fileView->ensureItemVisible( item );
1211 }
1212 }
1213}
1214
1215TQString KDirOperator::makeCompletion(const TQString& string)
1216{
1217 if ( string.isEmpty() ) {
1218 m_fileView->clearSelection();
1219 return TQString::null;
1220 }
1221
1222 prepareCompletionObjects();
1223 return myCompletion.makeCompletion( string );
1224}
1225
1226TQString KDirOperator::makeDirCompletion(const TQString& string)
1227{
1228 if ( string.isEmpty() ) {
1229 m_fileView->clearSelection();
1230 return TQString::null;
1231 }
1232
1233 prepareCompletionObjects();
1234 return myDirCompletion.makeCompletion( string );
1235}
1236
1237void KDirOperator::prepareCompletionObjects()
1238{
1239 if ( !m_fileView )
1240 return;
1241
1242 if ( myCompleteListDirty ) { // create the list of all possible completions
1243 KFileItemListIterator it( *(m_fileView->items()) );
1244 for( ; it.current(); ++it ) {
1245 KFileItem *item = it.current();
1246
1247 myCompletion.addItem( item->name() );
1248 if ( item->isDir() )
1249 myDirCompletion.addItem( item->name() );
1250 }
1251 myCompleteListDirty = false;
1252 }
1253}
1254
1255void KDirOperator::slotCompletionMatch(const TQString& match)
1256{
1257 setCurrentItem( match );
1258 emit completion( match );
1259}
1260
1261void KDirOperator::setupActions()
1262{
1263 myActionCollection = new TDEActionCollection( topLevelWidget(), this, "KDirOperator::myActionCollection" );
1264
1265 actionMenu = new TDEActionMenu( i18n("Menu"), myActionCollection, "popupMenu" );
1266 upAction = KStdAction::up( this, TQ_SLOT( cdUp() ), myActionCollection, "up" );
1267 upAction->setText( i18n("Parent Folder") );
1268 backAction = KStdAction::back( this, TQ_SLOT( back() ), myActionCollection, "back" );
1269 forwardAction = KStdAction::forward( this, TQ_SLOT(forward()), myActionCollection, "forward" );
1270 homeAction = KStdAction::home( this, TQ_SLOT( home() ), myActionCollection, "home" );
1271 homeAction->setText(i18n("Home Folder"));
1272 reloadAction = KStdAction::redisplay( this, TQ_SLOT(rereadDir()), myActionCollection, "reload" );
1273 actionSeparator = new TDEActionSeparator( myActionCollection, "separator" );
1274 d->viewActionSeparator = new TDEActionSeparator( myActionCollection,
1275 "viewActionSeparator" );
1276 mkdirAction = new TDEAction( i18n("New Folder..."), 0,
1277 this, TQ_SLOT( mkdir() ), myActionCollection, "mkdir" );
1278 TDEAction* trash = new TDEAction( i18n( "Move to Trash" ), "edittrash", Key_Delete, myActionCollection, "trash" );
1279 connect( trash, TQ_SIGNAL( activated( TDEAction::ActivationReason, TQt::ButtonState ) ),
1280 this, TQ_SLOT( trashSelected( TDEAction::ActivationReason, TQt::ButtonState ) ) );
1281 new TDEAction( i18n( "Delete" ), "edit-delete", SHIFT+Key_Delete, this,
1282 TQ_SLOT( deleteSelected() ), myActionCollection, "delete" );
1283 mkdirAction->setIcon( TQString::fromLatin1("folder-new") );
1284 reloadAction->setText( i18n("Reload") );
1285 reloadAction->setShortcut( TDEStdAccel::shortcut( TDEStdAccel::Reload ));
1286
1287
1288 // the sort menu actions
1289 sortActionMenu = new TDEActionMenu( i18n("Sorting"), myActionCollection, "sorting menu");
1290 byNameAction = new TDERadioAction( i18n("By Name"), 0,
1291 this, TQ_SLOT( slotSortByName() ),
1292 myActionCollection, "by name" );
1293 byDateAction = new TDERadioAction( i18n("By Date"), 0,
1294 this, TQ_SLOT( slotSortByDate() ),
1295 myActionCollection, "by date" );
1296 bySizeAction = new TDERadioAction( i18n("By Size"), 0,
1297 this, TQ_SLOT( slotSortBySize() ),
1298 myActionCollection, "by size" );
1299 reverseAction = new TDEToggleAction( i18n("Reverse"), 0,
1300 this, TQ_SLOT( slotSortReversed() ),
1301 myActionCollection, "reversed" );
1302
1303 TQString sortGroup = TQString::fromLatin1("sort");
1304 byNameAction->setExclusiveGroup( sortGroup );
1305 byDateAction->setExclusiveGroup( sortGroup );
1306 bySizeAction->setExclusiveGroup( sortGroup );
1307
1308
1309 dirsFirstAction = new TDEToggleAction( i18n("Folders First"), 0,
1310 myActionCollection, "dirs first");
1311 caseInsensitiveAction = new TDEToggleAction(i18n("Case Insensitive"), 0,
1312 myActionCollection, "case insensitive" );
1313
1314 connect( dirsFirstAction, TQ_SIGNAL( toggled( bool ) ),
1315 TQ_SLOT( slotToggleDirsFirst() ));
1316 connect( caseInsensitiveAction, TQ_SIGNAL( toggled( bool ) ),
1317 TQ_SLOT( slotToggleIgnoreCase() ));
1318
1319
1320
1321 // the view menu actions
1322 viewActionMenu = new TDEActionMenu( i18n("&View"), myActionCollection, "view menu" );
1323 connect( viewActionMenu->popupMenu(), TQ_SIGNAL( aboutToShow() ),
1324 TQ_SLOT( insertViewDependentActions() ));
1325
1326 shortAction = new TDERadioAction( i18n("Short View"), "view_multicolumn",
1327 TDEShortcut(), myActionCollection, "short view" );
1328 detailedAction = new TDERadioAction( i18n("Detailed View"), "view_detailed",
1329 TDEShortcut(), myActionCollection, "detailed view" );
1330
1331 showHiddenAction = new TDEToggleAction( i18n("Show Hidden Files"), TDEShortcut(),
1332 myActionCollection, "show hidden" );
1333// showHiddenAction->setCheckedState( i18n("Hide Hidden Files") );
1334 separateDirsAction = new TDEToggleAction( i18n("Separate Folders"), TDEShortcut(),
1335 this,
1336 TQ_SLOT(slotSeparateDirs()),
1337 myActionCollection, "separate dirs" );
1338 TDEToggleAction *previewAction = new TDEToggleAction(i18n("Show Preview"),
1339 "thumbnail", TDEShortcut(),
1340 myActionCollection,
1341 "preview" );
1342 previewAction->setCheckedState(i18n("Hide Preview"));
1343 connect( previewAction, TQ_SIGNAL( toggled( bool )),
1344 TQ_SLOT( togglePreview( bool )));
1345
1346
1347 TQString viewGroup = TQString::fromLatin1("view");
1348 shortAction->setExclusiveGroup( viewGroup );
1349 detailedAction->setExclusiveGroup( viewGroup );
1350
1351 connect( shortAction, TQ_SIGNAL( activated() ),
1352 TQ_SLOT( slotSimpleView() ));
1353 connect( detailedAction, TQ_SIGNAL( activated() ),
1354 TQ_SLOT( slotDetailedView() ));
1355 connect( showHiddenAction, TQ_SIGNAL( toggled( bool ) ),
1356 TQ_SLOT( slotToggleHidden( bool ) ));
1357
1358 new TDEAction( i18n("Properties"), TDEShortcut(ALT+Key_Return), this,
1359 TQ_SLOT(slotProperties()), myActionCollection, "properties" );
1360}
1361
1362void KDirOperator::setupMenu()
1363{
1364 setupMenu(AllActions);
1365}
1366
1367void KDirOperator::setupMenu(int whichActions)
1368{
1369 // first fill the submenus (sort and view)
1370 sortActionMenu->popupMenu()->clear();
1371 sortActionMenu->insert( byNameAction );
1372 sortActionMenu->insert( byDateAction );
1373 sortActionMenu->insert( bySizeAction );
1374 sortActionMenu->insert( actionSeparator );
1375 sortActionMenu->insert( reverseAction );
1376 sortActionMenu->insert( dirsFirstAction );
1377 sortActionMenu->insert( caseInsensitiveAction );
1378
1379 // now plug everything into the popupmenu
1380 actionMenu->popupMenu()->clear();
1381 if (whichActions & NavActions)
1382 {
1383 actionMenu->insert( upAction );
1384 actionMenu->insert( backAction );
1385 actionMenu->insert( forwardAction );
1386 actionMenu->insert( homeAction );
1387 actionMenu->insert( actionSeparator );
1388 }
1389
1390 if (whichActions & FileActions)
1391 {
1392 actionMenu->insert( mkdirAction );
1393 if (currUrl.isLocalFile() && !(TDEApplication::keyboardMouseState() & TQt::ShiftButton))
1394 actionMenu->insert( myActionCollection->action( "trash" ) );
1395 TDEConfig *globalconfig = TDEGlobal::config();
1396 TDEConfigGroupSaver cs( globalconfig, TQString::fromLatin1("KDE") );
1397 if (!currUrl.isLocalFile() || (TDEApplication::keyboardMouseState() & TQt::ShiftButton) ||
1398 globalconfig->readBoolEntry("ShowDeleteCommand", false))
1399 actionMenu->insert( myActionCollection->action( "delete" ) );
1400 actionMenu->insert( actionSeparator );
1401 }
1402
1403 if (whichActions & SortActions)
1404 {
1405 actionMenu->insert( sortActionMenu );
1406 actionMenu->insert( actionSeparator );
1407 }
1408
1409 if (whichActions & ViewActions)
1410 {
1411 actionMenu->insert( viewActionMenu );
1412 actionMenu->insert( actionSeparator );
1413 }
1414
1415 if (whichActions & FileActions)
1416 {
1417 actionMenu->insert( myActionCollection->action( "properties" ) );
1418 }
1419}
1420
1421void KDirOperator::updateSortActions()
1422{
1423 if ( KFile::isSortByName( mySorting ) )
1424 byNameAction->setChecked( true );
1425 else if ( KFile::isSortByDate( mySorting ) )
1426 byDateAction->setChecked( true );
1427 else if ( KFile::isSortBySize( mySorting ) )
1428 bySizeAction->setChecked( true );
1429
1430 dirsFirstAction->setChecked( KFile::isSortDirsFirst( mySorting ) );
1431 caseInsensitiveAction->setChecked( KFile::isSortCaseInsensitive(mySorting) );
1432 caseInsensitiveAction->setEnabled( KFile::isSortByName( mySorting ) );
1433
1434 if ( m_fileView )
1435 reverseAction->setChecked( m_fileView->isReversed() );
1436}
1437
1438void KDirOperator::updateViewActions()
1439{
1440 KFile::FileView fv = static_cast<KFile::FileView>( m_viewKind );
1441
1442 separateDirsAction->setChecked( KFile::isSeparateDirs( fv ) &&
1443 separateDirsAction->isEnabled() );
1444
1445 shortAction->setChecked( KFile::isSimpleView( fv ));
1446 detailedAction->setChecked( KFile::isDetailView( fv ));
1447}
1448
1449void KDirOperator::readConfig( TDEConfig *kc, const TQString& group )
1450{
1451 if ( !kc )
1452 return;
1453 TQString oldGroup = kc->group();
1454 if ( !group.isEmpty() )
1455 kc->setGroup( group );
1456
1457 defaultView = 0;
1458 int sorting = 0;
1459
1460 TQString viewStyle = kc->readEntry( TQString::fromLatin1("View Style"),
1461 TQString::fromLatin1("Simple") );
1462 if ( viewStyle == TQString::fromLatin1("Detail") )
1463 defaultView |= KFile::Detail;
1464 else
1465 defaultView |= KFile::Simple;
1466 if ( kc->readBoolEntry( TQString::fromLatin1("Separate Directories"),
1467 DefaultMixDirsAndFiles ) )
1468 defaultView |= KFile::SeparateDirs;
1469 if ( kc->readBoolEntry(TQString::fromLatin1("Show Preview"), false))
1470 defaultView |= KFile::PreviewContents;
1471
1472 if ( kc->readBoolEntry( TQString::fromLatin1("Sort case insensitively"),
1473 DefaultCaseInsensitive ) )
1474 sorting |= TQDir::IgnoreCase;
1475 if ( kc->readBoolEntry( TQString::fromLatin1("Sort directories first"),
1476 DefaultDirsFirst ) )
1477 sorting |= TQDir::DirsFirst;
1478
1479
1480 TQString name = TQString::fromLatin1("Name");
1481 TQString sortBy = kc->readEntry( TQString::fromLatin1("Sort by"), name );
1482 if ( sortBy == name )
1483 sorting |= TQDir::Name;
1484 else if ( sortBy == TQString::fromLatin1("Size") )
1485 sorting |= TQDir::Size;
1486 else if ( sortBy == TQString::fromLatin1("Date") )
1487 sorting |= TQDir::Time;
1488
1489 mySorting = static_cast<TQDir::SortSpec>( sorting );
1490 setSorting( mySorting );
1491
1492
1493 if ( kc->readBoolEntry( TQString::fromLatin1("Show hidden files"),
1494 DefaultShowHidden ) ) {
1495 showHiddenAction->setChecked( true );
1496 dir->setShowingDotFiles( true );
1497 }
1498 if ( kc->readBoolEntry( TQString::fromLatin1("Sort reversed"),
1499 DefaultSortReversed ) )
1500 reverseAction->setChecked( true );
1501
1502 kc->setGroup( oldGroup );
1503}
1504
1505void KDirOperator::writeConfig( TDEConfig *kc, const TQString& group )
1506{
1507 if ( !kc )
1508 return;
1509
1510 const TQString oldGroup = kc->group();
1511
1512 if ( !group.isEmpty() )
1513 kc->setGroup( group );
1514
1515 TQString sortBy = TQString::fromLatin1("Name");
1516 if ( KFile::isSortBySize( mySorting ) )
1517 sortBy = TQString::fromLatin1("Size");
1518 else if ( KFile::isSortByDate( mySorting ) )
1519 sortBy = TQString::fromLatin1("Date");
1520 kc->writeEntry( TQString::fromLatin1("Sort by"), sortBy );
1521
1522 kc->writeEntry( TQString::fromLatin1("Sort reversed"),
1523 reverseAction->isChecked() );
1524 kc->writeEntry( TQString::fromLatin1("Sort case insensitively"),
1525 caseInsensitiveAction->isChecked() );
1526 kc->writeEntry( TQString::fromLatin1("Sort directories first"),
1527 dirsFirstAction->isChecked() );
1528
1529 // don't save the separate dirs or preview when an application specific
1530 // preview is in use.
1531 bool appSpecificPreview = false;
1532 if ( myPreview ) {
1533 TQWidget *preview = const_cast<TQWidget*>( myPreview ); // grmbl
1534 KFileMetaPreview *tmp = dynamic_cast<KFileMetaPreview*>( preview );
1535 appSpecificPreview = (tmp == 0L);
1536 }
1537
1538 if ( !appSpecificPreview ) {
1539 if ( separateDirsAction->isEnabled() )
1540 kc->writeEntry( TQString::fromLatin1("Separate Directories"),
1541 separateDirsAction->isChecked() );
1542
1543 TDEToggleAction *previewAction = static_cast<TDEToggleAction*>(myActionCollection->action("preview"));
1544 if ( previewAction->isEnabled() ) {
1545 bool hasPreview = previewAction->isChecked();
1546 kc->writeEntry( TQString::fromLatin1("Show Preview"), hasPreview );
1547 }
1548 }
1549
1550 kc->writeEntry( TQString::fromLatin1("Show hidden files"),
1551 showHiddenAction->isChecked() );
1552
1553 KFile::FileView fv = static_cast<KFile::FileView>( m_viewKind );
1554 TQString style;
1555 if ( KFile::isDetailView( fv ) )
1556 style = TQString::fromLatin1("Detail");
1557 else if ( KFile::isSimpleView( fv ) )
1558 style = TQString::fromLatin1("Simple");
1559 kc->writeEntry( TQString::fromLatin1("View Style"), style );
1560
1561 kc->setGroup( oldGroup );
1562}
1563
1564
1565void KDirOperator::resizeEvent( TQResizeEvent * )
1566{
1567 if (m_fileView)
1568 m_fileView->widget()->resize( size() );
1569
1570 if ( progress->parent() == this ) // might be reparented into a statusbar
1571 progress->move(2, height() - progress->height() -2);
1572}
1573
1574void KDirOperator::setOnlyDoubleClickSelectsFiles( bool enable )
1575{
1576 d->onlyDoubleClickSelectsFiles = enable;
1577 if ( m_fileView )
1578 m_fileView->setOnlyDoubleClickSelectsFiles( enable );
1579}
1580
1581bool KDirOperator::onlyDoubleClickSelectsFiles() const
1582{
1583 return d->onlyDoubleClickSelectsFiles;
1584}
1585
1586void KDirOperator::slotStarted()
1587{
1588 progress->setProgress( 0 );
1589 // delay showing the progressbar for one second
1590 d->progressDelayTimer->start( 1000, true );
1591}
1592
1593void KDirOperator::slotShowProgress()
1594{
1595 progress->raise();
1596 progress->show();
1597 TQApplication::flushX();
1598}
1599
1600void KDirOperator::slotProgress( int percent )
1601{
1602 progress->setProgress( percent );
1603 // we have to redraw this as fast as possible
1604 if ( progress->isVisible() )
1605 TQApplication::flushX();
1606}
1607
1608
1609void KDirOperator::slotIOFinished()
1610{
1611 d->progressDelayTimer->stop();
1612 slotProgress( 100 );
1613 progress->hide();
1614 emit finishedLoading();
1615 resetCursor();
1616
1617 if ( m_fileView )
1618 m_fileView->listingCompleted();
1619}
1620
1621void KDirOperator::slotCanceled()
1622{
1623 emit finishedLoading();
1624 resetCursor();
1625
1626 if ( m_fileView )
1627 m_fileView->listingCompleted();
1628}
1629
1630KProgress * KDirOperator::progressBar() const
1631{
1632 return progress;
1633}
1634
1635void KDirOperator::clearHistory()
1636{
1637 backStack.clear();
1638 backAction->setEnabled( false );
1639 forwardStack.clear();
1640 forwardAction->setEnabled( false );
1641}
1642
1643void KDirOperator::slotViewActionAdded( TDEAction *action )
1644{
1645 if ( viewActionMenu->popupMenu()->count() == 5 ) // need to add a separator
1646 viewActionMenu->insert( d->viewActionSeparator );
1647
1648 viewActionMenu->insert( action );
1649}
1650
1651void KDirOperator::slotViewActionRemoved( TDEAction *action )
1652{
1653 viewActionMenu->remove( action );
1654
1655 if ( viewActionMenu->popupMenu()->count() == 6 ) // remove the separator
1656 viewActionMenu->remove( d->viewActionSeparator );
1657}
1658
1659void KDirOperator::slotViewSortingChanged( TQDir::SortSpec sort )
1660{
1661 mySorting = sort;
1662 updateSortActions();
1663}
1664
1665void KDirOperator::setEnableDirHighlighting( bool enable )
1666{
1667 d->dirHighlighting = enable;
1668}
1669
1670bool KDirOperator::dirHighlighting() const
1671{
1672 return d->dirHighlighting;
1673}
1674
1675void KDirOperator::slotProperties()
1676{
1677 if ( m_fileView ) {
1678 const KFileItemList *list = m_fileView->selectedItems();
1679 if ( !list->isEmpty() )
1680 (void) new KPropertiesDialog( *list, this, "props dlg", true);
1681 }
1682}
1683
1684void KDirOperator::slotClearView()
1685{
1686 if ( m_fileView )
1687 m_fileView->clearView();
1688}
1689
1690// ### temporary code
1691#include <dirent.h>
1692bool KDirOperator::isReadable( const KURL& url )
1693{
1694 if ( !url.isLocalFile() )
1695 return true; // what else can we say?
1696
1697 KDE_struct_stat buf;
1698 TQString ts = url.path(+1);
1699 bool readable = ( KDE_stat( TQFile::encodeName( ts ), &buf) == 0 );
1700 if (readable) { // further checks
1701 DIR *test;
1702 test = opendir( TQFile::encodeName( ts )); // we do it just to test here
1703 readable = (test != 0);
1704 if (test)
1705 closedir(test);
1706 }
1707 return readable;
1708}
1709
1710void KDirOperator::togglePreview( bool on )
1711{
1712 if ( on )
1713 slotDefaultPreview();
1714 else
1715 setView( (KFile::FileView) (m_viewKind & ~(KFile::PreviewContents|KFile::PreviewInfo)) );
1716}
1717
1718void KDirOperator::slotRefreshItems( const KFileItemList& items )
1719{
1720 if ( !m_fileView )
1721 return;
1722
1723 KFileItemListIterator it( items );
1724 for ( ; it.current(); ++it )
1725 m_fileView->updateView( it.current() );
1726}
1727
1728void KDirOperator::setViewConfig( TDEConfig *config, const TQString& group )
1729{
1730 d->config = config;
1731 d->configGroup = group;
1732}
1733
1734TDEConfig * KDirOperator::viewConfig()
1735{
1736 return d->config;
1737}
1738
1739TQString KDirOperator::viewConfigGroup() const
1740{
1741 return d->configGroup;
1742}
1743
1744bool KDirOperator::eventFilter(TQObject *obj, TQEvent *ev)
1745{
1746 if (ev->type() == TQEvent::MouseButtonRelease)
1747 {
1748 TQMouseEvent *mouseEv = static_cast<TQMouseEvent *>(ev);
1749 switch (mouseEv->button())
1750 {
1751 case TQMouseEvent::HistoryBackButton:
1752 back();
1753 return true;
1754 case TQMouseEvent::HistoryForwardButton:
1755 forward();
1756 return true;
1757 }
1758 }
1759 return false;
1760}
1761
1762void KDirOperator::virtual_hook( int, void* )
1763{ /*BASE::virtual_hook( id, data );*/ }
1764
1765#include "tdediroperator.moc"
KCombiView
This view is designed to combine two KFileViews into one widget, to show directories on the left side...
Definition: kcombiview.h:56
KCombiView::setRight
void setRight(KFileView *view)
Sets the view to be shown in the right.
Definition: kcombiview.cpp:68
KDirOperator::setDropOptions
void setDropOptions(int options)
Sets the options for dropping files.
Definition: tdediroperator.cpp:941
KDirOperator::setAcceptDrops
virtual void setAcceptDrops(bool b)
Reimplemented - allow dropping of files if b is true.
Definition: tdediroperator.cpp:934
KDirOperator::createView
virtual KFileView * createView(TQWidget *parent, KFile::FileView view)
A view factory for creating predefined fileviews.
Definition: tdediroperator.cpp:886
KDirOperator::itemDeleted
void itemDeleted(KFileItem *)
Removes the given KFileItem item from the view (usually called from KDirLister).
Definition: tdediroperator.cpp:1181
KDirOperator::dropped
void dropped(const KFileItem *item, TQDropEvent *event, const KURL::List &urls)
Emitted when files are dropped.
KDirOperator::numFiles
int numFiles() const
Definition: tdediroperator.cpp:287
KDirOperator::setPreviewWidget
void setPreviewWidget(const TQWidget *w)
Sets a preview-widget to be shown next to the file-view.
Definition: tdediroperator.cpp:266
KDirOperator::rereadDir
void rereadDir()
Re-reads the current url.
Definition: tdediroperator.cpp:693
KDirOperator::setupActions
void setupActions()
Sets up all the actions.
Definition: tdediroperator.cpp:1261
KDirOperator::progressBar
KProgress * progressBar() const
Definition: tdediroperator.cpp:1630
KDirOperator::updateSortActions
void updateSortActions()
Updates the sorting-related actions to comply with the current sorting.
Definition: tdediroperator.cpp:1421
KDirOperator::trash
TDEIO::CopyJob * trash(const KFileItemList &items, TQWidget *parent, bool ask=true, bool showProgress=true)
Starts and returns a TDEIO::CopyJob to trash the given items.
Definition: tdediroperator.cpp:507
KDirOperator::setMimeFilter
void setMimeFilter(const TQStringList &mimetypes)
Sets a list of mimetypes as filter.
Definition: tdediroperator.cpp:806
KDirOperator::updateSelectionDependentActions
void updateSelectionDependentActions()
Enables/disables actions that are selection dependent.
Definition: tdediroperator.cpp:257
KDirOperator::close
void close()
Stops loading immediately.
Definition: tdediroperator.cpp:575
KDirOperator::KDirOperator
KDirOperator(const KURL &urlName=KURL(), TQWidget *parent=0, const char *name=0)
Constructs the KDirOperator with no initial view.
Definition: tdediroperator.cpp:97
KDirOperator::viewConfigGroup
TQString viewConfigGroup() const
Returns the group name used for saving and restoring view's configuration.
Definition: tdediroperator.cpp:1739
KDirOperator::prepareCompletionObjects
void prepareCompletionObjects()
Synchronizes the completion objects with the entries of the currently listed url.
Definition: tdediroperator.cpp:1237
KDirOperator::updateViewActions
void updateViewActions()
Updates the view-related actions to comply with the current KFile::FileView.
Definition: tdediroperator.cpp:1438
KDirOperator::forward
void forward()
Goes one step forward in the history and opens that url.
Definition: tdediroperator.cpp:762
KDirOperator::setViewConfig
void setViewConfig(TDEConfig *config, const TQString &group)
Sets the config object and the to be used group in KDirOperator.
Definition: tdediroperator.cpp:1728
KDirOperator::back
void back()
Goes one step back in the history and opens that url.
Definition: tdediroperator.cpp:748
KDirOperator::viewConfig
TDEConfig * viewConfig()
Returns the TDEConfig object used for saving and restoring view's configuration.
Definition: tdediroperator.cpp:1734
KDirOperator::setSorting
void setSorting(TQDir::SortSpec)
Sets the way to sort files and directories.
Definition: tdediroperator.cpp:170
KDirOperator::makeCompletion
TQString makeCompletion(const TQString &)
Tries to complete the given string (only completes files).
Definition: tdediroperator.cpp:1215
KDirOperator::clearHistory
void clearHistory()
Clears the forward and backward history.
Definition: tdediroperator.cpp:1635
KDirOperator::viewWidget
TQWidget * viewWidget() const
Returns the widget of the current view.
Definition: tdediroperator.h:232
KDirOperator::cdUp
void cdUp()
Goes one directory up from the current url.
Definition: tdediroperator.cpp:779
KDirOperator::onlyDoubleClickSelectsFiles
bool onlyDoubleClickSelectsFiles() const
Definition: tdediroperator.cpp:1581
KDirOperator::clearFilter
void clearFilter()
Clears both the namefilter and mimetype filter, so that all files and directories will be shown.
Definition: tdediroperator.cpp:793
KDirOperator::selectFile
void selectFile(const KFileItem *item)
Emits fileSelected( item )
Definition: tdediroperator.cpp:1191
KDirOperator::mode
KFile::Mode mode() const
Definition: tdediroperator.cpp:1088
KDirOperator::makeDirCompletion
TQString makeDirCompletion(const TQString &)
Tries to complete the given string (only completes directores).
Definition: tdediroperator.cpp:1226
KDirOperator::setDirLister
void setDirLister(KDirLister *lister)
Sets a custom KDirLister to list directories.
Definition: tdediroperator.cpp:1120
KDirOperator::selectDir
void selectDir(const KFileItem *item)
Enters the directory specified by the given item.
Definition: tdediroperator.cpp:1176
KDirOperator::updateDir
void updateDir()
to update the view after changing the settings
Definition: tdediroperator.cpp:686
KDirOperator::resetCursor
void resetCursor()
Restores the normal cursor after showing the busy-cursor.
Definition: tdediroperator.cpp:178
KDirOperator::mkdir
void mkdir()
Opens a dialog to create a new directory.
Definition: tdediroperator.cpp:387
KDirOperator::actionCollection
TDEActionCollection * actionCollection() const
an accessor to a collection of all available Actions.
Definition: tdediroperator.h:389
KDirOperator::del
TDEIO::DeleteJob * del(const KFileItemList &items, bool ask=true, bool showProgress=true)
Starts and returns a TDEIO::DeleteJob to delete the given items.
Definition: tdediroperator.cpp:438
KDirOperator::isRoot
bool isRoot() const
Definition: tdediroperator.h:254
KDirOperator::deleteSelected
void deleteSelected()
Deletes the currently selected files/directories.
Definition: tdediroperator.cpp:497
KDirOperator::setOnlyDoubleClickSelectsFiles
void setOnlyDoubleClickSelectsFiles(bool enable)
This is a KFileDialog specific hack: we want to select directories with single click,...
Definition: tdediroperator.cpp:1574
KDirOperator::dirHighlighting
bool dirHighlighting() const
Definition: tdediroperator.cpp:1670
KDirOperator::fileHighlighted
void fileHighlighted(const KFileItem *item)
Emitted when a file is highlighted or generally the selection changes in multiselection mode.
KDirOperator::setNameFilter
void setNameFilter(const TQString &filter)
Sets a filter like "*.cpp *.h *.o".
Definition: tdediroperator.cpp:800
KDirOperator::setupMenu
void setupMenu()
Sets up the context-menu with all the necessary actions.
Definition: tdediroperator.cpp:1362
KDirOperator::writeConfig
virtual void writeConfig(TDEConfig *, const TQString &group=TQString::null)
Saves the current settings like sorting, simple or detailed view.
Definition: tdediroperator.cpp:1505
KDirOperator::nameFilter
const TQString & nameFilter() const
Definition: tdediroperator.h:155
KDirOperator::dirOnlyMode
bool dirOnlyMode() const
Definition: tdediroperator.h:537
KDirOperator::setMode
void setMode(KFile::Mode m)
Sets the listing/selection mode for the views, an OR'ed combination of.
Definition: tdediroperator.cpp:1093
KDirOperator::setView
void setView(KFileView *view)
Sets a new KFileView to be used for showing and browsing files.
Definition: tdediroperator.cpp:1106
KDirOperator::url
KURL url() const
Definition: tdediroperator.cpp:774
KDirOperator::readConfig
virtual void readConfig(TDEConfig *, const TQString &group=TQString::null)
Reads the default settings for a view, i.e.
Definition: tdediroperator.cpp:1449
KDirOperator::home
void home()
Enters the home directory.
Definition: tdediroperator.cpp:786
KDirOperator::sorting
TQDir::SortSpec sorting() const
Definition: tdediroperator.h:249
KDirOperator::activatedMenu
virtual void activatedMenu(const KFileItem *, const TQPoint &pos)
Called upon right-click to activate the popupmenu.
Definition: tdediroperator.cpp:249
KDirOperator::pathChanged
void pathChanged()
Called after setURL() to load the directory, update the history, etc.
Definition: tdediroperator.cpp:710
KDirOperator::view
KFileView * view() const
Definition: tdediroperator.h:226
KDirOperator::setURL
void setURL(const KURL &url, bool clearforward)
Sets a new url to list.
Definition: tdediroperator.cpp:638
KDirOperator::~KDirOperator
virtual ~KDirOperator()
Destroys the KDirOperator.
Definition: tdediroperator.cpp:152
KDirOperator::slotCompletionMatch
void slotCompletionMatch(const TQString &match)
Tries to make the given match as current item in the view and emits completion( match )
Definition: tdediroperator.cpp:1255
KDirOperator::insertNewFiles
void insertNewFiles(const KFileItemList &newone)
Adds a new list of KFileItems to the view (coming from KDirLister)
Definition: tdediroperator.cpp:1150
KDirOperator::setCurrentItem
void setCurrentItem(const TQString &filename)
Clears the current selection and attempts to set filename the current file.
Definition: tdediroperator.cpp:1198
KDirOperator::trashSelected
void trashSelected(TDEAction::ActivationReason, TQt::ButtonState)
Trashes the currently selected files/directories.
Definition: tdediroperator.cpp:560
KDirOperator::setEnableDirHighlighting
void setEnableDirHighlighting(bool enable)
When going up in the directory hierarchy, KDirOperator can highlight the directory that was just left...
Definition: tdediroperator.cpp:1665
KDirOperator::numDirs
int numDirs() const
Definition: tdediroperator.cpp:282
KDirOperator::viewChanged
void viewChanged(KFileView *newView)
Emitted whenever the current fileview is changed, either by an explicit call to setView() or by the u...
KDirOperator::highlightFile
void highlightFile(const KFileItem *i)
Emits fileHighlighted( i )
Definition: tdediroperator.h:753
KDirOperator::checkPreviewSupport
bool checkPreviewSupport()
Checks if there support from TDEIO::PreviewJob for the currently shown files, taking mimeFilter() and...
Definition: tdediroperator.cpp:812
KFileDetailView
A list-view capable of showing KFileItem'.
Definition: tdefiledetailview.h:109
KFileIconView
An icon-view capable of showing KFileItem's.
Definition: tdefileiconview.h:83
KFilePreview
Definition: tdefilepreview.h:40
KFileViewSignaler
internal class to make easier to use signals possible
Definition: tdefileview.h:37
KFileView
This class defines an interface to all file views.
Definition: tdefileview.h:97
KFileView::clearSelection
virtual void clearSelection()=0
Clears any selection, unhighlights everything.
KFileView::numFiles
uint numFiles() const
Definition: tdefileview.h:210
KFileView::setViewName
void setViewName(const TQString &name)
Sets the name of the view, which could be displayed somewhere.
Definition: tdefileview.h:239
KFileView::numDirs
uint numDirs() const
Definition: tdefileview.h:215
KFileView::listingCompleted
virtual void listingCompleted()
This hook is called when all items of the currently listed directory are listed and inserted into the...
Definition: tdefileview.cpp:360
KFileView::items
const KFileItemList * items() const
Definition: tdefileview.cpp:283
KFileView::setCurrentItem
void setCurrentItem(const TQString &filename)
Sets filename the current item in the view, if available.
Definition: tdefileview.cpp:268
KFileView::isReversed
bool isReversed() const
Tells whether the current items are in reversed order (shortcut to sorting() & TQDir::Reversed).
Definition: tdefileview.h:198
KFileView::setOnlyDoubleClickSelectsFiles
void setOnlyDoubleClickSelectsFiles(bool enable)
This is a KFileDialog specific hack: we want to select directories with single click,...
Definition: tdefileview.h:320
KFileView::selectedItems
const KFileItemList * selectedItems() const
Definition: tdefileview.cpp:296
KFileView::sorting
TQDir::SortSpec sorting() const
Returns the sorting order of the internal list.
Definition: tdefileview.h:176
KFileView::currentFileItem
virtual KFileItem * currentFileItem() const =0
KFileView::updateView
virtual void updateView(bool f=true)
does a repaint of the view.
Definition: tdefileview.cpp:259
KFileView::setDropOptions
void setDropOptions(int options)
Specify DND options.
Definition: tdefileview.cpp:397
KFileView::widget
virtual TQWidget * widget()=0
a pure virtual function to get a TQWidget, that can be added to other widgets.
KFileView::removeItem
virtual void removeItem(const KFileItem *item)
Removes an item from the list; has to be implemented by the view.
Definition: tdefileview.cpp:346
KFileView::ensureItemVisible
virtual void ensureItemVisible(const KFileItem *i)=0
pure virtual function, that should be implemented to make item i visible, i.e.
KFileView::setSorting
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
Definition: tdefileview.cpp:151
KFileView::actionCollection
virtual TDEActionCollection * actionCollection() const
Definition: tdefileview.cpp:365
KFileView::clear
virtual void clear()
Clears the view and all item lists.
Definition: tdefileview.cpp:156
KFileView::addItemList
void addItemList(const KFileItemList &list)
inserts a list of items.
Definition: tdefileview.cpp:130
KFileView::setSelected
virtual void setSelected(const KFileItem *, bool enable)=0
Tells the view that it should highlight the item.
KFileView::clearView
virtual void clearView()=0
pure virtual function, that should be implemented to clear the view.
KFile
KFile is a class which provides a namespace for some enumerated values associated with the tdefile li...
Definition: tdefile.h:32
KFile::Mode
Mode
Modes of operation for the dialog.
Definition: tdefile.h:42
KFile::isPreviewInfo
static bool isPreviewInfo(const FileView &view)
Definition: tdefile.h:123
KPropertiesDialog
The main properties dialog class.
Definition: kpropertiesdialog.h:71

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdefile by doxygen 1.9.4
This website is maintained by Timothy Pearson.