[Kst] [Bug 130195] Datasources should enforce field uniquity
Andrew Walker
arwalker at sumusltd.com
Wed May 9 19:30:35 CEST 2007
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=130195
------- Additional Comments From arwalker sumusltd com 2007-05-09 19:30 -------
SVN commit 662958 by arwalker:
CCBUG:130195 Make search for duplicate field names more efficient
M +19 -21 kstdatasource.cpp
--- branches/work/kst/1.5/kst/src/libkst/kstdatasource.cpp #662957:662958
@ -330,31 +330,13 @
QValueList<PluginSortContainer> bestPlugins = bestPluginsForSource(fn, type);
QStringList rc;
- for (QValueList<PluginSortContainer>::Iterator i = bestPlugins.begin(); i != bestPlugins.end(); ++i) {
+ for (QValueList<PluginSortContainer>::Iterator it = bestPlugins.begin(); it != bestPlugins.end(); ++it) {
QString typeSuggestion;
- rc = (*i).plugin->fieldList(kConfigObject, fn, QString::null, &typeSuggestion, complete);
+ rc = (*it).plugin->fieldList(kConfigObject, fn, QString::null, &typeSuggestion, complete);
if (!rc.isEmpty()) {
- //
- // check for duplicate field names and warn the user if necessary...
- //
- QStringList::const_iterator it = rc.begin();
- QString str;
-
- for (; it != rc.end(); ) {
- str = (*it);
- ++it;
- if (it != rc.end()) {
- if (rc.find(it, str) != rc.end()) {
- KstDebug::self()->log(i18n( "The datasource has at least one duplicate field name; '%1'. As a result one or more fields will not be accessible." ).arg(str), KstDebug::Error);
-
- break;
- }
- }
- }
-
if (outType) {
if (typeSuggestion.isEmpty()) {
- *outType = (*i).plugin->provides()[0];
+ *outType = (*it).plugin->provides()[0];
} else {
*outType = typeSuggestion;
}
@ -363,6 +345,22 @
}
}
+ if (!rc.isEmpty()) {
+ //
+ // check for duplicate field names and warn the user if necessary...
+ //
+ QMap<QString, QString> map;
+
+ for (QStringList::const_iterator it = rc.begin(); it != rc.end(); ++it) {
+ map.insert(*it, *it);
+ }
+
+ if (map.size() != rc.size()) {
+ KstDebug::self()->log( i18n("The datasource '%1' has at least one duplicate field name. As a result one or more fields will not be accessible.").arg(filename), KstDebug::Error);
+ }
+ }
+
+
return rc;
}
More information about the Kst
mailing list