1 /***************************************************************************** 2 * Copyright (C) 2000-2002 Shie Erlich <erlich@users.sourceforge.net> * 3 * Copyright (C) 2000-2002 Rafi Yanai <yanai@users.sourceforge.net> * 4 * Copyright (C) 2004-2019 Krusader Krew [https://krusader.org] * 5 * * 6 * This file is part of Krusader [https://krusader.org]. * 7 * * 8 * Krusader is free software: you can redistribute it and/or modify * 9 * it under the terms of the GNU General Public License as published by * 10 * the Free Software Foundation, either version 2 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * Krusader is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU General Public License * 19 * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * 20 *****************************************************************************/ 21 22 #ifndef KRVIEWITEM_H 23 #define KRVIEWITEM_H 24 25 // QtCore 26 #include <QRect> 27 #include <QString> 28 // QtGui 29 #include <QPixmap> 30 31 #include <KIO/Global> 32 33 class FileItem; 34 class KrInterView; 35 class KrViewProperties; 36 37 /** 38 * @brief A view item representing a file inside a KrView 39 */ 40 class KrViewItem 41 { 42 friend class KrView; 43 44 public: 45 KrViewItem(FileItem *fileitem, KrInterView *parentView); ~KrViewItem()46 virtual ~KrViewItem() {} 47 48 const QString& name(bool withExtension = true) const; hasExtension()49 inline bool hasExtension() const { 50 return _hasExtension; 51 } extension()52 inline const QString& extension() const { 53 return _extension; 54 } 55 /** Return description text for status bar. */ 56 QString description() const; 57 58 QPixmap icon(); 59 60 bool isSelected() const; 61 void setSelected(bool s); 62 QRect itemRect() const; 63 void redraw(); 64 65 // DON'T USE THOSE OUTSIDE THE VIEWS!!! getFileItem()66 inline const FileItem* getFileItem() const { 67 return _fileitem; 68 } setFileItem(FileItem * fileitem)69 inline void setFileItem(FileItem *fileitem) { 70 _fileitem = fileitem; 71 } getMutableFileItem()72 inline FileItem* getMutableFileItem() { 73 return _fileitem; 74 } isDummy()75 inline bool isDummy() const { 76 return dummyFileItem; 77 } isHidden()78 inline bool isHidden() const { 79 return _hidden; 80 } 81 82 // used INTERNALLY when calculation of dir size changes the displayed size of the item 83 void setSize(KIO::filesize_t size); 84 85 protected: 86 FileItem* _fileitem; // each view item holds a pointer to a corresponding file item for fast access 87 KrInterView * _view; // the parent view this item belongs to 88 bool dummyFileItem; // used in case our item represents the ".." (updir) item 89 const KrViewProperties* _viewProperties; 90 bool _hasExtension; 91 bool _hidden; 92 QString _name; 93 QString _extension; 94 }; 95 96 #endif 97