| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# 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
    00758     void fileHighlighted( const KFileItem *item );
    00759     void dirActivated( const KFileItem *item );
    00760     void fileSelected( const KFileItem *item );
    00761
    00762 private:
    00766     QPtrStack<KURL> backStack;
    00767
    00771     QPtrStack<KURL> forwardStack;
    00772
    00773     KDirLister *dir;
    00774     KURL currUrl;
    00775
    00776     KCompletion myCompletion;
    00777     KCompletion myDirCompletion;
    00778     bool myCompleteListDirty;
    00779     QDir::SortSpec mySorting;
    00780
    00785     bool checkPreviewInternal() const;
    00786
    00791     void checkPath(const QString& txt, bool takeFiles = false);
    00792
    00793     void connectView(KFileView *);
    00794
    00795     KFileView *m_fileView;
    00796     KFileItemList pendingMimeTypes;
    00797
    00798     // the enum KFile::FileView as an int
    00799     int m_viewKind;
    00800     int defaultView;
    00801
    00802     KFile::Mode myMode;
    00803     KProgress *progress;
    00804
    00805     const QWidget *myPreview;    // temporary pointer for the preview widget
    00806
    00807     // actions for the popupmenus
    00808     // ### clean up all those -- we have them all in the actionMenu!
    00809     KActionMenu *actionMenu;
    00810
    00811     KAction     *backAction;
    00812     KAction     *forwardAction;
    00813     KAction     *homeAction;
    00814     KAction     *upAction;
    00815     KAction     *reloadAction;
    00816     KActionSeparator *actionSeparator;
    00817     KAction     *mkdirAction;
    00818
    00819     KActionMenu *sortActionMenu;
    00820     KRadioAction *byNameAction;
    00821     KRadioAction *byDateAction;
    00822     KRadioAction *bySizeAction;
    00823     KToggleAction *reverseAction;
    00824     KToggleAction *dirsFirstAction;
    00825     KToggleAction *caseInsensitiveAction;
    00826
    00827     KActionMenu *viewActionMenu;
    00828     KRadioAction *shortAction;
    00829     KRadioAction *detailedAction;
    00830     KToggleAction *showHiddenAction;
    00831     KToggleAction *separateDirsAction;
    00832
    00833     KActionCollection *myActionCollection;
    00834     KActionCollection *viewActionCollection;
    00835
    00836 private slots:
    00840     void slotDetailedView();
    00841     void slotSimpleView();
    00842     void slotToggleHidden( bool );
    00843
    00844     void slotSeparateDirs();
    00845     void slotDefaultPreview();
    00846     void togglePreview( bool );
    00847
    00848     void slotSortByName();
    00849     void slotSortBySize();
    00850     void slotSortByDate();
    00851     void slotSortReversed();
    00852     void slotToggleDirsFirst();
    00853     void slotToggleIgnoreCase();
    00854
    00855     void slotStarted();
    00856     void slotProgress( int );
    00857     void slotShowProgress();
    00858     void slotIOFinished();
    00859     void slotCanceled();
    00860     void slotRedirected( const KURL& );
    00861
    00862     void slotViewActionAdded( KAction * );
    00863     void slotViewActionRemoved( KAction * );
    00864     void slotViewSortingChanged( QDir::SortSpec );
    00865
    00866     void slotClearView();
    00867     void slotRefreshItems( const KFileItemList& items );
    00868
    00869     void slotProperties();
    00870
    00871     void insertViewDependentActions();
    00872
    00873 private:
    00874     static bool isReadable( const KURL& url );
    00875
    00876 protected:
    00877     virtual void virtual_hook( int id, void* data );
    00878 private:
    00879     class KDirOperatorPrivate;
    00880     KDirOperatorPrivate *d;
    00881 };
    00882
    00883 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:13:24 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001