• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

digikam

albumicongroupitem.cpp

Go to the documentation of this file.
00001 /* ============================================================
00002  *
00003  * This file is a part of digiKam project
00004  * http://www.digikam.org
00005  *
00006  * Date        : 2005-04-25
00007  * Description : implementation to render album icons group item.
00008  *
00009  * Copyright (C) 2005 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
00010  *
00011  * This program is free software; you can redistribute it
00012  * and/or modify it under the terms of the GNU General
00013  * Public License as published by the Free Software Foundation;
00014  * either version 2, or (at your option)
00015  * any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * ============================================================ */
00023 
00024 // Qt includes.
00025 
00026 #include <QPixmap>
00027 #include <QPainter>
00028 
00029 // KDE includes.
00030 
00031 #include <klocale.h>
00032 #include <kglobal.h>
00033 #include <kcalendarsystem.h>
00034 
00035 // Local includes.
00036 
00037 #include "albummanager.h"
00038 #include "album.h"
00039 #include "themeengine.h"
00040 #include "albumsettings.h"
00041 #include "albumiconview.h"
00042 #include "albumicongroupitem.h"
00043 
00044 namespace Digikam
00045 {
00046 
00047 AlbumIconGroupItem::AlbumIconGroupItem(AlbumIconView* view, int albumID)
00048                   : IconGroupItem(view), m_albumID(albumID), m_view(view)
00049 {
00050 }
00051 
00052 AlbumIconGroupItem::~AlbumIconGroupItem()
00053 {
00054 }
00055 
00056 int AlbumIconGroupItem::compare(IconGroupItem* group)
00057 {
00058     AlbumIconGroupItem* agroup = (AlbumIconGroupItem*)group;
00059 
00060     PAlbum* mine = AlbumManager::instance()->findPAlbum(m_albumID);
00061     PAlbum* his  = AlbumManager::instance()->findPAlbum(agroup->m_albumID);
00062 
00063     if (!mine || !his)
00064         return 0;
00065 
00066     const AlbumSettings *settings = m_view->settings();
00067 
00068     switch (settings->getImageSortOrder())
00069     {
00070         case(AlbumSettings::ByIName):
00071         case(AlbumSettings::ByISize):
00072         case(AlbumSettings::ByIPath):
00073         case(AlbumSettings::ByIRating):
00074         {
00075             return mine->albumPath().localeAwareCompare(his->albumPath());
00076         }
00077         case(AlbumSettings::ByIDate):
00078         {
00079             if (mine->date() < his->date())
00080                 return -1;
00081             else if (mine->date() > his->date())
00082                 return 1;
00083             else
00084                 return 0;
00085         }
00086     }
00087 
00088     return 0;
00089 }
00090 
00091 void AlbumIconGroupItem::paintBanner(QPainter *p)
00092 {
00093     AlbumManager* man = AlbumManager::instance();
00094     PAlbum* album     = man->findPAlbum(m_albumID);
00095 
00096     QString dateAndComments;
00097     QString prettyUrl;
00098 
00099     if (album)
00100     {
00101         QDate  date  = album->date();
00102 
00103         dateAndComments = i18np("%1 %2 - 1 Item", "%1 %2 - %3 Items",
00104                                 KGlobal::locale()->calendar()->monthName(date, KCalendarSystem::LongName),
00105                                 KGlobal::locale()->calendar()->year(date),
00106                                 count());
00107 
00108         if (!album->caption().isEmpty())
00109         {
00110             QString caption = album->caption();
00111             dateAndComments += " - " + caption.replace('\n', ' ');
00112         }
00113 
00114         prettyUrl = album->prettyUrl();
00115     }
00116 
00117     QRect r(0, 0, rect().width(), rect().height());
00118 
00119     p->drawPixmap(0, 0, m_view->bannerPixmap());
00120 
00121     QFont fn(m_view->font());
00122     fn.setBold(true);
00123     int fnSize = fn.pointSize();
00124     bool usePointSize;
00125     if (fnSize > 0)
00126     {
00127         fn.setPointSize(fnSize+2);
00128         usePointSize = true;
00129     }
00130     else
00131     {
00132         fnSize = fn.pixelSize();
00133         fn.setPixelSize(fnSize+2);
00134         usePointSize = false;
00135     }
00136 
00137     p->setPen(ThemeEngine::instance()->textSelColor());
00138     p->setFont(fn);
00139 
00140     QRect tr;
00141     p->drawText(5, 5, r.width(), r.height(),
00142                Qt::AlignLeft | Qt::AlignTop,
00143                prettyUrl.left(-1), &tr);
00144 
00145     r.setY(tr.height() + 2);
00146 
00147     if (usePointSize)
00148         fn.setPointSize(m_view->font().pointSize());
00149     else
00150         fn.setPixelSize(m_view->font().pixelSize());
00151 
00152     fn.setBold(false);
00153     p->setFont(fn);
00154 
00155     p->drawText(5, r.y(), r.width(), r.height(),
00156                Qt::AlignLeft | Qt::AlignVCenter, dateAndComments);
00157 }
00158 
00159 }  // namespace Digikam

digikam

Skip menu "digikam"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • digikam
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal