kio Library API Documentation

kdiroperator.h

00001 // -*- c++ -*-
00002 /* This file is part of the KDE libraries
00003     Copyright (C) 1999 Stephan Kulow <coolo@kde.org>
00004           2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA 02111-1307, USA.
00020 */
00021 #ifndef KDIROPERATOR_H_
00022 #define KDIROPERATOR_H_
00023 
00024 #include <qwidget.h>
00025 #include <qptrstack.h>
00026 
00027 #include <kaction.h>
00028 #include <kcompletion.h>
00029 
00030 #include <kdirlister.h>
00031 
00032 #include <kfileview.h>
00033 #include <kfileitem.h>
00034 #include <kfile.h>
00035 
00036 class QPopupMenu;
00037 class QTimer;
00038 
00039 class KAction;
00040 class KDirLister;
00041 class KToggleAction;
00042 class KActionSeparator;
00043 class KActionMenu;
00044 class QWidgetStack;
00045 class KProgress;
00046 namespace KIO {
00047   class DeleteJob;
00048 }
00049 
00098 class KDirOperator : public QWidget
00099 {
00100     Q_OBJECT
00101 
00102  public:
00107     enum ActionTypes { SortActions = 1,
00108                        ViewActions = 2,
00109                        NavActions = 4,
00110                        FileActions = 8,
00111                        AllActions = 15 };
00119     KDirOperator(const KURL& urlName = KURL(),
00120          QWidget *parent = 0, const char* name = 0);
00124     virtual ~KDirOperator();
00125 
00129     void setShowHiddenFiles ( bool s ) { showHiddenAction->setChecked( s ); }
00130 
00134     bool showHiddenFiles () const { return showHiddenAction->isChecked(); }
00135 
00139     void close();
00140 
00148     void setNameFilter(const QString& filter);
00149 
00154     const QString& nameFilter() const { return dir->nameFilter(); }
00155 
00173     void setMimeFilter( const QStringList& mimetypes );
00174 
00178     QStringList mimeFilter() const { return dir->mimeFilters(); }
00179 
00187     void clearFilter();
00188 
00192     KURL url() const;
00193 
00199     void setURL(const KURL& url, bool clearforward);
00200 
00205     void setCurrentItem( const QString& filename );
00206 
00217     void setView(KFileView *view);
00218 
00223     KFileView * view() const { return m_fileView; }
00224 
00229     QWidget * viewWidget() const { return m_fileView ? m_fileView->widget() : 0L; }
00230 
00235     void setView(KFile::FileView view);
00236 
00240     void setSorting( QDir::SortSpec );
00241 
00245     QDir::SortSpec sorting() const { return mySorting; }
00246 
00250     bool isRoot() const { return url().path() == QChar('/'); }
00251 
00255     KDirLister *dirLister() const { return dir; }
00256 
00261     KProgress * progressBar() const;
00262 
00274     void setMode( KFile::Mode m );
00278     KFile::Mode mode() const;
00279 
00285     void setPreviewWidget(const QWidget *w);
00286 
00291     const KFileItemList * selectedItems() const {
00292     return ( m_fileView ? m_fileView->selectedItems() : 0L );
00293     }
00294 
00298     inline bool isSelected( const KFileItem *item ) const {
00299     return ( m_fileView ? m_fileView->isSelected( item ) : false );
00300     }
00301 
00306     int numDirs() const;
00307 
00312     int numFiles() const;
00313 
00322     KCompletion * completionObject() const {
00323     return const_cast<KCompletion *>( &myCompletion );
00324     }
00325 
00334     KCompletion *dirCompletionObject() const {
00335     return const_cast<KCompletion *>( &myDirCompletion );
00336     }
00337 
00381     KActionCollection * actionCollection() const { return myActionCollection; }
00382 
00400     void setViewConfig( KConfig *config, const QString& group );
00401     
00409     KConfig *viewConfig();
00410 
00418     QString viewConfigGroup() const;
00419     
00433     virtual void readConfig( KConfig *, const QString& group = QString::null );
00434 
00441     virtual void writeConfig( KConfig *, const QString& group = QString::null );
00442 
00443 
00454     void setOnlyDoubleClickSelectsFiles( bool enable );
00455 
00461     bool onlyDoubleClickSelectsFiles() const;
00462 
00471     bool mkdir( const QString& directory, bool enterDirectory = true );
00472 
00479     KIO::DeleteJob * del( const KFileItemList& items,
00480                           bool ask = true, bool showProgress = true );
00481 
00490     KIO::DeleteJob * del( const KFileItemList& items, QWidget *parent,
00491                           bool ask = true, bool showProgress = true );
00492 
00496     void clearHistory();
00497 
00507     void setEnableDirHighlighting( bool enable );
00508 
00515     bool dirHighlighting() const;
00516 
00521     bool dirOnlyMode() const { return dirOnlyMode( myMode ); }
00522 
00523     static bool dirOnlyMode( uint mode ) {
00524         return ( (mode & KFile::Directory) &&
00525                  (mode & (KFile::File | KFile::Files)) == 0 );
00526     }
00527 
00532     void setupMenu(int whichActions);
00533 
00534 protected:
00549      virtual KFileView* createView( QWidget* parent, KFile::FileView view );
00553     void setDirLister( KDirLister *lister );
00554 
00558     void resizeEvent( QResizeEvent * );
00559 
00564     void setupActions();
00565 
00570     void updateSortActions();
00571 
00576     void updateViewActions();
00577 
00583     void setupMenu();
00584 
00592     void prepareCompletionObjects();
00593 
00599     bool checkPreviewSupport();
00600 
00601 public slots:
00605     void back();
00606 
00610     void forward();
00611 
00615     void home();
00616 
00620     void cdUp();
00621 
00625     void updateDir();
00626 
00630     void rereadDir();
00631 
00635     void mkdir();
00636 
00640     void deleteSelected();
00641 
00647     void updateSelectionDependentActions();
00648 
00652     QString makeCompletion(const QString&);
00653 
00657     QString makeDirCompletion(const QString&);
00658 
00659 protected slots:
00664     void resetCursor();
00665 
00670     void pathChanged();
00671 
00676     void insertNewFiles(const KFileItemList &newone);
00677 
00682     void itemDeleted(KFileItem *);
00683 
00687     void selectDir(const KFileItem *item );
00688 
00692     void selectFile(const KFileItem *item);
00693 
00697     void highlightFile(const KFileItem* i) { emit fileHighlighted( i ); }
00698 
00702     virtual void activatedMenu( const KFileItem *, const QPoint& pos );
00703 
00707     void sortByName()       { byNameAction->setChecked( true ); }
00708 
00712     void sortBySize()       { bySizeAction->setChecked( true ); }
00713 
00717     void sortByDate()       { byDateAction->setChecked( true ); }
00718 
00722     void sortReversed()     { reverseAction->setChecked( !reverseAction->isChecked() ); }
00723 
00727     void toggleDirsFirst()  { dirsFirstAction->setChecked( !dirsFirstAction->isChecked() ); }
00728 
00732     void toggleIgnoreCase()     { caseInsensitiveAction->setChecked( !caseInsensitiveAction->isChecked() ); }
00733 
00738     void slotCompletionMatch(const QString& match);
00739 
00740 signals:
00741     void urlEntered(const KURL& );
00742     void updateInformation(int files, int dirs);
00743     void completion(const QString&);
00744     void finishedLoading();
00745 
00751     void viewChanged( KFileView * newView );
00752 
00753     void fileHighlighted(const KFileItem*);
00754     void dirActivated(const KFileItem*);
00755     void fileSelected(const KFileItem*);
00756 
00757 private:
00761     QPtrStack<KURL> backStack;
00762 
00766     QPtrStack<KURL> forwardStack;
00767 
00768     KDirLister *dir;
00769     KURL currUrl;
00770 
00771     KCompletion myCompletion;
00772     KCompletion myDirCompletion;
00773     bool myCompleteListDirty;
00774     QDir::SortSpec mySorting;
00775 
00780     bool checkPreviewInternal() const;
00781 
00786     void checkPath(const QString& txt, bool takeFiles = false);
00787 
00788     void connectView(KFileView *);
00789 
00790     KFileView *m_fileView;
00791     KFileItemList pendingMimeTypes;
00792 
00793     // the enum KFile::FileView as an int
00794     int m_viewKind;
00795     int defaultView;
00796 
00797     KFile::Mode myMode;
00798     KProgress *progress;
00799 
00800     const QWidget *myPreview;    // temporary pointer for the preview widget
00801 
00802     // actions for the popupmenus
00803     // ### clean up all those -- we have them all in the actionMenu!
00804     KActionMenu *actionMenu;
00805 
00806     KAction     *backAction;
00807     KAction     *forwardAction;
00808     KAction     *homeAction;
00809     KAction     *upAction;
00810     KAction     *reloadAction;
00811     KActionSeparator *actionSeparator;
00812     KAction     *mkdirAction;
00813 
00814     KActionMenu *sortActionMenu;
00815     KRadioAction *byNameAction;
00816     KRadioAction *byDateAction;
00817     KRadioAction *bySizeAction;
00818     KToggleAction *reverseAction;
00819     KToggleAction *dirsFirstAction;
00820     KToggleAction *caseInsensitiveAction;
00821 
00822     KActionMenu *viewActionMenu;
00823     KRadioAction *shortAction;
00824     KRadioAction *detailedAction;
00825     KToggleAction *showHiddenAction;
00826     KToggleAction *separateDirsAction;
00827 
00828     KActionCollection *myActionCollection;
00829     KActionCollection *viewActionCollection;
00830 
00831 private slots:
00835     void slotDetailedView();
00836     void slotSimpleView();
00837     void slotToggleHidden( bool );
00838 
00839     void slotSeparateDirs();
00840     void slotDefaultPreview();
00841     void togglePreview( bool );
00842 
00843     void slotSortByName();
00844     void slotSortBySize();
00845     void slotSortByDate();
00846     void slotSortReversed();
00847     void slotToggleDirsFirst();
00848     void slotToggleIgnoreCase();
00849 
00850     void slotStarted();
00851     void slotProgress( int );
00852     void slotShowProgress();
00853     void slotIOFinished();
00854     void slotCanceled();
00855     void slotRedirected( const KURL& );
00856 
00857     void slotViewActionAdded( KAction * );
00858     void slotViewActionRemoved( KAction * );
00859     void slotViewSortingChanged( QDir::SortSpec );
00860 
00861     void slotClearView();
00862     void slotRefreshItems( const KFileItemList& items );
00863 
00864     void slotProperties();
00865     
00866     void insertViewDependentActions();
00867     
00868 private:
00869     static bool isReadable( const KURL& url );
00870 
00871 protected:
00872     virtual void virtual_hook( int id, void* data );
00873 private:
00874     class KDirOperatorPrivate;
00875     KDirOperatorPrivate *d;
00876 };
00877 
00878 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:28 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001