File indexing completed on 2024-05-05 17:57:15

0001 /*
0002     SPDX-FileCopyrightText: 2000-2002 Shie Erlich <erlich@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2000-2002 Rafi Yanai <yanai@users.sourceforge.net>
0004     SPDX-FileCopyrightText: 2004-2022 Krusader Krew <https://krusader.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef KRVIEWITEM_H
0010 #define KRVIEWITEM_H
0011 
0012 // QtCore
0013 #include <QRect>
0014 #include <QString>
0015 // QtGui
0016 #include <QPixmap>
0017 
0018 #include <KIO/Global>
0019 
0020 class FileItem;
0021 class KrInterView;
0022 class KrViewProperties;
0023 
0024 /**
0025  * @brief A view item representing a file inside a KrView
0026  */
0027 class KrViewItem
0028 {
0029     friend class KrView;
0030 
0031 public:
0032     KrViewItem(FileItem *fileitem, KrInterView *parentView);
0033     virtual ~KrViewItem()
0034     {
0035     }
0036 
0037     const QString &name(bool withExtension = true) const;
0038     inline bool hasExtension() const
0039     {
0040         return _hasExtension;
0041     }
0042     inline const QString &extension() const
0043     {
0044         return _extension;
0045     }
0046     /** Return description text for status bar. */
0047     QString description() const;
0048 
0049     QPixmap icon();
0050 
0051     bool isSelected() const;
0052     void setSelected(bool s);
0053     QRect itemRect() const;
0054     void redraw();
0055 
0056     // DON'T USE THOSE OUTSIDE THE VIEWS!!!
0057     inline const FileItem *getFileItem() const
0058     {
0059         return _fileitem;
0060     }
0061     inline void setFileItem(FileItem *fileitem)
0062     {
0063         _fileitem = fileitem;
0064     }
0065     inline FileItem *getMutableFileItem()
0066     {
0067         return _fileitem;
0068     }
0069     inline bool isDummy() const
0070     {
0071         return dummyFileItem;
0072     }
0073     inline bool isHidden() const
0074     {
0075         return _hidden;
0076     }
0077 
0078     // used INTERNALLY when calculation of dir size changes the displayed size of the item
0079     void setSize(KIO::filesize_t size);
0080 
0081 protected:
0082     FileItem *_fileitem; // each view item holds a pointer to a corresponding file item for fast access
0083     KrInterView *_view; // the parent view this item belongs to
0084     bool dummyFileItem; // used in case our item represents the ".." (updir) item
0085     const KrViewProperties *_viewProperties;
0086     bool _hasExtension;
0087     bool _hidden;
0088     QString _name;
0089     QString _extension;
0090 };
0091 
0092 #endif