Diffstat (limited to 'noncore/net/opietooth/manager/filelistitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/filelistitem.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/filelistitem.cpp b/noncore/net/opietooth/manager/filelistitem.cpp new file mode 100644 index 0000000..86fcc54 --- a/dev/null +++ b/noncore/net/opietooth/manager/filelistitem.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | /* $Id$ */ | ||
2 | /* Directory tree entry */ | ||
3 | /*************************************************************************** | ||
4 | * * | ||
5 | * This program is free software; you can redistribute it and/or modify * | ||
6 | * it under the terms of the GNU General Public License as published by * | ||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||
8 | * (at your option) any later version. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
11 | #include "filelistitem.h" | ||
12 | #include <qpe/resource.h> | ||
13 | |||
14 | using namespace OpieTooth; | ||
15 | |||
16 | FileListItem::FileListItem(QListView* parent, stat_entry_t* ent, int size) : | ||
17 | QListViewItem(parent) | ||
18 | { | ||
19 | init(ent, size); | ||
20 | } | ||
21 | |||
22 | FileListItem::FileListItem(QListViewItem* parent, stat_entry_t* ent, int size) : | ||
23 | QListViewItem(parent), m_name(ent->name) | ||
24 | { | ||
25 | init(ent, size); | ||
26 | } | ||
27 | |||
28 | void FileListItem::init(stat_entry_t* ent, int size) | ||
29 | { | ||
30 | if (ent == NULL) { | ||
31 | type = IS_DIR; | ||
32 | m_name = ".."; //Upper directory | ||
33 | m_size = 0; | ||
34 | } | ||
35 | else { | ||
36 | m_name = ent->name; | ||
37 | if (ent->mode == 16877) | ||
38 | type = IS_DIR; | ||
39 | else | ||
40 | type = IS_FILE; | ||
41 | } | ||
42 | if (type == IS_DIR) { | ||
43 | setPixmap(0, Resource::loadPixmap("folder")); | ||
44 | setText(0, m_name + QString("/")); | ||
45 | m_size = 0; | ||
46 | } | ||
47 | else { | ||
48 | setPixmap(0, Resource::loadPixmap("c_src")); | ||
49 | setText(0, m_name); | ||
50 | m_size = size; | ||
51 | setText(1, QString::number(m_size)); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | QString FileListItem::key(int, bool) const | ||
56 | { | ||
57 | QString str; //resulting string | ||
58 | if (type == IS_DIR) | ||
59 | str = "0"; | ||
60 | else | ||
61 | str = "1"; | ||
62 | str += m_name; | ||
63 | return str; | ||
64 | } | ||
65 | |||
66 | enum dtype FileListItem::gettype() | ||
67 | { | ||
68 | return type; | ||
69 | } | ||
70 | |||
71 | //eof | ||