Diffstat (limited to 'kaddressbook/views/colorlistbox.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/colorlistbox.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp index 2bddca6..46a59a1 100644 --- a/kaddressbook/views/colorlistbox.cpp +++ b/kaddressbook/views/colorlistbox.cpp | |||
@@ -16,41 +16,46 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qpainter.h> | 21 | #include <qpainter.h> |
22 | //Added by qt3to4: | ||
23 | #include <QDragEnterEvent> | ||
24 | #include <QDropEvent> | ||
25 | #include <QDragMoveEvent> | ||
26 | #include <QDragLeaveEvent> | ||
22 | 27 | ||
23 | #include <kcolordialog.h> | 28 | #include <kcolordialog.h> |
24 | 29 | ||
25 | #ifndef KAB_EMBEDDED | 30 | #ifndef KAB_EMBEDDED |
26 | #include <kcolordrag.h> | 31 | #include <kcolordrag.h> |
27 | #endif //KAB_EMBEDDED | 32 | #endif //KAB_EMBEDDED |
28 | 33 | ||
29 | #include "colorlistbox.h" | 34 | #include "colorlistbox.h" |
30 | #ifdef DESKTOP_VERSION | 35 | #ifdef DESKTOP_VERSION |
31 | #include <qcolordialog.h> | 36 | #include <qcolordialog.h> |
32 | #endif | 37 | #endif |
33 | 38 | ||
34 | ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) | 39 | ColorListBox::ColorListBox( QWidget *parent, const char *name, Qt::WFlags f ) |
35 | :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) | 40 | :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) |
36 | { | 41 | { |
37 | connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); | 42 | connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); |
38 | connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); | 43 | connect( this, SIGNAL(clicked(Q3ListBoxItem *)), this, SLOT(slotNewColor(Q3ListBoxItem *)) ); |
39 | setAcceptDrops( true); | 44 | setAcceptDrops( true); |
40 | } | 45 | } |
41 | 46 | ||
42 | 47 | ||
43 | void ColorListBox::setEnabled( bool state ) | 48 | void ColorListBox::setEnabled( bool state ) |
44 | { | 49 | { |
45 | if( state == isEnabled() ) | 50 | if( state == isEnabled() ) |
46 | { | 51 | { |
47 | return; | 52 | return; |
48 | } | 53 | } |
49 | 54 | ||
50 | QListBox::setEnabled( state ); | 55 | Q3ListBox::setEnabled( state ); |
51 | for( uint i=0; i<count(); i++ ) | 56 | for( uint i=0; i<count(); i++ ) |
52 | { | 57 | { |
53 | updateItem( i ); | 58 | updateItem( i ); |
54 | } | 59 | } |
55 | } | 60 | } |
56 | 61 | ||
@@ -72,16 +77,16 @@ QColor ColorListBox::color( uint index ) const | |||
72 | { | 77 | { |
73 | ColorListItem *colorItem = (ColorListItem*)item(index); | 78 | ColorListItem *colorItem = (ColorListItem*)item(index); |
74 | return( colorItem->color() ); | 79 | return( colorItem->color() ); |
75 | } | 80 | } |
76 | else | 81 | else |
77 | { | 82 | { |
78 | return( black ); | 83 | return( Qt::black ); |
79 | } | 84 | } |
80 | } | 85 | } |
81 | void ColorListBox::slotNewColor(QListBoxItem * i) | 86 | void ColorListBox::slotNewColor(Q3ListBoxItem * i) |
82 | { | 87 | { |
83 | if ( i ) | 88 | if ( i ) |
84 | newColor( index( i ) ); | 89 | newColor( index( i ) ); |
85 | } | 90 | } |
86 | 91 | ||
87 | void ColorListBox::newColor( int index ) | 92 | void ColorListBox::newColor( int index ) |
@@ -195,13 +200,13 @@ qDebug("ColorListBox::dropEvent drag&drop currently not supported"); | |||
195 | 200 | ||
196 | } | 201 | } |
197 | 202 | ||
198 | 203 | ||
199 | 204 | ||
200 | ColorListItem::ColorListItem( const QString &text, const QColor &color ) | 205 | ColorListItem::ColorListItem( const QString &text, const QColor &color ) |
201 | : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) | 206 | : Q3ListBoxItem(), mColor( color ), mBoxWidth( 30 ) |
202 | { | 207 | { |
203 | setText( text ); | 208 | setText( text ); |
204 | } | 209 | } |
205 | 210 | ||
206 | 211 | ||
207 | const QColor &ColorListItem::color( void ) | 212 | const QColor &ColorListItem::color( void ) |
@@ -226,20 +231,20 @@ void ColorListItem::paint( QPainter *p ) | |||
226 | p->setPen( Qt::black ); | 231 | p->setPen( Qt::black ); |
227 | p->drawRect( 3, 1, mBoxWidth, h-1 ); | 232 | p->drawRect( 3, 1, mBoxWidth, h-1 ); |
228 | p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); | 233 | p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); |
229 | } | 234 | } |
230 | 235 | ||
231 | 236 | ||
232 | int ColorListItem::height(const QListBox *lb ) const | 237 | int ColorListItem::height(const Q3ListBox *lb ) const |
233 | { | 238 | { |
234 | return( lb->fontMetrics().lineSpacing()+1 ); | 239 | return( lb->fontMetrics().lineSpacing()+1 ); |
235 | } | 240 | } |
236 | 241 | ||
237 | 242 | ||
238 | int ColorListItem::width(const QListBox *lb ) const | 243 | int ColorListItem::width(const Q3ListBox *lb ) const |
239 | { | 244 | { |
240 | return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); | 245 | return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); |
241 | } | 246 | } |
242 | 247 | ||
243 | #ifndef KAB_EMBEDDED | 248 | #ifndef KAB_EMBEDDED_ |
244 | #include "colorlistbox.moc" | 249 | #include "moc_colorlistbox.cpp" |
245 | #endif //KAB_EMBEDDED | 250 | #endif //KAB_EMBEDDED |