author | leseb <leseb> | 2002-06-13 17:11:03 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-13 17:11:03 (UTC) |
commit | 615176c17202f1a8aa7aa504b8dd747b089385a9 (patch) (side-by-side diff) | |
tree | b5906e134037cd72871e0cecac4a3c9ed4c9a9e2 | |
parent | 54de91b66a2f0f985ff89503e919f85713d1f22c (diff) | |
download | opie-615176c17202f1a8aa7aa504b8dd747b089385a9.zip opie-615176c17202f1a8aa7aa504b8dd747b089385a9.tar.gz opie-615176c17202f1a8aa7aa504b8dd747b089385a9.tar.bz2 |
More progress in page attributes
-rw-r--r-- | noncore/graphics/drawpad/page.cpp | 24 | ||||
-rw-r--r-- | noncore/graphics/drawpad/page.h | 12 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pageinformationdialog.cpp | 49 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pageinformationdialog.h | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 45 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.h | 6 |
6 files changed, 134 insertions, 6 deletions
diff --git a/noncore/graphics/drawpad/page.cpp b/noncore/graphics/drawpad/page.cpp index 35ec0e0..7034a20 100644 --- a/noncore/graphics/drawpad/page.cpp +++ b/noncore/graphics/drawpad/page.cpp @@ -17,4 +17,5 @@ Page::Page() : QPixmap() { + m_lastModified = QDateTime::currentDateTime(); } @@ -22,4 +23,5 @@ Page::Page(int w, int h) : QPixmap(w, h) { + m_lastModified = QDateTime::currentDateTime(); } @@ -27,4 +29,5 @@ Page::Page(const QSize& size) : QPixmap(size) { + m_lastModified = QDateTime::currentDateTime(); } @@ -32,2 +35,23 @@ Page::~Page() { } + +QString Page::title() const +{ + return m_title; +} + +QDateTime Page::lastModified() const +{ + return m_lastModified; +} + +void Page::setTitle(QString title) +{ + m_title = title; +} + +void Page::setLastModified(QDateTime lastModified) +{ + m_lastModified = lastModified; +} + diff --git a/noncore/graphics/drawpad/page.h b/noncore/graphics/drawpad/page.h index 888f552..020ab1f 100644 --- a/noncore/graphics/drawpad/page.h +++ b/noncore/graphics/drawpad/page.h @@ -17,4 +17,6 @@ #include <qpixmap.h> +#include <qdatetime.h> + class Page : public QPixmap { @@ -25,4 +27,14 @@ public: ~Page(); + + QString title() const; + QDateTime lastModified() const; + + void setTitle(QString title); + void setLastModified(QDateTime lastModified); + +private: + QString m_title; + QDateTime m_lastModified; }; diff --git a/noncore/graphics/drawpad/pageinformationdialog.cpp b/noncore/graphics/drawpad/pageinformationdialog.cpp index 54cf89d..c0d055e 100644 --- a/noncore/graphics/drawpad/pageinformationdialog.cpp +++ b/noncore/graphics/drawpad/pageinformationdialog.cpp @@ -16,4 +16,7 @@ #include "page.h" +#include <qpe/config.h> +#include <qpe/timestring.h> + #include <qgroupbox.h> #include <qlabel.h> @@ -31,5 +34,10 @@ PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox); + m_pTitleLineEdit = new QLineEdit(generalGroupBox); + m_pTitleLineEdit->setText(page->title()); + + QLabel* dateLabel = new QLabel(tr("Date:"), generalGroupBox); + QLabel* dateValueLabel = new QLabel(dateTimeString(m_pPage->lastModified()), generalGroupBox); QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); @@ -44,9 +52,13 @@ PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const generalGroupBox->layout()->setSpacing(4); sizeGroupBox->layout()->setSpacing(4); - QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 1, 1); + QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 2, 2); QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); generalLayout->addWidget(titleLabel, 0, 0); generalLayout->addWidget(m_pTitleLineEdit, 0, 1); + generalLayout->addWidget(dateLabel, 1, 0); + generalLayout->addWidget(dateValueLabel, 1, 1); + + generalLayout->setColStretch(1, 1); sizeLayout->addWidget(widthLabel, 0, 0); @@ -69,2 +81,37 @@ QString PageInformationDialog::selectedTitle() return (m_pTitleLineEdit->text()); } + +QString PageInformationDialog::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; +} diff --git a/noncore/graphics/drawpad/pageinformationdialog.h b/noncore/graphics/drawpad/pageinformationdialog.h index cce74ec..60662a9 100644 --- a/noncore/graphics/drawpad/pageinformationdialog.h +++ b/noncore/graphics/drawpad/pageinformationdialog.h @@ -19,4 +19,6 @@ class Page; +#include <qdatetime.h> + class QLineEdit; @@ -32,4 +34,6 @@ public: private: + QString dateTimeString(QDateTime dateTime); + Page* m_pPage; 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) diff --git a/noncore/graphics/drawpad/thumbnailview.h b/noncore/graphics/drawpad/thumbnailview.h index 88c3b27..2eac667 100644 --- a/noncore/graphics/drawpad/thumbnailview.h +++ b/noncore/graphics/drawpad/thumbnailview.h @@ -22,4 +22,6 @@ class DrawPadCanvas; class Page; +#include <qdatetime.h> + class QToolButton; @@ -37,4 +39,6 @@ public: private: + QString dateTimeString(QDateTime dateTime); + Page* m_pPage; @@ -43,5 +47,5 @@ private: QString m_titleText; QString m_dimensionText; - QString m_dateTimeText; + QString m_dateText; QColor m_alternateColor; |