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
|
/*
Copyright (C) 2005-2009 Michel de Boer <michel@twinklephone.com>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "historylistview.h"
#include "util.h"
#include "userintf.h"
#include "qpixmap.h"
//Added by qt3to4:
#include <q3mimefactory.h>
HistoryListViewItem::HistoryListViewItem( Q3ListView * parent, const t_call_record &cr, t_user *user_config, time_t _last_viewed) :
Q3ListViewItem(parent,
time2str(cr.time_start, "%d %b %Y %H:%M:%S").c_str(),
cr.get_direction().c_str(),
(cr.direction == t_call_record::DIR_IN ?
ui->format_sip_address(user_config,
cr.from_display, cr.from_uri).c_str() :
ui->format_sip_address(user_config,
cr.to_display, cr.to_uri).c_str()),
cr.subject.c_str(),
cr.invite_resp_reason.c_str())
{
call_record = cr;
last_viewed = _last_viewed;
// Set direction icon
setPixmap(HISTCOL_DIRECTION, (cr.direction == t_call_record::DIR_IN ?
QPixmap(":/icons/images/1leftarrow-yellow.png") :
QPixmap(":/icons/images/1rightarrow.png")));
// Set status icon
setPixmap(HISTCOL_STATUS, (cr.invite_resp_code < 300 ?
QPixmap(":/icons/images/ok.png") :
QPixmap(":/icons/images/cancel.png")));
}
void HistoryListViewItem::paintCell(QPainter *painter, const QColorGroup &cg,
int column, int width, int align)
{
painter->save();
QColorGroup grp(cg);
if (call_record.time_start > last_viewed &&
call_record.rel_cause == t_call_record::CS_FAILURE &&
call_record.direction == t_call_record::DIR_IN)
{
// Highlight missed calls since last view
grp.setColor(QColorGroup::Base, QColor("yellow"));
}
Q3ListViewItem::paintCell(painter, grp, column, width, align);
painter->restore();
}
int HistoryListViewItem::compare ( Q3ListViewItem * i, int col, bool ascending ) const
{
if (col != HISTCOL_TIMESTAMP) {
return Q3ListViewItem::compare(i, col, ascending);
}
if (call_record.time_start < ((HistoryListViewItem *)i)->get_time_start()) {
return -1;
}
if (call_record.time_start == ((HistoryListViewItem *)i)->get_time_start()) {
return 0;
}
return 1;
}
time_t HistoryListViewItem::get_time_start(void) const
{
return call_record.time_start;
}
t_call_record HistoryListViewItem::get_call_record(void) const
{
return call_record;
}
|