Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

SubalbumsIconView Class Reference

#include <subalbumsIconView.h>

Inheritance diagram for SubalbumsIconView:

[legend]
Collaboration diagram for SubalbumsIconView:
[legend]
List of all members.

Detailed Description

Extension of iconview, used to list all subalbums in album. Supports drag-n-drop within iconview such that subalbums can be reordered, as well as dropping photos from subalbums to allow photos to be moved from one subalbum to another.

Definition at line 31 of file subalbumsIconView.h.

Signals

void itemHasMoved ()

Public Member Functions

 SubalbumsIconView (QWidget *parent)
int getTextWidth ()
QSize minimumSizeHint () const
QSize sizeHint () const

Protected Member Functions

void drawContents (QPainter *p, int clipx, int clipy, int clipw, int cliph)
QDragObject * dragObject ()
void contentsMousePressEvent (QMouseEvent *e)
void contentsDragMoveEvent (QDragMoveEvent *e)

Private Slots

void repaintGroup (QIconViewItem *pseudoSelection)
void clearPseudoSelection ()

Private Member Functions

void contentsDropEvent (QDropEvent *e)

Private Attributes

QPixmap bufferPixmap
QPoint dragStartPos
SubalbumPreviewWidgetcurrentPseudoSelection
int textWidth


Constructor & Destructor Documentation

SubalbumsIconView::SubalbumsIconView QWidget parent  ) 
 

Definition at line 28 of file subalbumsIconView.cpp.

References clearPseudoSelection(), currentPseudoSelection, repaintGroup(), SubalbumsIconView(), and textWidth.

Referenced by SubalbumsIconView().

00028 : QIconView( parent ) 00029 { 00030 // setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum); 00031 setMouseTracking(true); 00032 00033 currentPseudoSelection = NULL; 00034 00035 //connect mouse over events to paint pseudo selection in ligher blue 00036 connect( this, SIGNAL(onItem(QIconViewItem*)), 00037 this, SLOT(repaintGroup(QIconViewItem*)) ); 00038 00039 //clear any pseudo selection when mouse moves off icons 00040 connect( this, SIGNAL(onViewport()), 00041 this, SLOT(clearPseudoSelection()) ); 00042 00043 //compute textWidth for collection names using a calibration string 00044 QString calibrationString( qApp->translate("SubalbumPreviewWidget", "Calibration String") ); 00045 QFontMetrics fm( qApp->font() ); 00046 textWidth = fm.width( calibrationString ); 00047 }


Member Function Documentation

void SubalbumsIconView::clearPseudoSelection  )  [private, slot]
 

Definition at line 167 of file subalbumsIconView.cpp.

References currentPseudoSelection, and SubalbumPreviewWidget::setMousedOver().

Referenced by repaintGroup(), and SubalbumsIconView().

00168 { 00169 //if old pseudo selection unselect it 00170 if(currentPseudoSelection != NULL) 00171 { 00172 currentPseudoSelection->setMousedOver(false); 00173 repaintItem(currentPseudoSelection); 00174 currentPseudoSelection = NULL; 00175 } 00176 }

void SubalbumsIconView::contentsDragMoveEvent QDragMoveEvent *  e  )  [protected]
 

Definition at line 111 of file subalbumsIconView.cpp.

References contentsDragMoveEvent(), currentPseudoSelection, and SubalbumPreviewWidget::setMousedOver().

Referenced by contentsDragMoveEvent().

00112 { 00113 QIconView::contentsDragMoveEvent( e ); 00114 e->accept(true); 00115 00116 //if source of drag is not from application then return 00117 if(e->source() == NULL) 00118 return; 00119 00120 //if source of drag is from within this view then return, in the future we'll put 00121 //drag code in here to drag indicators for rearranging the items of the iconview 00122 if(e->source() == viewport() ) 00123 { 00124 00125 } 00126 //else if source is from photos iconview 00127 else if(e->source()->parentWidget() == ((LayoutWidget*)parentWidget()->parentWidget())->getSubalbum()->getPhotos() ) 00128 { 00129 SubalbumPreviewWidget* item = (SubalbumPreviewWidget*)findItem( e->pos() ); 00130 00131 //if item pointer same as current pseudo selection ignore 00132 if(item == currentPseudoSelection) 00133 { 00134 return; 00135 } 00136 00137 //unpaint old selection 00138 if(currentPseudoSelection != NULL) 00139 { 00140 currentPseudoSelection->setMousedOver(false); 00141 repaintItem(currentPseudoSelection); 00142 } 00143 00144 //set new selection 00145 currentPseudoSelection = item; 00146 00147 //repaint new selection 00148 if(currentPseudoSelection != NULL) 00149 { 00150 currentPseudoSelection->setMousedOver(true); 00151 repaintItem(currentPseudoSelection); 00152 } 00153 } 00154 }

void SubalbumsIconView::contentsDropEvent QDropEvent *  e  )  [private]
 

Definition at line 49 of file subalbumsIconView.cpp.

References contentsDropEvent(), and itemHasMoved().

Referenced by contentsDropEvent().

00050 { 00051 QIconView::contentsDropEvent( e ); 00052 00053 //if drop originated from this viewport then emit item moved signal 00054 if(e->source() == viewport() ) 00055 emit itemHasMoved(); 00056 }

void SubalbumsIconView::contentsMousePressEvent QMouseEvent *  e  )  [protected]
 

Definition at line 71 of file subalbumsIconView.cpp.

References contentsMousePressEvent(), and dragStartPos.

Referenced by contentsMousePressEvent().

00072 { 00073 //ignore all clicks other than left-clicks 00074 if( e->button() != Qt::LeftButton ) return; 00075 00076 dragStartPos = e->pos(); 00077 QIconView::contentsMousePressEvent( e ); 00078 }

QDragObject * SubalbumsIconView::dragObject  )  [protected]
 

Definition at line 80 of file subalbumsIconView.cpp.

References buffer, and dragStartPos.

00081 { 00082 //no item selected? 00083 if( !currentItem() ) 00084 return 0; 00085 00086 //create drag object 00087 QIconDrag *drag = new QIconDrag( viewport() ); 00088 00089 //create buffer and paint item to buffer 00090 QRect r = currentItem()->rect(); 00091 QPixmap buffer( r.width(), r.height() ); 00092 QPainter painter( &buffer, this ); 00093 painter.translate( -r.x(), -r.y() ); 00094 ((SubalbumPreviewWidget*)currentItem())->paint( &painter ); 00095 00096 //clip off background color around edges which was used for anti-aliasing edges. 00097 //result image will have semi-selection oval around it. 00098 QBitmap bit = buffer.createHeuristicMask(); 00099 buffer.setMask( bit ); 00100 00101 //set pixmap to use buffer 00102 drag->setPixmap( buffer, QPoint( dragStartPos.x() - r.x(), dragStartPos.y() - r.y() ) ); 00103 00104 //we don't want to show any rectangles, but if we don't append two null rectangles the last drag rectangles this iconview displayed 00105 //possibly form objects dropped onto it from outside the viewport, aka photos, will be drawn! :( 00106 drag->append( QIconDragItem(), QRect(), QRect() ); 00107 00108 return drag; 00109 }

void SubalbumsIconView::drawContents QPainter *  p,
int  clipx,
int  clipy,
int  clipw,
int  cliph
[protected]
 

Definition at line 58 of file subalbumsIconView.cpp.

References bufferPixmap, and drawContents().

Referenced by drawContents().

00059 { 00060 if( bufferPixmap.size() != size()) 00061 { bufferPixmap.resize( size() ); } 00062 QPainter bufferPainter( &bufferPixmap, viewport() ); 00063 int xOffset = clipx - contentsX(); 00064 int yOffset = clipy - contentsY(); 00065 00066 bufferPainter.translate( -contentsX(), -contentsY() ); 00067 QIconView::drawContents( &bufferPainter, clipx, clipy, clipw, cliph ); 00068 bitBlt(p->device(), xOffset, yOffset, &bufferPixmap, xOffset, yOffset, clipw, cliph ); 00069 }

int SubalbumsIconView::getTextWidth  ) 
 

Definition at line 178 of file subalbumsIconView.cpp.

References textWidth.

Referenced by SubalbumPreviewWidget::initializeItemRect(), and SubalbumPreviewWidget::setText().

00179 { return textWidth; }

void SubalbumsIconView::itemHasMoved  )  [signal]
 

Referenced by contentsDropEvent().

QSize SubalbumsIconView::minimumSizeHint  )  const
 

Definition at line 181 of file subalbumsIconView.cpp.

References sizeHint().

00181 { return sizeHint(); }

void SubalbumsIconView::repaintGroup QIconViewItem pseudoSelection  )  [private, slot]
 

Definition at line 156 of file subalbumsIconView.cpp.

References clearPseudoSelection(), currentPseudoSelection, repaintGroup(), and SubalbumPreviewWidget::setMousedOver().

Referenced by repaintGroup(), and SubalbumsIconView().

00157 { 00158 //if old pseudo selection unselect it 00159 clearPseudoSelection(); 00160 00161 //paint new selection 00162 currentPseudoSelection = (SubalbumPreviewWidget*)pseudoSelection; 00163 currentPseudoSelection->setMousedOver(true); 00164 repaintItem(currentPseudoSelection); 00165 }

QSize SubalbumsIconView::sizeHint  )  const
 

Definition at line 183 of file subalbumsIconView.cpp.

Referenced by minimumSizeHint().

00184 { 00185 QSize s = QIconView::sizeHint(); 00186 00187 //find max item width 00188 s.setWidth(0); 00189 QIconViewItem *item; 00190 for( item = firstItem(); item != NULL; item = item->nextItem() ) 00191 { 00192 if(item->width() > s.width() ) 00193 s.setWidth( item->width() ); 00194 } 00195 s.setWidth( s.width() + 2*spacing() + verticalScrollBar()->sizeHint().width() ); 00196 return s; 00197 }


Member Data Documentation

QPixmap SubalbumsIconView::bufferPixmap [private]
 

Definition at line 59 of file subalbumsIconView.h.

Referenced by drawContents().

SubalbumPreviewWidget* SubalbumsIconView::currentPseudoSelection [private]
 

Definition at line 61 of file subalbumsIconView.h.

Referenced by clearPseudoSelection(), contentsDragMoveEvent(), repaintGroup(), and SubalbumsIconView().

QPoint SubalbumsIconView::dragStartPos [private]
 

Definition at line 60 of file subalbumsIconView.h.

Referenced by contentsMousePressEvent(), and dragObject().

int SubalbumsIconView::textWidth [private]
 

Definition at line 65 of file subalbumsIconView.h.

Referenced by getTextWidth(), and SubalbumsIconView().


The documentation for this class was generated from the following files:
Generated on Sun Mar 4 19:43:09 2007 for AlbumShaper by doxygen 1.3.7