digikam
albumiconviewtooltip.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 : 2008-12-10 00007 * Description : album icon view tool tip 00008 * 00009 * Copyright (C) 2008-2009 by Gilles Caulier <caulier dot gilles at gmail dot com> 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 #include "albumiconviewtooltip.h" 00025 00026 // Qt includes 00027 00028 #include <QPixmap> 00029 #include <QPainter> 00030 #include <QTextDocument> 00031 #include <QDateTime> 00032 00033 // KDE includes 00034 00035 00036 #include <klocale.h> 00037 #include <kfileitem.h> 00038 #include <kglobal.h> 00039 #include <kdeversion.h> 00040 00041 // Local includes 00042 00043 #include "albumiconview.h" 00044 #include "albumiconitem.h" 00045 #include "albumsettings.h" 00046 #include "tooltipfiller.h" 00047 00048 namespace Digikam 00049 { 00050 00051 class AlbumIconViewToolTipPriv 00052 { 00053 public: 00054 00055 AlbumIconViewToolTipPriv() 00056 { 00057 view = 0; 00058 iconItem = 0; 00059 } 00060 00061 AlbumIconView *view; 00062 00063 AlbumIconItem *iconItem; 00064 }; 00065 00066 AlbumIconViewToolTip::AlbumIconViewToolTip(AlbumIconView* view) 00067 : DItemToolTip(), d(new AlbumIconViewToolTipPriv) 00068 { 00069 d->view = view; 00070 } 00071 00072 AlbumIconViewToolTip::~AlbumIconViewToolTip() 00073 { 00074 delete d; 00075 } 00076 00077 void AlbumIconViewToolTip::setIconItem(AlbumIconItem* iconItem) 00078 { 00079 d->iconItem = iconItem; 00080 00081 if (!d->iconItem || 00082 !AlbumSettings::instance()->showToolTipsIsValid()) 00083 { 00084 hide(); 00085 } 00086 else 00087 { 00088 updateToolTip(); 00089 reposition(); 00090 if (isHidden() && !toolTipIsEmpty()) 00091 show(); 00092 } 00093 } 00094 00095 QRect AlbumIconViewToolTip::repositionRect() 00096 { 00097 if (!d->iconItem) return QRect(); 00098 00099 QRect rect = d->iconItem->clickToOpenRect(); 00100 rect.moveTopLeft(d->view->contentsToViewport(rect.topLeft())); 00101 rect.moveTopLeft(d->view->viewport()->mapToGlobal(rect.topLeft())); 00102 return rect; 00103 } 00104 00105 QString AlbumIconViewToolTip::tipContents() 00106 { 00107 if (!d->iconItem) return QString(); 00108 ImageInfo info = d->iconItem->imageInfo(); 00109 return ToolTipFiller::imageInfoTipContents(info); 00110 } 00111 00112 } // namespace Digikam
KDE 4.4 API Reference