mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
generic: adjust to KDateTime removal
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
7ddfeb4410
commit
52cb8a6df0
17 changed files with 54 additions and 58 deletions
|
@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#include <QFileInfo>
|
||||
|
||||
// KDE
|
||||
#include <KDateTime>
|
||||
#include <KLocale>
|
||||
#include <KUrl>
|
||||
|
||||
|
@ -52,7 +51,7 @@ FileNameFormater::~FileNameFormater()
|
|||
delete d;
|
||||
}
|
||||
|
||||
QString FileNameFormater::format(const KUrl& url, const KDateTime& dateTime)
|
||||
QString FileNameFormater::format(const KUrl& url, const QDateTime& dateTime)
|
||||
{
|
||||
QFileInfo info(url.fileName());
|
||||
|
||||
|
|
|
@ -23,14 +23,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
|
||||
// Qt
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
|
||||
// KDE
|
||||
|
||||
// Local
|
||||
|
||||
#include <QString>
|
||||
|
||||
class KDateTime;
|
||||
class KUrl;
|
||||
|
||||
namespace Gwenview
|
||||
|
@ -49,7 +48,7 @@ public:
|
|||
* Given an url and its dateTime, returns a filename according to the
|
||||
* format passed to the constructor
|
||||
*/
|
||||
QString format(const KUrl& url, const KDateTime& dateTime);
|
||||
QString format(const KUrl& url, const QDateTime& dateTime);
|
||||
|
||||
/**
|
||||
* Returns a map whose keys are the available keywords and values are the
|
||||
|
|
|
@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
// Qt
|
||||
|
||||
// KDE
|
||||
#include <KDateTime>
|
||||
#include <KDebug>
|
||||
#include <KFileItem>
|
||||
#include <KLocale>
|
||||
|
@ -118,7 +117,7 @@ struct ImporterPrivate
|
|||
// 'src' url is temporary: if we import "foo/image.jpg" and
|
||||
// "bar/image.jpg", both images will be temporarily saved in the
|
||||
// 'src' url.
|
||||
KDateTime dateTime = TimeUtils::dateTimeForFileItem(item, TimeUtils::SkipCache);
|
||||
QDateTime dateTime = TimeUtils::dateTimeForFileItem(item, TimeUtils::SkipCache);
|
||||
fileName = mFileNameFormater->format(src, dateTime);
|
||||
} else {
|
||||
fileName = src.fileName();
|
||||
|
|
|
@ -23,9 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
|
||||
// Qt
|
||||
#include <QTextDocument>
|
||||
#include <QDateTime>
|
||||
|
||||
// KDE
|
||||
#include <KDateTime>
|
||||
#include <KLocale>
|
||||
|
||||
// Local
|
||||
|
@ -37,7 +37,7 @@ namespace Gwenview
|
|||
{
|
||||
|
||||
static const QString PREVIEW_FILENAME = "PICT0012.JPG";
|
||||
static const KDateTime PREVIEW_DATETIME = KDateTime(QDate(2009, 10, 25), QTime(17, 51, 18));
|
||||
static const QDateTime PREVIEW_DATETIME = QDateTime(QDate(2009, 10, 25), QTime(17, 51, 18));
|
||||
|
||||
struct ImporterConfigDialogPrivate : public Ui_ImporterConfigDialog
|
||||
{
|
||||
|
|
|
@ -21,10 +21,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
// Qt
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
|
||||
// KDE
|
||||
#include <KDebug>
|
||||
#include <KDateTime>
|
||||
#include <KDirLister>
|
||||
|
||||
// Local
|
||||
|
@ -224,9 +224,8 @@ bool SortedDirModel::lessThan(const QModelIndex& left, const QModelIndex& right)
|
|||
return KDirSortFilterProxyModel::lessThan(left, right);
|
||||
}
|
||||
|
||||
const KDateTime leftDate = TimeUtils::dateTimeForFileItem(leftItem);
|
||||
const KDateTime rightDate = TimeUtils::dateTimeForFileItem(rightItem);
|
||||
|
||||
const QDateTime leftDate = TimeUtils::dateTimeForFileItem(leftItem);
|
||||
const QDateTime rightDate = TimeUtils::dateTimeForFileItem(rightItem);
|
||||
return leftDate < rightDate;
|
||||
}
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ void PreviewItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||
}
|
||||
|
||||
if (!isDir && (d->mDetails & PreviewItemDelegate::DateDetail)) {
|
||||
const KDateTime dt = TimeUtils::dateTimeForFileItem(fileItem);
|
||||
const QDateTime dt = TimeUtils::dateTimeForFileItem(fileItem);
|
||||
d->drawText(painter, textRect, fgColor, KGlobal::locale()->formatDateTime(dt));
|
||||
textRect.moveTop(textRect.bottom());
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ static KUrl urlForIndex(const QModelIndex& index)
|
|||
|
||||
struct Thumbnail
|
||||
{
|
||||
Thumbnail(const QPersistentModelIndex& index_, const KDateTime& mtime)
|
||||
Thumbnail(const QPersistentModelIndex& index_, const QDateTime& mtime)
|
||||
: mIndex(index_)
|
||||
, mModificationTime(mtime)
|
||||
, mRough(true)
|
||||
|
@ -117,7 +117,7 @@ struct Thumbnail
|
|||
return groupSize == qMax(mFullSize.width(), mFullSize.height());
|
||||
}
|
||||
|
||||
void prepareForRefresh(const KDateTime& mtime)
|
||||
void prepareForRefresh(const QDateTime& mtime)
|
||||
{
|
||||
mModificationTime = mtime;
|
||||
mGroupPix = QPixmap();
|
||||
|
@ -129,7 +129,7 @@ struct Thumbnail
|
|||
}
|
||||
|
||||
QPersistentModelIndex mIndex;
|
||||
KDateTime mModificationTime;
|
||||
QDateTime mModificationTime;
|
||||
/// The pix loaded from .thumbnails/{large,normal}
|
||||
QPixmap mGroupPix;
|
||||
/// Scaled version of mGroupPix, adjusted to ThumbnailView::thumbnailSize
|
||||
|
@ -208,7 +208,7 @@ struct ThumbnailViewPrivate
|
|||
QPixmap pix;
|
||||
QSize fullSize;
|
||||
mDocumentInfoProvider->thumbnailForDocument(url, group, &pix, &fullSize);
|
||||
mThumbnailForUrl[url] = Thumbnail(QPersistentModelIndex(index), KDateTime::currentLocalDateTime());
|
||||
mThumbnailForUrl[url] = Thumbnail(QPersistentModelIndex(index), QDateTime::currentDateTime());
|
||||
q->setThumbnail(item, pix);
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ void ThumbnailView::dataChanged(const QModelIndex& topLeft, const QModelIndex& b
|
|||
// result this method will also be called for views which are not
|
||||
// currently visible, and do not yet have a thumbnail for the
|
||||
// modified url.
|
||||
KDateTime mtime = item.time(KFileItem::ModificationTime);
|
||||
QDateTime mtime = item.time(KFileItem::ModificationTime);
|
||||
if (it->mModificationTime != mtime) {
|
||||
// dataChanged() is called when the file changes but also when
|
||||
// the model fetched additional data such as semantic info. To
|
||||
|
|
|
@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#include <QFile>
|
||||
|
||||
// KDE
|
||||
#include <KDateTime>
|
||||
#include <KDebug>
|
||||
#include <KFileItem>
|
||||
#include <KExiv2>
|
||||
|
@ -41,12 +40,12 @@ namespace TimeUtils
|
|||
|
||||
struct CacheItem
|
||||
{
|
||||
KDateTime fileMTime;
|
||||
KDateTime realTime;
|
||||
QDateTime fileMTime;
|
||||
QDateTime realTime;
|
||||
|
||||
void update(const KFileItem& fileItem)
|
||||
{
|
||||
KDateTime time = fileItem.time(KFileItem::ModificationTime);
|
||||
QDateTime time = fileItem.time(KFileItem::ModificationTime);
|
||||
if (fileMTime == time) {
|
||||
return;
|
||||
}
|
||||
|
@ -89,7 +88,7 @@ struct CacheItem
|
|||
return false;
|
||||
}
|
||||
|
||||
KDateTime dt = KDateTime::fromString(exifvalue, "yyyy:MM:dd hh:mm:ss");
|
||||
QDateTime dt = QDateTime::fromString(exifvalue, "yyyy:MM:dd hh:mm:ss");
|
||||
if (!dt.isValid()) {
|
||||
kWarning() << "Invalid date in exif header of" << path << exifvalue;
|
||||
return false;
|
||||
|
@ -102,7 +101,7 @@ struct CacheItem
|
|||
|
||||
typedef QHash<KUrl, CacheItem> Cache;
|
||||
|
||||
KDateTime dateTimeForFileItem(const KFileItem& fileItem, CachePolicy cachePolicy)
|
||||
QDateTime dateTimeForFileItem(const KFileItem& fileItem, CachePolicy cachePolicy)
|
||||
{
|
||||
if (cachePolicy == SkipCache) {
|
||||
CacheItem item;
|
||||
|
|
|
@ -21,11 +21,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
|
|||
#ifndef TIMEUTILS_H
|
||||
#define TIMEUTILS_H
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
// Local
|
||||
#include <lib/gwenviewlib_export.h>
|
||||
|
||||
class KFileItem;
|
||||
class KDateTime;
|
||||
|
||||
namespace Gwenview
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ enum CachePolicy
|
|||
UseCache
|
||||
};
|
||||
|
||||
GWENVIEWLIB_EXPORT KDateTime dateTimeForFileItem(const KFileItem&, CachePolicy cachePolicy = UseCache);
|
||||
GWENVIEWLIB_EXPORT QDateTime dateTimeForFileItem(const KFileItem&, CachePolicy cachePolicy = UseCache);
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
// Qt
|
||||
#include <QSignalSpy>
|
||||
#include <QDateTime>
|
||||
|
||||
// KDE
|
||||
#include <KDateTime>
|
||||
#include <KDebug>
|
||||
#include <qtest_kde.h>
|
||||
|
||||
|
@ -183,7 +183,7 @@ void ImporterTest::testFileNameFormater()
|
|||
|
||||
KUrl url = KUrl("file://foo/bar/" + fileName);
|
||||
FileNameFormater fileNameFormater(format);
|
||||
QCOMPARE(fileNameFormater.format(url, KDateTime::fromString(dateTime, Qt::ISODate)), expected);
|
||||
QCOMPARE(fileNameFormater.format(url, QDateTime::fromString(dateTime, Qt::ISODate)), expected);
|
||||
}
|
||||
|
||||
#define NEW_ROW(fileName, dateTime, format, expected) QTest::newRow(fileName) << fileName << dateTime << format << expected
|
||||
|
|
|
@ -46,10 +46,10 @@ static void touchFile(const QString& path)
|
|||
void TimeUtilsTest::testBasic_data()
|
||||
{
|
||||
QTest::addColumn<QString>("fileName");
|
||||
QTest::addColumn<KDateTime>("expectedDateTime");
|
||||
QTest::addColumn<QDateTime>("expectedDateTime");
|
||||
|
||||
NEW_ROW("date/exif-datetimeoriginal.jpg", KDateTime(KDateTime::fromString("2003-03-10T17:45:21", Qt::ISODate)));
|
||||
NEW_ROW("date/exif-datetime-only.jpg", KDateTime(KDateTime::fromString("2003-03-25T02:02:21", Qt::ISODate)));
|
||||
NEW_ROW("date/exif-datetimeoriginal.jpg", QDateTime::fromString("2003-03-10T17:45:21", Qt::ISODate));
|
||||
NEW_ROW("date/exif-datetime-only.jpg", QDateTime::fromString("2003-03-25T02:02:21", Qt::ISODate));
|
||||
|
||||
KUrl url = urlForTestFile("test.png");
|
||||
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
|
||||
|
@ -59,8 +59,8 @@ void TimeUtilsTest::testBasic_data()
|
|||
void TimeUtilsTest::testBasic()
|
||||
{
|
||||
QFETCH(QString, fileName);
|
||||
QFETCH(KDateTime, expectedDateTime);
|
||||
KDateTime dateTime;
|
||||
QFETCH(QDateTime, expectedDateTime);
|
||||
QDateTime dateTime;
|
||||
KUrl url = urlForTestFile(fileName);
|
||||
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, url);
|
||||
|
||||
|
@ -77,14 +77,14 @@ void TimeUtilsTest::testCache()
|
|||
QVERIFY(tempFile.open());
|
||||
KUrl url = KUrl::fromLocalFile(tempFile.fileName());
|
||||
KFileItem item1(KFileItem::Unknown, KFileItem::Unknown, url);
|
||||
KDateTime dateTime1 = TimeUtils::dateTimeForFileItem(item1);
|
||||
QDateTime dateTime1 = TimeUtils::dateTimeForFileItem(item1);
|
||||
QCOMPARE(dateTime1, item1.time(KFileItem::ModificationTime));
|
||||
|
||||
QTest::qWait(1200);
|
||||
touchFile(url.toLocalFile());
|
||||
|
||||
KFileItem item2(KFileItem::Unknown, KFileItem::Unknown, url);
|
||||
KDateTime dateTime2 = TimeUtils::dateTimeForFileItem(item2);
|
||||
QDateTime dateTime2 = TimeUtils::dateTimeForFileItem(item2);
|
||||
|
||||
QVERIFY(dateTime1 != dateTime2);
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <KIcon>
|
||||
|
||||
#include <KDateTime>
|
||||
#include <QDateTime>
|
||||
#include <KDebug>
|
||||
#include <KGlobal>
|
||||
#include <KLocale>
|
||||
|
@ -87,25 +87,26 @@ QDateTime DateTimeRunner::datetime(const QString &tz, QString &tzName)
|
|||
|
||||
if (tz.compare(QLatin1String("UTC"), Qt::CaseInsensitive) == 0) {
|
||||
tzName = QLatin1String( "UTC" );
|
||||
dt = KDateTime::currentDateTime(KTimeZone::utc());
|
||||
dt = KTimeZone::utc().toZoneTime(QDateTime::currentDateTimeUtc());
|
||||
return dt;
|
||||
}
|
||||
|
||||
foreach (const KTimeZone &zone, KSystemTimeZones::zones()) {
|
||||
const QString zoneName = zone.name();
|
||||
const QDateTime zoneDateTime = zone.toZoneTime(QDateTime::currentDateTimeUtc());
|
||||
if (zoneName.compare(tz, Qt::CaseInsensitive) == 0) {
|
||||
tzName = zoneName;
|
||||
dt = KDateTime::currentDateTime(zone);
|
||||
dt = zoneDateTime;
|
||||
break;
|
||||
} else if (!dt.isValid()) {
|
||||
if (zoneName.contains(tz, Qt::CaseInsensitive)) {
|
||||
tzName = zoneName;
|
||||
dt = KDateTime::currentDateTime(zone);
|
||||
dt = zoneDateTime;
|
||||
} else {
|
||||
foreach (const QByteArray &abbrev, zone.abbreviations()) {
|
||||
if (QString(abbrev).contains(tz, Qt::CaseInsensitive)) {
|
||||
tzName = abbrev;
|
||||
dt = KDateTime::currentDateTime(zone);
|
||||
dt = zoneDateTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "connectiondelegate.h"
|
||||
#include "remotedesktopsmodel.h"
|
||||
|
||||
#include <KDateTime>
|
||||
#include <QDateTime>
|
||||
#include <KDebug>
|
||||
#include <KIcon>
|
||||
#include <KIconLoader>
|
||||
|
@ -38,8 +38,8 @@ ConnectionDelegate::ConnectionDelegate(QObject *parent) :
|
|||
QString ConnectionDelegate::displayText(const QVariant &value, const QLocale& locale) const
|
||||
{
|
||||
if (value.type() == QVariant::DateTime) {
|
||||
KDateTime lastConnected = KDateTime(value.toDateTime());
|
||||
KDateTime currentTime = KDateTime::currentUtcDateTime();
|
||||
QDateTime lastConnected = value.toDateTime();
|
||||
QDateTime currentTime = QDateTime::currentDateTimeUtc();
|
||||
|
||||
int daysAgo = lastConnected.daysTo(currentTime);
|
||||
if (daysAgo <= 1 && lastConnected.secsTo(currentTime) < 86400) {
|
||||
|
|
|
@ -235,8 +235,8 @@ void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &grou
|
|||
item.favorite = false;
|
||||
|
||||
// since we are in the history folder collect statitics and add them
|
||||
KDateTime connected = KDateTime();
|
||||
KDateTime created = KDateTime();
|
||||
QDateTime connected = QDateTime();
|
||||
QDateTime created = QDateTime();
|
||||
bool ok = false;
|
||||
// first the created datetime
|
||||
created.setTime_t(bm.metaDataItem("time_added").toLongLong(&ok));
|
||||
|
@ -252,8 +252,8 @@ void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &grou
|
|||
} else {
|
||||
if (newItem) {
|
||||
// if this is a new item, just add the rest of the required data
|
||||
item.lastConnected = KDateTime();
|
||||
item.created = KDateTime();
|
||||
item.lastConnected = QDateTime();
|
||||
item.created = QDateTime();
|
||||
item.visits = 0;
|
||||
item.favorite = true;
|
||||
item.source = RemoteDesktop::Bookmarks;
|
||||
|
@ -289,7 +289,7 @@ void RemoteDesktopsModel::servicesChanged()
|
|||
if (!remoteDesktops.contains(item)) {
|
||||
item.title = service.name;
|
||||
item.source = RemoteDesktop::Zeroconf;
|
||||
item.created = KDateTime::currentLocalDateTime();
|
||||
item.created = QDateTime::currentDateTime();
|
||||
item.favorite = false;
|
||||
item.visits = 0;
|
||||
remoteDesktops.append(item);
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#ifndef REMOTEDESKTOPSMODEL_H
|
||||
#define REMOTEDESKTOPSMODEL_H
|
||||
|
||||
#include <QtCore/qabstractitemmodel.h>
|
||||
#include <KDateTime>
|
||||
#include <QAbstractTableModel>
|
||||
#include <QDateTime>
|
||||
|
||||
#ifdef BUILD_ZEROCONF
|
||||
#include <kdnssd.h>
|
||||
|
@ -41,8 +41,8 @@ public:
|
|||
Q_DECLARE_FLAGS(Sources, Source)
|
||||
QString title;
|
||||
QString url;
|
||||
KDateTime lastConnected;
|
||||
KDateTime created;
|
||||
QDateTime lastConnected;
|
||||
QDateTime created;
|
||||
int visits;
|
||||
RemoteDesktop::Source source;
|
||||
bool favorite;
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
private:
|
||||
QList<RemoteDesktop> remoteDesktops;
|
||||
QString getLastConnectedString(KDateTime lastConnected, bool fuzzy = false) const;
|
||||
QString getLastConnectedString(QDateTime lastConnected, bool fuzzy = false) const;
|
||||
void removeAllItemsFromSources(RemoteDesktop::Sources sources);
|
||||
void buildModelFromBookmarkGroup(const KBookmarkGroup &group);
|
||||
KBookmarkManager *m_manager;
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include <kglobal.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kdatetime.h>
|
||||
#include <klocale.h>
|
||||
#include <kglobalsettings.h>
|
||||
#include <kcomponentdata.h>
|
||||
|
@ -32,6 +31,7 @@
|
|||
#include <QString>
|
||||
#include <QTextStream>
|
||||
#include <QTextDocument>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
|
@ -77,7 +77,7 @@ QString HtmlReport::header()
|
|||
const QString unameString = QString(info.sysname) + ' ' + info.nodename + ' ' + info.release + ' ' + info.version + ' ' + info.machine;
|
||||
|
||||
s << "<table>\n"
|
||||
<< tableLine(i18n("Date:"), KGlobal::locale()->formatDateTime(KDateTime::currentLocalDateTime()))
|
||||
<< tableLine(i18n("Date:"), KGlobal::locale()->formatDateTime(QDateTime::currentDateTime()))
|
||||
<< tableLine(i18n("Program version:"), KGlobal::mainComponent().aboutData()->version())
|
||||
<< tableLine(i18n("Backend:"), QString("%1 (%2)").arg(CoreBackendManager::self()->backend()->about().programName()).arg(CoreBackendManager::self()->backend()->about().version()))
|
||||
<< tableLine(i18n("KDE version:"), KDE_VERSION_STRING)
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <QTextDocument>
|
||||
|
||||
#include <kdeversion.h>
|
||||
#include <kdatetime.h>
|
||||
#include <kglobal.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <klocale.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue