-rw-r--r-- | noncore/graphics/drawpad/drawpadcanvas.cpp | 4 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp index dcf0871..4547b41 100644 --- a/noncore/graphics/drawpad/drawpadcanvas.cpp +++ b/noncore/graphics/drawpad/drawpadcanvas.cpp @@ -53,105 +53,105 @@ private: }; State m_state; QString m_title; QDateTime m_date; ulong m_dataLenght; QString m_dataFormat; QList<Page> m_pages; }; DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler() { m_state = Unknown; } DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler() { } QList<Page> DrawPadCanvasXmlHandler::pages() { return m_pages; } bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) { Q_CONST_UNUSED(namespaceURI) Q_CONST_UNUSED(localName) if (qName == "image") { m_title = QString(); - m_date = QDateTime(QDate(1970, 1, 1)); + m_date = QDateTime::currentDateTime(); } else if (qName == "title") { m_state = InTitle; } else if (qName == "date") { m_state = InDate; } else if (qName == "data") { m_state = InData; m_dataLenght = atts.value("length").toULong(); m_dataFormat = atts.value("format"); if (m_dataFormat.isEmpty()) { m_dataFormat = "XPM"; } } return true; } bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName, const QString& qName) { Q_CONST_UNUSED(namespaceURI) Q_CONST_UNUSED(localName) if (qName == "title") { m_state = Unknown; } else if (qName == "date") { m_state = Unknown; } else if (qName == "data") { m_state = Unknown; } return true; } bool DrawPadCanvasXmlHandler::characters(const QString& ch) { if (m_state == InTitle) { m_title = ch; } else if (m_state == InDate) { - m_date = m_date.addSecs(ch.toInt()); + m_date = QDateTime(QDate(1970, 1, 1)).addSecs(ch.toInt()); } else if (m_state == InData) { QByteArray byteArray(ch.length() / 2); for (int i = 0; i < (int)ch.length() / 2; i++) { char h = ch[2 * i].latin1(); char l = ch[2 * i + 1].latin1(); uchar r = 0; if (h <= '9') { r += h - '0'; } else { r += h - 'a' + 10; } r = r << 4; if (l <= '9') { r += l - '0'; } else { r += l - 'a' + 10; } byteArray[i] = r; } QImage image; if (m_dataFormat == "XPM") { if (m_dataLenght < ch.length() * 5) { m_dataLenght = ch.length() * 5; } diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 81ec79f..14092bf 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp @@ -37,67 +37,67 @@ PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) QImage image = m_pPage->convertToImage(); int previewWidth = THUMBNAIL_SIZE; int previewHeight = THUMBNAIL_SIZE; float widthScale = 1.0; float heightScale = 1.0; if (previewWidth < image.width()) { widthScale = (float)previewWidth / float(image.width()); } if (previewHeight < image.height()) { heightScale = (float)previewHeight / float(image.height()); } float scale = (widthScale < heightScale ? widthScale : heightScale); QImage thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); m_thumbnail.convertFromImage(thumbnailImage); 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_dateText = QObject::tr("Date:") + " " + dateTimeString(m_pPage->lastModified()); QColor baseColor = parent->colorGroup().base(); int h, s, v; baseColor.hsv(&h, &s, &v); if (v > 128) { - m_alternateColor = baseColor.dark(106); + m_alternateColor = baseColor.dark(115); } else if (baseColor != Qt::black) { - m_alternateColor = baseColor.light(110); + m_alternateColor = baseColor.light(115); } else { m_alternateColor = QColor(32, 32, 32); } } PageListBoxItem::~PageListBoxItem() { } int PageListBoxItem::height(const QListBox*) const { return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); } int PageListBoxItem::width(const QListBox* lb) const { QFontMetrics fontMetrics = lb->fontMetrics(); int maxtextLength = QMAX(fontMetrics.width(m_titleText), QMAX(fontMetrics.width(m_dimensionText), fontMetrics.width(m_dateText))); return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); } void PageListBoxItem::paint(QPainter *painter) { QRect itemRect = listBox()->itemRect(this); if (!selected() && (listBox()->index(this) % 2)) { painter->fillRect(0, 0, itemRect.width(), itemRect.height(), m_alternateColor); } |