Commit e2bcecb8 authored by André Wöbbeking's avatar André Wöbbeking
Browse files

use user's settings (locale and timezone) to display dates.

svn path=/trunk/kdesdk/cervisia/; revision=196472
parent 51a91efe
......@@ -18,6 +18,7 @@
#include <kconfig.h>
#include <klocale.h>
#include <kprocess.h>
#include <krfcdate.h>
#include "annotateview.h"
#include "cvsprogressdlg.h"
......@@ -76,7 +77,8 @@ bool AnnotateDialog::parseCvsAnnotate(const QString &sandbox, const QString &rep
const QString &filename, const QString &annorev)
{
QStringList strlist;
QString rev, date, author, comment, content;
QString rev, author, comment, content;
QDate date;
QMap<QString, QString> logmap;
enum { Begin, Tags, Admin, Revision,
Author, Branches, Comment, Finished } state;
......@@ -175,7 +177,9 @@ bool AnnotateDialog::parseCvsAnnotate(const QString &sandbox, const QString &rep
rev = line.left(13).stripWhiteSpace();
comment = logmap[rev];
author = line.mid(14, 8).stripWhiteSpace();
date = line.mid(23, 9);
QDateTime d;
d.setTime_t(KRFCDate::parseDate(line.mid(23, 9)), Qt::UTC);
date = d.date();
content = line.mid(35, line.length()-35);
if (comment.isNull())
comment = "";
......@@ -271,7 +275,8 @@ bool AnnotateDialog::parseCvsAnnotate(DCOPRef& cvsService, const QString& fileNa
// process cvs annotate output
QString date, author, content;
QString author, content;
QDate date;
bool odd = false;
QString oldRevision = "";
while( dlg. getLine(line) )
......@@ -279,7 +284,9 @@ bool AnnotateDialog::parseCvsAnnotate(DCOPRef& cvsService, const QString& fileNa
rev = line.left(13).stripWhiteSpace();
comment = logmap[rev];
author = line.mid(14, 8).stripWhiteSpace();
date = line.mid(23, 9);
QDateTime d;
d.setTime_t(KRFCDate::parseDate(line.mid(23, 9)), Qt::UTC);
date = d.date();
content = line.mid(35, line.length()-35);
if( comment.isNull() )
comment = "";
......
......@@ -13,11 +13,14 @@
#include "annotateview.h"
#include <qdatetime.h>
#include <qheader.h>
#include <qpainter.h>
#include <qstylesheet.h>
#include <kconfig.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <klocale.h>
#include "cervisiapart.h"
#include "tiplabel.h"
......@@ -30,7 +33,7 @@ public:
enum { LineNumberColumn, AuthorColumn, ContentColumn };
AnnotateViewItem(AnnotateView *parent, const QString &rev, const QString &author,
const QString &date, const QString &content, const QString &comment,
const QDate &date, const QString &content, const QString &comment,
bool odd, int linenumber);
virtual int compare(QListViewItem *item, int col, bool ascending) const;
......@@ -41,7 +44,7 @@ public:
private:
QString mrev;
QString mauthor;
QString mdate;
QDate mdate;
QString mcontent;
QString mcomment;
bool modd;
......@@ -56,7 +59,7 @@ const int AnnotateViewItem::BORDER = 4;
AnnotateViewItem::AnnotateViewItem(AnnotateView *parent, const QString &rev, const QString &author,
const QString &date, const QString &content, const QString &comment,
const QDate &date, const QString &content, const QString &comment,
bool odd, int linenumber)
: QListViewItem(parent),
mrev(rev), mauthor(author), mdate(date), mcontent(content),
......@@ -174,7 +177,7 @@ void AnnotateView::hideLabel()
}
void AnnotateView::addLine(const QString &rev, const QString &author, const QString &date,
void AnnotateView::addLine(const QString &rev, const QString &author, const QDate &date,
const QString &content, const QString &comment, bool odd)
{
(void) new AnnotateViewItem(this, rev, author, date, content, comment, odd, childCount()+1);
......@@ -210,7 +213,8 @@ void AnnotateView::contentsMouseMoveEvent(QMouseEvent *e)
text += "</b>&nbsp;&nbsp;";
text += QStyleSheet::escape(item->mauthor);
text += "&nbsp;&nbsp;<b>";
text += QStyleSheet::escape(item->mdate);
const bool shortFormat(true);
text += QStyleSheet::escape(KGlobal::locale()->formatDate(item->mdate, shortFormat));
text += "</b>";
QStringList list = QStringList::split("\n", item->mcomment);
QStringList::Iterator it;
......
......@@ -15,8 +15,10 @@
#ifndef ANNOTATEVIEW_H
#define ANNOTATEVIEW_H
#include <qlistview.h>
class QDate;
class TipLabel;
class AnnotateViewItem;
......@@ -29,7 +31,7 @@ public:
AnnotateView( QWidget *parent=0, const char *name=0 );
~AnnotateView();
void addLine(const QString &rev, const QString &author, const QString &date,
void addLine(const QString &rev, const QString &author, const QDate &date,
const QString &content, const QString &comment, bool odd);
virtual QSize sizeHint() const;
......
......@@ -26,6 +26,7 @@
#include <kmessagebox.h>
#include <kconfig.h>
#include <kprocess.h>
#include <krfcdate.h>
#include "annotatedlg.h"
#include "cvsprogressdlg.h"
......@@ -194,7 +195,8 @@ void LogDialog::saveOptions(KConfig *config)
bool LogDialog::parseCvsLog(const QString &sbox, const QString &repo, const QString &fname)
{
QStringList strlist;
QString tag, rev, date, author, comment;
QString tag, rev, author, comment;
QDateTime date;
enum { Begin, Tags, Admin, Revision,
Author, Branches, Comment, Finished } state;
......@@ -267,8 +269,10 @@ bool LogDialog::parseCvsLog(const QString &sbox, const QString &repo, const QStr
break;
case Author:
strlist = splitLine(line);
date = strlist[2];
date = strlist[1] + " " + date.left(date.length()-1);
// convert date in ISO format (YYYY-MM-DDTHH:MM:SS)
strlist[1].replace('/', '-');
strlist[2].truncate(8); // Time foramt is HH:MM:SS
date.setTime_t(KRFCDate::parseDateISO8601(strlist[1] + 'T' + strlist[2]));
author = strlist[4];
author = author.left(author.length()-1);
comment = "";
......@@ -374,7 +378,8 @@ bool LogDialog::parseCvsLog(const QString &sbox, const QString &repo, const QStr
bool LogDialog::parseCvsLog(DCOPRef& cvsService, const QString& fileName)
{
QString tag, rev, date, author, comment;
QString tag, rev, author, comment;
QDateTime date;
enum { Begin, Tags, Admin, Revision,
Author, Branches, Comment, Finished } state;
......@@ -448,8 +453,10 @@ bool LogDialog::parseCvsLog(DCOPRef& cvsService, const QString& fileName)
case Author:
{
QStringList strlist = splitLine(line);
date = strlist[2];
date = strlist[1] + " " + date.left(date.length()-1);
// convert date in ISO format (YYYY-MM-DDTHH:MM:SS)
strlist[1].replace('/', '-');
strlist[2].truncate(8); // Time foramt is HH:MM:SS
date.setTime_t(KRFCDate::parseDateISO8601(strlist[1] + 'T' + strlist[2]));
author = strlist[4];
author = author.left(author.length()-1);
comment = "";
......@@ -600,7 +607,7 @@ void LogDialog::revisionSelected(QString rev, bool rmb)
revbox[rmb?1:0]->setText(rev);
authorbox[rmb?1:0]->setText(it.current()->author);
datebox[rmb?1:0]->setText(it.current()->date);
datebox[rmb?1:0]->setText(KGlobal::locale()->formatDateTime(it.current()->date));
commentbox[rmb?1:0]->setText(it.current()->comment);
tagsbox[rmb?1:0]->setText(it.current()->tagcomment);
......
......@@ -18,6 +18,7 @@
#include <dcopref.h>
#include <kdialogbase.h>
#include <qdatetime.h>
#include <qptrlist.h>
......@@ -37,7 +38,7 @@ class RevisionInfo
public:
QString rev;
QString author;
QString date;
QDateTime date;
QString comment;
QString tagcomment;
};
......
......@@ -14,12 +14,13 @@
#include "loglist.h"
#include <qdatetime.h>
#include <qheader.h>
#include <qkeycode.h>
#include <qstrlist.h>
#include <qstylesheet.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kglobal.h>
#include <klocale.h>
#include "tiplabel.h"
......@@ -33,7 +34,7 @@ public:
enum { Revision, Author, Date, Branch, Comment, Tags };
LogListViewItem(QListView *list,
const QString &rev, const QString &author, const QString &date,
const QString &rev, const QString &author, const QDateTime &date,
const QString &comment, const QString &tagcomment);
virtual int compare(QListViewItem* i, int col, bool) const;
......@@ -43,16 +44,17 @@ private:
static QString extractOrdinaryTags(const QString &s);
static QString extractBranchName(const QString &s);
QString mrev, mauthor, mdate;
QString mrev, mauthor;
QDateTime mdate;
QString mcomment, mtagcomment;
friend class LogListView;
};
LogListViewItem::LogListViewItem( QListView *list,
const QString &rev, const QString &author, const QString &date,
const QString &rev, const QString &author, const QDateTime &date,
const QString &comment, const QString &tagcomment )
: QListViewItem(list, rev, author, date+" ",
: QListViewItem(list, rev, author, KGlobal::locale()->formatDateTime(date),
extractBranchName(tagcomment), truncateLine(comment), extractOrdinaryTags(tagcomment)),
mrev(rev), mauthor(author), mdate(date), mcomment(comment), mtagcomment(tagcomment)
{
......@@ -143,6 +145,9 @@ int LogListViewItem::compare(QListViewItem* i, int col, bool ascending) const
case Revision:
iResult = ::compareRevisions(mrev, pItem->mrev);
break;
case Date:
iResult = ::compare(mdate, pItem->mdate);
break;
default:
iResult = QListViewItem::compare(i, col, ascending);
}
......@@ -253,7 +258,7 @@ void LogListView::hideLabel()
}
void LogListView::addRevision(const QString &rev, const QString &author, const QString &date,
void LogListView::addRevision(const QString &rev, const QString &author, const QDateTime &date,
const QString &comment, const QString &tagcomment)
{
(void) new LogListViewItem(this, rev, author, date, comment, tagcomment);
......@@ -311,7 +316,7 @@ void LogListView::contentsMouseMoveEvent(QMouseEvent *e)
text += "</b>&nbsp;&nbsp;";
text += QStyleSheet::escape(item->mauthor);
text += "&nbsp;&nbsp;<b>";
text += QStyleSheet::escape(item->mdate);
text += QStyleSheet::escape(KGlobal::locale()->formatDateTime(item->mdate));
text += "</b>";
QStringList list2 = QStringList::split("\n", item->mcomment);
QStringList::Iterator it2;
......
......@@ -19,6 +19,7 @@
#include "listview.h"
class QDateTime;
class KConfig;
class TipLabel;
class LogListViewItem;
......@@ -29,10 +30,10 @@ class LogListView : public ListView
Q_OBJECT
public:
LogListView( QWidget *parent=0, const char *name=0 );
~LogListView();
explicit LogListView( QWidget *parent=0, const char *name=0 );
virtual ~LogListView();
void addRevision(const QString &rev, const QString &author, const QString &date,
void addRevision(const QString &rev, const QString &author, const QDateTime &date,
const QString &comment, const QString &tagcomment);
void setSelectedPair(const QString &selectionA, const QString &selectionB);
......
......@@ -14,11 +14,14 @@
#include "logtree.h"
#include <qapplication.h>
#include <qdatetime.h>
#include <qpainter.h>
#include <qstylesheet.h>
#include <qtooltip.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kglobalsettings.h>
#include <klocale.h>
#include "tiplabel.h"
#include "misc.h"
......@@ -37,7 +40,7 @@ class LogTreeItem
public:
QString rev;
QString author;
QString date;
QDateTime date;
QString comment;
QString tagcomment;
QString taglist;
......@@ -104,7 +107,7 @@ void LogTreeView::hideLabel()
}
void LogTreeView::addRevision(const QString &rev, const QString &author, const QString &date,
void LogTreeView::addRevision(const QString &rev, const QString &author, const QDateTime &date,
const QString &comment, const QString &taglist,
const QString &tagcomment)
{
......@@ -472,7 +475,7 @@ void LogTreeView::mouseMoveEvent(QMouseEvent *e)
text += "</b>&nbsp;&nbsp;";
text += QStyleSheet::escape(item->author);
text += "&nbsp;&nbsp;<b>";
text += QStyleSheet::escape(item->date);
text += QStyleSheet::escape(KGlobal::locale()->formatDateTime(item->date));
text += "</b>";
QStringList list2 = QStringList::split("\n", item->comment);
QStringList::Iterator it2;
......
......@@ -20,6 +20,8 @@
#include "qttableview.h"
class QDateTime;
class LogTreeItem;
class LogTreeConnection;
class TipLabel;
......@@ -33,10 +35,10 @@ class LogTreeView : public QtTableView
Q_OBJECT
public:
LogTreeView( QWidget *parent=0, const char *name=0 );
~LogTreeView();
explicit LogTreeView( QWidget *parent=0, const char *name=0 );
virtual ~LogTreeView();
void addRevision(const QString &rev, const QString &author, const QString &date,
void addRevision(const QString &rev, const QString &author, const QDateTime &date,
const QString &comment, const QString &taglist, const QString &tagcomment);
void setSelectedPair(QString selectionA, QString selectionB);
void collectConnections();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment