14 #include <q3popupmenu.h> 16 #include <qapplication.h> 17 #include <qstringlist.h> 19 #include <q3dragobject.h> 20 #include <qstringlist.h> 22 #include <QContextMenuEvent> 24 #include <QMouseEvent> 34 #include "../config.h" 35 #include "../backend/photo.h" 36 #include "../backend/album.h" 37 #include "../configuration/configuration.h" 47 virtual bool drag(DragMode mode)
48 {
return Q3DragObject::drag( Q3DragObject::DragCopy ); }
53 viewport()->setBackgroundMode( Qt::NoBackground );
74 connect(
this, SIGNAL(onViewport()),
89 Q3IconDrag *drag =
new Q3IconDrag( viewport() );
117 bool &posIsleftOfItem )
120 if ( firstItem() == NULL )
128 if( !item->isSelected() && item->contains(pos) )
130 (*nearestItem) = item;
131 posIsleftOfItem = pos.x() < item->x() + (item->width()/2);
135 item = item->nextItem();
142 while( item != NULL && item->isSelected() )
143 { item = item->prevItem(); }
146 if( item != NULL && pos.y() > (item->y() + item->height()) )
148 (*nearestItem) = item;
149 posIsleftOfItem =
false;
157 while( item != NULL && item->isSelected() )
158 { item = item->nextItem(); }
161 if( item != NULL && pos.y() < item->y() )
163 (*nearestItem) = item;
164 posIsleftOfItem =
true;
170 for(x = pos.x()-1; x>=0; x--)
172 item = findItem( QPoint(x, pos.y()) );
173 if( item == NULL || item->isSelected() )
continue;
176 (*nearestItem) = item;
177 posIsleftOfItem =
false;
182 for(x = pos.x()+1; x<
width(); x++)
184 item = findItem( QPoint(x, pos.y()) );
185 if( item == NULL || item->isSelected() )
continue;
188 (*nearestItem) = item;
189 posIsleftOfItem =
true;
206 int itemWidth = firstItem()->width();
207 int itemHeight = firstItem()->height();
209 for(y = pos.y()-(itemHeight/2); y >= 0; y-=(itemHeight/2) )
211 for(x =
width(); x >= 0; x-=(itemWidth/2))
213 item = findItem( QPoint(x, y) );
214 if( item == NULL || item->isSelected() ) {
continue; }
217 (*nearestItem) = item;
218 posIsleftOfItem =
false;
230 Q3IconView::contentsDropEvent( e );
233 if(e->source() == viewport() )
250 while(current != NULL)
252 if(current->isSelected()) { num++; }
253 current = current->nextItem();
257 int xpos = item->x() - num;
258 current = firstItem();
259 while(current != NULL)
261 if(current->isSelected())
263 current->move(xpos, item->y());
266 current = current->nextItem();
273 int xpos = item->x() + (item->width()/2) + 1;
275 while(current != NULL)
277 if(current->isSelected())
279 current->move(xpos, item->y());
282 current = current->nextItem();
292 QStringList fileNames;
293 if( Q3UriDrag::decodeLocalFiles( e, fileNames ) )
309 while(current != NULL)
311 if(current->isSelected())
313 current = current->nextItem();
324 Q3PopupMenu contextMenu(
this );
326 contextMenu.insertItem( QIcon( QPixmap(QString(
IMAGE_PATH)+
"menuIcons/setAlbumImage.png") ),
329 contextMenu.insertItem( QIcon( QPixmap(QString(
IMAGE_PATH)+
"menuIcons/setSubalbumImage.png") ),
332 contextMenu.exec( QPoint(e->globalX(), e->globalY()) );
351 p->fillRect( r, brush );
359 int xOffset = clipx - contentsX();
360 int yOffset = clipy - contentsY();
362 bufferPainter.translate( -contentsX(), -contentsY() );
363 Q3IconView::drawContents( &bufferPainter, clipx, clipy, clipw, cliph );
364 bitBlt(p->device(), xOffset, yOffset, &
bufferPixmap, xOffset, yOffset, clipw, cliph );
373 if(pseudoSelection != NULL)
387 if( findItem( viewport()->mapFromGlobal( QCursor::pos() )+=QPoint( contentsX(), contentsY() ) ) ==
currentPseudoSelection )
409 infoButtonRec.moveBy( -contentsX(), -contentsY() );
412 QPoint
topLeft = mapToGlobal( QPoint(0,0) );
413 infoButtonRec.moveBy( topLeft.x(), topLeft.y() );
416 if( infoButtonRec.contains( point.x(), point.y() ) )
421 qApp->processEvents();
427 ((
Window*)qApp->mainWidget())->getConfig()->getBool(
"layout",
"animation" ) );
434 Q3IconView::contentsMousePressEvent( e );
439 Q3IconView::contentsMouseMoveEvent( e );
446 setCursor( QCursor( Qt::ArrowCursor ) );
457 setCursor( QCursor( Qt::PointingHandCursor ) );
465 setCursor( QCursor( Qt::ArrowCursor ) );
486 (
"layout",
"animation" ) );
495 if( e->state() & Qt::ControlModifier &&
numSelected() > 0)
500 if(e->state() & Qt::ControlModifier &&
numSelected() > 0)
509 Q3IconView::keyPressEvent(e);
void contentsMouseMoveEvent(QMouseEvent *e)
void contentsMousePressEvent(QMouseEvent *e)
void contentsDropEvent(QDropEvent *e)
void addPhotos(QStringList)
virtual bool drag(DragMode mode)
force all drags to COPY (not move/delete) original files!!!
QPixmap * backgroundImage
PhotoDescEdit * curPhotoDescEdit
void rotate270SelectedPhotos()
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget...
void repaintGroup(Q3IconViewItem *pseudoSelection)
void contextMenuEvent(QContextMenuEvent *e)
PhotosIconView(QWidget *parent)
Q3DragObject * dragObject()
void keyPressEvent(QKeyEvent *e)
void drawBackground(QPainter *p, const QRect &r)
void clearPseudoSelection()
PhotoDrag(QWidget *dragSource=0, const char *name=0)
bool findNearestUnselectedPhoto(const QPoint &pos, Q3IconViewItem **nearestItem, bool &posIsleftOfItem)
void rotate90SelectedPhotos()
void captureClick(Q3IconViewItem *, const QPoint &)
void removeSelectedPhotos()
PhotoPreviewWidget * currentPseudoSelection
void drawContents(QPainter *p, int clipx, int clipy, int clipw, int cliph)
PhotoPreviewWidget * rightClickedPhoto