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