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 / kfileiconview.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  7.4 KB  |  266 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 KFILEICONVIEW_H
  22. #define KFILEICONVIEW_H
  23.  
  24. class KFileItem;
  25. class QWidget;
  26. class QLabel;
  27.  
  28. #include <kiconview.h>
  29. #include <kiconloader.h>
  30. #include <kfileview.h>
  31. #include <kmimetyperesolver.h>
  32. #include <kfile.h>
  33.  
  34. /**
  35.  * An item for the iconview, that has a reference to its corresponding
  36.  * KFileItem.
  37.  */
  38. class KIO_EXPORT KFileIconViewItem : public KIconViewItem
  39. {
  40. public:
  41.     KFileIconViewItem( QIconView *parent, const QString &text,
  42.                const QPixmap &pixmap,
  43.                KFileItem *fi )
  44.     : KIconViewItem( parent, text, pixmap ), inf( fi ) {}
  45.     /**
  46.      * @since 3.1
  47.      */
  48.     KFileIconViewItem( QIconView *parent, KFileItem *fi )
  49.     : KIconViewItem( parent ), inf( fi ) {}
  50.  
  51.     virtual ~KFileIconViewItem();
  52.  
  53.     /**
  54.      * @returns the corresponding KFileItem
  55.      */
  56.     KFileItem *fileInfo() const {
  57.     return inf;
  58.     }
  59.  
  60. private:
  61.     KFileItem *inf;
  62.  
  63. private:
  64.     class KFileIconViewItemPrivate;
  65.     KFileIconViewItemPrivate *d;
  66.  
  67. };
  68.  
  69. namespace KIO {
  70.     class Job;
  71. }
  72.  
  73. /**
  74.  * An icon-view capable of showing KFileItem's. Used in the filedialog
  75.  * for example. Most of the documentation is in KFileView class.
  76.  *
  77.  * @see KDirOperator
  78.  * @see KCombiView
  79.  * @see KFileDetailView
  80.  */
  81. class KIO_EXPORT KFileIconView : public KIconView, public KFileView
  82. {
  83.     Q_OBJECT
  84.  
  85. public:
  86.     KFileIconView(QWidget *parent, const char *name);
  87.     virtual ~KFileIconView();
  88.  
  89.     virtual QWidget *widget() { return this; }
  90.     virtual void clearView();
  91.     virtual void setAutoUpdate( bool ) {} // ### unused. remove in KDE4
  92.  
  93.     virtual void updateView( bool );
  94.     virtual void updateView(const KFileItem*);
  95.     virtual void removeItem(const KFileItem*);
  96.  
  97.     virtual void listingCompleted();
  98.  
  99.     virtual void insertItem( KFileItem *i );
  100.     virtual void setSelectionMode( KFile::SelectionMode sm );
  101.  
  102.     virtual void setSelected(const KFileItem *, bool);
  103.     virtual bool isSelected(const KFileItem *i) const;
  104.     virtual void clearSelection();
  105.     virtual void selectAll();
  106.     virtual void invertSelection();
  107.  
  108.     virtual void setCurrentItem( const KFileItem * );
  109.     virtual KFileItem * currentFileItem() const;
  110.     virtual KFileItem * firstFileItem() const;
  111.     virtual KFileItem * nextItem( const KFileItem * ) const;
  112.     virtual KFileItem * prevItem( const KFileItem * ) const;
  113.  
  114.     /**
  115.      * Sets the size of the icons to show. Defaults to KIcon::SizeSmall.
  116.      */
  117.     void setIconSize( int size );
  118.  
  119.     /**
  120.      * Sets the size of the previews. Defaults to KIcon::SizeLarge.
  121.      */
  122.     void setPreviewSize( int size );
  123.  
  124.     /**
  125.      * Disables the "Maximum file size" configuration option for previews
  126.      *
  127.      * Set this before calling showPreviews()
  128.      *
  129.      * @since 3.4
  130.      **/
  131.     void setIgnoreMaximumSize(bool ignoreSize=true);
  132.  
  133.     /**
  134.      * @returns the current size used for icons.
  135.      */
  136.     int iconSize() const { return myIconSize; }
  137.  
  138.     void ensureItemVisible( const KFileItem * );
  139.  
  140.     virtual void setSorting(QDir::SortSpec sort);
  141.  
  142.     virtual void readConfig( KConfig *, const QString& group = QString::null );
  143.     virtual void writeConfig( KConfig *, const QString& group = QString::null);
  144.  
  145.     // for KMimeTypeResolver
  146.     void mimeTypeDeterminationFinished();
  147.     void determineIcon( KFileIconViewItem *item );
  148.     QScrollView *scrollWidget() const { return (QScrollView*) this; }
  149.     void setAcceptDrops(bool b) 
  150.     {  
  151.       KIconView::setAcceptDrops(b); 
  152.       viewport()->setAcceptDrops(b);
  153.     }
  154.  
  155. public slots:
  156.     /**
  157.      * Starts loading previews for all files shown and shows them. Switches
  158.      * into 'large rows' mode, if that isn't the current mode yet.
  159.      * 
  160.      * @sa setIgnoreMaximumSize
  161.      */
  162.     void showPreviews();
  163.  
  164.     void zoomIn();
  165.     
  166.     void zoomOut();
  167.     
  168.     /**
  169.      * Reimplemented for performance reasons.
  170.      * @since 3.1
  171.      */
  172.     virtual void arrangeItemsInGrid( bool updated = true );
  173.  
  174. protected:
  175.     /**
  176.      * Reimplemented to not let QIconView eat return-key events
  177.      */
  178.     virtual void keyPressEvent( QKeyEvent * );
  179.  
  180.     /**
  181.      * Reimplemented to remove an eventual tooltip
  182.      */
  183.     virtual void hideEvent( QHideEvent * );
  184.  
  185.     // ### workaround for Qt3 bug (see #35080)
  186.     virtual void showEvent( QShowEvent * );
  187.  
  188.     virtual bool eventFilter( QObject *o, QEvent *e );
  189.  
  190.     // DND support
  191.     virtual QDragObject *dragObject();
  192.     virtual void contentsDragEnterEvent( QDragEnterEvent *e );
  193.     virtual void contentsDragMoveEvent( QDragMoveEvent *e );
  194.     virtual void contentsDragLeaveEvent( QDragLeaveEvent *e );
  195.     virtual void contentsDropEvent( QDropEvent *ev );
  196.  
  197.     // KDE4: Make virtual
  198.     bool acceptDrag(QDropEvent* e ) const;
  199.  
  200. private slots:
  201.     void selected( QIconViewItem *item );
  202.     void slotActivate( QIconViewItem * );
  203.     void highlighted( QIconViewItem *item );
  204.     void showToolTip( QIconViewItem *item );
  205.     void removeToolTip();
  206.     void slotActivateMenu( QIconViewItem *, const QPoint& );
  207.     void slotSelectionChanged();
  208.  
  209.     void slotSmallColumns();
  210.     void slotLargeRows();
  211.     void slotPreviewsToggled( bool );
  212.  
  213.     void slotPreviewResult( KIO::Job * );
  214.     void gotPreview( const KFileItem *item, const QPixmap& pix );
  215.     void slotAutoOpen();
  216.  
  217. signals:
  218.     /**
  219.      * The user dropped something.
  220.      * @p fileItem points to the item dropped on or can be 0 if the 
  221.      * user dropped on empty space.
  222.      * @since 3.2
  223.      */
  224.     void dropped(QDropEvent *event, KFileItem *fileItem);
  225.     /**
  226.      * The user dropped the URLs @p urls.
  227.      * @p url points to the item dropped on or can be empty if the
  228.      * user dropped on empty space.
  229.      * @since 3.2
  230.      */
  231.     void dropped(QDropEvent *event, const KURL::List &urls, const KURL &url);
  232.  
  233. private:
  234.     KMimeTypeResolver<KFileIconViewItem,KFileIconView> *m_resolver;
  235.  
  236.     QLabel *toolTip;
  237.     int th;
  238.     int myIconSize;
  239.  
  240.     virtual void insertItem(QIconViewItem *a, QIconViewItem *b) { KIconView::insertItem(a, b); }
  241.     virtual void setSelectionMode(QIconView::SelectionMode m) { KIconView::setSelectionMode(m); }
  242.     virtual void setSelected(QIconViewItem *i, bool a, bool b) { KIconView::setSelected(i, a, b); }
  243.  
  244.     bool canPreview( const KFileItem * ) const;
  245.     void stopPreview();
  246.  
  247.     void updateIcons();
  248.  
  249.     inline KFileIconViewItem * viewItem( const KFileItem *item ) const {
  250.         if ( item )
  251.             return (KFileIconViewItem *) item->extraData( this );
  252.         return 0L;
  253.     }
  254.  
  255.     void initItem(KFileIconViewItem *item, const KFileItem *i,
  256.                   bool updateTextAndPixmap );
  257.  
  258. protected:
  259.     virtual void virtual_hook( int id, void* data );
  260. private:
  261.     class KFileIconViewPrivate;
  262.     KFileIconViewPrivate *d;
  263. };
  264.  
  265. #endif // KFILESIMPLEVIEW_H
  266.