AlbumShaper 1.0a3
SubalbumsIconView Class Reference

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. More...

#include <subalbumsIconView.h>

Inheritance diagram for SubalbumsIconView:
Collaboration diagram for SubalbumsIconView:

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)
 
Q3DragObject * dragObject ()
 
void contentsMousePressEvent (QMouseEvent *e)
 
void contentsDragMoveEvent (QDragMoveEvent *e)
 

Private Slots

void repaintGroup (Q3IconViewItem *pseudoSelection)
 
void clearPseudoSelection ()
 

Private Member Functions

void contentsDropEvent (QDropEvent *e)
 

Private Attributes

QPixmap bufferPixmap
 
QPoint dragStartPos
 
SubalbumPreviewWidgetcurrentPseudoSelection
 
int textWidth
 

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 36 of file subalbumsIconView.h.

Constructor & Destructor Documentation

◆ SubalbumsIconView()

SubalbumsIconView::SubalbumsIconView ( QWidget * parent)

Definition at line 32 of file subalbumsIconView.cpp.

32 : Q3IconView( parent )
33{
34// setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum);
35 setMouseTracking(true);
36
38
39 //connect mouse over events to paint pseudo selection in ligher blue
40 connect( this, SIGNAL(onItem(Q3IconViewItem*)),
41 this, SLOT(repaintGroup(Q3IconViewItem*)) );
42
43 //clear any pseudo selection when mouse moves off icons
44 connect( this, SIGNAL(onViewport()),
45 this, SLOT(clearPseudoSelection()) );
46
47 //compute textWidth for collection names using a calibration string
48 QString calibrationString( qApp->translate("SubalbumPreviewWidget", "Calibration String") );
49 QFontMetrics fm( qApp->font() );
50 textWidth = fm.width( calibrationString );
51}
void repaintGroup(Q3IconViewItem *pseudoSelection)
SubalbumPreviewWidget * currentPseudoSelection

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

Member Function Documentation

◆ clearPseudoSelection

void SubalbumsIconView::clearPseudoSelection ( )
privateslot

Definition at line 171 of file subalbumsIconView.cpp.

172{
173 //if old pseudo selection unselect it
174 if(currentPseudoSelection != NULL)
175 {
177 repaintItem(currentPseudoSelection);
179 }
180}

References currentPseudoSelection, and SubalbumPreviewWidget::setMousedOver().

Referenced by repaintGroup(), and SubalbumsIconView().

◆ contentsDragMoveEvent()

void SubalbumsIconView::contentsDragMoveEvent ( QDragMoveEvent * e)
protected

Definition at line 115 of file subalbumsIconView.cpp.

116{
117 Q3IconView::contentsDragMoveEvent( e );
118 e->accept(true);
119
120 //if source of drag is not from application then return
121 if(e->source() == NULL)
122 return;
123
124 //if source of drag is from within this view then return, in the future we'll put
125 //drag code in here to drag indicators for rearranging the items of the iconview
126 if(e->source() == viewport() )
127 {
128
129 }
130 //else if source is from photos iconview
131 else if(e->source()->parentWidget() == ((LayoutWidget*)parentWidget()->parentWidget())->getSubalbum()->getPhotos() )
132 {
133 SubalbumPreviewWidget* item = (SubalbumPreviewWidget*)findItem( e->pos() );
134
135 //if item pointer same as current pseudo selection ignore
136 if(item == currentPseudoSelection)
137 {
138 return;
139 }
140
141 //unpaint old selection
142 if(currentPseudoSelection != NULL)
143 {
145 repaintItem(currentPseudoSelection);
146 }
147
148 //set new selection
150
151 //repaint new selection
152 if(currentPseudoSelection != NULL)
153 {
155 repaintItem(currentPseudoSelection);
156 }
157 }
158}
Displays list of subalbums and a particular subalbum layout.
Displays subalbum icon and name.

References currentPseudoSelection, and SubalbumPreviewWidget::setMousedOver().

◆ contentsDropEvent()

void SubalbumsIconView::contentsDropEvent ( QDropEvent * e)
private

Definition at line 53 of file subalbumsIconView.cpp.

54{
55 Q3IconView::contentsDropEvent( e );
56
57 //if drop originated from this viewport then emit item moved signal
58 if(e->source() == viewport() )
59 emit itemHasMoved();
60}

References itemHasMoved().

◆ contentsMousePressEvent()

void SubalbumsIconView::contentsMousePressEvent ( QMouseEvent * e)
protected

Definition at line 75 of file subalbumsIconView.cpp.

76{
77 //ignore all clicks other than left-clicks
78 if( e->button() != Qt::LeftButton ) return;
79
80 dragStartPos = e->pos();
81 Q3IconView::contentsMousePressEvent( e );
82}

