15 #include <q3iconview.h> 16 #include <qfontmetrics.h> 17 #include <qapplication.h> 20 #include <Q3ValueList> 25 #include "../backend/subalbum.h" 26 #include "../backend/photo.h" 27 #include "../backend/tools/imageTools.h" 32 #include "../backend/tools/guiTools.h" 34 #include "../backend/album.h" 39 clipText( salbum->getName(), 2, parent->getTextWidth()),
40 *salbum->getRepresentativeImage(
MEDIUM) )
64 QColor lightLightBlue( 152, 180, 226 );
65 QColor darkLightBlue(193, 210, 238);
66 QColor darkBlue(35, 75, 139);
67 QColor background = darkLightBlue;
72 QSize newSize = r.size().expandedTo(buffer.size() );
73 buffer.resize(newSize);
74 buffer.fill( background );
77 QPainter bufferPainter(&buffer);
78 bufferPainter.translate( -r.x(), -r.y() );
81 bufferPainter.setClipping(
false);
84 bool paintRect =
false;
86 if(isSelected()) { paintColor = darkBlue; paintRect =
true; }
87 else if(
mousedOver) { paintColor = lightLightBlue; paintRect =
true; }
96 r2.setLeft( r.left() + 4);
97 r2.setRight( r.right() - 4);
99 r2.setBottom( r.bottom() );
100 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40 ) );
102 r2.setLeft( r2.left() + 1);
103 r2.setRight( r2.right() - 1);
104 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67 ) );
107 r2.setLeft( r2.left() - 3);
108 r2.setRight( r2.right() + 3);
109 r2.setTop( r2.top() + 1 );
110 r2.setBottom( r2.bottom() - 1);
111 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40 ) );
113 r2.setLeft( r2.left() + 1);
114 r2.setRight( r2.right() - 1);
115 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67 ) );
118 r2.setLeft( r2.left() - 2);
119 r2.setRight( r2.right() + 2);
120 r2.setTop( r2.top() + 1 );
121 r2.setBottom( r2.bottom() - 1);
122 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40) );
124 r2.setTop( r2.top() + 1);
125 r2.setBottom( r2.bottom() - 1);
126 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67) );
129 r2.setLeft( r2.left() - 1 );
130 r2.setRight( r2.right() + 1 );
131 r2.setTop( r2.top() + 1);
132 r2.setBottom( r2.bottom() - 1);
133 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.40) );
135 r2.setTop( r2.top() + 1);
136 r2.setBottom( r2.bottom() - 1);
137 bufferPainter.fillRect( r2,
blendColors( paintColor, background, 0.67) );
141 r2.setLeft( r.left() + 1);
142 r2.setRight( r.right() - 1);
143 r2.setTop( r.top() + 4 );
144 r2.setBottom( r.bottom() - 4);
145 bufferPainter.fillRect( r2, paintColor );
147 r2.setLeft( r2.left() + 1);
148 r2.setRight( r2.right() - 1);
149 r2.setTop( r2.top() - 2 );
150 r2.setBottom( r2.bottom() + 2 );
151 bufferPainter.fillRect( r2, paintColor );
153 r2.setLeft( r2.left() + 2);
154 r2.setRight( r2.right() - 2);
155 r2.setTop( r2.top() - 1 );
156 r2.setBottom( r2.bottom() + 1 );
157 bufferPainter.fillRect( r2, paintColor );
161 bufferPainter.drawPixmap( x()+4 , y() + 4, *pixmap());
164 int align = Qt::AlignLeft | Qt::AlignTop | Qt::TextWrapAnywhere;
166 bufferPainter.setPen( Qt::white );
168 bufferPainter.setPen( Qt::black );
169 bufferPainter.drawText( x() + 4 + pixmapRect().
width(),
175 p->drawPixmap( x(), y(), buffer );
181 if(e->source() == NULL)
187 if(e->source()->parentWidget() ==
parent)
189 if(e->pos().y() < (y() + (
height()/2)))
191 parent->currentItem()->move(x(), y() - 1);
195 parent->currentItem()->move(x(), y() + (
height()/2) + 1);
207 e->source()->parentWidget() ==
218 while(current != NULL)
221 if(current->isSelected())
234 current = current->nextItem();
239 current = current->nextItem();
244 oldSubalbumWidget->
getPhotos()->arrangeItemsInGrid();
256 if(pos().y() >= i->pos().y())
265 QImage icon(imageName);
273 QFontMetrics fm( qApp->font() );
276 int idealImageHeight = fm.leading() + 2*fm.height();
279 int idealImageWidth = (4 * idealImageHeight ) / 3;
282 int actualImageWidth = 0;
283 int actualImageHeight = 0;
285 idealImageWidth, idealImageHeight,
286 actualImageWidth, actualImageHeight );
289 if(actualImageHeight == idealImageHeight - 1)
291 actualImageHeight = idealImageHeight;
294 QImage scaledIcon= icon.smoothScale( actualImageWidth, actualImageHeight );
295 QImage* paddedScaledIcon =
new QImage(idealImageWidth, idealImageHeight, scaledIcon.depth());
296 paddedScaledIcon->setAlphaBuffer(
true);
300 for(x=0; x< idealImageWidth; x++)
302 for(y=0; y<idealImageHeight; y++)
304 paddedScaledIcon->setPixel(x,y, qRgba(255, 255, 255,0) );
309 int xDiff = idealImageWidth - actualImageWidth;
310 int yDiff = idealImageHeight - actualImageHeight;
312 for(x= xDiff/2; x < (xDiff/2) + actualImageWidth; x++)
315 for(y= yDiff/2; y < (yDiff/2) + actualImageHeight; y++)
317 paddedScaledIcon->setPixel(x, y, scaledIcon.pixel(x2, y2));
326 paddedScaledIcon->setPixel(0, 0, qRgba(255, 0,0,0) );
327 paddedScaledIcon->setPixel(idealImageWidth-1, 0, qRgba(255, 0,0,0) );
328 paddedScaledIcon->setPixel(0, idealImageHeight-1, qRgba(255, 0,0,0) );
329 paddedScaledIcon->setPixel(idealImageWidth-1, idealImageHeight-1, qRgba(255, 0,0,0) );
332 QPixmap* padddedScaledPix =
new QPixmap( paddedScaledIcon->width(), paddedScaledIcon->height() );
333 padddedScaledPix->convertFromImage( *paddedScaledIcon );
334 delete paddedScaledIcon;
335 return padddedScaledPix;
342 Q3IconViewItem::calcRect( text_ );
351 QRect pr = pixmapRect();
352 int prWidth = pr.width();
353 int prHeight = pr.height();
354 pr.setTopLeft( QPoint(3,3) );
355 pr.setBottomRight( QPoint(pr.left()+prWidth, pr.top()+prHeight) );
360 QRect tr = textRect();
361 tr.setTop( pixmapRect().top() );
362 tr.setBottom( pixmapRect().bottom() );
363 tr.setLeft( pixmapRect().right() + 2 );
364 tr.setRight( tr.left() + textWidth );
368 int itemW = 3 + pixmapRect().width() + (tr.left() - pr.right()) + textRect().width() + 3;
369 int itemH = 3 + pixmapRect().height() + 3;
370 setItemRect( QRect( pixmapRect().left() - 3, pixmapRect().top() - 3, itemW, itemH ) );
385 double alpha2 = 1-alpha;
386 return QColor( (
int)(alpha*a.red() + alpha2*b.red()),
387 (
int)(alpha*a.green() + alpha2*b.green()),
388 (
int)(alpha*a.blue() + alpha2*b.blue()) );
bool addPhoto(QString fileName, bool replaceDescription=false, Photo *newPhoto=NULL)
Adds a new photo to the Subalbum and appends it to the end, returns TRUE if successful.
A photo consists of a full size image, a smaller slide show image, a very small thumbnail image...
Extension of iconview, used to list all subalbums in album. Supports drag-n-drop within iconview such...
A subalbum contains photos.
void photoMoved(Photo *val)
Removes a specified photo without deleting the object.