2
2
* Copyright (C) 1999-2002 Bernd Gehrmann <bernd@mail.berlios.de>
3
* Copyright (c) 2003-2007 AndrƩ Wƶbbeking <Woebbeking@kde.org>
3
* Copyright (c) 2003-2008 AndrƩ Wƶbbeking <Woebbeking@kde.org>
5
5
* This program is free software; you can redistribute it and/or modify
6
6
* it under the terms of the GNU General Public License as published by
155
156
fileItem->setRevTag(entry.m_revision, entry.m_tag);
156
157
fileItem->setDate(entry.m_dateTime);
157
fileItem->setPixmap(0, isBinary ? SmallIcon("binary") : QPixmap());
158
fileItem->setPixmap(0, isBinary ? SmallIcon("application-octet-stream")
178
180
const QFileInfoList *files = dir.entryInfoList();
181
QFileInfoListIterator it(*files);
182
for (; it.current(); ++it)
183
Q_FOREACH (QFileInfo info, *files)
185
entry.m_name = it.current()->fileName();
186
if (it.current()->isDir())
186
entry.m_name = info.fileName();
188
189
entry.m_type = Entry::Dir;
189
190
createDirItem(entry);
218
219
UpdateItem* UpdateDirItem::insertItem(UpdateItem* item)
220
QPair<TMapItemsByName::iterator, bool> result
221
= m_itemsByName.insert(TMapItemsByName::value_type(item->entry().m_name, item));
221
const TMapItemsByName::iterator it = m_itemsByName.find(item->entry().m_name);
222
if (it != m_itemsByName.end())
224
224
// OK, an item with that name already exists. If the item type is the
225
225
// same then keep the old one to preserve it's status information
226
UpdateItem* existingItem = *result.first;
226
UpdateItem* existingItem = *it;
227
227
if (existingItem->rtti() == item->rtti())
247
251
return (it != m_itemsByName.end()) ? *it : 0;
250
// Qt-3.3.8 changed the parsing in QDateTime::fromString() but introduced
251
// a bug which leads to the problem that days with 1 digit will incorrectly being
252
// parsed as day 0 - which is invalid.
253
// workaround with the implementation from Qt-3.3.6
254
QDateTime parseDateTime(const QString &s)
256
static const char * const qt_shortMonthNames[] = {
257
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
258
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
260
QString monthName( s.mid( 4, 3 ) );
262
// Assume that English monthnames are the default
263
for ( int i = 0; i < 12; ++i ) {
264
if ( monthName == qt_shortMonthNames[i] ) {
269
// If English names can't be found, search the localized ones
271
for ( int i = 1; i <= 12; ++i ) {
272
if ( monthName == QDate::shortMonthName( i ) ) {
278
if ( month < 1 || month > 12 ) {
279
qWarning( "QDateTime::fromString: Parameter out of range" );
283
int day = s.mid( 8, 2 ).simplifyWhiteSpace().toInt();
284
int year = s.right( 4 ).toInt();
285
QDate date( year, month, day );
287
int hour, minute, second;
288
int pivot = s.find( QRegExp(QString::fromLatin1("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]")) );
290
hour = s.mid( pivot, 2 ).toInt();
291
minute = s.mid( pivot+3, 2 ).toInt();
292
second = s.mid( pivot+6, 2 ).toInt();
293
time.setHMS( hour, minute, second );
295
return QDateTime( date, time );
298
255
// Format of the CVS/Entries file:
299
256
// /NAME/REVISION/[CONFLICT+]TIMESTAMP/OPTIONS/TAGDATE
303
260
const QString path(filePath() + QDir::separator());
305
262
QFile f(path + "CVS/Entries");
306
if( f.open(IO_ReadOnly) )
263
if( f.open(QIODevice::ReadOnly) )
308
265
QTextStream stream(&f);
309
while( !stream.eof() )
266
while( !stream.atEnd() )
311
268
QString line = stream.readLine();
334
291
const QString options(line.section('/', 4, 4));
335
292
entry.m_tag = line.section('/', 5, 5);
337
const bool isBinary(options.find("-kb") >= 0);
294
const bool isBinary = options.contains("-kb");
339
296
// file date in local time
340
297
entry.m_dateTime = QFileInfo(path + entry.m_name).lastModified();
346
303
entry.m_status = Cervisia::LocallyRemoved;
347
304
rev.remove(0, 1);
349
else if (timestamp.find('+') >= 0)
306
else if (timestamp.contains('+'))
351
308
entry.m_status = Cervisia::Conflict;
355
// workaround Qt-3.3.8 bug with our own function (see function above)
356
// const QDateTime date(QDateTime::fromString(timestamp)); // UTC Time
357
const QDateTime date(parseDateTime(timestamp)); // UTC Time
358
QDateTime fileDateUTC;
359
fileDateUTC.setTime_t(entry.m_dateTime.toTime_t(), Qt::UTC);
312
QDateTime date(QDateTime::fromString(timestamp)); // UTC Time
313
date.setTimeSpec(Qt::UTC);
314
const QDateTime fileDateUTC(entry.m_dateTime.toUTC());
360
315
if (date != fileDateUTC)
361
316
entry.m_status = Cervisia::LocallyModified;
390
345
if (!dir.exists(it.key()))
392
347
fileItem->setStatus(Cervisia::Removed);
393
fileItem->setRevTag(QString::null, QString::null);
348
fileItem->setRevTag(QString(), QString());
457
412
view->setFilter(view->filter());
460
QListViewItem::setOpen(open);
415
Q3ListViewItem::setOpen(open);
464
int UpdateDirItem::compare(QListViewItem* i,
419
int UpdateDirItem::compare(Q3ListViewItem* i,
466
421
bool bAscending) const
522
477
bool visible(true);
523
478
if (filter & UpdateView::OnlyDirectories)
526
bool unmodified = (entry().m_status == Cervisia::UpToDate) ||
481
bool unmodified = (entry().m_status == Cervisia::UpToDate) ||
527
482
(entry().m_status == Cervisia::Unknown);
528
483
if ((filter & UpdateView::NoUpToDate) && unmodified)
663
618
iResult = entry().m_name.localeAwareCompare(item->entry().m_name);
666
iResult = KMimeType::findByPath(entry().m_name)->comment().localeAwareCompare(KMimeType::findByPath(item->entry().m_name)->comment());
669
621
if ((iResult = ::compare(statusClass(), item->statusClass())) == 0)
670
622
iResult = entry().m_name.localeAwareCompare(item->entry().m_name);
752
701
const QFont oldFont(p->font());
753
702
QColorGroup mycg(cg);
754
if (color.isValid() && color != KGlobalSettings::textColor())
703
if (color.isValid() && color != KColorScheme(QPalette::Active, KColorScheme::View).foreground().color())
756
705
QFont myFont(oldFont);
757
706
myFont.setBold(true);
758
707
p->setFont(myFont);
759
mycg.setColor(QColorGroup::Text, color);
708
mycg.setColor(QPalette::Text, color);
762
QListViewItem::paintCell(p, mycg, col, width, align);
711
Q3ListViewItem::paintCell(p, mycg, col, width, align);
764
713
if (color.isValid())
781
730
UpdateDirItem* dirItem(rootItem);
783
if (dirPath != QChar('.'))
732
if (dirPath != QLatin1String("."))
785
const QStringList& dirNames(QStringList::split('/', dirPath));
734
const QStringList& dirNames(dirPath.split('/'));
786
735
const QStringList::const_iterator itDirNameEnd(dirNames.end());
787
736
for (QStringList::const_iterator itDirName(dirNames.begin());
788
737
itDirName != itDirNameEnd; ++itDirName)
792
741
UpdateItem* item = dirItem->findItem(dirName);
793
742
if (isFileItem(item))
795
kdDebug(8050) << "findOrCreateDirItem(): file changed to dir " << dirName << endl;
744
kDebug(8050) << "file changed to dir " << dirName;
802
kdDebug(8050) << "findOrCreateDirItem(): create dir item " << dirName << endl;
751
kDebug(8050) << "create dir item " << dirName;
804
753
entry.m_name = dirName;
805
754
entry.m_type = Entry::Dir;