author | leseb <leseb> | 2002-06-13 17:11:03 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-13 17:11:03 (UTC) |
commit | 615176c17202f1a8aa7aa504b8dd747b089385a9 (patch) (unidiff) | |
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 | |||
@@ -16,18 +16,42 @@ | |||
16 | Page::Page() | 16 | Page::Page() |
17 | : QPixmap() | 17 | : QPixmap() |
18 | { | 18 | { |
19 | m_lastModified = QDateTime::currentDateTime(); | ||
19 | } | 20 | } |
20 | 21 | ||
21 | Page::Page(int w, int h) | 22 | Page::Page(int w, int h) |
22 | : QPixmap(w, h) | 23 | : QPixmap(w, h) |
23 | { | 24 | { |
25 | m_lastModified = QDateTime::currentDateTime(); | ||
24 | } | 26 | } |
25 | 27 | ||
26 | Page::Page(const QSize& size) | 28 | Page::Page(const QSize& size) |
27 | : QPixmap(size) | 29 | : QPixmap(size) |
28 | { | 30 | { |
31 | m_lastModified = QDateTime::currentDateTime(); | ||
29 | } | 32 | } |
30 | 33 | ||
31 | Page::~Page() | 34 | Page::~Page() |
32 | { | 35 | { |
33 | } | 36 | } |
37 | |||
38 | QString Page::title() const | ||
39 | { | ||
40 | return m_title; | ||
41 | } | ||
42 | |||
43 | QDateTime Page::lastModified() const | ||
44 | { | ||
45 | return m_lastModified; | ||
46 | } | ||
47 | |||
48 | void Page::setTitle(QString title) | ||
49 | { | ||
50 | m_title = title; | ||
51 | } | ||
52 | |||
53 | void 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 | |||
@@ -16,6 +16,8 @@ | |||
16 | 16 | ||
17 | #include <qpixmap.h> | 17 | #include <qpixmap.h> |
18 | 18 | ||
19 | #include <qdatetime.h> | ||
20 | |||
19 | class Page : public QPixmap | 21 | class Page : public QPixmap |
20 | { | 22 | { |
21 | public: | 23 | public: |
@@ -24,6 +26,16 @@ public: | |||
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 | |||
36 | private: | ||
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 | |||
@@ -15,6 +15,9 @@ | |||
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> |
@@ -30,7 +33,12 @@ PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const | |||
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 | ||
@@ -43,11 +51,15 @@ PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const | |||
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); |
@@ -68,3 +80,38 @@ QString PageInformationDialog::selectedTitle() | |||
68 | { | 80 | { |
69 | return (m_pTitleLineEdit->text()); | 81 | return (m_pTitleLineEdit->text()); |
70 | } | 82 | } |
83 | |||
84 | QString 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 | |||
@@ -18,6 +18,8 @@ | |||
18 | 18 | ||
19 | class Page; | 19 | class Page; |
20 | 20 | ||
21 | #include <qdatetime.h> | ||
22 | |||
21 | class QLineEdit; | 23 | class QLineEdit; |
22 | 24 | ||
23 | class PageInformationDialog : public QDialog | 25 | class PageInformationDialog : public QDialog |
@@ -31,6 +33,8 @@ public: | |||
31 | QString selectedTitle(); | 33 | QString selectedTitle(); |
32 | 34 | ||
33 | private: | 35 | private: |
36 | QString dateTimeString(QDateTime dateTime); | ||
37 | |||
34 | Page* m_pPage; | 38 | Page* m_pPage; |
35 | 39 | ||
36 | QLineEdit* m_pTitleLineEdit; | 40 | QLineEdit* m_pTitleLineEdit; |
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 | |||
@@ -18,7 +18,9 @@ | |||
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> |
@@ -54,10 +56,10 @@ PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) | |||
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; |
@@ -86,7 +88,7 @@ int PageListBoxItem::width(const QListBox* lb) const | |||
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 | } |
@@ -117,7 +119,7 @@ void PageListBoxItem::paint(QPainter *painter) | |||
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); |
@@ -129,6 +131,41 @@ Page* PageListBoxItem::page() const | |||
129 | return m_pPage; | 131 | return m_pPage; |
130 | } | 132 | } |
131 | 133 | ||
134 | QString 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 | |||
132 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) | 169 | PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) |
133 | : QListBox(parent, name) | 170 | : QListBox(parent, name) |
134 | { | 171 | { |
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 | |||
@@ -21,6 +21,8 @@ class DrawPad; | |||
21 | class DrawPadCanvas; | 21 | class DrawPadCanvas; |
22 | class Page; | 22 | class Page; |
23 | 23 | ||
24 | #include <qdatetime.h> | ||
25 | |||
24 | class QToolButton; | 26 | class QToolButton; |
25 | 27 | ||
26 | class PageListBoxItem : public QListBoxItem | 28 | class PageListBoxItem : public QListBoxItem |
@@ -36,13 +38,15 @@ public: | |||
36 | Page* page() const; | 38 | Page* page() const; |
37 | 39 | ||
38 | private: | 40 | private: |
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 | }; |