From kde-commits Tue Jul 31 23:11:44 2012 From: Islam Wazery Date: Tue, 31 Jul 2012 23:11:44 +0000 To: kde-commits Subject: [digikam/development/3.0.0] utilities/cameragui/items: Added the necessary items for import tool Message-Id: <20120731231144.EE32BA60C6 () git ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=134377659305999 Git commit 5046d142eb7882d26835411b5913fee0f39aef25 by Islam Wazery. Committed on 01/08/2012 at 00:42. Pushed by wazery into branch 'development/3.0.0'. Added the necessary items for import tool M +8 -5 utilities/cameragui/items/importcategorydrawer.cpp M +74 -105 utilities/cameragui/items/importdelegate.cpp M +6 -3 utilities/cameragui/items/importdelegate.h M +7 -1 utilities/cameragui/items/importdelegatepriv.h M +81 -51 utilities/cameragui/items/itemviewimportdelegate.cpp M +9 -1 utilities/cameragui/items/itemviewimportdelegate.h M +5 -0 utilities/cameragui/items/itemviewimportdelegatepriv.h http://commits.kde.org/digikam/5046d142eb7882d26835411b5913fee0f39aef25 diff --git a/utilities/cameragui/items/importcategorydrawer.cpp b/utilities= /cameragui/items/importcategorydrawer.cpp index 51aad63..47e6f8d 100644 --- a/utilities/cameragui/items/importcategorydrawer.cpp +++ b/utilities/cameragui/items/importcategorydrawer.cpp @@ -22,11 +22,12 @@ * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ = #include "importcategorydrawer.moc" -#include "importcategorydrawer.h" //TODO: Remove this line +#include "importcategorydrawer.h" = // Qt includes = #include +#include = // KDE includes = @@ -48,6 +49,7 @@ public: { lowerSpacing =3D 0; view =3D 0; + rect =3D QRect(0, -1, 0, -1);//TODO: Remove this line. } = QFont font; @@ -99,7 +101,7 @@ void ImportCategoryDrawer::setDefaultViewOptions(const Q= StyleOptionViewItem& opt = void ImportCategoryDrawer::invalidatePaintingCache() { - if (d->rect.isNull()) + if (d->rect.isEmpty()) { return; } @@ -152,9 +154,10 @@ void ImportCategoryDrawer::drawCategory(const QModelIn= dex& index, int /*sortRole case CamItemSortSettings::OneCategory: viewHeaderText(index, &header, &subLine); break; - case CamItemSortSettings::CategoryByFormat: - textForFormat(index, &header, &subLine); - break; + //TODO: + //case CamItemSortSettings::CategoryByFormat: + //textForFormat(index, &header, &subLine); + //break; } = p->setPen(kapp->palette().color(QPalette::HighlightedText)); diff --git a/utilities/cameragui/items/importdelegate.cpp b/utilities/camer= agui/items/importdelegate.cpp index 7324f51..8cf10fc 100644 --- a/utilities/cameragui/items/importdelegate.cpp +++ b/utilities/cameragui/items/importdelegate.cpp @@ -1,42 +1,22 @@ -/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - * - * This file is a part of digiKam project - * http://www.digikam.org - * - * Date : 2012-07-08 - * Description : Qt item view for images - the delegate - * - * Copyright (C) 2012 by Islam Wazery - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ - -#include "importdelegate.moc" +#include "importdelegate.h" +#include "importdelegatepriv.h" = // Qt includes = -#include "QCache" +#include +#include +#include = // KDE includes = -#include +#include #include = // Local includes = -#include "importdelegatepriv.h" +#include "importimagemodel.h" +#include "importfiltermodel.h" #include "importsettings.h" -#include "imagedelegateoverlay.h" = namespace Digikam { @@ -61,23 +41,25 @@ void ImportDelegate::ImportDelegatePrivate::clearRects() ImportDelegate::ImportDelegate(QObject* parent) : ItemViewImportDelegate(*new ImportDelegatePrivate, parent) { + } = ImportDelegate::ImportDelegate(ImportDelegate::ImportDelegatePrivate& dd, = QObject* parent) : ItemViewImportDelegate(dd, parent) { + } = ImportDelegate::~ImportDelegate() { Q_D(ImportDelegate); - Q_UNUSED(d); + Q_UNUSED(d); // To please compiler about warnings. } = void ImportDelegate::setView(ImportCategorizedView* view) { Q_D(ImportDelegate); - Digikam::ImageDelegateOverlayContainer::setViewOnAllOverlays(view); + setViewOnAllOverlays(view); = if (d->currentView) { @@ -243,14 +225,15 @@ void ImportDelegate::paint(QPainter* p, const QStyleO= ptionViewItem& option, cons const_cast(this)->updateActualPixmapRect(index, a= ctualPixmapRect); } = - //TODO: Implement Rating + //TODO: Implement rating in import tool. //if (!d->ratingRect.isNull()) //{ // drawRating(p, index, d->ratingRect, info.rating(), isSelected); //} = + //TODO: Implement labels in import tool. // Draw Color Label rectangle - //TODO: drawColorLabelRect(p, option, isSelected, info.colorLabel()); + //drawColorLabelRect(p, option, isSelected, info.colorLabel()); = p->setPen(isSelected ? kapp->palette().color(QPalette::HighlightedText) : kapp->palette().color(QPalette::Text)); @@ -268,16 +251,6 @@ void ImportDelegate::paint(QPainter* p, const QStyleOp= tionViewItem& option, cons drawName(p, d->nameRect, info.name); } = - //if (!d->titleRect.isNull()) - //{ - // drawTitle(p, d->titleRect, info.title()); - //} - - //if (!d->commentsRect.isNull()) - //{ - // drawComments(p, d->commentsRect, info.comment()); - //} - if (!d->dateRect.isNull()) { drawCreationDate(p, d->dateRect, info.photoInfo.dateTime); @@ -288,46 +261,42 @@ void ImportDelegate::paint(QPainter* p, const QStyleO= ptionViewItem& option, cons drawModificationDate(p, d->modDateRect, info.mtime); } = - //if (!d->resolutionRect.isNull()) - //{ - // drawImageSize(p, d->resolutionRect, info.dimensions()); - //} - if (!d->sizeRect.isNull()) { - drawFileSize(p, d->sizeRect, qlonglong(info.size)); + drawFileSize(p, d->sizeRect, info.size); } = - //TOOD: Implement the grouping in import interface + if (!d->resolutionRect.isNull()) + { + QSize dimensions(info.width, info.height); + drawImageSize(p, d->resolutionRect, dimensions); + } + + //TODO: Implement grouping in import tool. //if (!d->groupRect.isNull()) //{ // drawGroupIndicator(p, d->groupRect, info.numberOfGroupedImages(), // index.data(ImportFilterModel::GroupIsOpenRole= ).toBool()); //} = - //TOOD: Implement tagging in import interface + //TODO: Implement tags in import tool. //if (!d->tagRect.isNull()) //{ // QString tags =3D AlbumManager::instance()->tagNames(info.tagIds(= )).join(", "); // drawTags(p, d->tagRect, tags, isSelected); //} = - //TOOD: Implement color labels in import interface + //TODO: Implement labels in import tool. //if (!d->pickLabelRect.isNull()) //{ // drawPickLabelIcon(p, d->pickLabelRect, info.pickLabel()); //} = - //bool left =3D index.data(ImportImageModel::LTLeftPanelRole).toBool(= ); - //bool right =3D index.data(ImportImageModel::LTRightPanelRole).toBool= (); - //drawPanelSideIcon(p, left, right); - - //if (d->drawImageFormat) - //{ - // QString frm =3D info.mime; - // if (frm.contains("-")) frm =3D frm.section('-', -1); // For RA= W format annoted as "RAW-xxx" =3D> "xxx" - // drawImageFormat(p, actualPixmapRect, frm); - //} + if (d->drawImageFormat) + { + QString frm =3D info.mime; + drawImageFormat(p, actualPixmapRect, frm); + } = if (d->drawFocusFrame) { @@ -440,11 +409,11 @@ void ImportDelegate::updateSizeRectsAndPixmaps() = prepareBackground(); = - //TODO: + //TODO: Implement rating in import tool. //if (!d->ratingRect.isNull()) //{ - // // Normally we prepare the pixmaps over the background of the ra= ting rect. - // // If the rating is drawn over the thumbnail, we can only draw o= ver a transparent pixmap. + // Normally we prepare the pixmaps over the background of the rati= ng rect. + // If the rating is drawn over the thumbnail, we can only draw ove= r a transparent pixmap. // prepareRatingPixmaps(!d->ratingOverThumbnail); //} = @@ -560,7 +529,7 @@ int ImportDelegate::calculatethumbSizeToFit(int ws) return (ts1); } = -// ------ ImportThumbnailDelegate ---------------------------------------- +// --- ImportThumbnailDelegate --------------------------------------- = void ImportThumbnailDelegatePrivate::init(ImportThumbnailDelegate* q) { @@ -596,8 +565,9 @@ void ImportThumbnailDelegate::setDefaultViewOptions(con= st QStyleOptionViewItem& int ImportThumbnailDelegate::maximumSize() const { Q_D(const ImportThumbnailDelegate); - //FIXME: Need to examine this line and make sure of it return Thumbnai= lLoadThread::maximumThumbnailPixmapSize(true) + 2*d->radius + 2*d->margin; - return (2*d->radius + 2*d->margin); + //FIXME: Fix thumbnails issues. + //return ThumbnailLoadThread::maximumThumbnailPixmapSize(true) + 2*d->= radius + 2*d->margin; + return 256;// dummy return } = int ImportThumbnailDelegate::minimumSize() const @@ -627,8 +597,8 @@ void ImportThumbnailDelegate::updateContentWidth() maxSize =3D d->viewSize.width(); } = - //FIXME: Need to examine this line and make sure of it d->thumbSize = =3D ThumbnailLoadThread::thumbnailPixmapSize(true, maxSize - 2*d->radius - = 2*d->margin); - d->thumbSize =3D maxSize - 2*d->radius - 2*d->margin; + //FIXME: Fix thumbnails issues. + //d->thumbSize =3D ThumbnailLoadThread::thumbnailPixmapSize(true, maxS= ize - 2*d->radius - 2*d->margin); = ImportDelegate::updateContentWidth(); } @@ -641,12 +611,12 @@ void ImportThumbnailDelegate::updateRects() d->rect =3D QRect(0, 0, d->contentWidth + 2*d->margin, d->c= ontentWidth + 2*d->margin); d->drawImageFormat =3D ImportSettings::instance()->getIconShowImageFor= mat(); = -//TODO: Implement rating. -// if (ImportSettings::instance()->getIconShowRating()) -// { -// int top =3D d->rect.bottom() - d->margin - d->starPolygonS= ize.height() - 2; -// d->ratingRect =3D QRect(d->margin, top, d->contentWidth, d->star= PolygonSize.height()); -// } + //TODO: Implement rating in import tool. + //if (ImportSettings::instance()->getIconShowRating()) + //{ + // int top =3D d->rect.bottom() - d->margin - d->starPolygonS= ize.height() - 2; + // d->ratingRect =3D QRect(d->margin, top, d->contentWidth, d->star= PolygonSize.height()); + //} = if (d->flow =3D=3D QListView::LeftToRight) { @@ -658,20 +628,23 @@ void ImportThumbnailDelegate::updateRects() } } = -// ------ ImportNormalDelegate ---------------------------------------- +// --- ImportNormalDelegate ----------------------------------------------= --------------------------------------------------------- = void ImportNormalDelegatePrivate::init(ImportNormalDelegate* q, ImportCate= gorizedView* parent) { + categoryDrawer =3D new ImportCategoryDrawer(parent); = QObject::connect(ImportSettings::instance(), SIGNAL(setupChanged()), q, SLOT(slotSetupChanged())); } = +// -----------------------------------------------------------------------= ------------------------- = ImportNormalDelegate::ImportNormalDelegate(ImportCategorizedView* parent) : ImportDelegate(*new ImportNormalDelegatePrivate, parent) { + Q_D(ImportNormalDelegate); d->init(this, parent); } @@ -679,6 +652,7 @@ ImportNormalDelegate::ImportNormalDelegate(ImportCatego= rizedView* parent) ImportNormalDelegate::ImportNormalDelegate(ImportNormalDelegatePrivate& dd= , ImportCategorizedView* parent) : ImportDelegate(dd, parent) { + Q_D(ImportNormalDelegate); d->init(this, parent); } @@ -691,23 +665,23 @@ void ImportNormalDelegate::updateRects() { Q_D(ImportNormalDelegate); = - int y =3D d->margin; - d->pixmapRect =3D QRect(d->margin, y, d->contentW= idth, d->contentWidth); - y =3D d->pixmapRect.bottom(); - d->imageInformationRect =3D QRect(d->margin, y, d->contentW= idth, 0); + int y =3D d->margin; + d->pixmapRect =3D QRect(d->margin, y, d->conten= tWidth, d->contentWidth); + y =3D d->pixmapRect.bottom(); + d->imageInformationRect =3D QRect(d->margin, y, d->conten= tWidth, 0); const ImportSettings* ImportSettings =3D ImportSettings::instance(); - d->drawImageFormat =3D ImportSettings->getIconShowImag= eFormat(); + d->drawImageFormat =3D ImportSettings->getIconShowIm= ageFormat(); = const int iconSize =3D KIconLoader::SizeSmallMedium; - //FIXME: d->pickLabelRect =3D QRect(d->margin, y, iconSize, iconSize= ); - d->groupRect =3D QRect(d->contentWidth - iconSize, y, iconSize, = iconSize); + //TODO: d->pickLabelRect =3D QRect(d->margin, y, iconSize, iconSize); + //d->groupRect =3D QRect(d->contentWidth - iconSize, y, iconSize= , iconSize); = -//TODO: Implement rating. -// if (ImportSettings->getIconShowRating()) -// { -// d->ratingRect =3D QRect(d->margin, y, d->contentWidth, d->starPo= lygonSize.height()); -// y =3D d->ratingRect.bottom(); -// } + //TODO: Implement rating in import tool. + //if (ImportSettings->getIconShowRating()) + //{ + // d->ratingRect =3D QRect(d->margin, y, d->contentWidth, d->starPo= lygonSize.height()); + // y =3D d->ratingRect.bottom(); + //} = if (ImportSettings->getIconShowName()) { @@ -715,12 +689,6 @@ void ImportNormalDelegate::updateRects() y =3D d->nameRect.bottom(); } = -// if (ImportSettings->getIconShowTitle()) -// { -// d->titleRect =3D QRect(d->margin, y, d->contentWidth, d->oneRowR= egRect.height()); -// y =3D d->titleRect.bottom(); -// } - if (ImportSettings->getIconShowDate()) { d->dateRect =3D QRect(d->margin, y, d->contentWidth, d->oneRowXtra= Rect.height()); @@ -733,11 +701,12 @@ void ImportNormalDelegate::updateRects() y =3D d->modDateRect.bottom(); } = -// if (ImportSettings->getIconShowResolution()) -// { -// d->resolutionRect =3D QRect(d->margin, y, d->contentWidth, d->on= eRowXtraRect.height()); -// y =3D d->resolutionRect.bottom() ; -// } + //TODO: Add resolution entry in ImportSettings. + //if (ImportSettings->getIconShowResolution()) + //{ + // d->resolutionRect =3D QRect(d->margin, y, d->contentWidth, d->on= eRowXtraRect.height()); + // y =3D d->resolutionRect.bottom() ; + //} = if (ImportSettings->getIconShowSize()) { @@ -745,11 +714,11 @@ void ImportNormalDelegate::updateRects() y =3D d->sizeRect.bottom(); } = -// if (ImportSettings->getIconShowTags()) -// { -// d->tagRect =3D QRect(d->margin, y, d->contentWidth, d->oneRowCom= Rect.height()); -// y =3D d->tagRect.bottom(); -// } + //if (ImportSettings->getIconShowTags()) + //{ + // d->tagRect =3D QRect(d->margin, y, d->contentWidth, d->oneRowCom= Rect.height()); + // y =3D d->tagRect.bottom(); + //} = d->imageInformationRect.setBottom(y); = diff --git a/utilities/cameragui/items/importdelegate.h b/utilities/camerag= ui/items/importdelegate.h index c9e535d..ec71ac3 100644 --- a/utilities/cameragui/items/importdelegate.h +++ b/utilities/cameragui/items/importdelegate.h @@ -24,12 +24,14 @@ #ifndef IMPORTDELEGATE_H #define IMPORTDELEGATE_H = +#include + // Local includes = #include "itemviewimportdelegate.h" #include "importthumbnailmodel.h" -#include "importcategorizedview.h" #include "importcategorydrawer.h" +#include "importcategorizedview.h" = namespace Digikam { @@ -76,13 +78,14 @@ public: virtual void prepareThumbnails(ImportThumbnailModel* thumbModel, const= QList& indexes); = /** - * Retrieve the thumbnail pixmap in given size for the ImageModel::Thu= mbnailRole for - * the given index from the given index, which must adhere to ImageThu= mbnailModel semantics. + * Retrieve the thumbnail pixmap in given size for the ImportImageMode= l::ThumbnailRole for + * the given index from the given index, which must adhere to ImportTh= umbnailModel semantics. */ static QPixmap retrieveThumbnailPixmap(const QModelIndex& index, int t= humbnailSize); = public: = + // Declared as public because of use in ImportNormalDelegate class. class ImportDelegatePrivate; = protected: diff --git a/utilities/cameragui/items/importdelegatepriv.h b/utilities/cam= eragui/items/importdelegatepriv.h index 342a2cc..dfdf774 100644 --- a/utilities/cameragui/items/importdelegatepriv.h +++ b/utilities/cameragui/items/importdelegatepriv.h @@ -8,12 +8,14 @@ = // Local includes = -#include "importdelegate.h" +#include "importcategorizedview.h" #include "itemviewimportdelegatepriv.h" = namespace Digikam { = +class ImportCategoryDrawer; + class ImportDelegate::ImportDelegatePrivate : public ItemViewImportDelegat= ePrivate { public: @@ -63,6 +65,8 @@ public: virtual void clearRects(); }; = +// --- ImportThumbnailDelegate -------------------------------------------= --------- + class ImportThumbnailDelegatePrivate : public ImportDelegate::ImportDelega= tePrivate { public: @@ -87,6 +91,8 @@ public: void init(ImportThumbnailDelegate* q); }; = +// --- ImportNormalDelegate ----------------------------------------------= ------ + class ImportNormalDelegatePrivate : public ImportDelegate::ImportDelegateP= rivate { public: diff --git a/utilities/cameragui/items/itemviewimportdelegate.cpp b/utiliti= es/cameragui/items/itemviewimportdelegate.cpp index e429e98..cd47d32 100644 --- a/utilities/cameragui/items/itemviewimportdelegate.cpp +++ b/utilities/cameragui/items/itemviewimportdelegate.cpp @@ -22,73 +22,32 @@ * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ = #include "itemviewimportdelegate.moc" +#include "itemviewimportdelegatepriv.h" +#include "itemviewimportdelegate.h" //TODO: Remove this line. = // Qt includes = +#include #include +#include = // KDE includes = +#include #include #include +#include +#include #include = // Local includes = +#include "imagedelegateoverlay.h" #include "thememanager.h" = namespace Digikam { = -class ItemViewImportDelegatePrivate -{ -public: - - ItemViewImportDelegatePrivate(); - virtual ~ItemViewImportDelegatePrivate() {} - - void init(ItemViewImportDelegate* const _q); - - void makeStarPolygon(); - - /// Resets cached rects. Remember to reimplement in subclass for added= rects. - virtual void clearRects(); - -public: - - int spacing; - QSize gridSize; - - QRect rect; - QRect ratingRect; - - QPixmap regPixmap; - QPixmap selPixmap; - QVector ratingPixmaps; - - QFont font; - QFont fontReg; - QFont fontCom; - QFont fontXtra; - - QPolygon starPolygon; - QSize starPolygonSize; - - ThumbnailSize thumbSize; - - QPersistentModelIndex editingRating; - - ItemViewImportDelegate* q; - - QRect oneRowRegRect; - QRect oneRowComRect; - QRect oneRowXtraRect; - - // constant values for drawing - int radius; - int margin; -}; - ItemViewImportDelegatePrivate::ItemViewImportDelegatePrivate() { spacing =3D 0; @@ -138,9 +97,15 @@ void ItemViewImportDelegatePrivate::makeStarPolygon() // ---- ItemViewImportDelegate -------------------------------------------= ---- = ItemViewImportDelegate::ItemViewImportDelegate(QObject* const parent) - : DItemDelegate(parent), d(new ItemViewImportDelegatePrivate) + : DItemDelegate(parent), d_ptr(new ItemViewImportDelegatePrivate) +{ + d_ptr->init(this); +} + +ItemViewImportDelegate::ItemViewImportDelegate(ItemViewImportDelegatePriva= te& dd, QObject* parent) + : DItemDelegate(parent), d_ptr(&dd) { - d->init(this); + d_ptr->init(this); } = ItemViewImportDelegate::~ItemViewImportDelegate() @@ -271,6 +236,7 @@ void ItemViewImportDelegate::invalidatePaintingCache() { Q_D(ItemViewImportDelegate); QSize oldGridSize =3D d->gridSize; + qDebug() << "Width: " << d->gridSize.width() << "Height: " << d->gridS= ize.height();//TODO: Remove this line. updateSizeRectsAndPixmaps(); = if (oldGridSize !=3D d->gridSize) @@ -332,6 +298,56 @@ void ItemViewImportDelegate::drawModificationDate(QPai= nter* p, const QRect& date p->drawText(dateRect, Qt::AlignCenter, str);//squeezedTextCached(p, da= teRect.width(), str)); } = +void ItemViewImportDelegate::drawImageFormat(QPainter* p, const QRect& r, = const QString& mime) const +{ + Q_D(const ItemViewImportDelegate); + + if (!mime.isEmpty() && !r.isNull()) + { + p->save(); + + QFont fnt(d->fontReg); + fnt.setWeight(QFont::Black); + fnt.setItalic(false); + p->setFont(fnt); + p->setPen(QPen(Qt::gray)); + p->setOpacity(0.50); + + QRect bRect =3D p->boundingRect(r, Qt::AlignTop | Qt::AlignHCenter= , mime.toUpper()); + bRect.adjust(-1, -1, 1, 1); + bRect.translate(0, 1); + + p->fillRect(bRect, Qt::SolidPattern); + p->setPen(QPen(Qt::white)); + p->setOpacity(1.0); + p->drawText(bRect, Qt::AlignTop | Qt::AlignHCenter, mime.toUpper()= ); + + p->restore(); + } +} + +void ItemViewImportDelegate::drawImageSize(QPainter* p, const QRect& dimsR= ect, const QSize& dims) const +{ + Q_D(const ItemViewImportDelegate); + + if (dims.isValid()) + { + p->setFont(d->fontXtra); + QString mpixels, resolution; + mpixels.setNum(dims.width()*dims.height()/1000000.0, 'f', 2); + + if (dims.isValid()) + resolution =3D i18nc("%1 width, %2 height, %3 mpixels", "%1x%2= (%3Mpx)", + dims.width(), dims.height(), mpixels); + else + { + resolution =3D i18nc("unknown image resolution", "Unknown"); + } + + p->drawText(dimsRect, Qt::AlignCenter, resolution); + } +} + void ItemViewImportDelegate::drawFileSize(QPainter* p, const QRect& r, qlo= nglong bytes) const { Q_D(const ItemViewImportDelegate); @@ -359,6 +375,20 @@ void ItemViewImportDelegate::drawPanelSideIcon(QPainte= r* p, bool left, bool righ } } = +void ItemViewImportDelegate::drawFocusRect(QPainter* p, const QStyleOption= ViewItem& option, + bool isSelected) const +{ + Q_D(const ItemViewImportDelegate); + + if (option.state & QStyle::State_HasFocus) //?? is current item + { + p->setPen(QPen(isSelected ? kapp->palette().color(QPalette::Highli= ghtedText) + : kapp->palette().color(QPalette::Text), + 1, Qt::DotLine)); + p->drawRect(1, 1, d->rect.width()-3, d->rect.height()-3); + } +} + void ItemViewImportDelegate::drawGroupIndicator(QPainter* p, const QRect& = r, int numberOfGroupedImages,= bool open) const { diff --git a/utilities/cameragui/items/itemviewimportdelegate.h b/utilities= /cameragui/items/itemviewimportdelegate.h index 94a6e3e..684762e 100644 --- a/utilities/cameragui/items/itemviewimportdelegate.h +++ b/utilities/cameragui/items/itemviewimportdelegate.h @@ -26,6 +26,7 @@ = // Local includes = +#include "itemviewimportdelegatepriv.h" #include "thumbnailsize.h" #include "ditemdelegate.h" #include "imagedelegateoverlay.h" @@ -33,6 +34,12 @@ namespace Digikam { = +class ImportCategoryDrawer; +class ImportCategorizedView; +class ImportFilterModel; +class ImportImageModel; +class ItemViewImportDelegatePrivate; + class ItemViewImportDelegate : public DItemDelegate, public ImageDelegateO= verlayContainer // Some reuse of the existing model-view classes. { Q_OBJECT @@ -92,6 +99,7 @@ protected: void drawCreationDate(QPainter* p, const QRect& dateRect, const QDateT= ime& date) const; void drawModificationDate(QPainter* p, const QRect& dateRect, const QD= ateTime& date) const; void drawImageSize(QPainter* p, const QRect& dimsRect, const QSize& di= ms) const; + void drawImageFormat(QPainter* p, const QRect& dimsRect, const QString= & mime) const; void drawFileSize(QPainter* p, const QRect& r, qlonglong bytes) const; void drawGroupIndicator(QPainter* p, const QRect& r, int numberOfGroup= edImages, bool open) const; void drawPanelSideIcon(QPainter* p, bool left, bool right) const; @@ -109,7 +117,7 @@ protected: = protected: = - class ItemViewImportDelegatePrivate* const d; + ItemViewImportDelegatePrivate* const d_ptr; ItemViewImportDelegate(ItemViewImportDelegatePrivate& dd, QObject* par= ent); = private: diff --git a/utilities/cameragui/items/itemviewimportdelegatepriv.h b/utili= ties/cameragui/items/itemviewimportdelegatepriv.h index e476d45..91f9608 100644 --- a/utilities/cameragui/items/itemviewimportdelegatepriv.h +++ b/utilities/cameragui/items/itemviewimportdelegatepriv.h @@ -32,6 +32,11 @@ #include #include = +// KDE includes + +#include +#include + // Local includes = #include "thumbnailsize.h"