Diffstat (limited to 'noncore/graphics/drawpad/thumbnailview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 1eadc13..35955e8 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp @@ -19,5 +19,7 @@ #include "page.h" +#include <qpe/config.h> #include <qpe/resource.h> +#include <qpe/timestring.h> #include <qapplication.h> @@ -55,8 +57,8 @@ PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) m_thumbnail.convertFromImage(thumbnailImage); - m_titleText = QObject::tr("Title:") + " -"; + m_titleText = QObject::tr("Title:") + " " + m_pPage->title(); m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->width()) + "x" + QString::number(m_pPage->height()); - m_dateTimeText = QObject::tr("Date:") + " -"; + m_dateText = QObject::tr("Date:") + " " + dateTimeString(m_pPage->lastModified()); QColor baseColor = parent->colorGroup().base(); @@ -87,5 +89,5 @@ int PageListBoxItem::width(const QListBox* lb) const int maxtextLength = QMAX(fontMetrics.width(m_titleText), QMAX(fontMetrics.width(m_dimensionText), - fontMetrics.width(m_dateTimeText))); + fontMetrics.width(m_dateText))); return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); @@ -118,5 +120,5 @@ void PageListBoxItem::paint(QPainter *painter) painter->setFont(standardFont); painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); - painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateTimeText); + painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { @@ -130,4 +132,39 @@ Page* PageListBoxItem::page() const } +QString PageListBoxItem::dateTimeString(QDateTime dateTime) +{ + QString result; + + Config config("qpe"); + config.setGroup("Date"); + + QChar separator = config.readEntry("Separator", "/")[0]; + DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); + + for (int i = 0; i < 3; i++) { + switch((shortOrder >> (i * 3)) & 0x0007) { + case 0x0001: + result += QString().sprintf("%02d", dateTime.date().day()); + break; + case 0x0002: + result += QString().sprintf("%02d", dateTime.date().month()); + break; + case 0x0004: + result += QString().sprintf("%04d", dateTime.date().year()); + break; + default: + break; + } + + if (i < 2) { + result += separator; + } + } + + result += QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()); + + return result; +} + PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) : QListBox(parent, name) |