summaryrefslogtreecommitdiffstats
path: root/src/gui/historylistview.cpp
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2015-04-13 09:21:39 +0200
committerMichal Kubecek <mkubecek@suse.cz>2015-04-13 09:21:39 +0200
commite2bc6f4153813cc570ae814c8ddb74628009b488 (patch)
treea40b171be1d859c2232ccc94f758010f9ae54d3c /src/gui/historylistview.cpp
downloadtwinkle-e2bc6f4153813cc570ae814c8ddb74628009b488.tar
twinkle-e2bc6f4153813cc570ae814c8ddb74628009b488.tar.gz
twinkle-e2bc6f4153813cc570ae814c8ddb74628009b488.tar.lz
twinkle-e2bc6f4153813cc570ae814c8ddb74628009b488.tar.xz
twinkle-e2bc6f4153813cc570ae814c8ddb74628009b488.zip
initial checkin
Check in contents of upstream 1.4.2 tarball, exclude generated files.
Diffstat (limited to 'src/gui/historylistview.cpp')
-rw-r--r--src/gui/historylistview.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/gui/historylistview.cpp b/src/gui/historylistview.cpp
new file mode 100644
index 0000000..2f9806c
--- /dev/null
+++ b/src/gui/historylistview.cpp
@@ -0,0 +1,89 @@
+/*
+ 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"
+
+HistoryListViewItem::HistoryListViewItem( QListView * parent, const t_call_record &cr, t_user *user_config, time_t _last_viewed) :
+ QListViewItem(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::fromMimeSource("1leftarrow-yellow.png") :
+ QPixmap::fromMimeSource("1rightarrow.png")));
+
+ // Set status icon
+ setPixmap(HISTCOL_STATUS, (cr.invite_resp_code < 300 ?
+ QPixmap::fromMimeSource("ok.png") :
+ QPixmap::fromMimeSource("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"));
+ }
+ QListViewItem::paintCell(painter, grp, column, width, align);
+ painter->restore();
+}
+
+int HistoryListViewItem::compare ( QListViewItem * i, int col, bool ascending ) const
+{
+ if (col != HISTCOL_TIMESTAMP) {
+ return QListViewItem::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;
+}