File indexing completed on 2025-01-19 03:50:39

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-12-10
0007  * Description : album icon view tool tip
0008  *
0009  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText: 2013      by Michael G. Hansen <mike at mghansen dot de>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "tooltipfiller.h"
0017 
0018 // Qt includes
0019 
0020 #include <QDateTime>
0021 #include <QLocale>
0022 
0023 // KDE includes
0024 
0025 #include <klocalizedstring.h>
0026 
0027 // Local includes
0028 
0029 #include "digikam_debug.h"
0030 #include "albummanager.h"
0031 #include "collectionlocation.h"
0032 #include "collectionmanager.h"
0033 #include "applicationsettings.h"
0034 #include "album.h"
0035 #include "coredbinfocontainers.h"
0036 #include "dimgfiltermanager.h"
0037 #include "ditemtooltip.h"
0038 #include "filteraction.h"
0039 #include "iteminfo.h"
0040 #include "itempropertiestab.h"
0041 #include "colorlabelwidget.h"
0042 #include "picklabelwidget.h"
0043 #include "albumthumbnailloader.h"
0044 #include "thumbnailsize.h"
0045 
0046 namespace Digikam
0047 {
0048 
0049 QString ToolTipFiller::imageInfoTipContents(const ItemInfo& info)
0050 {
0051     QString              str;
0052     ApplicationSettings* const settings = ApplicationSettings::instance();
0053     DToolTipStyleSheet   cnt(settings->getToolTipsFont());
0054 
0055     ImageCommonContainer commonInfo     = info.imageCommonContainer();
0056     ImageMetadataContainer photoInfo    = info.imageMetadataContainer();
0057     VideoMetadataContainer videoInfo    = info.videoMetadataContainer();
0058     QString tip                         = cnt.tipHeader;
0059 
0060     // -- File properties ----------------------------------------------
0061 
0062     if (settings->getToolTipsShowFileName()  ||
0063         settings->getToolTipsShowFileDate()  ||
0064         settings->getToolTipsShowFileSize()  ||
0065         settings->getToolTipsShowImageType() ||
0066         settings->getToolTipsShowImageDim()  ||
0067         settings->getToolTipsShowImageAR())
0068 
0069     {
0070         tip += cnt.headBeg + i18n("File Properties") + cnt.headEnd;
0071 
0072         if (settings->getToolTipsShowFileName())
0073         {
0074             tip += cnt.cellBeg + i18nc("filename",
0075                                        "Name:") + cnt.cellMid;
0076             tip += commonInfo.fileName + cnt.cellEnd;
0077         }
0078 
0079         if (settings->getToolTipsShowFileDate())
0080         {
0081             QDateTime modifiedDate = commonInfo.fileModificationDate;
0082             str                    = QLocale().toString(modifiedDate, QLocale::ShortFormat);
0083             tip                   += cnt.cellBeg + i18n("Date:") + cnt.cellMid + str + cnt.cellEnd;
0084         }
0085 
0086         if (settings->getToolTipsShowFileSize())
0087         {
0088             tip                   += cnt.cellBeg + i18n("Size:") + cnt.cellMid;
0089             QString localeFileSize = QLocale().toString(commonInfo.fileSize);
0090             str                    = i18n("%1 (%2)", ItemPropertiesTab::humanReadableBytesCount(commonInfo.fileSize), localeFileSize);
0091             tip                   += str + cnt.cellEnd;
0092         }
0093 
0094         if (settings->getToolTipsShowImageType())
0095         {
0096             tip += cnt.cellBeg + i18n("Type:") + cnt.cellMid + commonInfo.format + cnt.cellEnd;
0097         }
0098 
0099         if (settings->getToolTipsShowImageDim())
0100         {
0101             if ((commonInfo.width == 0) || (commonInfo.height == 0))
0102             {
0103                 str = i18nc("unknown / invalid image dimension",
0104                             "Unknown");
0105             }
0106             else
0107             {
0108                 QString mpixels = QLocale().toString(commonInfo.width*commonInfo.height/1000000.0, 'f', 1);
0109                 str = i18nc("width x height (megapixels Mpx)", "%1x%2 (%3Mpx)",
0110                             commonInfo.width, commonInfo.height, mpixels);
0111             }
0112 
0113             tip += cnt.cellBeg + i18n("Dimensions:") + cnt.cellMid + str + cnt.cellEnd;
0114         }
0115 
0116        if (settings->getToolTipsShowImageAR())
0117         {
0118             if (!ItemPropertiesTab::aspectRatioToString(commonInfo.width, commonInfo.height, str))
0119             {
0120                 str = i18nc("unknown / invalid image aspect ratio",
0121                             "Unknown");
0122             }
0123 
0124             tip += cnt.cellBeg + i18n("Aspect Ratio:") + cnt.cellMid + str + cnt.cellEnd;
0125         }
0126 
0127     }
0128 
0129     // -- Photograph Info ----------------------------------------------------
0130 
0131     if (settings->getToolTipsShowPhotoMake()  ||
0132         settings->getToolTipsShowPhotoLens()  ||
0133         settings->getToolTipsShowPhotoDate()  ||
0134         settings->getToolTipsShowPhotoFocal() ||
0135         settings->getToolTipsShowPhotoExpo()  ||
0136         settings->getToolTipsShowPhotoMode()  ||
0137         settings->getToolTipsShowPhotoFlash() ||
0138         settings->getToolTipsShowPhotoWB())
0139     {
0140         if (!photoInfo.allFieldsNull || commonInfo.creationDate.isValid())
0141         {
0142             QString metaStr;
0143             tip += cnt.headBeg + i18n("Photograph Properties") + cnt.headEnd;
0144 
0145             if (settings->getToolTipsShowPhotoMake())
0146             {
0147                 ItemPropertiesTab::shortenedMakeInfo(photoInfo.make);
0148                 ItemPropertiesTab::shortenedModelInfo(photoInfo.model);
0149 
0150                 str = QString::fromUtf8("%1 / %2").arg(photoInfo.make.isEmpty() ? cnt.unavailable : photoInfo.make)
0151                       .arg(photoInfo.model.isEmpty() ? cnt.unavailable : photoInfo.model);
0152 
0153                 if (str.length() > cnt.maxStringLength)
0154                 {
0155                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0156                 }
0157 
0158                 metaStr += cnt.cellBeg + i18n("Make/Model:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0159             }
0160 
0161             if (settings->getToolTipsShowPhotoLens())
0162             {
0163                 str          = photoInfo.lens.isEmpty() ? cnt.unavailable : photoInfo.lens;
0164                 QString lens = i18nc("camera lens", "Lens:");
0165 
0166                 if (str.length() > cnt.maxStringLength)
0167                 {
0168                     int space = str.lastIndexOf(QLatin1Char(' '), cnt.maxStringLength);
0169 
0170                     if (space == -1)
0171                     {
0172                         space = cnt.maxStringLength;
0173                     }
0174 
0175                     metaStr += cnt.cellBeg + lens + cnt.cellMid + str.left(space).toHtmlEscaped() + cnt.cellEnd;
0176 
0177                     str  = str.mid(space+1);
0178                     lens = QString();
0179                 }
0180 
0181                 if (str.length() > cnt.maxStringLength)
0182                 {
0183                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0184                 }
0185 
0186                 metaStr += cnt.cellBeg + lens + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0187             }
0188 
0189             if (settings->getToolTipsShowPhotoDate())
0190             {
0191                 if (commonInfo.creationDate.isValid())
0192                 {
0193                     str = QLocale().toString(commonInfo.creationDate, QLocale::ShortFormat);
0194 
0195                     if (str.length() > cnt.maxStringLength)
0196                     {
0197                         str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0198                     }
0199 
0200                     metaStr += cnt.cellBeg + i18nc("creation date of the image",
0201                                                    "Created:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0202                 }
0203                 else
0204                 {
0205                     metaStr += cnt.cellBeg + i18nc("creation date of the image",
0206                                                    "Created:") + cnt.cellMid + cnt.unavailable.toHtmlEscaped() + cnt.cellEnd;
0207                 }
0208             }
0209 
0210             if (settings->getToolTipsShowPhotoFocal())
0211             {
0212                 str = photoInfo.aperture.isEmpty() ? cnt.unavailable : photoInfo.aperture;
0213 
0214                 if (photoInfo.focalLength35.isEmpty())
0215                 {
0216                     str += QString::fromUtf8(" / %1").arg(photoInfo.focalLength.isEmpty() ? cnt.unavailable : photoInfo.focalLength);
0217                 }
0218                 else
0219                 {
0220                     str += QString::fromUtf8(" / %1").arg(i18n("%1 (%2)",photoInfo.focalLength,photoInfo.focalLength35));
0221                 }
0222 
0223                 if (str.length() > cnt.maxStringLength)
0224                 {
0225                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0226                 }
0227 
0228                 metaStr += cnt.cellBeg + i18n("Aperture/Focal:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0229             }
0230 
0231             if (settings->getToolTipsShowPhotoExpo())
0232             {
0233                 str = QString::fromUtf8("%1 / %2").arg(photoInfo.exposureTime.isEmpty() ? cnt.unavailable : photoInfo.exposureTime)
0234                       .arg(photoInfo.sensitivity.isEmpty() ? cnt.unavailable : i18n("%1 ISO",photoInfo.sensitivity));
0235 
0236                 if (str.length() > cnt.maxStringLength)
0237                 {
0238                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0239                 }
0240 
0241                 metaStr += cnt.cellBeg + i18n("Exposure/Sensitivity:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0242             }
0243 
0244             if (settings->getToolTipsShowPhotoMode())
0245             {
0246                 if      (photoInfo.exposureMode.isEmpty() && photoInfo.exposureProgram.isEmpty())
0247                 {
0248                     str = cnt.unavailable;
0249                 }
0250                 else if (!photoInfo.exposureMode.isEmpty() && photoInfo.exposureProgram.isEmpty())
0251                 {
0252                     str = photoInfo.exposureMode;
0253                 }
0254                 else if (photoInfo.exposureMode.isEmpty() && !photoInfo.exposureProgram.isEmpty())
0255                 {
0256                     str = photoInfo.exposureProgram;
0257                 }
0258                 else
0259                 {
0260                     str = QString::fromUtf8("%1 / %2").arg(photoInfo.exposureMode).arg(photoInfo.exposureProgram);
0261                 }
0262 
0263                 if (str.length() > cnt.maxStringLength)
0264                 {
0265                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0266                 }
0267 
0268                 metaStr += cnt.cellBeg + i18n("Mode/Program:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0269             }
0270 
0271             if (settings->getToolTipsShowPhotoFlash())
0272             {
0273                 str = photoInfo.flashMode.isEmpty() ? cnt.unavailable : photoInfo.flashMode;
0274 
0275                 if (str.length() > cnt.maxStringLength)
0276                 {
0277                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0278                 }
0279 
0280                 metaStr += cnt.cellBeg + i18nc("camera flash settings",
0281                                                "Flash:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0282             }
0283 
0284             if (settings->getToolTipsShowPhotoWB())
0285             {
0286                 str = photoInfo.whiteBalance.isEmpty() ? cnt.unavailable : photoInfo.whiteBalance;
0287 
0288                 if (str.length() > cnt.maxStringLength)
0289                 {
0290                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0291                 }
0292 
0293                 metaStr += cnt.cellBeg + i18n("White Balance:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0294             }
0295 
0296             tip += metaStr;
0297         }
0298     }
0299 
0300     // -- Video Metadata Info ----------------------------------------------------
0301 
0302     if (settings->getToolTipsShowVideoAspectRatio()        ||
0303         settings->getToolTipsShowVideoDuration()           ||
0304         settings->getToolTipsShowVideoFrameRate()          ||
0305         settings->getToolTipsShowVideoVideoCodec()         ||
0306         settings->getToolTipsShowVideoAudioBitRate()       ||
0307         settings->getToolTipsShowVideoAudioChannelType()   ||
0308         settings->getToolTipsShowVideoAudioCodec())
0309     {
0310         if (!videoInfo.allFieldsNull)
0311         {
0312             QString metaStr;
0313             tip += cnt.headBeg + i18n("Audio/Video Properties") + cnt.headEnd;
0314 
0315             if (settings->getToolTipsShowVideoAspectRatio())
0316             {
0317                 str = videoInfo.aspectRatio.isEmpty() ? cnt.unavailable : videoInfo.aspectRatio;
0318 
0319                 if (str.length() > cnt.maxStringLength)
0320                 {
0321                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0322                 }
0323 
0324                 metaStr += cnt.cellBeg + i18n("Aspect Ratio:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0325             }
0326 
0327             if (settings->getToolTipsShowVideoDuration())
0328             {
0329                 QString durationString;
0330                 bool ok                = false;
0331                 const int durationVal  = videoInfo.duration.toInt(&ok);
0332 
0333                 if (ok)
0334                 {
0335                     unsigned int r, d, h, m, s, f;
0336                     r = qAbs(durationVal);
0337                     d = r / 86400000;
0338                     r = r % 86400000;
0339                     h = r / 3600000;
0340                     r = r % 3600000;
0341                     m = r / 60000;
0342                     r = r % 60000;
0343                     s = r / 1000;
0344                     f = r % 1000;
0345 
0346                     durationString = QString().asprintf("%d.%02d:%02d:%02d.%03d", d, h, m, s, f);
0347                 }
0348 
0349                 str = videoInfo.duration.isEmpty() ? cnt.unavailable : durationString;
0350 
0351                 if (str.length() > cnt.maxStringLength)
0352                 {
0353                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0354                 }
0355 
0356                 metaStr += cnt.cellBeg + i18n("Duration:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0357             }
0358 
0359             if (settings->getToolTipsShowVideoFrameRate())
0360             {
0361                 QString frameRateString;
0362                 bool ok;
0363                 const double frameRateDouble = videoInfo.frameRate.toDouble(&ok);
0364 
0365                 if (ok)
0366                 {
0367                     frameRateString = QLocale().toString(frameRateDouble);
0368                 }
0369 
0370                 str = videoInfo.frameRate.isEmpty() ? cnt.unavailable : frameRateString;
0371 
0372                 if (str.length() > cnt.maxStringLength)
0373                 {
0374                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0375                 }
0376 
0377                 metaStr += cnt.cellBeg + i18n("Frame Rate:") + cnt.cellMid + str.toHtmlEscaped() + i18n(" fps") + cnt.cellEnd;
0378             }
0379 
0380             if (settings->getToolTipsShowVideoVideoCodec())
0381             {
0382                 str = videoInfo.videoCodec.isEmpty() ? cnt.unavailable : videoInfo.videoCodec;
0383 
0384                 if (str.length() > cnt.maxStringLength)
0385                 {
0386                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0387                 }
0388 
0389                 metaStr += cnt.cellBeg + i18n("Video Codec:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0390             }
0391 
0392             if (settings->getToolTipsShowVideoAudioBitRate())
0393             {
0394                 QString audioBitRateString = str;
0395                 bool ok;
0396                 const int audioBitRateInt  = videoInfo.audioBitRate.toInt(&ok);
0397 
0398                 if (ok)
0399                 {
0400                     audioBitRateString = QLocale().toString(audioBitRateInt);
0401                 }
0402 
0403                 str = videoInfo.audioBitRate.isEmpty() ? cnt.unavailable : audioBitRateString;
0404 
0405                 if (str.length() > cnt.maxStringLength)
0406                 {
0407                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0408                 }
0409 
0410                 metaStr += cnt.cellBeg + i18n("Audio Bit Rate:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0411             }
0412 
0413             if (settings->getToolTipsShowVideoAudioChannelType())
0414             {
0415                 str = videoInfo.audioChannelType.isEmpty() ? cnt.unavailable : videoInfo.audioChannelType;
0416 
0417                 if (str.length() > cnt.maxStringLength)
0418                 {
0419                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0420                 }
0421 
0422                 metaStr += cnt.cellBeg + i18n("Audio Channel Type:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0423             }
0424 
0425             if (settings->getToolTipsShowVideoAudioCodec())
0426             {
0427                 str = videoInfo.audioCodec.isEmpty() ? cnt.unavailable : videoInfo.audioCodec;
0428 
0429                 if (str.length() > cnt.maxStringLength)
0430                 {
0431                     str = str.left(cnt.maxStringLength-3) + QLatin1String("...");
0432                 }
0433 
0434                 metaStr += cnt.cellBeg + i18n("Audio Codec:") + cnt.cellMid + str.toHtmlEscaped() + cnt.cellEnd;
0435             }
0436 
0437             tip += metaStr;
0438         }
0439     }
0440 
0441     // -- digiKam properties  ------------------------------------------
0442 
0443     if (settings->getToolTipsShowAlbumName()    ||
0444         settings->getToolTipsShowTitles()       ||
0445         settings->getToolTipsShowComments()     ||
0446         settings->getToolTipsShowTags()         ||
0447         settings->getToolTipsShowLabelRating())
0448     {
0449         tip += cnt.headBeg + i18n("digiKam Properties") + cnt.headEnd;
0450 
0451         if (settings->getToolTipsShowAlbumName())
0452         {
0453             PAlbum* const album = AlbumManager::instance()->findPAlbum(info.albumId());
0454 
0455             if (album)
0456             {
0457                 tip += cnt.cellSpecBeg + i18n("Album:") + cnt.cellSpecMid + album->albumPath().remove(0, 1) + cnt.cellSpecEnd;
0458             }
0459         }
0460 
0461         if (settings->getToolTipsShowTitles())
0462         {
0463             str = info.title();
0464 
0465             if (str.isEmpty())
0466             {
0467                 str = QLatin1String("---");
0468             }
0469 
0470             tip += cnt.cellSpecBeg + i18nc("title of the file",
0471                                            "Title:") + cnt.cellSpecMid +
0472                    cnt.breakString((str.size() > 100) ? str.left(100) + QLatin1String("...") : str) + cnt.cellSpecEnd;
0473         }
0474 
0475         if (settings->getToolTipsShowComments())
0476         {
0477             str = info.comment();
0478 
0479             if (str.isEmpty())
0480             {
0481                 str = QLatin1String("---");
0482             }
0483 
0484             tip += cnt.cellSpecBeg + i18nc("caption of the file",
0485                                            "Caption:") + cnt.cellSpecMid +
0486                    cnt.breakString((str.size() > 100) ? str.left(100) + QLatin1String("...") : str) + cnt.cellSpecEnd;
0487         }
0488 
0489         if (settings->getToolTipsShowTags())
0490         {
0491             QStringList tagPaths = AlbumManager::instance()->tagPaths(info.tagIds(), false);
0492             tagPaths.sort();
0493 
0494             QString tags(i18n("Tags:"));
0495 
0496             if (tagPaths.isEmpty())
0497             {
0498                 tip += cnt.cellSpecBeg + tags + cnt.cellSpecMid + QLatin1String("---") + cnt.cellSpecEnd;
0499             }
0500             else
0501             {
0502                 QString title = tags;
0503                 QString tagText;
0504 
0505                 for (int i = 0 ; i < tagPaths.size() ; ++i)
0506                 {
0507                     tagText = tagPaths.at(i);
0508 
0509                     if (tagText.size() > cnt.maxStringLength)
0510                     {
0511                         tagText = cnt.elidedText(tagPaths.at(i), Qt::ElideLeft);
0512                     }
0513 
0514                     tip += cnt.cellSpecBeg + title + cnt.cellSpecMid + tagText.toHtmlEscaped() + cnt.cellSpecEnd;
0515                     title.clear();
0516                 }
0517             }
0518         }
0519 
0520         if (settings->getToolTipsShowLabelRating())
0521         {
0522             str        = PickLabelWidget::labelPickName((PickLabel)info.pickLabel());
0523             str       += QLatin1String(" / ");
0524 
0525             str       += ColorLabelWidget::labelColorName((ColorLabel)info.colorLabel());
0526             str       += QLatin1String(" / ");
0527 
0528             int rating = info.rating();
0529 
0530             if ((rating > RatingMin) && (rating <= RatingMax))
0531             {
0532                 for (int i = 0 ; i < rating ; ++i)
0533                 {
0534                     str += QChar(0x2730);
0535                     str += QLatin1Char(' ');
0536                 }
0537             }
0538             else
0539             {
0540                 str += QLatin1String("---");
0541             }
0542 
0543             tip += cnt.cellSpecBeg + i18n("Labels:") + cnt.cellSpecMid + str + cnt.cellSpecEnd;
0544         }
0545     }
0546 
0547     tip += cnt.tipFooter;
0548 
0549     return tip;
0550 }
0551 
0552 QString ToolTipFiller::albumTipContents(PAlbum* const album, int count)
0553 {
0554     if (!album || album->isTrashAlbum())
0555     {
0556         return QString();
0557     }
0558 
0559     QString                    str;
0560     ApplicationSettings* const settings = ApplicationSettings::instance();
0561     DToolTipStyleSheet         cnt(settings->getToolTipsFont());
0562     QString                    tip      = cnt.tipHeader;
0563 
0564     if (settings->getToolTipsShowAlbumTitle()      ||
0565         settings->getToolTipsShowAlbumDate()       ||
0566         settings->getToolTipsShowAlbumCollection() ||
0567         settings->getToolTipsShowAlbumCategory()   ||
0568         settings->getToolTipsShowAlbumCaption())
0569     {
0570         tip += cnt.headBeg + i18n("Album Properties") + cnt.headEnd;
0571 
0572         if (settings->getToolTipsShowAlbumTitle())
0573         {
0574             tip += cnt.cellBeg + i18nc("@info: item properties", "Name:") + cnt.cellMid;
0575             tip += album->title() + cnt.cellEnd;
0576         }
0577 
0578         if (settings->getShowFolderTreeViewItemsCount())
0579         {
0580             tip += cnt.cellBeg + i18n("Items:") + cnt.cellMid;
0581             tip += QString::number(count) + cnt.cellEnd;
0582         }
0583 
0584         if (settings->getToolTipsShowAlbumCollection())
0585         {
0586             tip += cnt.cellBeg + i18n("Collection:") + cnt.cellMid;
0587             CollectionLocation col = CollectionManager::instance()->locationForAlbumRootId(album->albumRootId());
0588             tip += !col.isNull() ? col.label() : QString() + cnt.cellEnd;
0589         }
0590 
0591         if (settings->getToolTipsShowAlbumDate())
0592         {
0593             QDate date = album->date();
0594             str        = QLocale().toString(date, QLocale::ShortFormat);
0595             tip        += cnt.cellBeg + i18n("Date:") + cnt.cellMid + str + cnt.cellEnd;
0596         }
0597 
0598         if (settings->getToolTipsShowAlbumCategory())
0599         {
0600             str = album->category();
0601 
0602             if (str.isEmpty())
0603             {
0604                 str = QLatin1String("---");
0605             }
0606 
0607             tip += cnt.cellSpecBeg + i18n("Category:") + cnt.cellSpecMid +
0608                    cnt.breakString(str) + cnt.cellSpecEnd;
0609         }
0610 
0611         if (settings->getToolTipsShowAlbumCaption())
0612         {
0613             str = album->caption();
0614 
0615             if (str.isEmpty())
0616             {
0617                 str = QLatin1String("---");
0618             }
0619 
0620             tip += cnt.cellSpecBeg + i18nc("@info: item properties", "Caption:") + cnt.cellSpecMid +
0621                    cnt.breakString(str) + cnt.cellSpecEnd;
0622         }
0623 
0624         if (settings->getToolTipsShowAlbumPreview())
0625         {
0626             tip += cnt.cellSpecBeg + i18n("Preview:") + cnt.cellSpecMid +
0627             cnt.imageAsBase64(AlbumThumbnailLoader::instance()->getAlbumThumbnailDirectly(album).toImage()) +
0628             //cnt.imageAsBase64(AlbumThumbnailLoader::instance()->getAlbumPreviewDirectly(album, ThumbnailSize::Medium)) +
0629             cnt.cellSpecEnd;
0630         }
0631     }
0632 
0633     tip += cnt.tipFooter;
0634 
0635     return tip;
0636 }
0637 
0638 QString ToolTipFiller::filterActionTipContents(const FilterAction& action)
0639 {
0640     if (action.isNull())
0641     {
0642         return QString();
0643     }
0644 
0645     QString            str;
0646     DToolTipStyleSheet cnt(ApplicationSettings::instance()->getToolTipsFont());
0647     QString            tip = cnt.tipHeader;
0648 
0649     tip += cnt.headBeg + i18n("Filter") + cnt.headEnd;
0650 
0651     // Displayable name
0652 
0653     tip += cnt.cellBeg + i18nc("@info: item properties", "Name:") + cnt.cellMid
0654         + DImgFilterManager::instance()->i18nDisplayableName(action) + cnt.cellEnd;
0655 
0656     // Category
0657 
0658     QString reproducible = QLatin1String("---");
0659 
0660     switch (action.category())
0661     {
0662         case FilterAction::ReproducibleFilter:
0663         {
0664             reproducible = i18nc("Image filter reproducible: Yes", "Yes");
0665             break;
0666         }
0667 
0668         case FilterAction::ComplexFilter:
0669         {
0670             reproducible = i18nc("Image filter reproducible: Partially", "Partially");
0671             break;
0672         }
0673 
0674         case FilterAction::DocumentedHistory:
0675         {
0676             reproducible = i18nc("Image filter reproducible: No", "No");
0677             break;
0678         }
0679 
0680         default:
0681         {
0682             break;
0683         }
0684     };
0685 
0686     tip += cnt.cellBeg + i18n("Reproducible:") + cnt.cellMid
0687          + reproducible + cnt.cellEnd;
0688 
0689     // Description
0690 
0691     str = action.description();
0692 
0693     if (str.isEmpty())
0694     {
0695         str = QLatin1String("---");
0696     }
0697 
0698     tip += cnt.cellSpecBeg + i18nc("Image filter description", "Description:") + cnt.cellSpecMid
0699         + cnt.breakString(str) + cnt.cellSpecEnd;
0700 
0701     // Identifier + version
0702 
0703     tip += cnt.cellBeg + i18n("Identifier:") + cnt.cellMid
0704         + action.identifier() + QLatin1String(" (v") + QString::number(action.version()) + QLatin1String(") ") + cnt.cellEnd;
0705 
0706     if (action.hasParameters())
0707     {
0708         tip += cnt.headBeg + i18n("Technical Parameters") + cnt.headEnd;
0709 
0710         const QHash<QString, QVariant>& params = action.parameters();
0711         QList<QString> keys                    = params.keys();
0712         std::sort(keys.begin(), keys.end());
0713 
0714         Q_FOREACH (const QString& rootKey, keys)
0715         {
0716             QHash<QString, QVariant>::const_iterator it;
0717 
0718             for (it = params.find(rootKey) ; ((it != params.end()) && (it.key() == rootKey)) ; ++it)
0719             {
0720                 if (it.key().isEmpty() || !it.value().isValid())
0721                 {
0722                     continue;
0723                 }
0724 
0725                 if (it.key().startsWith(QLatin1String("curveData")))
0726                 {
0727                     str = i18n("<i>Binary Data</i>");
0728                 }
0729                 else
0730                 {
0731                     str = it.value().toString();
0732                 }
0733 
0734                 if (str.length() > cnt.maxStringLength)
0735                 {
0736                     str = cnt.elidedText(str, Qt::ElideRight);
0737                 }
0738 
0739                 QString key = it.key();
0740                 QChar first = key.at(0);
0741 
0742                 if (first.isLower())
0743                 {
0744                     key.replace(0, 1, first.toUpper());
0745                 }
0746 
0747                 tip += cnt.cellBeg + key + cnt.cellMid
0748                     + str + cnt.cellEnd;
0749             }
0750         }
0751     }
0752 
0753     tip += cnt.tipFooter;
0754 
0755     return tip;
0756 }
0757 
0758 } // namespace Digikam