1
// krazy:excludeall=qclasses
3
//////////////////////////////////////////////////////////////////////////////
4
// oxygencomboboxdata.cpp
5
// data container for QComboBox transition
8
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
10
// Permission is hereby granted, free of charge, to any person obtaining a copy
11
// of this software and associated documentation files (the "Software"), to
12
// deal in the Software without restriction, including without limitation the
13
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14
// sell copies of the Software, and to permit persons to whom the Software is
15
// furnished to do so, subject to the following conditions:
17
// The above copyright notice and this permission notice shall be included in
18
// all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27
//////////////////////////////////////////////////////////////////////////////
29
#include "oxygencomboboxdata.h"
30
#include "oxygencomboboxdata.moc"
35
//______________________________________________________
36
ComboBoxData::ComboBoxData( QObject* parent, QComboBox* target, int duration ):
37
TransitionData( parent, target, duration ),
40
_target.data()->installEventFilter( this );
41
connect( _target.data(), SIGNAL( destroyed() ), SLOT( targetDestroyed() ) );
42
connect( _target.data(), SIGNAL( currentIndexChanged( int ) ), SLOT( indexChanged() ) );
45
//___________________________________________________________________
46
void ComboBoxData::indexChanged( void )
49
if( recursiveCheck() ) return;
51
if( transition().data()->isAnimated() )
52
{ transition().data()->endAnimation(); }
54
if( initializeAnimation() ) animate();
55
else transition().data()->hide();
59
//___________________________________________________________________
60
bool ComboBoxData::eventFilter( QObject* object, QEvent* event )
63
// make sure engine is enabled
64
if( !( enabled() && object == _target.data() ) )
65
{ return TransitionData::eventFilter( object, event ); }
67
// make sure that target is not editable
68
if( _target.data()->isEditable() )
69
{ return TransitionData::eventFilter( object, event ); }
71
switch( event->type() )
77
if( !recursiveCheck() && _target.data()->isVisible() )
78
{ _timer.start( 0, this ); }
84
return TransitionData::eventFilter( object, event );
88
//___________________________________________________________________
89
void ComboBoxData::timerEvent( QTimerEvent* event )
91
if( event->timerId() == _timer.timerId() )
95
if( enabled() && transition() && _target && !_target.data()->isVisible() )
97
setRecursiveCheck( true );
98
transition().data()->setEndPixmap( transition().data()->grab( _target.data(), targetRect() ) );
99
setRecursiveCheck( false );
102
} else return TransitionData::timerEvent( event );
106
//___________________________________________________________________
107
bool ComboBoxData::initializeAnimation( void )
109
if( !( enabled() && _target && _target.data()->isVisible() ) ) return false;
110
if( _target.data()->isEditable() )
113
do nothing for editable comboboxes because
114
lineEditor animations are handled directly
119
transition().data()->setOpacity(0);
120
transition().data()->setGeometry( targetRect() );
121
transition().data()->setStartPixmap( transition().data()->currentPixmap() );
122
transition().data()->show();
123
transition().data()->raise();
127
//___________________________________________________________________
128
bool ComboBoxData::animate( void )
132
if( !enabled() ) return false;
135
setRecursiveCheck( true );
136
transition().data()->setEndPixmap( transition().data()->grab( _target.data(), targetRect() ) );
137
setRecursiveCheck( false );
140
transition().data()->animate();
146
//___________________________________________________________________
147
void ComboBoxData::targetDestroyed( void )