# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | 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 #include <kdirlister.h>
    00030 #include <kfileview.h>
    00031 #include <kfileitem.h>
    00032 #include <kfile.h>
    00033
    00034 class QPopupMenu;
    00035 class QTimer;
    00036
    00037 class KAction;
    00038 class KDirLister;
    00039 class KToggleAction;
    00040 class KActionSeparator;
    00041 class KActionMenu;
    00042 class QWidgetStack;
    00043 class KProgress;
    00044 namespace KIO {
    00045   class CopyJob;
    00046   class DeleteJob;
    00047 }
    00048
    00097 class KIO_EXPORT KDirOperator : public QWidget
    00098 {
    00099     Q_OBJECT
    00100
    00101  public:
    00106     enum ActionTypes { SortActions = 1,
    00107                        ViewActions = 2,
    00108                        NavActions = 4,
    00109                        FileActions = 8,
    00110                        AllActions = 15 };
    00118     KDirOperator(const KURL& urlName = KURL(),
    00119          QWidget *parent = 0, const char* name = 0);
    00123     virtual ~KDirOperator();
    00124
    00128     // ### KDE4: make virtual
    00129     void setShowHiddenFiles ( bool s ) { showHiddenAction->setChecked( s ); }
    00130
    00134     bool showHiddenFiles () const { return showHiddenAction->isChecked(); }
    00135
    00139     void close();
    00141     virtual bool close( bool alsoDelete ) { return QWidget::close( alsoDelete ); }
    00142
    00150     void setNameFilter(const QString& filter);
    00151
    00156     const QString& nameFilter() const { return dir->nameFilter(); }
    00157
    00175     void setMimeFilter( const QStringList& mimetypes );
    00176
    00180     QStringList mimeFilter() const { return dir->mimeFilters(); }
    00181
    00189     void clearFilter();
    00190
    00194     KURL url() const;
    00195
    00201     // ### KDE4: make virtual
    00202     void setURL(const KURL& url, bool clearforward);
    00203
    00208     void setCurrentItem( const QString& filename );
    00209
    00220     // ### KDE4: make virtual
    00221     void setView(KFileView *view);
    00222
    00227     KFileView * view() const { return m_fileView; }
    00228
    00233     QWidget * viewWidget() const { return m_fileView ? m_fileView->widget() : 0L; }
    00234
    00239     // ### KDE4: make virtual
    00240     void setView(KFile::FileView view);
    00241
    00245     void setSorting( QDir::SortSpec );
    00246
    00250     QDir::SortSpec sorting() const { return mySorting; }
    00251
    00255     bool isRoot() const { return url().path() == QChar('/'); }
    00256
    00260     KDirLister *dirLister() const { return dir; }
    00261
    00266     KProgress * progressBar() const;
    00267
    00279     // ### KDE4: make virtual
    00280     void setMode( KFile::Mode m );
    00284     KFile::Mode mode() const;
    00285
    00291     // ### KDE4: make virtual
    00292     void setPreviewWidget(const QWidget *w);
    00293
    00298     const KFileItemList * selectedItems() const {
    00299     return ( m_fileView ? m_fileView->selectedItems() : 0L );
    00300     }
    00301
    00305     inline bool isSelected( const KFileItem *item ) const {
    00306     return ( m_fileView ? m_fileView->isSelected( item ) : false );
    00307     }
    00308
    00313     int numDirs() const;
    00314
    00319     int numFiles() const;
    00320
    00329     KCompletion * completionObject() const {
    00330     return const_cast<KCompletion *>( &myCompletion );
    00331     }
    00332
    00341     KCompletion *dirCompletionObject() const {
    00342     return const_cast<KCompletion *>( &myDirCompletion );
    00343     }
    00344
    00390     KActionCollection * actionCollection() const { return myActionCollection; }
    00391
    00409     // ### KDE4: make virtual
    00410     void setViewConfig( KConfig *config, const QString& group );
    00411
    00419     KConfig *viewConfig();
    00420
    00428     QString viewConfigGroup() const;
    00429
    00443     virtual void readConfig( KConfig *, const QString& group = QString::null );
    00444
    00451     virtual void writeConfig( KConfig *, const QString& group = QString::null );
    00452
    00453
    00464     void setOnlyDoubleClickSelectsFiles( bool enable );
    00465
    00471     bool onlyDoubleClickSelectsFiles() const;
    00472
    00481     // ### KDE4: make virtual and turn QString into KURL
    00482     bool mkdir( const QString& directory, bool enterDirectory = true );
    00483
    00491     // ### KDE4: make virtual
    00492     KIO::DeleteJob * del( const KFileItemList& items,
    00493                           bool ask = true, bool showProgress = true );
    00494
    00504     // ### KDE4: make virtual
    00505     KIO::DeleteJob * del( const KFileItemList& items, QWidget *parent,
    00506                           bool ask = true, bool showProgress = true );
    00507
    00511     void clearHistory();
    00512
    00522     // ### KDE4: make virtual
    00523     void setEnableDirHighlighting( bool enable );
    00524
    00531     bool dirHighlighting() const;
    00532
    00537     bool dirOnlyMode() const { return dirOnlyMode( myMode ); }
    00538
    00539     static bool dirOnlyMode( uint mode ) {
    00540         return ( (mode & KFile::Directory) &&
    00541                  (mode & (KFile::File | KFile::Files)) == 0 );
    00542     }
    00543
    00548     void setupMenu(int whichActions);
    00549
    00554     virtual void setAcceptDrops(bool b);
    00555
    00561      // ### KDE4: make virtual
    00562     void setDropOptions(int options);
    00563
    00573      // ### KDE4: make virtual
    00574     KIO::CopyJob * trash( const KFileItemList& items, QWidget *parent,
    00575                        bool ask = true, bool showProgress = true );
    00576
    00577 protected:
    00592      virtual KFileView* createView( QWidget* parent, KFile::FileView view );
    00596     // ### KDE4: make virtual
    00597     void setDirLister( KDirLister *lister );
    00598
    00599     virtual void resizeEvent( QResizeEvent * );
    00600
    00605     void setupActions();
    00606
    00611     void updateSortActions();
    00612
    00617     void updateViewActions();
    00618
    00624     void setupMenu();
    00625
    00633     void prepareCompletionObjects();
    00634
    00640     bool checkPreviewSupport();
    00641
    00642 public slots:
    00646     // ### KDE4: make virtual
    00647     void back();
    00648
    00652     // ### KDE4: make virtual
    00653     void forward();
    00654
    00658     // ### KDE4: make virtual
    00659     void home();
    00660
    00664     // ### KDE4: make virtual
    00665     void cdUp();
    00666
    00670     void updateDir();
    00671
    00675     // ### KDE4: make virtual
    00676     void rereadDir();
    00677
    00681     // ### KDE4: make virtual
    00682     void mkdir();
    00683
    00687     // ### KDE4: make virtual
    00688     void deleteSelected();
    00689
    00695     void updateSelectionDependentActions();
    00696
    00700     QString makeCompletion(const QString&);
    00701
    00705     QString makeDirCompletion(const QString&);
    00706
    00711     // ### KDE4: make virtual
    00712     void trashSelected(KAction::ActivationReason, Qt::ButtonState);
    00713
    00714 protected slots:
    00719     void resetCursor();
    00720
    00725     void pathChanged();
    00726
    00731     void insertNewFiles(const KFileItemList &newone);
    00732
    00737     void itemDeleted(KFileItem *);
    00738
    00742     // ### KDE4: make virtual
    00743     void selectDir(const KFileItem *item );
    00744
    00748     void selectFile(const KFileItem *item);
    00749
    00753     void highlightFile(const KFileItem* i) { emit fileHighlighted( i ); }
    00754
    00758     virtual void activatedMenu( const KFileItem *, const QPoint& pos );
    00759
    00763     void sortByName()       { byNameAction->setChecked( true ); }
    00764
    00768     void sortBySize()       { bySizeAction->setChecked( true ); }
    00769
    00773     void sortByDate()       { byDateAction->setChecked( true ); }
    00774
    00778     void sortReversed()     { reverseAction->setChecked( !reverseAction->isChecked() ); }
    00779
    00783     void toggleDirsFirst()  { dirsFirstAction->setChecked( !dirsFirstAction->isChecked() ); }
    00784
    00788     void toggleIgnoreCase()     { caseInsensitiveAction->setChecked( !caseInsensitiveAction->isChecked() ); }
    00789
    00794     void slotCompletionMatch(const QString& match);
    00795
    00796 signals:
    00797     void urlEntered(const KURL& );
    00798     void updateInformation(int files, int dirs);
    00799     void completion(const QString&);
    00800     void finishedLoading();
    00801
    00807     void viewChanged( KFileView * newView );
    00808
    00814     void fileHighlighted( const KFileItem *item );
    00815     void dirActivated( const KFileItem *item );
    00816     void fileSelected( const KFileItem *item );
    00825     void dropped(const KFileItem *item, QDropEvent*event, const KURL::List&urls);
    00826 private:
    00830     QPtrStack<KURL> backStack;
    00831
    00835     QPtrStack<KURL> forwardStack;
    00836
    00837     KDirLister *dir;
    00838     KURL currUrl;
    00839
    00840     KCompletion myCompletion;
    00841     KCompletion myDirCompletion;
    00842     bool myCompleteListDirty;
    00843     QDir::SortSpec mySorting;
    00844
    00849     bool checkPreviewInternal() const;
    00850
    00855     void checkPath(const QString& txt, bool takeFiles = false);
    00856
    00857     void connectView(KFileView *);
    00858
    00859     KFileView *m_fileView;
    00860     KFileItemList pendingMimeTypes;
    00861
    00862     // the enum KFile::FileView as an int
    00863     int m_viewKind;
    00864     int defaultView;
    00865
    00866     KFile::Mode myMode;
    00867     KProgress *progress;
    00868
    00869     const QWidget *myPreview;    // temporary pointer for the preview widget
    00870
    00871     // actions for the popupmenus
    00872     // ### clean up all those -- we have them all in the actionMenu!
    00873     KActionMenu *actionMenu;
    00874
    00875     KAction     *backAction;
    00876     KAction     *forwardAction;
    00877     KAction     *homeAction;
    00878     KAction     *upAction;
    00879     KAction     *reloadAction;
    00880     KActionSeparator *actionSeparator;
    00881     KAction     *mkdirAction;
    00882
    00883     KActionMenu *sortActionMenu;
    00884     KRadioAction *byNameAction;
    00885     KRadioAction *byDateAction;
    00886     KRadioAction *bySizeAction;
    00887     KToggleAction *reverseAction;
    00888     KToggleAction *dirsFirstAction;
    00889     KToggleAction *caseInsensitiveAction;
    00890
    00891     KActionMenu *viewActionMenu;
    00892     KRadioAction *shortAction;
    00893     KRadioAction *detailedAction;
    00894     KToggleAction *showHiddenAction;
    00895     KToggleAction *separateDirsAction;
    00896
    00897     KActionCollection *myActionCollection;
    00898     KActionCollection *viewActionCollection;
    00899
    00900 private slots:
    00904     void slotDetailedView();
    00905     void slotSimpleView();
    00906     void slotToggleHidden( bool );
    00907
    00908     void slotSeparateDirs();
    00909     void slotDefaultPreview();
    00910     void togglePreview( bool );
    00911
    00912     void slotSortByName();
    00913     void slotSortBySize();
    00914     void slotSortByDate();
    00915     void slotSortReversed();
    00916     void slotToggleDirsFirst();
    00917     void slotToggleIgnoreCase();
    00918
    00919     void slotStarted();
    00920     void slotProgress( int );
    00921     void slotShowProgress();
    00922     void slotIOFinished();
    00923     void slotCanceled();
    00924     void slotRedirected( const KURL& );
    00925
    00926     void slotViewActionAdded( KAction * );
    00927     void slotViewActionRemoved( KAction * );
    00928     void slotViewSortingChanged( QDir::SortSpec );
    00929
    00930     void slotClearView();
    00931     void slotRefreshItems( const KFileItemList& items );
    00932
    00933     void slotProperties();
    00934
    00935     void insertViewDependentActions();
    00936
    00937 private:
    00938     static bool isReadable( const KURL& url );
    00939
    00940 protected:
    00941     virtual void virtual_hook( int id, void* data );
    00942 private:
    00943     class KDirOperatorPrivate;
    00944     KDirOperatorPrivate *d;
    00945 };
    00946
    00947 #endif

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:23:56 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003