References dragStartPos.

◆ dragObject()

Q3DragObject * SubalbumsIconView::dragObject ( )
protected

Definition at line 84 of file subalbumsIconView.cpp.

85{
86 //no item selected?
87 if( !currentItem() )
88 return 0;
89
90 //create drag object
91 Q3IconDrag *drag = new Q3IconDrag( viewport() );
92
93 //create buffer and paint item to buffer
94 QRect r = currentItem()->rect();
95 QPixmap buffer( r.width(), r.height() );
96 QPainter painter( &buffer );
97 painter.translate( -r.x(), -r.y() );
98 ((SubalbumPreviewWidget*)currentItem())->paint( &painter );
99
100 //clip off background color around edges which was used for anti-aliasing edges.
101 //result image will have semi-selection oval around it.
102 QBitmap bit = buffer.createHeuristicMask();
103 buffer.setMask( bit );
104
105 //set pixmap to use buffer
106 drag->setPixmap( buffer, QPoint( dragStartPos.x() - r.x(), dragStartPos.y() - r.y() ) );
107
108 //we don't want to show any rectangles, but if we don't append two null rectangles the last drag rectangles this iconview displayed
109 //possibly form objects dropped onto it from outside the viewport, aka photos, will be drawn! :(
110 drag->append( Q3IconDragItem(), QRect(), QRect() );
111
112 return drag;
113}
float * buffer
Definition blur.cpp:80

References buffer, and dragStartPos.

◆ drawContents()

void SubalbumsIconView::drawContents ( QPainter * p,
int clipx,
int clipy,
int clipw,
int cliph )
protected

Definition at line 62 of file subalbumsIconView.cpp.

63{
64 if( bufferPixmap.size() != size())
65 { bufferPixmap.resize( size() ); }
66 QPainter bufferPainter( &bufferPixmap );
67 int xOffset = clipx - contentsX();
68 int yOffset = clipy - contentsY();
69
70 bufferPainter.translate( -contentsX(), -contentsY() );
71 Q3IconView::drawContents( &bufferPainter, clipx, clipy, clipw, cliph );
72 bitBlt(p->device(), xOffset, yOffset, &bufferPixmap, xOffset, yOffset, clipw, cliph );
73}

References bufferPixmap.

◆ getTextWidth()

int SubalbumsIconView::getTextWidth ( )

Definition at line 182 of file subalbumsIconView.cpp.

183{ return textWidth; }

References textWidth.

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

◆ itemHasMoved

void SubalbumsIconView::itemHasMoved ( )
signal

Referenced by contentsDropEvent().

◆ minimumSizeHint()

QSize SubalbumsIconView::minimumSizeHint ( ) const

Definition at line 185 of file subalbumsIconView.cpp.

185{ return sizeHint(); }

References sizeHint().

◆ repaintGroup

void SubalbumsIconView::repaintGroup ( Q3IconViewItem * pseudoSelection)
privateslot

Definition at line 160 of file subalbumsIconView.cpp.

161{
162 //if old pseudo selection unselect it
164
165 //paint new selection
168 repaintItem(currentPseudoSelection);
169}

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

Referenced by SubalbumsIconView().

◆ sizeHint()

QSize SubalbumsIconView::sizeHint ( ) const

Definition at line 187 of file subalbumsIconView.cpp.

188{
189 QSize s = Q3IconView::sizeHint();
190
191 //find max item width
192 s.setWidth(0);
193 Q3IconViewItem *item;
194 for( item = firstItem(); item != NULL; item = item->nextItem() )
195 {
196 if(item->width() > s.width() )
197 s.setWidth( item->width() );
198 }
199 s.setWidth( s.width() + 2*spacing() + verticalScrollBar()->sizeHint().width() );
200 return s;
201}
int width
Definition blur.cpp:79

References sizeHint(), and width.

Referenced by minimumSizeHint(), and sizeHint().

Member Data Documentation

◆ bufferPixmap

QPixmap SubalbumsIconView::bufferPixmap
private

Definition at line 64 of file subalbumsIconView.h.

Referenced by drawContents().

◆ currentPseudoSelection

SubalbumPreviewWidget* SubalbumsIconView::currentPseudoSelection
private

◆ dragStartPos

QPoint SubalbumsIconView::dragStartPos
private

Definition at line 65 of file subalbumsIconView.h.

Referenced by contentsMousePressEvent(), and dragObject().

◆ textWidth

int SubalbumsIconView::textWidth
private

Definition at line 70 of file subalbumsIconView.h.

Referenced by getTextWidth(), and SubalbumsIconView().


The documentation for this class was generated from the following files: