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
|
//
// C++ Implementation: KbItem
//
// Description:
//
//
// Author: mkulke <sikor_sxe@radicalapproach.de>, (C) 2003
//
// Copyright: See COPYING file that comes with this distribution
//
//
// enable > 2gb support (LFS)
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#include <tqdatetime.h>
#include "kbfileinfo.h"
#include "kbitem.h"
KbItem::KbItem(KbFileInfo kfi, TQListView* parent, TQListViewItem* after) : TQListViewItem(parent, after)
{
m_file = kfi.fileName();
m_path = kfi.dirPath(),
m_date = kfi.Date(),
m_size = kfi.Size(),
m_date_int = kfi.DateInt();
setText(0, m_file);
setText(1, TQString::number(m_size));
setText(2, m_date);
}
KbItem::KbItem(TQListView* parent, TQListViewItem* after) : TQListViewItem(parent, after)
{
}
KbItem::~KbItem()
{
}
int KbItem::compare(TQListViewItem * i, int col, bool ascending) const
{
if ((this->rtti() == 1001) && (i->rtti() == 1002))
{
if (ascending) return -1;
else return 1;
}
else if ((this->rtti() == 1002) && (i->rtti() == 1001))
{
if (ascending) return 1;
else return -1;
}
if (col == 1)
{
unsigned int x = this->text(1).toInt();
unsigned int y = i->text(1).toInt();
if (x == y) return 0;
if (x < y) return -1;
if (x > y) return 1;
}
if (col == 2)
{
unsigned int x = this->m_date_int;
unsigned int y = static_cast<KbItem*>(i)->m_date_int;
if (x == y) return 0;
if (x < y) return -1;
if (x > y) return 1;
}
return TQListViewItem::compare(i, col, ascending);
}
|