home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kfiledetailview.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  6.3 KB  |  220 lines

  1. // -*- c++ -*-
  2. /* This file is part of the KDE libraries
  3.     Copyright (C) 1997 Stephan Kulow <coolo@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. #ifndef KFILEDETAILVIEW_H
  22. #define KFILEDETAILVIEW_H
  23.  
  24. class KFileItem;
  25. class QWidget;
  26. class QKeyEvent;
  27.  
  28. #include <klistview.h>
  29. #include <kmimetyperesolver.h>
  30.  
  31. #include "kfileview.h"
  32.  
  33. /**
  34.  * An item for the listiew, that has a reference to its corresponding
  35.  * KFileItem.
  36.  */
  37. class KIO_EXPORT KFileListViewItem : public KListViewItem
  38. {
  39. public:
  40.     KFileListViewItem( QListView *parent, const QString &text,
  41.                const QPixmap &icon, KFileItem *fi )
  42.     : KListViewItem( parent, text ), inf( fi ) {
  43.         setPixmap( 0, icon );
  44.         setText( 0, text );
  45.     }
  46.  
  47.     /**
  48.      * @since 3.1
  49.      */
  50.     KFileListViewItem( QListView *parent, KFileItem *fi )
  51.         : KListViewItem( parent ), inf( fi ) {
  52.         init();
  53.     }
  54.  
  55.     KFileListViewItem( QListView *parent, const QString &text,
  56.                const QPixmap &icon, KFileItem *fi,
  57.                QListViewItem *after)
  58.     : KListViewItem( parent, after ), inf( fi ) {
  59.         setPixmap( 0, icon );
  60.         setText( 0, text );
  61.     }
  62.     ~KFileListViewItem() {
  63.         inf->removeExtraData( listView() );
  64.     }
  65.  
  66.     /**
  67.      * @returns the corresponding KFileItem
  68.      */
  69.     KFileItem *fileInfo() const {
  70.     return inf;
  71.     }
  72.  
  73.     virtual QString key( int /*column*/, bool /*ascending*/ ) const {
  74.         return m_key;
  75.     }
  76.  
  77.     void setKey( const QString& key ) { m_key = key; }
  78.  
  79.     QRect rect() const
  80.     {
  81.         QRect r = listView()->itemRect(this);
  82.         return QRect( listView()->viewportToContents( r.topLeft() ),
  83.                       QSize( r.width(), r.height() ) );
  84.     }
  85.  
  86.     /**
  87.      * @since 3.1
  88.      */
  89.     void init();
  90.  
  91. private:
  92.     KFileItem *inf;
  93.     QString m_key;
  94.  
  95. private:
  96.     class KFileListViewItemPrivate;
  97.     KFileListViewItemPrivate *d;
  98.  
  99. };
  100.  
  101. /**
  102.  * A list-view capable of showing KFileItem'. Used in the filedialog
  103.  * for example. Most of the documentation is in KFileView class.
  104.  *
  105.  * @see KDirOperator
  106.  * @see KCombiView
  107.  * @see KFileIconView
  108.  */
  109. class KIO_EXPORT KFileDetailView : public KListView, public KFileView
  110. {
  111.     Q_OBJECT
  112.  
  113. public:
  114.     KFileDetailView(QWidget *parent, const char *name);
  115.     virtual ~KFileDetailView();
  116.  
  117.     virtual QWidget *widget() { return this; }
  118.     virtual void clearView();
  119.     virtual void setAutoUpdate( bool ) {} // ### unused. remove in KDE4
  120.  
  121.     virtual void setSelectionMode( KFile::SelectionMode sm );
  122.  
  123.     virtual void updateView( bool );
  124.     virtual void updateView(const KFileItem*);
  125.     virtual void removeItem( const KFileItem *);
  126.     virtual void listingCompleted();
  127.  
  128.     virtual void setSelected(const KFileItem *, bool);
  129.     virtual bool isSelected(const KFileItem *i) const;
  130.     virtual void clearSelection();
  131.     virtual void selectAll();
  132.     virtual void invertSelection();
  133.  
  134.     virtual void setCurrentItem( const KFileItem * );
  135.     virtual KFileItem * currentFileItem() const;
  136.     virtual KFileItem * firstFileItem() const;
  137.     virtual KFileItem * nextItem( const KFileItem * ) const;
  138.     virtual KFileItem * prevItem( const KFileItem * ) const;
  139.  
  140.     virtual void insertItem( KFileItem *i );
  141.  
  142.     // implemented to get noticed about sorting changes (for sortingIndicator)
  143.     virtual void setSorting( QDir::SortSpec );
  144.  
  145.     void ensureItemVisible( const KFileItem * );
  146.  
  147.     // for KMimeTypeResolver
  148.     void mimeTypeDeterminationFinished();
  149.     void determineIcon( KFileListViewItem *item );
  150.     QScrollView *scrollWidget() const { return (QScrollView*) this; }
  151.  
  152.     virtual void readConfig( KConfig *, const QString& group = QString::null );
  153.     virtual void writeConfig( KConfig *, const QString& group = QString::null);
  154.  
  155. signals:
  156.     /**
  157.      * The user dropped something.
  158.      * @p fileItem points to the item dropped on or can be 0 if the
  159.      * user dropped on empty space.
  160.      * @since 3.2
  161.      */
  162.     void dropped(QDropEvent *event, KFileItem *fileItem);
  163.     /**
  164.      * The user dropped the URLs @p urls.
  165.      * @p url points to the item dropped on or can be empty if the
  166.      * user dropped on empty space.
  167.      * @since 3.2
  168.      */
  169.     void dropped(QDropEvent *event, const KURL::List &urls, const KURL &url);
  170.  
  171. protected:
  172.     virtual void keyPressEvent( QKeyEvent * );
  173.  
  174.     // DND support
  175.     virtual QDragObject *dragObject();
  176.     virtual void contentsDragEnterEvent( QDragEnterEvent *e );
  177.     virtual void contentsDragMoveEvent( QDragMoveEvent *e );
  178.     virtual void contentsDragLeaveEvent( QDragLeaveEvent *e );
  179.     virtual void contentsDropEvent( QDropEvent *ev );
  180.     virtual bool acceptDrag(QDropEvent* e ) const;
  181.  
  182.     int m_sortingCol;
  183.  
  184. protected slots:
  185.     void slotSelectionChanged();
  186.  
  187. private slots:
  188.     void slotSortingChanged( int );
  189.     void selected( QListViewItem *item );
  190.     void slotActivate( QListViewItem *item );
  191.     void highlighted( QListViewItem *item );
  192.     void slotActivateMenu ( QListViewItem *item, const QPoint& pos );
  193.     void slotAutoOpen();
  194.  
  195. private:
  196.     virtual void insertItem(QListViewItem *i) { KListView::insertItem(i); }
  197.     virtual void setSorting(int i, bool b) { KListView::setSorting(i, b); }
  198.     virtual void setSelected(QListViewItem *i, bool b) { KListView::setSelected(i, b); }
  199.  
  200.     inline KFileListViewItem * viewItem( const KFileItem *item ) const {
  201.         if ( item )
  202.             return (KFileListViewItem *) item->extraData( this );
  203.         return 0L;
  204.     }
  205.  
  206.     void setSortingKey( KFileListViewItem *item, const KFileItem *i );
  207.  
  208.  
  209.     bool m_blockSortingSignal;
  210.     KMimeTypeResolver<KFileListViewItem,KFileDetailView> *m_resolver;
  211.  
  212. protected:
  213.     virtual void virtual_hook( int id, void* data );
  214. private:
  215.     class KFileDetailViewPrivate;
  216.     KFileDetailViewPrivate *d;
  217. };
  218.  
  219. #endif // KFILEDETAILVIEW_H
  220.