AlbumShaper
1.0a3
src
configuration
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
//==============================================
22
GroupsWidget::GroupsWidget
(
QWidget
* parent,
23
const
char
* name ) :
Q3IconView
( parent, name)
24
{
25
setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum);
26
}
27
//==============================================
28
void
GroupsWidget::contentsMousePressEvent
( QMouseEvent * e )
29
{
30
//ignore all clicks other than left-clicks
31
if
( e->button() != Qt::LeftButton )
return
;
32
33
Q3IconView::contentsMousePressEvent( e );
34
}
35
//==============================================
36
void
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
//==============================================
53
QSize
GroupsWidget::sizeHint
()
const
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
//==============================================
69
void
GroupsWidget::setTextWidth
(
int
val)
70
{
textWidth
= val; }
71
//==============================================
72
int
GroupsWidget::getTextWidth
()
73
{
return
textWidth
; }
74
//==============================================
75
76
GroupsWidget::contentsMousePressEvent
void contentsMousePressEvent(QMouseEvent *e)
Definition
groupsWidget.cpp:28
GroupsWidget::GroupsWidget
GroupsWidget(QWidget *parent=0, const char *name=0)
Definition
groupsWidget.cpp:22
GroupsWidget::textWidth
int textWidth
Definition
groupsWidget.h:46
GroupsWidget::sizeHint
QSize sizeHint() const
Definition
groupsWidget.cpp:53
GroupsWidget::getTextWidth
int getTextWidth()
Definition
groupsWidget.cpp:72
GroupsWidget::keyPressEvent
void keyPressEvent(QKeyEvent *e)
Definition
groupsWidget.cpp:36
GroupsWidget::setTextWidth
void setTextWidth(int val)
Definition
groupsWidget.cpp:69
Q3IconViewItem
Q3IconView
QWidget
groupsWidget.h
Generated by
1.12.0