AlbumShaper
1.0a3
src
gui
welcomeWindow
items.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 <QKeyEvent>
15
#include <QEvent>
16
17
//Projectwide includes
18
#include "
items.h
"
19
#include "
item.h
"
20
21
//==============================================
22
Items::Items
(
QWidget
* parent,
23
const
char
* name ) :
Q3IconView
( parent, name)
24
{
25
currentPseudoSelection
= NULL;
26
// setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum);
27
28
//connect mouse over events to paint pseudo selection in ligher blue
29
connect(
this
, SIGNAL(onItem(
Q3IconViewItem
*)),
30
this
, SLOT(
repaintGroup
(
Q3IconViewItem
*)) );
31
32
//clear any pseudo selection when mouse moves off icons
33
connect(
this
, SIGNAL(onViewport()),
34
this
, SLOT(
clearPseudoSelection
()) );
35
}
36
//==============================================
37
void
Items::keyPressEvent
( QKeyEvent* e )
38
{
39
//change key left/right presses to up/down events
40
int
key = e->key();
41
if
( key == Qt::Key_Left) key = Qt::Key_Up;
42
if
( key == Qt::Key_Right) key = Qt::Key_Down;
43
44
Q3IconView::keyPressEvent(
45
new
QKeyEvent(QEvent::KeyPress,
46
key,
47
e->ascii(),
48
e->state(),
49
e->text(),
50
e->isAutoRepeat(),
51
e->count() ) );
52
}
53
//==============================================
54
QSize
Items::sizeHint
()
const
55
{
56
QSize s = Q3IconView::sizeHint();
57
58
//find max item width
59
s.setWidth(0);
60
Q3IconViewItem
*item;
61
for
( item = firstItem(); item != NULL; item = item->nextItem() )
62
{
63
if
(item->width() + 2 > s.width() )
64
s.setWidth( item->width() );
65
}
66
s.setWidth( s.width() + 2*spacing() );
67
return
s;
68
}
69
//==============================================
70
void
Items::repaintGroup
(
Q3IconViewItem
* pseudoSelection)
71
{
72
//if old pseudo selection unselect it
73
clearPseudoSelection
();
74
75
//paint new selection
76
currentPseudoSelection
= (
Item
*)pseudoSelection;
77
currentPseudoSelection
->
setMousedOver
(
true
);
78
repaintItem(
currentPseudoSelection
);
79
}
80
//==============================================
81
void
Items::clearPseudoSelection
()
82
{
83
//if old pseudo selection unselect it
84
if
(
currentPseudoSelection
!= NULL)
85
{
86
currentPseudoSelection
->
setMousedOver
(
false
);
87
repaintItem(
currentPseudoSelection
);
88
currentPseudoSelection
= NULL;
89
}
90
}
91
//==============================================
Item
Definition
item.h:28
Item::setMousedOver
void setMousedOver(bool val)
Definition
item.cpp:60
Items::currentPseudoSelection
Item * currentPseudoSelection
Definition
items.h:40
Items::clearPseudoSelection
void clearPseudoSelection()
Definition
items.cpp:81
Items::Items
Items(QWidget *parent=0, const char *name=0)
Definition
items.cpp:22
Items::keyPressEvent
void keyPressEvent(QKeyEvent *e)
Definition
items.cpp:37
Items::sizeHint
QSize sizeHint() const
Definition
items.cpp:54
Items::repaintGroup
void repaintGroup(Q3IconViewItem *pseudoSelection)
Definition
items.cpp:70
Q3IconViewItem
Q3IconView
QWidget
item.h
items.h
Generated by
1.12.0