summaryrefslogtreecommitdiffstats
path: root/kshowmail/showlistviewitem.cpp
blob: e95ce9405301aeaf4990dd9dbb6f363a3c78879a (plain)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/***************************************************************************
                          showlistviewitem.cpp  -  description
                             -------------------
    begin                : Son Apr 21 2002
    copyright            : (C) 2002 by Eggert Ehmke
    email                : eggert.ehmke@berlin.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program 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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "showlistviewitem.h"

ShowListViewItem::ShowListViewItem (QListView * parent,
                  ShowListViewItem* after):
QListViewItem (parent, after)
{}

ShowListViewItem::ShowListViewItem( QListView * parent ) :
    QListViewItem( parent )
{
}

ShowListViewItem::~ShowListViewItem()
{}

QString ShowListViewItem::key (int column, bool /*ascending*/) const
{
	switch (column)
	{
	case _colNumber:
		return text (_colAccount) + text (_colNumber);
	case _colDate:
		return m_time;
	default:
		return text (column);
	}
}

/**
  * reimplement compare to solve bug #856005
  * standard compare is locale dependant
  */
int ShowListViewItem::compare( QListViewItem *i, int col,
                               bool ascending ) const
{
  if( col == _colNumber )
  {
    return text( _colNumber ).toInt() - i->text( _colNumber ).toInt();
  }
  else if( col == _colSize )
  {
    return text( _colSize ).toInt() - i->text( _colSize ).toInt();
  }
  else
    return key( col, ascending ).compare( i->key( col, ascending) );
}

void ShowListViewItem::setNumber (const QString& number)
{
  setText (_colNumber, number);
}

void ShowListViewItem::setAccount(const QString& account)
{
  setText (_colAccount, account);
}

void ShowListViewItem::setFrom(const QString& from)
{
  setText (_colFrom, from);
}

void ShowListViewItem::setTo(const QString& to)
{
  setText (_colTo, to);
}

void ShowListViewItem::setSubject(const QString& subject)
{
  setText (_colSubject, subject);
}

void ShowListViewItem::setDate(const QString& date)
{
  setText (_colDate, date);
}

void ShowListViewItem::setSize(const QString& size)
{
  setText (_colSize, size);
}

void ShowListViewItem::setContent(const QString& content)
{
  setText (_colContent, content);
}

void ShowListViewItem::setState(const QString& state)
{
  setText (_colState, state);
}

void ShowListViewItem::setTime (const QString& time)
{
	m_time = time;
}