1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/* This file is part of FSView.
Copyright (C) 2002, 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
KCachegrind is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/*
* FSView specialisaton of TreeMapItem class.
*/
#ifndef INODE_H
#define INODE_H
#include <tqmap.h>
#include <tqptrlist.h>
#include <tqfileinfo.h>
#include <tqstring.h>
#include <kmimetype.h>
#include "treemap.h"
#include "scan.h"
/**
* A specialized version of a TreeMapItem
* for representation of an Directory or File.
*
* These are dynamically created on drawing.
* The real breadth-first scanning of the filesystem
* uses ScanDir:scan.
*/
class Inode: public TreeMapItem, public ScanListener
{
public:
Inode();
Inode(ScanDir*, Inode*);
Inode(ScanFile*, Inode*);
~Inode();
void init(const TQString&);
void setPeer(ScanDir*);
TreeMapItemList* tqchildren();
double value() const;
double size() const;
unsigned int fileCount() const;
unsigned int dirCount() const;
TQString path() const;
TQString text(int i) const;
TQPixmap pixmap(int i) const;
TQColor backColor() const;
KMimeType::Ptr mimeType() const;
const TQFileInfo& fileInfo() const { return _info; }
ScanDir* dirPeer() { return _dirPeer; }
ScanFile* filePeer() { return _filePeer; }
bool isDir() { return (_dirPeer != 0); }
void sizeChanged(ScanDir*);
void scanFinished(ScanDir*);
void destroyed(ScanDir*);
void destroyed(ScanFile*);
private:
void setMetrics(double, unsigned int);
TQFileInfo _info;
ScanDir* _dirPeer;
ScanFile* _filePeer;
double _sizeEstimation;
unsigned int _fileCountEstimation, _dirCountEstimation;
bool _resortNeeded;
// Cached values, calculated lazy.
// This means a change even in const methods, thus has to be "mutable"
mutable bool _mimeSet, _mimePixmapSet;
mutable KMimeType::Ptr _mimeType;
mutable TQPixmap _mimePixmap;
};
#endif
|