From 12536efd16a95f4a3c6e13f0373cbd29d325549c Mon Sep 17 00:00:00 2001 From: nishant Date: Sun, 28 Mar 2010 19:48:32 +0000 Subject: [PATCH] sorting on date in messages and showing time only for same day messages git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2659 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MessagesDialog.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 34f53cb05..a1246c125 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -645,17 +645,20 @@ void MessagesDialog::insertMessages() // Date First.... (for sorting) { - QDateTime qtime; - qtime.setTime_t(it->ts); - if (it->ts < 86400) + QDateTime qdatetime; + qdatetime.setTime_t(it->ts); + + //if the mail is on same date show only time. + if (qdatetime.daysTo(QDateTime::currentDateTime()) == 0) { - QString timestamp = qtime.toString("hh:mm:ss"); - item3 -> setText(timestamp); + QTime qtime = qdatetime.time(); + QVariant varTime(qtime); + item3->setData(varTime, Qt::DisplayRole); } else { - QString timestamp = qtime.toString("dd.MM.yyyy hh:mm:ss"); - item3 -> setText(timestamp); + QVariant varDateTime(qdatetime); + item3->setData(varDateTime, Qt::DisplayRole); } }