Diffstat (limited to 'noncore/graphics/drawpad/pageinformationdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/pageinformationdialog.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
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 | } | ||