Commit 10fe15e2 authored by Shaheed Haque's avatar Shaheed Haque
Browse files

Add timestamp column to display. This allows one to easily see when files have...

Add timestamp column to display. This allows one to easily see when files have changed recently in the repository.

svn path=/trunk/kdesdk/cervisia/; revision=129291
parent 67424e49
INCLUDES = $(all_includes) INCLUDES = $(all_includes)
LDFLAGS = $(all_libraries) $(KDE_RPATH) LDFLAGS = $(all_libraries) $(KDE_RPATH)
CXXFLAGS = -UQT_NO_COMPAT CXXFLAGS = -UQT_NO_COMPAT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE
bin_PROGRAMS = cervisia bin_PROGRAMS = cervisia
lib_LTLIBRARIES = libcervisia.la lib_LTLIBRARIES = libcervisia.la
......
...@@ -128,7 +128,7 @@ QString userName() ...@@ -128,7 +128,7 @@ QString userName()
return QString(); return QString();
// I guess we don't have to support users with longer host names ;-) // I guess we don't have to support users with longer host names ;-)
(void) ::gethostname(hostname, sizeof hostname); gethostname(hostname, sizeof hostname);
QString res = pw->pw_gecos; QString res = pw->pw_gecos;
res += " <"; res += " <";
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <qstack.h> #include <qstack.h>
#include <kapp.h> #include <kapp.h>
#include <kdebug.h> #include <kdebug.h>
#include <kfileview.h>
#include <kglobalsettings.h> #include <kglobalsettings.h>
#include <kiconloader.h> #include <kiconloader.h>
#include <klocale.h> #include <klocale.h>
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <locale.h>
#include <time.h> #include <time.h>
#include "updateview.h" #include "updateview.h"
...@@ -44,7 +46,7 @@ public: ...@@ -44,7 +46,7 @@ public:
void syncWithEntries(); void syncWithEntries();
void updateChildItem(QString name, UpdateView::Status status, bool isdir); void updateChildItem(QString name, UpdateView::Status status, bool isdir);
void updateEntriesItem(QString name, UpdateView::Status status, bool isdir, void updateEntriesItem(QString name, UpdateView::Status status, bool isdir,
QString rev, QString tagname); QString rev, QString tagname, time_t timestamp);
virtual QString key(int col, bool) const; virtual QString key(int col, bool) const;
virtual QString text(int col) const; virtual QString text(int col) const;
virtual void setOpen(bool o); virtual void setOpen(bool o);
...@@ -83,6 +85,7 @@ public: ...@@ -83,6 +85,7 @@ public:
void setStatus(UpdateView::Status status, UpdateView::Filter filter); void setStatus(UpdateView::Status status, UpdateView::Filter filter);
void applyFilter(UpdateView::Filter filter); void applyFilter(UpdateView::Filter filter);
void setRevTag(QString rev, QString tag); void setRevTag(QString rev, QString tag);
void setTimestamp(time_t timestamp);
void setUndefinedState(bool b) void setUndefinedState(bool b)
{ m_undefined = b; } { m_undefined = b; }
void markUpdated(bool laststage, bool success, UpdateView::Filter filter); void markUpdated(bool laststage, bool success, UpdateView::Filter filter);
...@@ -93,6 +96,7 @@ private: ...@@ -93,6 +96,7 @@ private:
QString m_tag; QString m_tag;
bool m_undefined; bool m_undefined;
UpdateView::Status m_status; UpdateView::Status m_status;
time_t m_timestamp;
}; };
...@@ -162,7 +166,7 @@ void UpdateDirItem::updateChildItem(QString name, UpdateView::Status status, boo ...@@ -162,7 +166,7 @@ void UpdateDirItem::updateChildItem(QString name, UpdateView::Status status, boo
* new items and for items which were NotInCVS. * new items and for items which were NotInCVS.
*/ */
void UpdateDirItem::updateEntriesItem(QString name, UpdateView::Status status, bool isdir, void UpdateDirItem::updateEntriesItem(QString name, UpdateView::Status status, bool isdir,
QString rev, QString tagname) QString rev, QString tagname, time_t timestamp)
{ {
for (ListViewItem *item = myFirstChild(); item; for (ListViewItem *item = myFirstChild(); item;
item = item->myNextSibling() ) item = item->myNextSibling() )
...@@ -184,6 +188,7 @@ void UpdateDirItem::updateEntriesItem(QString name, UpdateView::Status status, b ...@@ -184,6 +188,7 @@ void UpdateDirItem::updateEntriesItem(QString name, UpdateView::Status status, b
viewitem->setStatus(status, filter); viewitem->setStatus(status, filter);
} }
viewitem->setRevTag(rev, tagname); viewitem->setRevTag(rev, tagname);
viewitem->setTimestamp(timestamp);
} }
return; return;
} }
...@@ -287,13 +292,25 @@ void UpdateDirItem::syncWithEntries() ...@@ -287,13 +292,25 @@ void UpdateDirItem::syncWithEntries()
rev.remove(0, 1); rev.remove(0, 1);
} }
else if (timestamp.find('+') != -1) else if (timestamp.find('+') != -1)
status = UpdateView::Conflict; {
status = UpdateView::Conflict;
timestamp.truncate(timestamp.find('+'));
}
else if (timestamp != lastModifiedStr(QString(dirPath() + name).latin1())) else if (timestamp != lastModifiedStr(QString(dirPath() + name).latin1()))
status = UpdateView::LocallyModified; status = UpdateView::LocallyModified;
else else
status = UpdateView::Unknown; status = UpdateView::Unknown;
updateEntriesItem(name, status, isdir, rev, tagdate); // Convert timestamp into a time.
char *oldLocale;
struct tm tmp;
time_t time;
oldLocale = setlocale(LC_TIME, "C");
strptime(timestamp, "%c" , &tmp);
setlocale(LC_TIME, oldLocale);
time = mktime(&tmp);
updateEntriesItem(name, status, isdir, rev, tagdate, time);
} }
fclose(f); fclose(f);
} }
...@@ -474,6 +491,10 @@ void UpdateViewItem::setRevTag(QString rev, QString tag) ...@@ -474,6 +491,10 @@ void UpdateViewItem::setRevTag(QString rev, QString tag)
} }
} }
void UpdateViewItem::setTimestamp(time_t timestamp)
{
m_timestamp = timestamp;
}
void UpdateViewItem::markUpdated(bool laststage, bool success, UpdateView::Filter filter) void UpdateViewItem::markUpdated(bool laststage, bool success, UpdateView::Filter filter)
{ {
...@@ -529,6 +550,11 @@ QString UpdateViewItem::key(int col, bool) const ...@@ -529,6 +550,11 @@ QString UpdateViewItem::key(int col, bool) const
return m_revision; // First approximation... return m_revision; // First approximation...
case 3: case 3:
return m_tag; return m_tag;
case 4:
//static QString sortingKey( const QString& value, bool isDir, int sortSpec);
//static QString sortingKey( KIO::filesize_t value, bool isDir,int sortSpec);
//return m_timestamp.toString();
return KFileView::sortingKey(m_timestamp, false, QDir::Time);
default: default:
return ""; return "";
} }
...@@ -574,6 +600,13 @@ QString UpdateViewItem::text(int col) const ...@@ -574,6 +600,13 @@ QString UpdateViewItem::text(int col) const
return m_revision; return m_revision;
case 3: case 3:
return m_tag; return m_tag;
case 4:
{
QDateTime timestamp;
timestamp.setTime_t(m_timestamp);
return timestamp.toString(Qt::LocalDate);
}
default: default:
return ""; return "";
} }
...@@ -613,6 +646,7 @@ UpdateView::UpdateView(QWidget *parent, const char *name) ...@@ -613,6 +646,7 @@ UpdateView::UpdateView(QWidget *parent, const char *name)
addColumn(i18n("Status")); addColumn(i18n("Status"));
addColumn(i18n("Revision")); addColumn(i18n("Revision"));
addColumn(i18n("Tag/Date")); addColumn(i18n("Tag/Date"));
addColumn(i18n("Timestamp"));
QFontMetrics fm( fontMetrics() ); QFontMetrics fm( fontMetrics() );
......
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