summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-12 10:26:57 (UTC)
committer zautrix <zautrix>2005-01-12 10:26:57 (UTC)
commitffa81b34b0d7b3c53f46869a05194072a339a69d (patch) (unidiff)
tree5c9e435b2c93ae803a449fff6fb902d2ce2419ff
parentf408fee4c6ca34ee9c4d997c0f29d1c8975fa545 (diff)
downloadkdepimpi-ffa81b34b0d7b3c53f46869a05194072a339a69d.zip
kdepimpi-ffa81b34b0d7b3c53f46869a05194072a339a69d.tar.gz
kdepimpi-ffa81b34b0d7b3c53f46869a05194072a339a69d.tar.bz2
compiling fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/typecombo.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/kaddressbook/typecombo.h b/kaddressbook/typecombo.h
index 191273d..5fbf0d3 100644
--- a/kaddressbook/typecombo.h
+++ b/kaddressbook/typecombo.h
@@ -1,193 +1,194 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef TYPECOMBO_H 24#ifndef TYPECOMBO_H
25#define TYPECOMBO_H 25#define TYPECOMBO_H
26 26
27#include <kabc/phonenumber.h> 27#include <kabc/phonenumber.h>
28#include <kcombobox.h> 28#include <kcombobox.h>
29#include <klocale.h>
29 30
30/** 31/**
31 Combo box for type information of Addresses and Phone numbers. 32 Combo box for type information of Addresses and Phone numbers.
32*/ 33*/
33template <class T> 34template <class T>
34class TypeCombo : public KComboBox 35class TypeCombo : public KComboBox
35{ 36{
36 public: 37 public:
37 typedef typename T::List List; 38 typedef typename T::List List;
38 typedef typename T::List::Iterator Iterator; 39 typedef typename T::List::Iterator Iterator;
39 40
40 TypeCombo( List &list, QWidget *parent, const char *name = 0 ); 41 TypeCombo( List &list, QWidget *parent, const char *name = 0 );
41 42
42 void setLineEdit( QLineEdit *edit ) { mLineEdit = edit; } 43 void setLineEdit( QLineEdit *edit ) { mLineEdit = edit; }
43 QLineEdit *lineEdit() const { return mLineEdit; } 44 QLineEdit *lineEdit() const { return mLineEdit; }
44 45
45 void updateTypes(); 46 void updateTypes();
46 47
47 void selectType( int type ); 48 void selectType( int type );
48 49
49 int selectedType(); 50 int selectedType();
50 51
51 Iterator selectedElement(); 52 Iterator selectedElement();
52 53
53 void insertType( const List &list, int type, 54 void insertType( const List &list, int type,
54 const T &defaultObject ); 55 const T &defaultObject );
55 void insertTypeList( const List &list ); 56 void insertTypeList( const List &list );
56 57
57 bool hasType( int type ); 58 bool hasType( int type );
58 59
59 private: 60 private:
60 List &mTypeList; 61 List &mTypeList;
61 QLineEdit *mLineEdit; 62 QLineEdit *mLineEdit;
62}; 63};
63 64
64template <class T> 65template <class T>
65#ifdef _WIN32_ 66#ifdef _WIN32_
66TypeCombo<T>::TypeCombo( typename TypeCombo::List &list, QWidget *parent, 67TypeCombo<T>::TypeCombo( typename TypeCombo::List &list, QWidget *parent,
67#else 68#else
68TypeCombo<T>::TypeCombo( TypeCombo::List &list, QWidget *parent, 69TypeCombo<T>::TypeCombo( TypeCombo::List &list, QWidget *parent,
69 70
70#endif 71#endif
71 const char *name ) 72 const char *name )
72 : KComboBox( parent), 73 : KComboBox( parent),
73//US my kde version has no KComboBox constructor witgh two parameters 74//US my kde version has no KComboBox constructor witgh two parameters
74//US : KComboBox( parent, name ), 75//US : KComboBox( parent, name ),
75 mTypeList( list ) 76 mTypeList( list )
76{ 77{
77} 78}
78 79
79template <class T> 80template <class T>
80void TypeCombo<T>::updateTypes() 81void TypeCombo<T>::updateTypes()
81{ 82{
82 // Remember current item 83 // Remember current item
83 QString currentId; 84 QString currentId;
84 int current = currentItem(); 85 int current = currentItem();
85 if ( current >= 0 ) currentId = mTypeList[ current ].id(); 86 if ( current >= 0 ) currentId = mTypeList[ current ].id();
86 87
87 clear(); 88 clear();
88 89
89 QMap<int,int> labelCount; 90 QMap<int,int> labelCount;
90 91
91 uint i; 92 uint i;
92 for( i = 0; i < mTypeList.count(); ++i ) { 93 for( i = 0; i < mTypeList.count(); ++i ) {
93 int type = ( mTypeList[ i ].type() & ~( T::Pref ) ); 94 int type = ( mTypeList[ i ].type() & ~( T::Pref ) );
94 QString label = mTypeList[ i ].typeLabel( type ); 95 QString label = mTypeList[ i ].typeLabel( type );
95 int count = 1; 96 int count = 1;
96 if ( labelCount.contains( type ) ) { 97 if ( labelCount.contains( type ) ) {
97 count = labelCount[ type ] + 1; 98 count = labelCount[ type ] + 1;
98 } 99 }
99 labelCount[ type ] = count; 100 labelCount[ type ] = count;
100 if ( count > 1 ) { 101 if ( count > 1 ) {
101 label = i18n("label (number)", "%1 (%2)").arg( label ) 102 label = i18n("label (number)", "%1 (%2)").arg( label )
102 .arg( QString::number( count ) ); 103 .arg( QString::number( count ) );
103 } 104 }
104 insertItem( label ); 105 insertItem( label );
105 } 106 }
106 107
107 // Restore previous current item 108 // Restore previous current item
108 if ( !currentId.isEmpty() ) { 109 if ( !currentId.isEmpty() ) {
109 for( i = 0; i < mTypeList.count(); ++i ) { 110 for( i = 0; i < mTypeList.count(); ++i ) {
110 if ( mTypeList[ i ].id() == currentId ) { 111 if ( mTypeList[ i ].id() == currentId ) {
111 setCurrentItem( i ); 112 setCurrentItem( i );
112 break; 113 break;
113 } 114 }
114 } 115 }
115 } 116 }
116} 117}
117 118
118template <class T> 119template <class T>
119void TypeCombo<T>::selectType( int type ) 120void TypeCombo<T>::selectType( int type )
120{ 121{
121 uint i; 122 uint i;
122 for( i = 0; i < mTypeList.count(); ++i ) { 123 for( i = 0; i < mTypeList.count(); ++i ) {
123 if ( (mTypeList[ i ].type() & ~T::Pref) == type ) { 124 if ( (mTypeList[ i ].type() & ~T::Pref) == type ) {
124 setCurrentItem( i ); 125 setCurrentItem( i );
125 break; 126 break;
126 } 127 }
127 } 128 }
128} 129}
129 130
130template <class T> 131template <class T>
131int TypeCombo<T>::selectedType() 132int TypeCombo<T>::selectedType()
132{ 133{
133 return mTypeList[ currentItem() ].type(); 134 return mTypeList[ currentItem() ].type();
134} 135}
135 136
136template <class T> 137template <class T>
137typename TypeCombo<T>::Iterator TypeCombo<T>::selectedElement() 138typename TypeCombo<T>::Iterator TypeCombo<T>::selectedElement()
138{ 139{
139 return mTypeList.at( currentItem() ); 140 return mTypeList.at( currentItem() );
140} 141}
141 142
142template <class T> 143template <class T>
143#ifdef _WIN32_ 144#ifdef _WIN32_
144void TypeCombo<T>::insertType( typename const TypeCombo::List &list, int type, 145void TypeCombo<T>::insertType( typename const TypeCombo::List &list, int type,
145#else 146#else
146void TypeCombo<T>::insertType( const TypeCombo::List &list, int type, 147void TypeCombo<T>::insertType( const TypeCombo::List &list, int type,
147#endif 148#endif
148 const T &defaultObject ) 149 const T &defaultObject )
149{ 150{
150 uint i; 151 uint i;
151 for ( i = 0; i < list.count(); ++i ) { 152 for ( i = 0; i < list.count(); ++i ) {
152 if ( list[ i ].type() == type ) { 153 if ( list[ i ].type() == type ) {
153 mTypeList.append( list[ i ] ); 154 mTypeList.append( list[ i ] );
154 break; 155 break;
155 } 156 }
156 } 157 }
157 if ( i == list.count() ) { 158 if ( i == list.count() ) {
158 mTypeList.append( defaultObject ); 159 mTypeList.append( defaultObject );
159 } 160 }
160} 161}
161 162
162template <class T> 163template <class T>
163#ifdef _WIN32_ 164#ifdef _WIN32_
164void TypeCombo<T>::insertTypeList( typename const TypeCombo::List &list ) 165void TypeCombo<T>::insertTypeList( typename const TypeCombo::List &list )
165#else 166#else
166void TypeCombo<T>::insertTypeList( const TypeCombo::List &list ) 167void TypeCombo<T>::insertTypeList( const TypeCombo::List &list )
167 168
168#endif 169#endif
169{ 170{
170 uint i; 171 uint i;
171 for ( i = 0; i < list.count(); ++i ) { 172 for ( i = 0; i < list.count(); ++i ) {
172 uint j; 173 uint j;
173 for( j = 0; j < mTypeList.count(); ++j ) { 174 for( j = 0; j < mTypeList.count(); ++j ) {
174 if ( list[ i ].id() == mTypeList[ j ].id() ) break; 175 if ( list[ i ].id() == mTypeList[ j ].id() ) break;
175 } 176 }
176 if ( j == mTypeList.count() ) { 177 if ( j == mTypeList.count() ) {
177 mTypeList.append( list[ i ] ); 178 mTypeList.append( list[ i ] );
178 } 179 }
179 } 180 }
180} 181}
181 182
182template <class T> 183template <class T>
183bool TypeCombo<T>::hasType( int type ) 184bool TypeCombo<T>::hasType( int type )
184{ 185{
185 for( uint i = 0; i < mTypeList.count(); ++i ) { 186 for( uint i = 0; i < mTypeList.count(); ++i ) {
186 if ( ( mTypeList[ i ].type() & ~T::Pref ) == type ) 187 if ( ( mTypeList[ i ].type() & ~T::Pref ) == type )
187 return true; 188 return true;
188 } 189 }
189 190
190 return false; 191 return false;
191} 192}
192 193
193#endif 194#endif