File indexing completed on 2024-05-05 16:39:00
0001 /* This file is part of the KDE project 0002 Copyright (C) 1998-2003 Carsten Pfeiffer <pfeiffer@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, version 2. 0007 0008 This program is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 General Public License for more details. 0012 0013 You should have received a copy of the GNU General Public License 0014 along with this program; see the file COPYING. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 0019 #ifndef FILEWIDGET_H 0020 #define FILEWIDGET_H 0021 0022 #include <KDirModel> 0023 #include <KDirOperator> 0024 0025 #include <QUrl> 0026 0027 class KFileItem; 0028 class KFileItemActions; 0029 class QEvent; 0030 class QResizeEvent; 0031 class FileFinder; 0032 0033 0034 class FileWidget : public KDirOperator 0035 { 0036 Q_OBJECT 0037 0038 public: 0039 enum WhichItem { Previous, Next, Current }; 0040 0041 FileWidget( const QUrl& url, QWidget *parent = 0L ); 0042 ~FileWidget(); 0043 0044 bool hasFiles() const; 0045 void reloadConfiguration(); 0046 0047 void setInitialItem( const QUrl& url ); 0048 0049 KFileItem getCurrentItem( bool onlyImage ) const { 0050 return getItem( Current, onlyImage ); 0051 } 0052 0053 KFileItem gotoFirstImage(); 0054 KFileItem gotoLastImage(); 0055 KFileItem getNext( bool go=true ); 0056 KFileItem getPrevious( bool go=true ); 0057 0058 0059 KFileItem getItem( WhichItem which, bool onlyImage ) const; 0060 0061 static bool isImage( const KFileItem& ); 0062 0063 void initActions(); 0064 0065 signals: 0066 void finished(); 0067 0068 protected: 0069 virtual bool eventFilter( QObject *o, QEvent * ) override; 0070 virtual void resizeEvent( QResizeEvent * ) override; 0071 virtual QSize sizeHint() const override; 0072 0073 private slots: 0074 void slotReturnPressed( const QString& text ); 0075 void findCompletion( const QString& ); 0076 void slotViewChanged(); 0077 0078 void slotItemsCleared(); 0079 void slotItemsDeleted( const KFileItemList& ); 0080 void slotHighlighted( const KFileItem& ); 0081 void slotContextMenu( const KFileItem &, QMenu *); 0082 0083 void slotURLEntered( const QUrl& url ); 0084 void slotFinishedLoading(); 0085 0086 private: 0087 KFileItem fileItemFor(const QModelIndex& index) const { 0088 if (index.isValid()) { 0089 return index.data(KDirModel::FileItemRole).value<KFileItem>(); 0090 } 0091 return KFileItem(); 0092 } 0093 0094 bool m_validCompletion; 0095 FileFinder *m_fileFinder; 0096 QString m_currentURL; 0097 QUrl m_initialName; 0098 KFileItemActions *m_fileItemActions; 0099 0100 }; 0101 0102 0103 #endif // FILEWIDGET_H