<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>AlbumShaper: photoPreviewWidget.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>photoPreviewWidget.cpp</h1><a href="photoPreviewWidget_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==============================================</span> <a name="l00002"></a>00002 <span class="comment">// copyright : (C) 2003-2005 by Will Stokes</span> <a name="l00003"></a>00003 <span class="comment">//==============================================</span> <a name="l00004"></a>00004 <span class="comment">// This program is free software; you can redistribute it</span> <a name="l00005"></a>00005 <span class="comment">// and/or modify it under the terms of the GNU General</span> <a name="l00006"></a>00006 <span class="comment">// Public License as published by the Free Software</span> <a name="l00007"></a>00007 <span class="comment">// Foundation; either version 2 of the License, or</span> <a name="l00008"></a>00008 <span class="comment">// (at your option) any later version.</span> <a name="l00009"></a>00009 <span class="comment">//==============================================</span> <a name="l00010"></a>00010 <a name="l00011"></a>00011 <span class="comment">//Systemwide includes</span> <a name="l00012"></a>00012 <span class="preprocessor">#include <qpixmap.h></span> <a name="l00013"></a>00013 <span class="preprocessor">#include <qstring.h></span> <a name="l00014"></a>00014 <span class="preprocessor">#include <qpainter.h></span> <a name="l00015"></a>00015 <span class="preprocessor">#include <qfontmetrics.h></span> <a name="l00016"></a>00016 <span class="preprocessor">#include <qapplication.h></span> <a name="l00017"></a>00017 <span class="preprocessor">#include <qrect.h></span> <a name="l00018"></a>00018 <span class="preprocessor">#include <qbitmap.h></span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="comment">//Projectwide includes</span> <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="photoPreviewWidget_8h.html">photoPreviewWidget.h</a>"</span> <a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="photosIconView_8h.html">photosIconView.h</a>"</span> <a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="window_8h.html">window.h</a>"</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "../config.h"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "../backend/photo.h"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "../backend/tools/guiTools.h"</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="comment">//==============================================</span> <a name="l00029"></a><a class="code" href="classPhotoPreviewWidget.html#ea4916ddf230f37c914099f522fefb4b">00029</a> <a class="code" href="classPhotoPreviewWidget.html#ea4916ddf230f37c914099f522fefb4b" title="Sets subalbum pointer.">PhotoPreviewWidget::PhotoPreviewWidget</a>( <a class="code" href="classQIconView.html">QIconView</a> *parent, <a class="code" href="classPhoto.html" title="A photo consists of a full size image, a smaller slide show image, a very small thumbnail...">Photo</a>* phto ) : <a name="l00030"></a>00030 <a class="code" href="classQIconViewItem.html">QIconViewItem</a>( parent, QString(<span class="stringliteral">""</span>), QPixmap(phto->getThumbnailFilename()) ) <a name="l00031"></a>00031 { <a name="l00032"></a>00032 <span class="comment">//initially item not moused over, set photo pointer</span> <a name="l00033"></a>00033 <a class="code" href="classPhotoPreviewWidget.html#470f63209ed369c3f9c147f11d0f11e6">mousedOver</a> = <span class="keyword">false</span>; <a name="l00034"></a>00034 this->phto = phto; <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="comment">//calibrated text width is icon width minus margin + info button size (info button is sized to be a square of height</span> <a name="l00037"></a>00037 <span class="comment">//equal to text height, aka fm.height)</span> <a name="l00038"></a>00038 QFontMetrics fm( qApp->font() ); <a name="l00039"></a>00039 <a class="code" href="classPhotoPreviewWidget.html#d2975bd54873312f3b3a799ec14d8852">calibratedWidth</a> = <a class="code" href="config_8h.html#f562473223519f4a32c8b5428c19c71e">THUMBNAIL_WIDTH</a> - <a class="code" href="photoPreviewWidget_8h.html#a85ac1cb0d23fe80344f98942a4b67b7">PHOTO_TEXT_MARGIN</a> - fm.height(); <a name="l00040"></a>00040 <a name="l00041"></a>00041 <span class="comment">//actually set the items text by clipping it using the calibration width we just computed</span> <a name="l00042"></a>00042 <a class="code" href="classPhotoPreviewWidget.html#ddb523fc7dd928131a9931b01be0f2b6">setText</a>( phto-><a class="code" href="classPhoto.html#db7ed08547098feeaff5753f2600f4bc" title="Gets the description.">getDescription</a>() ); <a name="l00043"></a>00043 <a name="l00044"></a>00044 <span class="comment">//update the items rectange which is a function of the text width, icon rect,</span> <a name="l00045"></a>00045 <span class="comment">//and margins for displaying selection and mouse over ovals</span> <a name="l00046"></a>00046 <a class="code" href="classPhotoPreviewWidget.html#1719368fda87885100c3b440be3db526">initializeItemRect</a>(); <a name="l00047"></a>00047 } <a name="l00048"></a>00048 <span class="comment">//==============================================</span> <a name="l00049"></a><a class="code" href="classPhotoPreviewWidget.html#f54da3447e6426891f5a1a40a0e3e1a7">00049</a> <a class="code" href="classPhoto.html" title="A photo consists of a full size image, a smaller slide show image, a very small thumbnail...">Photo</a>* <a class="code" href="classPhotoPreviewWidget.html#f54da3447e6426891f5a1a40a0e3e1a7" title="Returns photo pointer.">PhotoPreviewWidget::getPhoto</a>() <a name="l00050"></a>00050 { <a name="l00051"></a>00051 <span class="keywordflow">return</span> <a class="code" href="classPhotoPreviewWidget.html#482d401a94fe00a2a5bd1c2f9a999ad4" title="Pointer to photo backend object.">phto</a>; <a name="l00052"></a>00052 } <a name="l00053"></a>00053 <span class="comment">//==============================================</span> <a name="l00054"></a><a class="code" href="classPhotoPreviewWidget.html#32d90bce58cce24b83851f051dce3714">00054</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#32d90bce58cce24b83851f051dce3714" title="Update photo thumbnail from background object.">PhotoPreviewWidget::updateImage</a>() <a name="l00055"></a>00055 { <a name="l00056"></a>00056 <a class="code" href="classPhotoPreviewWidget.html#0622139cdc67fe47a5948fcf9c791b3b">setPixmap</a>( QPixmap(<a class="code" href="classPhotoPreviewWidget.html#482d401a94fe00a2a5bd1c2f9a999ad4" title="Pointer to photo backend object.">phto</a>-><a class="code" href="classPhoto.html#937a069696ef937d5ddd030b16946ded" title="Gets the thumbnail filename.">getThumbnailFilename</a>()), <span class="keyword">false</span>); <a name="l00057"></a>00057 } <a name="l00058"></a>00058 <span class="comment">//==============================================</span> <a name="l00059"></a><a class="code" href="classPhotoPreviewWidget.html#0622139cdc67fe47a5948fcf9c791b3b">00059</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#0622139cdc67fe47a5948fcf9c791b3b">PhotoPreviewWidget::setPixmap</a>(<span class="keyword">const</span> QPixmap& p, <span class="keywordtype">bool</span> redraw ) <a name="l00060"></a>00060 { <a name="l00061"></a>00061 <a class="code" href="classPhotoPreviewWidget.html#85c95ac886de95d09abfc1474153ac22" title="offsets used to center pixmap">pixmapXOffset</a> = (<a class="code" href="config_8h.html#f562473223519f4a32c8b5428c19c71e">THUMBNAIL_WIDTH</a> - p.width() ) / 2; <a name="l00062"></a>00062 <a class="code" href="classPhotoPreviewWidget.html#18e6c66b12c8f635dbf367190b090787">pixmapYOffset</a> = (<a class="code" href="config_8h.html#9a75757764d4f913469df0670d255050">THUMBNAIL_HEIGHT</a> - p.height() ) / 2; <a name="l00063"></a>00063 <a class="code" href="classPhotoPreviewWidget.html#0622139cdc67fe47a5948fcf9c791b3b">QIconViewItem::setPixmap</a>( p, redraw ); <a name="l00064"></a>00064 } <a name="l00065"></a>00065 <span class="comment">//==============================================</span> <a name="l00066"></a><a class="code" href="classPhotoPreviewWidget.html#a2645b8d8e9d18731397692dbb260137">00066</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#a2645b8d8e9d18731397692dbb260137" title="Update photo description.">PhotoPreviewWidget::updateDescription</a>() <a name="l00067"></a>00067 { <a name="l00068"></a>00068 <a class="code" href="classPhotoPreviewWidget.html#ddb523fc7dd928131a9931b01be0f2b6">setText</a>( <a class="code" href="classPhotoPreviewWidget.html#482d401a94fe00a2a5bd1c2f9a999ad4" title="Pointer to photo backend object.">phto</a>-><a class="code" href="classPhoto.html#db7ed08547098feeaff5753f2600f4bc" title="Gets the description.">getDescription</a>() ); <a name="l00069"></a>00069 } <a name="l00070"></a>00070 <span class="comment">//==============================================</span> <a name="l00071"></a><a class="code" href="classPhotoPreviewWidget.html#ddb523fc7dd928131a9931b01be0f2b6">00071</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#ddb523fc7dd928131a9931b01be0f2b6">PhotoPreviewWidget::setText</a> ( <span class="keyword">const</span> QString & text ) <a name="l00072"></a>00072 { <a name="l00073"></a>00073 <a class="code" href="classPhotoPreviewWidget.html#ddb523fc7dd928131a9931b01be0f2b6">QIconViewItem::setText</a>( <a class="code" href="guiTools_8cpp.html#a11db678e68ab73691473aa2d4ff8bfc" title="clip text to fit within numer of lines and max width">clipText</a>(text, 1, <a class="code" href="classPhotoPreviewWidget.html#d2975bd54873312f3b3a799ec14d8852">calibratedWidth</a>), <span class="keyword">false</span> ); <a name="l00074"></a>00074 } <a name="l00075"></a>00075 <span class="comment">//==============================================</span> <a name="l00076"></a><a class="code" href="classPhotoPreviewWidget.html#5a1d2b680d796a9e89eb5af1c0ad3285">00076</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#5a1d2b680d796a9e89eb5af1c0ad3285">PhotoPreviewWidget::paint</a>( QPainter *p ) <a name="l00077"></a>00077 { <a name="l00078"></a>00078 <span class="comment">//create colors</span> <a name="l00079"></a>00079 QColor offWhite( 255, 255, 255 ); <a name="l00080"></a>00080 QColor darkBlue(35, 75, 139); <a name="l00081"></a>00081 QColor paperColor; <a name="l00082"></a>00082 <a name="l00083"></a>00083 <span class="comment">//draw offwhite or selected color depending on if photo is selected</span> <a name="l00084"></a>00084 QRect paperRect( x(), y(), <a name="l00085"></a>00085 2*<a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> + pixmapRect().<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>(), <a name="l00086"></a>00086 2*<a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> + pixmapRect().<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>() + <a class="code" href="photoPreviewWidget_8h.html#a85ac1cb0d23fe80344f98942a4b67b7">PHOTO_TEXT_MARGIN</a> + textRect().<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>() ); <a name="l00087"></a>00087 <span class="keywordflow">if</span>(isSelected()) <a name="l00088"></a>00088 paperColor = darkBlue; <a name="l00089"></a>00089 <span class="keywordflow">else</span> <a name="l00090"></a>00090 paperColor = offWhite; <a name="l00091"></a>00091 p->fillRect( paperRect, QBrush( paperColor ) ); <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="comment">//paint pixmap</span> <a name="l00094"></a>00094 p->drawPixmap( x() + pixmapRect().x() + <a class="code" href="classPhotoPreviewWidget.html#85c95ac886de95d09abfc1474153ac22" title="offsets used to center pixmap">pixmapXOffset</a> + 1, <a name="l00095"></a>00095 y() + pixmapRect().y() + <a class="code" href="classPhotoPreviewWidget.html#18e6c66b12c8f635dbf367190b090787">pixmapYOffset</a> + 1, <a name="l00096"></a>00096 *pixmap()); <a name="l00097"></a>00097 <a name="l00098"></a>00098 <span class="comment">//paint text</span> <a name="l00099"></a>00099 <span class="keywordtype">int</span> align = AlignLeft | AlignTop | BreakAnywhere; <a name="l00100"></a>00100 <span class="keywordflow">if</span>(isSelected()) <a name="l00101"></a>00101 p->setPen( white ); <a name="l00102"></a>00102 <span class="keywordflow">else</span> <a name="l00103"></a>00103 p->setPen( black ); <a name="l00104"></a>00104 p->drawText( x() + textRect().x() + 1, y() + textRect().y() + 1, <a name="l00105"></a>00105 textRect().<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>(), textRect().<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>(), <a name="l00106"></a>00106 align, text() ); <a name="l00107"></a>00107 } <a name="l00108"></a>00108 <span class="comment">//==============================================</span> <a name="l00109"></a><a class="code" href="classPhotoPreviewWidget.html#cf01b867b25b67203ecf3ca72a6d5c53">00109</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#cf01b867b25b67203ecf3ca72a6d5c53" title="Repain iconview item.">PhotoPreviewWidget::paintItem</a>( QPainter* p, <span class="keyword">const</span> QColorGroup&) <a name="l00110"></a>00110 { <a name="l00111"></a>00111 <span class="comment">//resize old static buffer to new needed size, fill with widget background color</span> <a name="l00112"></a>00112 <span class="keyword">static</span> QPixmap <a class="code" href="blur_8cpp.html#fa761c0753ecc94346e155a39bd9ed9c">buffer</a>; <a name="l00113"></a>00113 QRect r = rect(); <a name="l00114"></a>00114 QSize newSize = r.size().expandedTo(buffer.size() ); <a name="l00115"></a>00115 buffer.resize(newSize); <a name="l00116"></a>00116 buffer.fill( white ); <a name="l00117"></a>00117 <a name="l00118"></a>00118 <span class="comment">//construct painter for buffer</span> <a name="l00119"></a>00119 QPainter bufferPainter(&buffer, <span class="keyword">this</span>); <a name="l00120"></a>00120 bufferPainter.translate( -r.x(), -r.y() ); <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="comment">//paint item</span> <a name="l00123"></a>00123 <a class="code" href="classPhotoPreviewWidget.html#5a1d2b680d796a9e89eb5af1c0ad3285">paint</a>(&bufferPainter); <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="comment">//paint edit button</span> <a name="l00126"></a>00126 <span class="keywordflow">if</span>(<a class="code" href="classPhotoPreviewWidget.html#470f63209ed369c3f9c147f11d0f11e6">mousedOver</a>) <a name="l00127"></a>00127 { <a name="l00128"></a>00128 QRect <a class="code" href="classPhotoPreviewWidget.html#c59e9c7026c537f86d06dd445d5e1433">photoInfoRect</a> = <a class="code" href="classPhotoPreviewWidget.html#a0a4a1da54f1ce102f3d3512afd2fb49">getPhotoInfoRect</a>(); <a name="l00129"></a>00129 bufferPainter.drawPixmap( photoInfoRect, * (((<a class="code" href="classWindow.html" title="Top level widget, encapsulates the title widget, the layout widget, and the toolbar...">Window</a>*) qApp->mainWidget())->photoInfo) ); <a name="l00130"></a>00130 } <a name="l00131"></a>00131 <a name="l00132"></a>00132 <span class="comment">//paint shadows</span> <a name="l00133"></a>00133 QPixmap* shadowBL, *shadowB, *shadowBR, *shadowR, *shadowTR; <a name="l00134"></a>00134 <a class="code" href="classWindow.html" title="Top level widget, encapsulates the title widget, the layout widget, and the toolbar...">Window</a>* window = (<a class="code" href="classWindow.html" title="Top level widget, encapsulates the title widget, the layout widget, and the toolbar...">Window</a>*) qApp->mainWidget(); <a name="l00135"></a>00135 shadowBL = window-><a class="code" href="classWindow.html#d68f87a6a1e7fdd961b9f61a6dc5b77e">shadowBL</a>; <a name="l00136"></a>00136 shadowB = window-><a class="code" href="classWindow.html#3a7de75fd4ecd6de02bb84768a477a30">shadowB</a>; <a name="l00137"></a>00137 shadowBR = window-><a class="code" href="classWindow.html#bd26badbcdfdcefe9068074ce49f2e07">shadowBR</a>; <a name="l00138"></a>00138 shadowR = window-><a class="code" href="classWindow.html#9aead52d78f783c05ccf575c957e9cc4">shadowR</a>; <a name="l00139"></a>00139 shadowTR = window-><a class="code" href="classWindow.html#20283cd11a7dd0d1ec4bd3d501d99f36">shadowTR</a>; <a name="l00140"></a>00140 <a name="l00141"></a>00141 QRect shadowRect; <a name="l00142"></a>00142 shadowRect.setLeft( x() + <a class="code" href="photoPreviewWidget_8h.html#ba57c2d0765d2249bcc18706eb86cdc4">PHOTO_SHADOW_END_OFFSET</a> ); <a name="l00143"></a>00143 shadowRect.setRight( shadowRect.left() + <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> ); <a name="l00144"></a>00144 shadowRect.setTop( y() + rect().<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>() - <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> ); <a name="l00145"></a>00145 shadowRect.setBottom( shadowRect.top() + <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> ); <a name="l00146"></a>00146 bufferPainter.drawPixmap( shadowRect, *shadowBL ); <a name="l00147"></a>00147 <a name="l00148"></a>00148 shadowRect.setLeft( shadowRect.right() + 1 ); <a name="l00149"></a>00149 shadowRect.setRight( x() + rect().<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>() - <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> - 1 ); <a name="l00150"></a>00150 bufferPainter.drawPixmap( shadowRect, *shadowB ); <a name="l00151"></a>00151 <a name="l00152"></a>00152 shadowRect.setLeft( shadowRect.right() + 1 ); <a name="l00153"></a>00153 shadowRect.setRight( shadowRect.left() + <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> ); <a name="l00154"></a>00154 bufferPainter.drawPixmap( shadowRect, *shadowBR ); <a name="l00155"></a>00155 <a name="l00156"></a>00156 shadowRect.setBottom( shadowRect.top() - 1 ); <a name="l00157"></a>00157 shadowRect.setTop( y() +<a class="code" href="photoPreviewWidget_8h.html#ba57c2d0765d2249bcc18706eb86cdc4">PHOTO_SHADOW_END_OFFSET</a> + <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> ); <a name="l00158"></a>00158 bufferPainter.drawPixmap( shadowRect, *shadowR ); <a name="l00159"></a>00159 <a name="l00160"></a>00160 shadowRect.setBottom( shadowRect.top() - 1 ); <a name="l00161"></a>00161 shadowRect.setTop( y() +<a class="code" href="photoPreviewWidget_8h.html#ba57c2d0765d2249bcc18706eb86cdc4">PHOTO_SHADOW_END_OFFSET</a> ); <a name="l00162"></a>00162 bufferPainter.drawPixmap( shadowRect, *shadowTR ); <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="comment">//draw buffer to screen</span> <a name="l00165"></a>00165 p->drawPixmap( x(), y(), buffer ); <a name="l00166"></a>00166 } <a name="l00167"></a>00167 <span class="comment">//==============================================</span> <a name="l00168"></a><a class="code" href="classPhotoPreviewWidget.html#d40116f02fe920262585aefcd929f7eb">00168</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#d40116f02fe920262585aefcd929f7eb">PhotoPreviewWidget::paintFocus</a>( QPainter*, <span class="keyword">const</span> QColorGroup& ) { } <a name="l00169"></a>00169 <span class="comment">//==============================================</span> <a name="l00170"></a><a class="code" href="classPhotoPreviewWidget.html#4e56de1e3bb4b7ce970a89d26d31a593">00170</a> <span class="keywordtype">bool</span> <a class="code" href="classPhotoPreviewWidget.html#4e56de1e3bb4b7ce970a89d26d31a593">PhotoPreviewWidget::acceptDrop</a>( <span class="keyword">const</span> QMimeSource *)<span class="keyword"> const</span> <a name="l00171"></a>00171 <span class="keyword"></span>{ <a name="l00172"></a>00172 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <span class="comment">//==============================================</span> <a name="l00175"></a><a class="code" href="classPhotoPreviewWidget.html#f22bb482f3ff13f026e350950d2cd07d">00175</a> <span class="keywordtype">int</span> <a class="code" href="classPhotoPreviewWidget.html#f22bb482f3ff13f026e350950d2cd07d">PhotoPreviewWidget::compare</a> ( <a class="code" href="classQIconViewItem.html">QIconViewItem</a> * i )<span class="keyword"> const</span> <a name="l00176"></a>00176 <span class="keyword"></span>{ <a name="l00177"></a>00177 <span class="keywordflow">if</span>( pos().y() > (i->pos().y() + <a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>()) || <a name="l00178"></a>00178 ( <a name="l00179"></a>00179 pos().y() >= i->pos().y() && <a name="l00180"></a>00180 pos().x() >= i->pos().x() <a name="l00181"></a>00181 )) <a name="l00182"></a>00182 { <span class="keywordflow">return</span> 1; } <a name="l00183"></a>00183 <span class="keywordflow">else</span> <a name="l00184"></a>00184 { <span class="keywordflow">return</span> -1; } <a name="l00185"></a>00185 } <a name="l00186"></a>00186 <span class="comment">//==============================================</span> <a name="l00187"></a><a class="code" href="classPhotoPreviewWidget.html#1719368fda87885100c3b440be3db526">00187</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#1719368fda87885100c3b440be3db526">PhotoPreviewWidget::initializeItemRect</a>() <a name="l00188"></a>00188 { <a name="l00189"></a>00189 <span class="comment">//set pixmap rect to be offset slightly from top left corner (by photo margin)</span> <a name="l00190"></a>00190 QRect pr = pixmapRect(); <a name="l00191"></a>00191 <span class="keywordtype">int</span> itemLeft = x(); <a name="l00192"></a>00192 <span class="keywordtype">int</span> itemTop = y(); <a name="l00193"></a>00193 <a name="l00194"></a>00194 <a class="code" href="classPhotoPreviewWidget.html#85c95ac886de95d09abfc1474153ac22" title="offsets used to center pixmap">pixmapXOffset</a> = (<a class="code" href="config_8h.html#f562473223519f4a32c8b5428c19c71e">THUMBNAIL_WIDTH</a> - pixmap()->width() ) / 2; <a name="l00195"></a>00195 <a class="code" href="classPhotoPreviewWidget.html#18e6c66b12c8f635dbf367190b090787">pixmapYOffset</a> = (<a class="code" href="config_8h.html#9a75757764d4f913469df0670d255050">THUMBNAIL_HEIGHT</a> - pixmap()->height() ) / 2; <a name="l00196"></a>00196 <a name="l00197"></a>00197 pr.setLeft( x() + <a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> ); <a name="l00198"></a>00198 pr.setRight( pr.left() + <a class="code" href="config_8h.html#f562473223519f4a32c8b5428c19c71e">THUMBNAIL_WIDTH</a> ); <a name="l00199"></a>00199 pr.setTop( y() + <a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> ); <a name="l00200"></a>00200 pr.setBottom( pr.top() + <a class="code" href="config_8h.html#9a75757764d4f913469df0670d255050">THUMBNAIL_HEIGHT</a> ); <a name="l00201"></a>00201 setPixmapRect( pr ); <a name="l00202"></a>00202 <a name="l00203"></a>00203 <span class="comment">//move text rect to be below new pixmap region.</span> <a name="l00204"></a>00204 <span class="comment">//reset height to allow for up to 3 lines of text.</span> <a name="l00205"></a>00205 QFontMetrics fm( qApp->font() ); <a name="l00206"></a>00206 QRect tr = QRect(); <a name="l00207"></a>00207 tr.setLeft( x() + <a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> ); <a name="l00208"></a>00208 tr.setRight( tr.left() +<a class="code" href="config_8h.html#f562473223519f4a32c8b5428c19c71e">THUMBNAIL_WIDTH</a> ); <a name="l00209"></a>00209 tr.setTop( y() + <a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> + <a class="code" href="config_8h.html#9a75757764d4f913469df0670d255050">THUMBNAIL_HEIGHT</a> + <a class="code" href="photoPreviewWidget_8h.html#a85ac1cb0d23fe80344f98942a4b67b7">PHOTO_TEXT_MARGIN</a> ); <a name="l00210"></a>00210 tr.setBottom( tr.top() + 0*fm.leading() + 1*fm.height() ); <a name="l00211"></a>00211 setTextRect( tr ); <a name="l00212"></a>00212 <a name="l00213"></a>00213 <span class="comment">//set overall item rect</span> <a name="l00214"></a>00214 <span class="keywordtype">int</span> itemW = <a class="code" href="config_8h.html#f562473223519f4a32c8b5428c19c71e">THUMBNAIL_WIDTH</a> + 2*<a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> + <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a>; <a name="l00215"></a>00215 <span class="keywordtype">int</span> itemH = <a class="code" href="config_8h.html#9a75757764d4f913469df0670d255050">THUMBNAIL_HEIGHT</a> + <a class="code" href="photoPreviewWidget_8h.html#a85ac1cb0d23fe80344f98942a4b67b7">PHOTO_TEXT_MARGIN</a> + textRect().height() + 2*<a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> + PHOTO_SHADOW; <a name="l00216"></a>00216 setItemRect( QRect( itemLeft, itemTop, itemW, itemH ) ); <a name="l00217"></a>00217 } <a name="l00218"></a>00218 <span class="comment">//==============================================</span> <a name="l00219"></a><a class="code" href="classPhotoPreviewWidget.html#81806a5a36fa6fbae947dd1aa2f09210">00219</a> <span class="keywordtype">void</span> <a class="code" href="classPhotoPreviewWidget.html#81806a5a36fa6fbae947dd1aa2f09210">PhotoPreviewWidget::setMousedOver</a>(<span class="keywordtype">bool</span> val) <a name="l00220"></a>00220 { <a name="l00221"></a>00221 <a class="code" href="classPhotoPreviewWidget.html#470f63209ed369c3f9c147f11d0f11e6">mousedOver</a> = val; <a name="l00222"></a>00222 } <a name="l00223"></a>00223 <span class="comment">//==============================================</span> <a name="l00224"></a><a class="code" href="classPhotoPreviewWidget.html#a0a4a1da54f1ce102f3d3512afd2fb49">00224</a> QRect <a class="code" href="classPhotoPreviewWidget.html#a0a4a1da54f1ce102f3d3512afd2fb49">PhotoPreviewWidget::getPhotoInfoRect</a>() <a name="l00225"></a>00225 { <a name="l00226"></a>00226 QRect <a class="code" href="classPhotoPreviewWidget.html#c59e9c7026c537f86d06dd445d5e1433">photoInfoRect</a>; <a name="l00227"></a>00227 QFontMetrics fm( qApp->font() ); <a name="l00228"></a>00228 photoInfoRect.setLeft( x() + rect().<a class="code" href="blur_8cpp.html#2474a5474cbff19523a51eb1de01cda4">width</a>() - fm.height() - <a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> - <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> - 1 ); <a name="l00229"></a>00229 photoInfoRect.setRight( photoInfoRect.left() + fm.height() ); <a name="l00230"></a>00230 photoInfoRect.setTop( y() + rect().<a class="code" href="blur_8cpp.html#d12fc34ce789bce6c8a05d8a17138534">height</a>() - fm.height() - <a class="code" href="photoPreviewWidget_8h.html#51af35a52d737b53581977578ece2eb2">PHOTO_MARGIN</a> - <a class="code" href="photoPreviewWidget_8h.html#10c8bd04b47d651b52518b055a9154bd">PHOTO_SHADOW</a> - 1 ); <a name="l00231"></a>00231 photoInfoRect.setBottom( photoInfoRect.top() + fm.height() ); <a name="l00232"></a>00232 <span class="keywordflow">return</span> photoInfoRect; <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <span class="comment">//==============================================</span> <a name="l00235"></a><a class="code" href="classPhotoPreviewWidget.html#fdd4a5baee26b0cb4f12fee37a165263">00235</a> QPoint <a class="code" href="classPhotoPreviewWidget.html#fdd4a5baee26b0cb4f12fee37a165263">PhotoPreviewWidget::getPhotoPos</a>() <a name="l00236"></a>00236 { <a name="l00237"></a>00237 <span class="comment">//get widget coordiantes of item</span> <a name="l00238"></a>00238 <span class="keywordtype">int</span> xpos,ypos; <a name="l00239"></a>00239 xpos = x() + pixmapRect().x() + <a class="code" href="classPhotoPreviewWidget.html#85c95ac886de95d09abfc1474153ac22" title="offsets used to center pixmap">pixmapXOffset</a> + 1; <a name="l00240"></a>00240 ypos = y() + pixmapRect().y() + <a class="code" href="classPhotoPreviewWidget.html#18e6c66b12c8f635dbf367190b090787">pixmapYOffset</a> + 1; <a name="l00241"></a>00241 <a name="l00242"></a>00242 <span class="comment">//shift by scrolled amount</span> <a name="l00243"></a>00243 xpos-= iconView()->contentsX(); <a name="l00244"></a>00244 ypos-= iconView()->contentsY(); <a name="l00245"></a>00245 <a name="l00246"></a>00246 <span class="comment">//offset by viewport top left</span> <a name="l00247"></a>00247 <span class="comment">//(why not iconview topleft? item actually placed in viewport which is placed in iconview. this</span> <a name="l00248"></a>00248 <span class="comment">//viewport can be offset (and when I wrote this code it was) from the iconview depending on Trolltech's</span> <a name="l00249"></a>00249 <span class="comment">//scrollview code which can using spacing between the viewport and scrolls widgets. since the viewport</span> <a name="l00250"></a>00250 <span class="comment">//is a full blown widget, we can figure out it's reall screen coordinates and need not consult the iconview object at all.</span> <a name="l00251"></a>00251 QPoint viewportTL = iconView()->viewport()->mapToGlobal( QPoint(0,0) ); <a name="l00252"></a>00252 xpos+= viewportTL.x(); <a name="l00253"></a>00253 ypos+= viewportTL.y(); <a name="l00254"></a>00254 <a name="l00255"></a>00255 <span class="keywordflow">return</span> QPoint(xpos,ypos); <a name="l00256"></a>00256 } <a name="l00257"></a>00257 <span class="comment">//==============================================</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 23 02:34:26 2009 for AlbumShaper by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> </body> </html>