00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "pageinformationdialog.h"
00015
00016 #include "page.h"
00017
00018 #include <qpe/config.h>
00019 #include <qpe/timestring.h>
00020
00021 #include <qgroupbox.h>
00022 #include <qlabel.h>
00023 #include <qlayout.h>
00024 #include <qlineedit.h>
00025
00026 PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const char* name)
00027 : QDialog(parent, name, true)
00028 {
00029 m_pPage = page;
00030
00031 setCaption(tr("Page Information"));
00032
00033 QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this);
00034
00035 QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox);
00036
00037 m_pTitleLineEdit = new QLineEdit(generalGroupBox);
00038 m_pTitleLineEdit->setText(page->title());
00039
00040 QLabel* dateLabel = new QLabel(tr("Date:"), generalGroupBox);
00041 QLabel* dateValueLabel = new QLabel(dateTimeString(m_pPage->lastModified()), generalGroupBox);
00042
00043 QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this);
00044
00045 QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox);
00046 QLabel* widthValueLabel = new QLabel(QString::number(m_pPage->pixmap()->width()), sizeGroupBox);
00047
00048 QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox);
00049 QLabel* heightValueLabel = new QLabel(QString::number(m_pPage->pixmap()->height()), sizeGroupBox);
00050
00051 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
00052 generalGroupBox->layout()->setSpacing(4);
00053 sizeGroupBox->layout()->setSpacing(4);
00054 QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 2, 2);
00055 QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2);
00056
00057 generalLayout->addWidget(titleLabel, 0, 0);
00058 generalLayout->addWidget(m_pTitleLineEdit, 0, 1);
00059 generalLayout->addWidget(dateLabel, 1, 0);
00060 generalLayout->addWidget(dateValueLabel, 1, 1);
00061
00062 generalLayout->setColStretch(1, 1);
00063
00064 sizeLayout->addWidget(widthLabel, 0, 0);
00065 sizeLayout->addWidget(widthValueLabel, 0, 1);
00066 sizeLayout->addWidget(heightLabel, 1, 0);
00067 sizeLayout->addWidget(heightValueLabel, 1, 1);
00068
00069 sizeLayout->setColStretch(1, 1);
00070
00071 mainLayout->addWidget(generalGroupBox);
00072 mainLayout->addWidget(sizeGroupBox);
00073 }
00074
00075 PageInformationDialog::~PageInformationDialog()
00076 {
00077 }
00078
00079 QString PageInformationDialog::selectedTitle()
00080 {
00081 return (m_pTitleLineEdit->text());
00082 }
00083
00084 QString PageInformationDialog::dateTimeString(QDateTime dateTime)
00085 {
00086 QString result;
00087
00088 Config config("qpe");
00089 config.setGroup("Date");
00090
00091 QChar separator = config.readEntry("Separator", "/")[0];
00092 DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear);
00093
00094 for (int i = 0; i < 3; i++) {
00095 switch((shortOrder >> (i * 3)) & 0x0007) {
00096 case 0x0001:
00097 result.append( QString().sprintf("%02d", dateTime.date().day()) );
00098 break;
00099 case 0x0002:
00100 result.append( QString().sprintf("%02d", dateTime.date().month()) );
00101 break;
00102 case 0x0004:
00103 result.append( QString().sprintf("%04d", dateTime.date().year()) );
00104 break;
00105 default:
00106 break;
00107 }
00108
00109 if (i < 2) {
00110 result.append( separator );
00111 }
00112 }
00113
00114 result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) );
00115
00116 return result;
00117 }