summaryrefslogtreecommitdiff
authorleseb <leseb>2002-06-13 17:11:03 (UTC)
committer leseb <leseb>2002-06-13 17:11:03 (UTC)
commit615176c17202f1a8aa7aa504b8dd747b089385a9 (patch) (unidiff)
treeb5906e134037cd72871e0cecac4a3c9ed4c9a9e2
parent54de91b66a2f0f985ff89503e919f85713d1f22c (diff)
downloadopie-615176c17202f1a8aa7aa504b8dd747b089385a9.zip
opie-615176c17202f1a8aa7aa504b8dd747b089385a9.tar.gz
opie-615176c17202f1a8aa7aa504b8dd747b089385a9.tar.bz2
More progress in page attributes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/page.cpp24
-rw-r--r--noncore/graphics/drawpad/page.h12
-rw-r--r--noncore/graphics/drawpad/pageinformationdialog.cpp49
-rw-r--r--noncore/graphics/drawpad/pageinformationdialog.h4
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp45
-rw-r--r--noncore/graphics/drawpad/thumbnailview.h6
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
@@ -1,33 +1,57 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "page.h" 14#include "page.h"
15 15
16Page::Page() 16Page::Page()
17 : QPixmap() 17 : QPixmap()
18{ 18{
19 m_lastModified = QDateTime::currentDateTime();
19} 20}
20 21
21Page::Page(int w, int h) 22Page::Page(int w, int h)
22 : QPixmap(w, h) 23 : QPixmap(w, h)
23{ 24{
25 m_lastModified = QDateTime::currentDateTime();
24} 26}
25 27
26Page::Page(const QSize& size) 28Page::Page(const QSize& size)
27 : QPixmap(size) 29 : QPixmap(size)
28{ 30{
31 m_lastModified = QDateTime::currentDateTime();
29} 32}
30 33
31Page::~Page() 34Page::~Page()
32{ 35{
33} 36}
37
38QString Page::title() const
39{
40 return m_title;
41}
42
43QDateTime Page::lastModified() const
44{
45 return m_lastModified;
46}
47
48void Page::setTitle(QString title)
49{
50 m_title = title;
51}
52
53void Page::setLastModified(QDateTime lastModified)
54{
55 m_lastModified = lastModified;
56}
57
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
@@ -1,29 +1,41 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef PAGE_H 14#ifndef PAGE_H
15#define PAGE_H 15#define PAGE_H
16 16
17#include <qpixmap.h> 17#include <qpixmap.h>
18 18
19#include <qdatetime.h>
20
19class Page : public QPixmap 21class Page : public QPixmap
20{ 22{
21public: 23public:
22 Page(); 24 Page();
23 Page(int w, int h); 25 Page(int w, int h);
24 Page(const QSize& size); 26 Page(const QSize& size);
25 27
26 ~Page(); 28 ~Page();
29
30 QString title() const;
31 QDateTime lastModified() const;
32
33 void setTitle(QString title);
34 void setLastModified(QDateTime lastModified);
35
36private:
37 QString m_title;
38 QDateTime m_lastModified;
27}; 39};
28 40
29#endif // PAGE_H 41#endif // PAGE_H
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
@@ -1,70 +1,117 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "pageinformationdialog.h" 14#include "pageinformationdialog.h"
15 15
16#include "page.h" 16#include "page.h"
17 17
18#include <qpe/config.h>
19#include <qpe/timestring.h>
20
18#include <qgroupbox.h> 21#include <qgroupbox.h>
19#include <qlabel.h> 22#include <qlabel.h>
20#include <qlayout.h> 23#include <qlayout.h>
21#include <qlineedit.h> 24#include <qlineedit.h>
22 25
23PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const char* name) 26PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const char* name)
24 : QDialog(parent, name, true) 27 : QDialog(parent, name, true)
25{ 28{
26 m_pPage = page; 29 m_pPage = page;
27 30
28 setCaption(tr("Page Information")); 31 setCaption(tr("Page Information"));
29 32
30 QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this); 33 QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this);
31 34
32 QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox); 35 QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox);
36
33 m_pTitleLineEdit = new QLineEdit(generalGroupBox); 37 m_pTitleLineEdit = new QLineEdit(generalGroupBox);
38 m_pTitleLineEdit->setText(page->title());
39
40 QLabel* dateLabel = new QLabel(tr("Date:"), generalGroupBox);
41 QLabel* dateValueLabel = new QLabel(dateTimeString(m_pPage->lastModified()), generalGroupBox);
34 42
35 QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this); 43 QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this);
36 44
37 QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox); 45 QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox);
38 QLabel* widthValueLabel = new QLabel(QString::number(m_pPage->width()), sizeGroupBox); 46 QLabel* widthValueLabel = new QLabel(QString::number(m_pPage->width()), sizeGroupBox);
39 47
40 QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox); 48 QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox);
41 QLabel* heightValueLabel = new QLabel(QString::number(m_pPage->height()), sizeGroupBox); 49 QLabel* heightValueLabel = new QLabel(QString::number(m_pPage->height()), sizeGroupBox);
42 50
43 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 51 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
44 generalGroupBox->layout()->setSpacing(4); 52 generalGroupBox->layout()->setSpacing(4);
45 sizeGroupBox->layout()->setSpacing(4); 53 sizeGroupBox->layout()->setSpacing(4);
46 QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 1, 1); 54 QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 2, 2);
47 QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2); 55 QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2);
48 56
49 generalLayout->addWidget(titleLabel, 0, 0); 57 generalLayout->addWidget(titleLabel, 0, 0);
50 generalLayout->addWidget(m_pTitleLineEdit, 0, 1); 58 generalLayout->addWidget(m_pTitleLineEdit, 0, 1);
59 generalLayout->addWidget(dateLabel, 1, 0);
60 generalLayout->addWidget(dateValueLabel, 1, 1);
61
62 generalLayout->setColStretch(1, 1);
51 63
52 sizeLayout->addWidget(widthLabel, 0, 0); 64 sizeLayout->addWidget(widthLabel, 0, 0);
53 sizeLayout->addWidget(widthValueLabel, 0, 1); 65 sizeLayout->addWidget(widthValueLabel, 0, 1);
54 sizeLayout->addWidget(heightLabel, 1, 0); 66 sizeLayout->addWidget(heightLabel, 1, 0);
55 sizeLayout->addWidget(heightValueLabel, 1, 1); 67 sizeLayout->addWidget(heightValueLabel, 1, 1);
56 68
57 sizeLayout->setColStretch(1, 1); 69 sizeLayout->setColStretch(1, 1);
58 70
59 mainLayout->addWidget(generalGroupBox); 71 mainLayout->addWidget(generalGroupBox);
60 mainLayout->addWidget(sizeGroupBox); 72 mainLayout->addWidget(sizeGroupBox);
61} 73}
62 74
63PageInformationDialog::~PageInformationDialog() 75PageInformationDialog::~PageInformationDialog()
64{ 76{
65} 77}
66 78
67QString PageInformationDialog::selectedTitle() 79QString PageInformationDialog::selectedTitle()
68{ 80{
69 return (m_pTitleLineEdit->text()); 81 return (m_pTitleLineEdit->text());
70} 82}
83
84QString PageInformationDialog::dateTimeString(QDateTime dateTime)
85{
86 QString result;
87
88 Config config("qpe");
89 config.setGroup("Date");
90
91 QChar separator = config.readEntry("Separator", "/")[0];
92 DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear);
93
94 for (int i = 0; i < 3; i++) {
95 switch((shortOrder >> (i * 3)) & 0x0007) {
96 case 0x0001:
97 result += QString().sprintf("%02d", dateTime.date().day());
98 break;
99 case 0x0002:
100 result += QString().sprintf("%02d", dateTime.date().month());
101 break;
102 case 0x0004:
103 result += QString().sprintf("%04d", dateTime.date().year());
104 break;
105 default:
106 break;
107 }
108
109 if (i < 2) {
110 result += separator;
111 }
112 }
113
114 result += QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute());
115
116 return result;
117}
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
@@ -1,39 +1,43 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef PAGEINFORMATIONDIALOG_H 14#ifndef PAGEINFORMATIONDIALOG_H
15#define PAGEINFORMATIONDIALOG_H 15#define PAGEINFORMATIONDIALOG_H
16 16
17#include <qdialog.h> 17#include <qdialog.h>
18 18
19class Page; 19class Page;
20 20
21#include <qdatetime.h>
22
21class QLineEdit; 23class QLineEdit;
22 24
23class PageInformationDialog : public QDialog 25class PageInformationDialog : public QDialog
24{ 26{
25 Q_OBJECT 27 Q_OBJECT
26 28
27public: 29public:
28 PageInformationDialog(Page* page, QWidget* parent = 0, const char* name = 0); 30 PageInformationDialog(Page* page, QWidget* parent = 0, const char* name = 0);
29 ~PageInformationDialog(); 31 ~PageInformationDialog();
30 32
31 QString selectedTitle(); 33 QString selectedTitle();
32 34
33private: 35private:
36 QString dateTimeString(QDateTime dateTime);
37
34 Page* m_pPage; 38 Page* m_pPage;
35 39
36 QLineEdit* m_pTitleLineEdit; 40 QLineEdit* m_pTitleLineEdit;
37}; 41};
38 42
39#endif // PAGEINFORMATIONDIALOG_H 43#endif // PAGEINFORMATIONDIALOG_H
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
@@ -1,155 +1,192 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "thumbnailview.h" 14#include "thumbnailview.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "drawpadcanvas.h" 17#include "drawpadcanvas.h"
18#include "newpagedialog.h" 18#include "newpagedialog.h"
19#include "page.h" 19#include "page.h"
20 20
21#include <qpe/config.h>
21#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/timestring.h>
22 24
23#include <qapplication.h> 25#include <qapplication.h>
24#include <qimage.h> 26#include <qimage.h>
25#include <qlayout.h> 27#include <qlayout.h>
26#include <qmessagebox.h> 28#include <qmessagebox.h>
27#include <qtoolbutton.h> 29#include <qtoolbutton.h>
28 30
29#define THUMBNAIL_SIZE 48 31#define THUMBNAIL_SIZE 48
30 32
31PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) 33PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent)
32 : QListBoxItem(parent) 34 : QListBoxItem(parent)
33{ 35{
34 m_pPage = page; 36 m_pPage = page;
35 37
36 QImage image = m_pPage->convertToImage(); 38 QImage image = m_pPage->convertToImage();
37 39
38 int previewWidth = THUMBNAIL_SIZE; 40 int previewWidth = THUMBNAIL_SIZE;
39 int previewHeight = THUMBNAIL_SIZE; 41 int previewHeight = THUMBNAIL_SIZE;
40 42
41 float widthScale = 1.0; 43 float widthScale = 1.0;
42 float heightScale = 1.0; 44 float heightScale = 1.0;
43 45
44 if (previewWidth < image.width()) { 46 if (previewWidth < image.width()) {
45 widthScale = (float)previewWidth / float(image.width()); 47 widthScale = (float)previewWidth / float(image.width());
46 } 48 }
47 49
48 if (previewHeight < image.height()) { 50 if (previewHeight < image.height()) {
49 heightScale = (float)previewHeight / float(image.height()); 51 heightScale = (float)previewHeight / float(image.height());
50 } 52 }
51 53
52 float scale = (widthScale < heightScale ? widthScale : heightScale); 54 float scale = (widthScale < heightScale ? widthScale : heightScale);
53 QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); 55 QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
54 56
55 m_thumbnail.convertFromImage(thumbnailImage); 57 m_thumbnail.convertFromImage(thumbnailImage);
56 58
57 m_titleText = QObject::tr("Title:") + " -"; 59 m_titleText = QObject::tr("Title:") + " " + m_pPage->title();
58 m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->width()) 60 m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->width())
59 + "x" + QString::number(m_pPage->height()); 61 + "x" + QString::number(m_pPage->height());
60 m_dateTimeText = QObject::tr("Date:") + " -"; 62 m_dateText = QObject::tr("Date:") + " " + dateTimeString(m_pPage->lastModified());
61 63
62 QColor baseColor = parent->colorGroup().base(); 64 QColor baseColor = parent->colorGroup().base();
63 int h, s, v; 65 int h, s, v;
64 baseColor.hsv(&h, &s, &v); 66 baseColor.hsv(&h, &s, &v);
65 67
66 if (v > 128) { 68 if (v > 128) {
67 m_alternateColor = baseColor.dark(106); 69 m_alternateColor = baseColor.dark(106);
68 } else if (baseColor != Qt::black) { 70 } else if (baseColor != Qt::black) {
69 m_alternateColor = baseColor.light(110); 71 m_alternateColor = baseColor.light(110);
70 } else { 72 } else {
71 m_alternateColor = QColor(32, 32, 32); 73 m_alternateColor = QColor(32, 32, 32);
72 } 74 }
73} 75}
74 76
75PageListBoxItem::~PageListBoxItem() 77PageListBoxItem::~PageListBoxItem()
76{ 78{
77} 79}
78 80
79int PageListBoxItem::height(const QListBox*) const 81int PageListBoxItem::height(const QListBox*) const
80{ 82{
81 return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); 83 return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height());
82} 84}
83 85
84int PageListBoxItem::width(const QListBox* lb) const 86int PageListBoxItem::width(const QListBox* lb) const
85{ 87{
86 QFontMetrics fontMetrics = lb->fontMetrics(); 88 QFontMetrics fontMetrics = lb->fontMetrics();
87 int maxtextLength = QMAX(fontMetrics.width(m_titleText), 89 int maxtextLength = QMAX(fontMetrics.width(m_titleText),
88 QMAX(fontMetrics.width(m_dimensionText), 90 QMAX(fontMetrics.width(m_dimensionText),
89 fontMetrics.width(m_dateTimeText))); 91 fontMetrics.width(m_dateText)));
90 92
91 return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); 93 return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width());
92} 94}
93 95
94void PageListBoxItem::paint(QPainter *painter) 96void PageListBoxItem::paint(QPainter *painter)
95{ 97{
96 QRect itemRect = listBox()->itemRect(this); 98 QRect itemRect = listBox()->itemRect(this);
97 99
98 if (!selected() && (listBox()->index(this) % 2)) { 100 if (!selected() && (listBox()->index(this) % 2)) {
99 painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); 101 painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor);
100 } 102 }
101 103
102 painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2, 104 painter->drawPixmap(2 + (THUMBNAIL_SIZE - m_thumbnail.width()) / 2,
103 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2, 105 2 + (THUMBNAIL_SIZE - m_thumbnail.height()) / 2,
104 m_thumbnail); 106 m_thumbnail);
105 107
106 QFont standardFont = painter->font(); 108 QFont standardFont = painter->font();
107 QFont boldFont = painter->font(); 109 QFont boldFont = painter->font();
108 boldFont.setBold(TRUE); 110 boldFont.setBold(TRUE);
109 111
110 QFontMetrics fontMetrics = painter->fontMetrics(); 112 QFontMetrics fontMetrics = painter->fontMetrics();
111 QRect textRect(THUMBNAIL_SIZE + 6, 2, 113 QRect textRect(THUMBNAIL_SIZE + 6, 2,
112 itemRect.width() - THUMBNAIL_SIZE - 8, 114 itemRect.width() - THUMBNAIL_SIZE - 8,
113 itemRect.height() - 4); 115 itemRect.height() - 4);
114 116
115 painter->setFont(boldFont); 117 painter->setFont(boldFont);
116 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); 118 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText);
117 119
118 painter->setFont(standardFont); 120 painter->setFont(standardFont);
119 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); 121 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText);
120 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateTimeText); 122 painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText);
121 123
122 if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { 124 if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) {
123 painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1); 125 painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1);
124 } 126 }
125} 127}
126 128
127Page* PageListBoxItem::page() const 129Page* PageListBoxItem::page() const
128{ 130{
129 return m_pPage; 131 return m_pPage;
130} 132}
131 133
134QString PageListBoxItem::dateTimeString(QDateTime dateTime)
135{
136 QString result;
137
138 Config config("qpe");
139 config.setGroup("Date");
140
141 QChar separator = config.readEntry("Separator", "/")[0];
142 DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear);
143
144 for (int i = 0; i < 3; i++) {
145 switch((shortOrder >> (i * 3)) & 0x0007) {
146 case 0x0001:
147 result += QString().sprintf("%02d", dateTime.date().day());
148 break;
149 case 0x0002:
150 result += QString().sprintf("%02d", dateTime.date().month());
151 break;
152 case 0x0004:
153 result += QString().sprintf("%04d", dateTime.date().year());
154 break;
155 default:
156 break;
157 }
158
159 if (i < 2) {
160 result += separator;
161 }
162 }
163
164 result += QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute());
165
166 return result;
167}
168
132PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 169PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
133 : QListBox(parent, name) 170 : QListBox(parent, name)
134{ 171{
135 m_pDrawPadCanvas = drawPadCanvas; 172 m_pDrawPadCanvas = drawPadCanvas;
136 173
137 setVScrollBarMode(QScrollView::AlwaysOn); 174 setVScrollBarMode(QScrollView::AlwaysOn);
138 175
139 updateView(); 176 updateView();
140} 177}
141 178
142PageListBox::~PageListBox() 179PageListBox::~PageListBox()
143{ 180{
144} 181}
145 182
146void PageListBox::updateView() 183void PageListBox::updateView()
147{ 184{
148 clear(); 185 clear();
149 186
150 if (m_pDrawPadCanvas) { 187 if (m_pDrawPadCanvas) {
151 QList<Page> pageList = m_pDrawPadCanvas->pages(); 188 QList<Page> pageList = m_pDrawPadCanvas->pages();
152 QListIterator<Page> it(pageList); 189 QListIterator<Page> it(pageList);
153 190
154 for (; it.current(); ++it) { 191 for (; it.current(); ++it) {
155 new PageListBoxItem(it.current(), this); 192 new PageListBoxItem(it.current(), this);
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
@@ -1,69 +1,73 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#ifndef THUMBNAILVIEW_H 14#ifndef THUMBNAILVIEW_H
15#define THUMBNAILVIEW_H 15#define THUMBNAILVIEW_H
16 16
17#include <qlistbox.h> 17#include <qlistbox.h>
18#include <qwidget.h> 18#include <qwidget.h>
19 19
20class DrawPad; 20class DrawPad;
21class DrawPadCanvas; 21class DrawPadCanvas;
22class Page; 22class Page;
23 23
24#include <qdatetime.h>
25
24class QToolButton; 26class QToolButton;
25 27
26class PageListBoxItem : public QListBoxItem 28class PageListBoxItem : public QListBoxItem
27{ 29{
28public: 30public:
29 PageListBoxItem(Page* page, QListBox* parent); 31 PageListBoxItem(Page* page, QListBox* parent);
30 ~PageListBoxItem(); 32 ~PageListBoxItem();
31 33
32 int height(const QListBox* lb) const; 34 int height(const QListBox* lb) const;
33 int width(const QListBox* lb) const; 35 int width(const QListBox* lb) const;
34 void paint(QPainter *painter); 36 void paint(QPainter *painter);
35 37
36 Page* page() const; 38 Page* page() const;
37 39
38private: 40private:
41 QString dateTimeString(QDateTime dateTime);
42
39 Page* m_pPage; 43 Page* m_pPage;
40 44
41 QPixmap m_thumbnail; 45 QPixmap m_thumbnail;
42 46
43 QString m_titleText; 47 QString m_titleText;
44 QString m_dimensionText; 48 QString m_dimensionText;
45 QString m_dateTimeText; 49 QString m_dateText;
46 50
47 QColor m_alternateColor; 51 QColor m_alternateColor;
48}; 52};
49 53
50class PageListBox : public QListBox 54class PageListBox : public QListBox
51{ 55{
52public: 56public:
53 PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0); 57 PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent = 0, const char* name = 0);
54 ~PageListBox(); 58 ~PageListBox();
55 59
56 void updateView(); 60 void updateView();
57 61
58 void select(Page* page); 62 void select(Page* page);
59 Page* selected() const; 63 Page* selected() const;
60 64
61private: 65private:
62 DrawPadCanvas* m_pDrawPadCanvas; 66 DrawPadCanvas* m_pDrawPadCanvas;
63}; 67};
64 68
65class ThumbnailView : public QWidget 69class ThumbnailView : public QWidget
66{ 70{
67 Q_OBJECT 71 Q_OBJECT
68 72
69public: 73public: