diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-07-24 11:49:27 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-07-24 11:49:27 -0500 |
commit | c3f8ee64e905cdb103b5bfa07525fb4e85c31120 (patch) | |
tree | 46eabe44a1b3af79971dcafb743a104af8e18e69 /src/kbitem.cpp | |
download | kasablanca-c3f8ee64e905cdb103b5bfa07525fb4e85c31120.tar.gz kasablanca-c3f8ee64e905cdb103b5bfa07525fb4e85c31120.zip |
Initial import of kasablanca 0.4.0.2
Diffstat (limited to 'src/kbitem.cpp')
-rw-r--r-- | src/kbitem.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/kbitem.cpp b/src/kbitem.cpp new file mode 100644 index 0000000..5978496 --- /dev/null +++ b/src/kbitem.cpp @@ -0,0 +1,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 <qdatetime.h> +#include "kbfileinfo.h" + +#include "kbitem.h" + + +KbItem::KbItem(KbFileInfo kfi, QListView* parent, QListViewItem* after) : QListViewItem(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, QString::number(m_size)); + setText(2, m_date); +} + +KbItem::KbItem(QListView* parent, QListViewItem* after) : QListViewItem(parent, after) +{ +} + +KbItem::~KbItem() +{ +} + +int KbItem::compare(QListViewItem * 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 QListViewItem::compare(i, col, ascending); +} + |