# kio Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kfileview.h

    00001 // -*- c++ -*-
    00002 /* This file is part of the KDE libraries
    00003     Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
    00004     Copyright (C) 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
    00022 #ifndef KFILEVIEW_H
    00023 #define KFILEVIEW_H
    00024
    00025 class QPoint;
    00026 class KActionCollection;
    00027
    00028 #include <qwidget.h>
    00029
    00030 #include "kfileitem.h"
    00031 #include "kfile.h"
    00032
    00037 class KFileViewSignaler : public QObject
    00038 {
    00039     Q_OBJECT
    00040
    00041 public:
    00046     void activate( const KFileItem *item ) {
    00047         if ( item->isDir() )
    00048             emit dirActivated( item );
    00049         else
    00050             emit fileSelected( item );
    00051     }
    00056     void highlightFile(const KFileItem *i) { emit fileHighlighted(i); }
    00057
    00058     void activateMenu( const KFileItem *i, const QPoint& pos ) {
    00059         emit activatedMenu( i, pos );
    00060     }
    00061
    00062     void changeSorting( QDir::SortSpec sorting ) {
    00063         emit sortingChanged( sorting );
    00064     }
    00065
    00066 signals:
    00067     void dirActivated(const KFileItem*);
    00068
    00069     void sortingChanged( QDir::SortSpec );
    00070
    00075     void fileHighlighted(const KFileItem*);
    00076     void fileSelected(const KFileItem*);
    00077     void activatedMenu( const KFileItem *i, const QPoint& );
    00078 };
    00079
    00094 class KFileView {
    00095
    00096 public:
    00097     KFileView();
    00098
    00102     virtual ~KFileView();
    00103
    00107     void addItemList(const KFileItemList &list);
    00108
    00114     virtual QWidget *widget() = 0;
    00115
    00119     QWidget *widget() const { return const_cast<KFileView*>(this)->widget(); }
    00120
    00124     void setCurrentItem( const QString &filename );
    00125
    00130     virtual void setCurrentItem( const KFileItem *item ) = 0;
    00131
    00137     virtual KFileItem *currentFileItem() const = 0;
    00138
    00142     virtual void clear();
    00143
    00150     virtual void updateView(bool f = true);
    00151
    00152     virtual void updateView(const KFileItem*);
    00153
    00158     virtual void removeItem(const KFileItem *item);
    00159
    00165     virtual void listingCompleted();
    00166
    00171     QDir::SortSpec sorting() const { return m_sorting; }
    00172
    00187     virtual void setSorting(QDir::SortSpec sort);
    00188
    00193     bool isReversed() const { return (m_sorting & QDir::Reversed); }
    00194
    00195     void sortReversed();
    00196
    00200     uint count() const { return filesNumber + dirsNumber; }
    00201
    00205     uint numFiles() const { return filesNumber; }
    00206
    00210     uint numDirs() const { return dirsNumber; }
    00211
    00212     virtual void setSelectionMode( KFile::SelectionMode sm );
    00213     virtual KFile::SelectionMode selectionMode() const;
    00214
    00215     enum ViewMode {
    00216         Files       = 1,
    00217         Directories = 2,
    00218         All = Files | Directories
    00219     };
    00220     virtual void setViewMode( ViewMode vm );
    00221     virtual ViewMode viewMode() const { return view_mode; }
    00222
    00228     QString viewName() const { return m_viewName; }
    00229
    00234     void setViewName( const QString& name ) { m_viewName = name; }
    00235
    00236     virtual void setParentView(KFileView *parent);
    00237
    00246     virtual void insertItem( KFileItem *i);
    00247
    00252     virtual void clearView() = 0;
    00253
    00258     virtual void ensureItemVisible( const KFileItem *i ) = 0;
    00259
    00264     virtual void clearSelection() = 0;
    00265
    00271     virtual void selectAll();
    00272
    00277     virtual void invertSelection();
    00278
    00283     virtual void setSelected(const KFileItem *, bool enable) = 0;
    00284
    00289     virtual bool isSelected( const KFileItem * ) const = 0;
    00290
    00294     const KFileItemList * selectedItems() const;
    00295
    00299     const KFileItemList * items() const;
    00300
    00301     virtual KFileItem * firstFileItem() const = 0;
    00302     virtual KFileItem * nextItem( const KFileItem * ) const = 0;
    00303     virtual KFileItem * prevItem( const KFileItem * ) const = 0;
    00304
    00315     void setOnlyDoubleClickSelectsFiles( bool enable ) {
    00316         myOnlyDoubleClickSelectsFiles = enable;
    00317     }
    00318
    00324     bool onlyDoubleClickSelectsFiles() const {
    00325         return myOnlyDoubleClickSelectsFiles;
    00326     }
    00327
    00332     bool updateNumbers(const KFileItem *i);
    00333
    00339     virtual KActionCollection * actionCollection() const;
    00340
    00341     KFileViewSignaler * signaler() const { return sig; }
    00342
    00343     virtual void readConfig( KConfig *, const QString& group = QString::null );
    00344     virtual void writeConfig( KConfig *, const QString& group = QString::null);
    00345
    00359     static QString sortingKey( const QString& value, bool isDir, int sortSpec);
    00360
    00367     static QString sortingKey( KIO::filesize_t value, bool isDir,int sortSpec);
    00368
    00369 protected:
    00374     KFileViewSignaler *sig;
    00375
    00376 private:
    00377     static QDir::SortSpec defaultSortSpec;
    00378     QDir::SortSpec m_sorting;
    00379     QString m_viewName;
    00380
    00384     uint filesNumber;
    00385     uint dirsNumber;
    00386
    00387     ViewMode view_mode;
    00388     KFile::SelectionMode selection_mode;
    00389
    00390     // never use! It's only guaranteed to contain valid items in the items()
    00391     // method!
    00392     mutable KFileItemList m_itemList;
    00393
    00394     mutable KFileItemList *m_selectedList;
    00395     bool myOnlyDoubleClickSelectsFiles;
    00396
    00397 protected:
    00398     virtual void virtual_hook( int id, void* data );
    00399 private:
    00400     class KFileViewPrivate;
    00401     KFileViewPrivate *d;
    00402 };
    00403
    00404 #endif // KFILEINFOLISTWIDGET_H

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:36 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001