kio Library API Documentation

kfiledetailview.h

00001 // -*- c++ -*- 00002 /* This file is part of the KDE libraries 00003 Copyright (C) 1997 Stephan Kulow <coolo@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef KFILEDETAILVIEW_H 00022 #define KFILEDETAILVIEW_H 00023 00024 class KFileItem; 00025 class QWidget; 00026 class QKeyEvent; 00027 00028 #include <klistview.h> 00029 #include <kmimetyperesolver.h> 00030 00031 #include "kfileview.h" 00032 00037 class KFileListViewItem : public KListViewItem 00038 { 00039 public: 00040 KFileListViewItem( QListView *parent, const QString &text, 00041 const QPixmap &icon, KFileItem *fi ) 00042 : KListViewItem( parent, text ), inf( fi ) { 00043 setPixmap( 0, icon ); 00044 setText( 0, text ); 00045 } 00046 00050 KFileListViewItem( QListView *parent, KFileItem *fi ) 00051 : KListViewItem( parent ), inf( fi ) { 00052 init(); 00053 } 00054 00055 KFileListViewItem( QListView *parent, const QString &text, 00056 const QPixmap &icon, KFileItem *fi, 00057 QListViewItem *after) 00058 : KListViewItem( parent, after ), inf( fi ) { 00059 setPixmap( 0, icon ); 00060 setText( 0, text ); 00061 } 00062 ~KFileListViewItem() { 00063 inf->removeExtraData( listView() ); 00064 } 00065 00069 KFileItem *fileInfo() const { 00070 return inf; 00071 } 00072 00073 virtual QString key( int /*column*/, bool /*ascending*/ ) const { 00074 return m_key; 00075 } 00076 00077 void setKey( const QString& key ) { m_key = key; } 00078 00079 QRect rect() const 00080 { 00081 QRect r = listView()->itemRect(this); 00082 return QRect( listView()->viewportToContents( r.topLeft() ), 00083 QSize( r.width(), r.height() ) ); 00084 } 00085 00089 void init(); 00090 00091 private: 00092 KFileItem *inf; 00093 QString m_key; 00094 00095 private: 00096 class KFileListViewItemPrivate; 00097 KFileListViewItemPrivate *d; 00098 00099 }; 00100 00109 class KFileDetailView : public KListView, public KFileView 00110 { 00111 Q_OBJECT 00112 00113 public: 00114 KFileDetailView(QWidget *parent, const char *name); 00115 virtual ~KFileDetailView(); 00116 00117 virtual QWidget *widget() { return this; } 00118 virtual void clearView(); 00119 virtual void setAutoUpdate( bool ) {} // ### unused. remove in KDE4 00120 00121 virtual void setSelectionMode( KFile::SelectionMode sm ); 00122 00123 virtual void updateView( bool ); 00124 virtual void updateView(const KFileItem*); 00125 virtual void removeItem( const KFileItem *); 00126 virtual void listingCompleted(); 00127 00128 virtual void setSelected(const KFileItem *, bool); 00129 virtual bool isSelected(const KFileItem *i) const; 00130 virtual void clearSelection(); 00131 virtual void selectAll(); 00132 virtual void invertSelection(); 00133 00134 virtual void setCurrentItem( const KFileItem * ); 00135 virtual KFileItem * currentFileItem() const; 00136 virtual KFileItem * firstFileItem() const; 00137 virtual KFileItem * nextItem( const KFileItem * ) const; 00138 virtual KFileItem * prevItem( const KFileItem * ) const; 00139 00140 virtual void insertItem( KFileItem *i ); 00141 00142 // implemented to get noticed about sorting changes (for sortingIndicator) 00143 virtual void setSorting( QDir::SortSpec ); 00144 00145 void ensureItemVisible( const KFileItem * ); 00146 00147 // for KMimeTypeResolver 00148 void mimeTypeDeterminationFinished(); 00149 void determineIcon( KFileListViewItem *item ); 00150 QScrollView *scrollWidget() const { return (QScrollView*) this; } 00151 00152 virtual void readConfig( KConfig *, const QString& group = QString::null ); 00153 virtual void writeConfig( KConfig *, const QString& group = QString::null); 00154 00155 signals: 00162 void dropped(QDropEvent *event, KFileItem *fileItem); 00169 void dropped(QDropEvent *event, const KURL::List &urls, const KURL &url); 00170 00171 protected: 00172 virtual void keyPressEvent( QKeyEvent * ); 00173 00174 // DND support 00175 virtual QDragObject *dragObject(); 00176 virtual void contentsDragEnterEvent( QDragEnterEvent *e ); 00177 virtual void contentsDragMoveEvent( QDragMoveEvent *e ); 00178 virtual void contentsDragLeaveEvent( QDragLeaveEvent *e ); 00179 virtual void contentsDropEvent( QDropEvent *ev ); 00180 virtual bool acceptDrag(QDropEvent* e ) const; 00181 00182 int m_sortingCol; 00183 00184 protected slots: 00185 void slotSelectionChanged(); 00186 00187 private slots: 00188 void slotSortingChanged( int ); 00189 void selected( QListViewItem *item ); 00190 void slotActivate( QListViewItem *item ); 00191 void highlighted( QListViewItem *item ); 00192 void slotActivateMenu ( QListViewItem *item, const QPoint& pos ); 00193 void slotAutoOpen(); 00194 00195 private: 00196 virtual void insertItem(QListViewItem *i) { KListView::insertItem(i); } 00197 virtual void setSorting(int i, bool b) { KListView::setSorting(i, b); } 00198 virtual void setSelected(QListViewItem *i, bool b) { KListView::setSelected(i, b); } 00199 00200 inline KFileListViewItem * viewItem( const KFileItem *item ) const { 00201 if ( item ) 00202 return (KFileListViewItem *) item->extraData( this ); 00203 return 0L; 00204 } 00205 00206 void setSortingKey( KFileListViewItem *item, const KFileItem *i ); 00207 00208 00209 bool m_blockSortingSignal; 00210 KMimeTypeResolver<KFileListViewItem,KFileDetailView> *m_resolver; 00211 00212 protected: 00213 virtual void virtual_hook( int id, void* data ); 00214 private: 00215 class KFileDetailViewPrivate; 00216 KFileDetailViewPrivate *d; 00217 }; 00218 00219 #endif // KFILEDETAILVIEW_H
KDE Logo
This file is part of the documentation for kio Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 10 18:55:26 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003