author | mickeyl <mickeyl> | 2004-04-24 15:11:39 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-24 15:11:39 (UTC) |
commit | 1a00a2edf5da1aa7d47c736bb718933f1c2e774b (patch) (unidiff) | |
tree | f14bdd2ac8aa2912238eb2ed254fa8cfe03e5b7f | |
parent | 2b700fa535661eb1ac897797f318a2694397a4d6 (diff) | |
download | opie-1a00a2edf5da1aa7d47c736bb718933f1c2e774b.zip opie-1a00a2edf5da1aa7d47c736bb718933f1c2e774b.tar.gz opie-1a00a2edf5da1aa7d47c736bb718933f1c2e774b.tar.bz2 |
gcc34 fixlet
-rw-r--r-- | noncore/apps/tableviewer/db/common.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/tableviewer/db/common.cpp b/noncore/apps/tableviewer/db/common.cpp index 6e544ba..b58af85 100644 --- a/noncore/apps/tableviewer/db/common.cpp +++ b/noncore/apps/tableviewer/db/common.cpp | |||
@@ -957,266 +957,266 @@ void KeyList::setKeyType(int i, TVVariant::KeyType t) | |||
957 | return; | 957 | return; |
958 | } | 958 | } |
959 | 959 | ||
960 | TVVariant KeyList::getKeyExample(int i) const | 960 | TVVariant KeyList::getKeyExample(int i) const |
961 | { | 961 | { |
962 | if(find(i)) | 962 | if(find(i)) |
963 | return find(i)->example(); | 963 | return find(i)->example(); |
964 | return TVVariant(); | 964 | return TVVariant(); |
965 | } | 965 | } |
966 | 966 | ||
967 | void KeyList::setKeyExample(int i, TVVariant example) | 967 | void KeyList::setKeyExample(int i, TVVariant example) |
968 | { | 968 | { |
969 | if(find(i)) | 969 | if(find(i)) |
970 | find(i)->setExample(example); | 970 | find(i)->setExample(example); |
971 | } | 971 | } |
972 | 972 | ||
973 | /*! | 973 | /*! |
974 | Returns the index of the key with name q | 974 | Returns the index of the key with name q |
975 | */ | 975 | */ |
976 | int KeyList::getKeyIndex(QString q) const | 976 | int KeyList::getKeyIndex(QString q) const |
977 | { | 977 | { |
978 | KeyListIterator it(*this); | 978 | KeyListIterator it(*this); |
979 | 979 | ||
980 | while(it.current()) { | 980 | while(it.current()) { |
981 | if(it.current()->name() == q) | 981 | if(it.current()->name() == q) |
982 | return it.currentKey(); | 982 | return it.currentKey(); |
983 | ++it; | 983 | ++it; |
984 | } | 984 | } |
985 | return -1; | 985 | return -1; |
986 | } | 986 | } |
987 | 987 | ||
988 | bool KeyList::validIndex(int i) const | 988 | bool KeyList::validIndex(int i) const |
989 | { | 989 | { |
990 | if(!find(i)) | 990 | if(!find(i)) |
991 | return FALSE; | 991 | return FALSE; |
992 | if(find(i)->delFlag()) | 992 | if(find(i)->delFlag()) |
993 | return FALSE; | 993 | return FALSE; |
994 | return TRUE; | 994 | return TRUE; |
995 | } | 995 | } |
996 | 996 | ||
997 | QDataStream &operator<<( QDataStream &s, const KeyList &k) | 997 | QDataStream &operator<<( QDataStream &s, const KeyList &k) |
998 | { | 998 | { |
999 | s << k.getNumFields(); | 999 | s << k.getNumFields(); |
1000 | 1000 | ||
1001 | KeyListIterator it(k); | 1001 | KeyListIterator it(k); |
1002 | 1002 | ||
1003 | while(it.current()) { | 1003 | while(it.current()) { |
1004 | s << (Q_UINT16)it.currentKey(); | 1004 | s << (Q_UINT16)it.currentKey(); |
1005 | s << it.current()->name(); | 1005 | s << it.current()->name(); |
1006 | s << it.current()->example(); | 1006 | s << it.current()->example(); |
1007 | s << (Q_UINT16)it.current()->flags(); | 1007 | s << (Q_UINT16)it.current()->flags(); |
1008 | ++it; | 1008 | ++it; |
1009 | } | 1009 | } |
1010 | return s; | 1010 | return s; |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | QDataStream &operator>>( QDataStream &s, KeyList &k) | 1013 | QDataStream &operator>>( QDataStream &s, KeyList &k) |
1014 | { | 1014 | { |
1015 | int i; | 1015 | int i; |
1016 | int size; | 1016 | int size; |
1017 | int index = 0; | 1017 | int index = 0; |
1018 | int flags = 0; | 1018 | int flags = 0; |
1019 | TVVariant type = TVVariant(); | 1019 | TVVariant type = TVVariant(); |
1020 | QString name; | 1020 | QString name; |
1021 | 1021 | ||
1022 | s >> size; | 1022 | s >> size; |
1023 | 1023 | ||
1024 | for (i=0; i < size; i++) { | 1024 | for (i=0; i < size; i++) { |
1025 | s >> (Q_UINT16 &)index; | 1025 | s >> (Q_UINT16 &)index; |
1026 | s >> name; | 1026 | s >> name; |
1027 | s >> type; | 1027 | s >> type; |
1028 | s >> (Q_UINT16 &)flags; | 1028 | s >> (Q_UINT16 &)flags; |
1029 | k.replace(index, new Key(name, type, flags)); | 1029 | k.replace(index, new Key(name, type, flags)); |
1030 | } | 1030 | } |
1031 | return s; | 1031 | return s; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | /*! | 1034 | /*! |
1035 | \class DataElem | 1035 | \class DataElem |
1036 | \brief A class representing a single row or element of a table in a DBStore | 1036 | \brief A class representing a single row or element of a table in a DBStore |
1037 | 1037 | ||
1038 | This class holds the data of a row in a table. | 1038 | This class holds the data of a row in a table. |
1039 | */ | 1039 | */ |
1040 | 1040 | ||
1041 | 1041 | ||
1042 | /*! | 1042 | /*! |
1043 | Constructs a DataElem. This function needs a container because the | 1043 | Constructs a DataElem. This function needs a container because the |
1044 | size, types of keys and primary key are all defined by the containing | 1044 | size, types of keys and primary key are all defined by the containing |
1045 | database | 1045 | database |
1046 | */ | 1046 | */ |
1047 | DataElem::DataElem(DBStore *c) : values(20) | 1047 | DataElem::DataElem(DBStore *c) : values(20) |
1048 | { | 1048 | { |
1049 | int size; | 1049 | int size; |
1050 | contained = c; | 1050 | contained = c; |
1051 | size = c->getNumFields(); | 1051 | size = c->getNumFields(); |
1052 | values.setAutoDelete(TRUE); | 1052 | values.setAutoDelete(TRUE); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | /*! | 1055 | /*! |
1056 | Destroys a DataElem and frees memory used by the DataElem | 1056 | Destroys a DataElem and frees memory used by the DataElem |
1057 | */ | 1057 | */ |
1058 | DataElem::~DataElem() { | 1058 | DataElem::~DataElem() { |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | 1061 | ||
1062 | 1062 | ||
1063 | QDataStream &operator<<( QDataStream &s, const DataElem &d) | 1063 | QDataStream &operator<<( QDataStream &s, const DataElem &d) |
1064 | { | 1064 | { |
1065 | int size = d.getNumFields(); | 1065 | int size = d.getNumFields(); |
1066 | 1066 | ||
1067 | s << size; /* redundent data but makes streaming easier */ | 1067 | s << size; /* redundent data but makes streaming easier */ |
1068 | KeyList k = d.getKeys(); | 1068 | KeyList k = d.getKeys(); |
1069 | 1069 | ||
1070 | KeyListIterator it(k); | 1070 | KeyListIterator it(k); |
1071 | 1071 | ||
1072 | while(it.current()) { | 1072 | while(it.current()) { |
1073 | s << (Q_UINT16)it.currentKey(); | 1073 | s << (Q_UINT16)it.currentKey(); |
1074 | s << d.getField(it.currentKey()); | 1074 | s << d.getField(it.currentKey()); |
1075 | ++it; | 1075 | ++it; |
1076 | } | 1076 | } |
1077 | return s; | 1077 | return s; |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | QDataStream &operator>>( QDataStream &s, DataElem &d) | 1080 | QDataStream &operator>>( QDataStream &s, DataElem &d) |
1081 | { | 1081 | { |
1082 | int i; | 1082 | int i; |
1083 | int size; | 1083 | int size; |
1084 | TVVariant t; | 1084 | TVVariant t; |
1085 | int index = 0; | 1085 | Q_UINT16 index = 0; |
1086 | 1086 | ||
1087 | s >> size; /* redundent data but makes streaming easier */ | 1087 | s >> size; /* redundent data but makes streaming easier */ |
1088 | if (size != d.getNumFields()) { | 1088 | if (size != d.getNumFields()) { |
1089 | owarn << "DataSize mis-match" << oendl; | 1089 | owarn << "DataSize mis-match" << oendl; |
1090 | return s; /* sanity check failed.. don't load */ | 1090 | return s; /* sanity check failed.. don't load */ |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | for(i = 0; i < size; i++) { | 1093 | for(i = 0; i < size; i++) { |
1094 | s >> (Q_UINT16)index; | 1094 | s >> index; |
1095 | s >> t; | 1095 | s >> t; |
1096 | d.setField(index, t); | 1096 | d.setField(index, t); |
1097 | } | 1097 | } |
1098 | return s; | 1098 | return s; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | /*! Returns the number of possible (not valid) fields in the data element */ | 1101 | /*! Returns the number of possible (not valid) fields in the data element */ |
1102 | int DataElem::getNumFields() const | 1102 | int DataElem::getNumFields() const |
1103 | { | 1103 | { |
1104 | return contained->getNumFields(); | 1104 | return contained->getNumFields(); |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | KeyList DataElem::getKeys() const | 1107 | KeyList DataElem::getKeys() const |
1108 | { | 1108 | { |
1109 | return *(contained->getKeys()); | 1109 | return *(contained->getKeys()); |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | /*! | 1112 | /*! |
1113 | This function determines whether field index i of the element has been | 1113 | This function determines whether field index i of the element has been |
1114 | set yet. | 1114 | set yet. |
1115 | 1115 | ||
1116 | \return A boolean value that is TRUE if the specfied field of this | 1116 | \return A boolean value that is TRUE if the specfied field of this |
1117 | element has been set and FALSE if the field has not yet been set | 1117 | element has been set and FALSE if the field has not yet been set |
1118 | */ | 1118 | */ |
1119 | bool DataElem::hasValidValue(int i) const | 1119 | bool DataElem::hasValidValue(int i) const |
1120 | { | 1120 | { |
1121 | if(!values.find(i)) | 1121 | if(!values.find(i)) |
1122 | return FALSE; | 1122 | return FALSE; |
1123 | if(!contained->getKeys()->validIndex(i)) | 1123 | if(!contained->getKeys()->validIndex(i)) |
1124 | return FALSE; | 1124 | return FALSE; |
1125 | return values.find(i)->isValid(); | 1125 | return values.find(i)->isValid(); |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | /*! | 1128 | /*! |
1129 | This function determines whether field name qs of the element has been | 1129 | This function determines whether field name qs of the element has been |
1130 | set yet. | 1130 | set yet. |
1131 | 1131 | ||
1132 | \return A boolean value that is TRUE if the specfied field of this | 1132 | \return A boolean value that is TRUE if the specfied field of this |
1133 | element has been set and FALSE if the field has not yet been set | 1133 | element has been set and FALSE if the field has not yet been set |
1134 | */ | 1134 | */ |
1135 | bool DataElem::hasValidValue(QString qs) const | 1135 | bool DataElem::hasValidValue(QString qs) const |
1136 | { | 1136 | { |
1137 | int i = contained->getKeyIndex(qs); | 1137 | int i = contained->getKeyIndex(qs); |
1138 | return hasValidValue(i); | 1138 | return hasValidValue(i); |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | /*! returns the type of the field specified by index i */ | 1141 | /*! returns the type of the field specified by index i */ |
1142 | TVVariant::KeyType DataElem::getFieldType(int i) const | 1142 | TVVariant::KeyType DataElem::getFieldType(int i) const |
1143 | { | 1143 | { |
1144 | return contained->getKeyType(i); | 1144 | return contained->getKeyType(i); |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | /*! returns the type of the field specified by name qs */ | 1147 | /*! returns the type of the field specified by name qs */ |
1148 | TVVariant::KeyType DataElem::getFieldType(QString qs) const | 1148 | TVVariant::KeyType DataElem::getFieldType(QString qs) const |
1149 | { | 1149 | { |
1150 | int i = contained->getKeyIndex(qs); | 1150 | int i = contained->getKeyIndex(qs); |
1151 | return contained->getKeyType(i); | 1151 | return contained->getKeyType(i); |
1152 | } | 1152 | } |
1153 | 1153 | ||
1154 | /*! | 1154 | /*! |
1155 | returns a pointer to the data stored in field index i for this | 1155 | returns a pointer to the data stored in field index i for this |
1156 | data element, (value may not be valid) | 1156 | data element, (value may not be valid) |
1157 | */ | 1157 | */ |
1158 | TVVariant DataElem::getField(int i) const | 1158 | TVVariant DataElem::getField(int i) const |
1159 | { | 1159 | { |
1160 | if(hasValidValue(i)) | 1160 | if(hasValidValue(i)) |
1161 | return TVVariant(*values.find(i)); | 1161 | return TVVariant(*values.find(i)); |
1162 | return TVVariant(); | 1162 | return TVVariant(); |
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | /*! | 1165 | /*! |
1166 | returns a pointer to the data stored in field name qs for this | 1166 | returns a pointer to the data stored in field name qs for this |
1167 | data element, (value may not be valid) | 1167 | data element, (value may not be valid) |
1168 | */ | 1168 | */ |
1169 | TVVariant DataElem::getField(QString qs) const | 1169 | TVVariant DataElem::getField(QString qs) const |
1170 | { | 1170 | { |
1171 | int i = contained->getKeyIndex(qs); | 1171 | int i = contained->getKeyIndex(qs); |
1172 | return getField(i); | 1172 | return getField(i); |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | /*! | 1175 | /*! |
1176 | Sets the value of the elements field index i to the value represented in | 1176 | Sets the value of the elements field index i to the value represented in |
1177 | the QString q. | 1177 | the QString q. |
1178 | 1178 | ||
1179 | \param i index of the field to set | 1179 | \param i index of the field to set |
1180 | \param q a string that can be parsed to get the value to be set | 1180 | \param q a string that can be parsed to get the value to be set |
1181 | */ | 1181 | */ |
1182 | void DataElem::setField(int i, QString q) | 1182 | void DataElem::setField(int i, QString q) |
1183 | { | 1183 | { |
1184 | /* from the type of the field, parse q and store */ | 1184 | /* from the type of the field, parse q and store */ |
1185 | TVVariant::KeyType kt = contained->getKeyType(i); | 1185 | TVVariant::KeyType kt = contained->getKeyType(i); |
1186 | 1186 | ||
1187 | TVVariant t = TVVariant(q); | 1187 | TVVariant t = TVVariant(q); |
1188 | 1188 | ||
1189 | switch(kt) { | 1189 | switch(kt) { |
1190 | case TVVariant::Int: { | 1190 | case TVVariant::Int: { |
1191 | t.asInt(); | 1191 | t.asInt(); |
1192 | setField(i, t); | 1192 | setField(i, t); |
1193 | return; | 1193 | return; |
1194 | } | 1194 | } |
1195 | case TVVariant::String: { | 1195 | case TVVariant::String: { |
1196 | t.asString(); | 1196 | t.asString(); |
1197 | setField(i, t); | 1197 | setField(i, t); |
1198 | return; | 1198 | return; |
1199 | } | 1199 | } |
1200 | case TVVariant::Date: { | 1200 | case TVVariant::Date: { |
1201 | t.asDate(); | 1201 | t.asDate(); |
1202 | setField(i, t); | 1202 | setField(i, t); |
1203 | return; | 1203 | return; |
1204 | } | 1204 | } |
1205 | case TVVariant::Time: { | 1205 | case TVVariant::Time: { |
1206 | t.asTime(); | 1206 | t.asTime(); |
1207 | setField(i, t); | 1207 | setField(i, t); |
1208 | return; | 1208 | return; |
1209 | } | 1209 | } |
1210 | default: | 1210 | default: |
1211 | qWarning( | 1211 | qWarning( |
1212 | QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q) | 1212 | QObject::tr("DataElem::setField(%1, %2) No valid type found").arg(i).arg(q) |
1213 | ); | 1213 | ); |
1214 | } | 1214 | } |
1215 | } | 1215 | } |
1216 | 1216 | ||
1217 | /*! | 1217 | /*! |
1218 | Sets the value of the elements field index i to the value at the pointer | 1218 | Sets the value of the elements field index i to the value at the pointer |
1219 | value. | 1219 | value. |
1220 | 1220 | ||
1221 | \param i index of the field to set | 1221 | \param i index of the field to set |
1222 | \param value a pointer to the (already allocated) value to set | 1222 | \param value a pointer to the (already allocated) value to set |