AlbumShaper 1.0a3
groupsWidget.cpp
Go to the documentation of this file.
1//==============================================
2// copyright : (C) 2003-2005 by Will Stokes
3//==============================================
4// This program is free software; you can redistribute it
5// and/or modify it under the terms of the GNU General
6// Public License as published by the Free Software
7// Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//==============================================
10
11//Systemwide includes
12#include <q3iconview.h>
13//Added by qt3to4:
14#include <QMouseEvent>
15#include <QKeyEvent>
16#include <QEvent>
17
18//Projectwide includes
19#include "groupsWidget.h"
20
21//==============================================
23 const char* name ) : Q3IconView( parent, name)
24{
25 setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum);
26}
27//==============================================
29{
30 //ignore all clicks other than left-clicks
31 if( e->button() != Qt::LeftButton ) return;
32
33 Q3IconView::contentsMousePressEvent( e );
34}
35//==============================================
36void GroupsWidget::keyPressEvent( QKeyEvent* e )
37{
38 //change key left/right presses to up/down events
39 int key = e->key();
40 if( key == Qt::Key_Left) key = Qt::Key_Up;
41 if( key == Qt::Key_Right) key = Qt::Key_Down;
42
43 Q3IconView::keyPressEvent(
44 new QKeyEvent(QEvent::KeyPress,
45 key,
46 e->ascii(),
47 e->state(),
48 e->text(),
49 e->isAutoRepeat(),
50 e->count() ) );
51}
52//==============================================
54{
55 QSize s = Q3IconView::sizeHint();
56
57 //find max item width
58 s.setWidth(0);
59 Q3IconViewItem *item;
60 for( item = firstItem(); item != NULL; item = item->nextItem() )
61 {
62 if(item->width() + 2 > s.width() )
63 s.setWidth( item->width() );
64 }
65 s.setWidth( s.width() + 2*spacing() );
66 return s;
67}
68//==============================================
70{ textWidth = val; }
71//==============================================
74//==============================================
75
76
void contentsMousePressEvent(QMouseEvent *e)
GroupsWidget(QWidget *parent=0, const char *name=0)
QSize sizeHint() const
void keyPressEvent(QKeyEvent *e)
void setTextWidth(int val)