@@ -58,135 +58,135 @@ QgsProviderRegistry *QgsProviderRegistry::instance(QString pluginPath)
58
58
59
59
QgsProviderRegistry::QgsProviderRegistry (QString pluginPath)
60
60
{
61
- // At startup, examine the libs in the qgis/lib dir and store those that
62
- // are a provider shared lib
63
- // check all libs in the current plugin directory and get name and descriptions
64
- // TODO figure out how to register and identify data source plugin for a specific
65
- // TODO layer type
66
- /* char **argv = qApp->argv();
67
- QString appDir = argv[0];
68
- int bin = appDir.findRev("/bin", -1, false);
69
- QString baseDir = appDir.left(bin);
70
- QString mLibraryDirectory = baseDir + "/lib"; */
71
- mLibraryDirectory = pluginPath;
72
-
73
- mLibraryDirectory .setSorting ( QDir::Name | QDir::IgnoreCase );
74
- mLibraryDirectory .setFilter ( QDir::Files | QDir::NoSymLinks );
61
+ // At startup, examine the libs in the qgis/lib dir and store those that
62
+ // are a provider shared lib
63
+ // check all libs in the current plugin directory and get name and descriptions
64
+ // TODO figure out how to register and identify data source plugin for a specific
65
+ // TODO layer type
66
+ /* char **argv = qApp->argv();
67
+ QString appDir = argv[0];
68
+ int bin = appDir.findRev("/bin", -1, false);
69
+ QString baseDir = appDir.left(bin);
70
+ QString mLibraryDirectory = baseDir + "/lib"; */
71
+ mLibraryDirectory = pluginPath;
72
+
73
+ mLibraryDirectory .setSorting ( QDir::Name | QDir::IgnoreCase );
74
+ mLibraryDirectory .setFilter ( QDir::Files | QDir::NoSymLinks );
75
75
76
76
#ifdef WIN32
77
- mLibraryDirectory .setNameFilter ( " *.dll" );
77
+ mLibraryDirectory .setNameFilter ( " *.dll" );
78
78
#else
79
- mLibraryDirectory .setNameFilter ( " *.so" );
79
+ mLibraryDirectory .setNameFilter ( " *.so" );
80
80
#endif
81
81
82
82
#ifdef QGISDEBUG
83
- cerr << " Checking " << mLibraryDirectory .path ().data () << " for provider plugins\n " ;
83
+ cerr << " Checking " << mLibraryDirectory .path ().data () << " for provider plugins\n " ;
84
84
#endif
85
85
86
- if (mLibraryDirectory .count () == 0 )
87
- {
88
- QString msg = QObject::tr (" No Data Provider Plugins" ,
89
- " No QGIS data provider plugins found in:" );
90
- msg += " \n " + mLibraryDirectory .path () + " \n\n " ;
91
- msg += QObject::tr (" No vector layers can be loaded. Check your QGIS installation" );
92
- QMessageBox::critical (0 , QObject::tr (" No Data Providers" ), msg);
93
- }
94
- else
95
- {
96
- const QFileInfoList list = mLibraryDirectory .entryInfoList ();
97
- QListIterator<QFileInfo> it ( list );
98
- QFileInfo fi;
86
+ if (mLibraryDirectory .count () == 0 )
87
+ {
88
+ QString msg = QObject::tr (" No Data Provider Plugins" ,
89
+ " No QGIS data provider plugins found in:" );
90
+ msg += " \n " + mLibraryDirectory .path () + " \n\n " ;
91
+ msg += QObject::tr (" No vector layers can be loaded. Check your QGIS installation" );
92
+ QMessageBox::critical (0 , QObject::tr (" No Data Providers" ), msg);
93
+ }
94
+ else
95
+ {
96
+ const QFileInfoList list = mLibraryDirectory .entryInfoList ();
97
+ QListIterator<QFileInfo> it ( list );
98
+ QFileInfo fi;
99
99
100
- while (it.hasNext ())
101
- {
102
- fi = it.next ();
100
+ while (it.hasNext ())
101
+ {
102
+ fi = it.next ();
103
103
104
- QLibrary *myLib = new QLibrary ( fi.filePath () );
104
+ QLibrary *myLib = new QLibrary ( fi.filePath () );
105
105
106
- bool loaded = myLib->load ();
106
+ bool loaded = myLib->load ();
107
107
108
- if (loaded)
109
- {
108
+ if (loaded)
109
+ {
110
110
#ifdef QGISDEBUG
111
- std::cout << " Checking " << myLib->library ().toLocal8Bit ().data () << std::endl;
111
+ std::cout << " Checking " << myLib->library ().toLocal8Bit ().data () << std::endl;
112
112
#endif
113
- // get the description and the key for the provider plugin
114
- isprovider_t *isProvider = (isprovider_t *) myLib->resolve (" isProvider" );
113
+ // get the description and the key for the provider plugin
114
+ isprovider_t *isProvider = (isprovider_t *) myLib->resolve (" isProvider" );
115
115
116
- if (isProvider)
117
- {
118
- // check to see if this is a provider plugin
119
- if (isProvider ())
120
- {
121
- // looks like a provider. get the key and description
122
- description_t *pDesc = (description_t *) myLib->resolve (" description" );
123
- providerkey_t *pKey = (providerkey_t *) myLib->resolve (" providerKey" );
124
- if (pDesc && pKey)
125
- {
126
- // add this provider to the provider map
127
- mProviders [pKey ()] =
128
- new QgsProviderMetadata (pKey (), pDesc (), myLib->library ());
116
+ if (isProvider)
117
+ {
118
+ // check to see if this is a provider plugin
119
+ if (isProvider ())
120
+ {
121
+ // looks like a provider. get the key and description
122
+ description_t *pDesc = (description_t *) myLib->resolve (" description" );
123
+ providerkey_t *pKey = (providerkey_t *) myLib->resolve (" providerKey" );
124
+ if (pDesc && pKey)
125
+ {
126
+ // add this provider to the provider map
127
+ mProviders [pKey ()] =
128
+ new QgsProviderMetadata (pKey (), pDesc (), myLib->library ());
129
129
#ifdef QGISDEBUG
130
- std::cout << " Loaded " << pDesc ().toLocal8Bit ().data () << std::endl;
130
+ std::cout << " Loaded " << pDesc ().toLocal8Bit ().data () << std::endl;
131
131
#endif
132
132
133
- // now get vector file filters, if any
134
- fileVectorFilters_t *pFileVectorFilters =
135
- (fileVectorFilters_t *) myLib->resolve (" fileVectorFilters" );
136
-
137
- if ( pFileVectorFilters )
138
- {
139
- QString vectorFileFilters = pFileVectorFilters ();
140
-
141
-
142
- // now get vector file filters, if any
143
- fileVectorFilters_t *pVectorFileFilters =
144
- (fileVectorFilters_t *) myLib->resolve (" fileVectorFilters" );
145
-
146
- if ( pVectorFileFilters )
147
- {
148
- QString fileVectorFilters = pVectorFileFilters ();
149
-
150
- if ( ! fileVectorFilters.isEmpty () )
151
- {
152
- mVectorFileFilters += fileVectorFilters;
153
- }
154
- else
155
- {
156
- QgsDebug ( QString (" No vector file filters for " + pKey ()).ascii () );
157
- }
158
- }
159
- else
160
- {
161
- QgsDebug ( " Unable to invoke fileVectorFilters()" );
162
- }
163
- }
164
- else
165
- {
166
- cout << myLib->library ().data ()
167
- << " Unable to find one of the required provider functions:\n\t providerKey() or description()"
168
- << endl;
169
- }
170
- }
171
- }
172
- else
173
- {
174
- QgsDebug ( " Unable to invoke fileVectorFilters()" );
175
- }
176
- }
133
+ // now get vector file filters, if any
134
+ fileVectorFilters_t *pFileVectorFilters =
135
+ (fileVectorFilters_t *) myLib->resolve (" fileVectorFilters" );
136
+
137
+ if ( pFileVectorFilters )
138
+ {
139
+ QString vectorFileFilters = pFileVectorFilters ();
140
+
141
+
142
+ // now get vector file filters, if any
143
+ fileVectorFilters_t *pVectorFileFilters =
144
+ (fileVectorFilters_t *) myLib->resolve (" fileVectorFilters" );
145
+
146
+ if ( pVectorFileFilters )
147
+ {
148
+ QString fileVectorFilters = pVectorFileFilters ();
149
+
150
+ if ( ! fileVectorFilters.isEmpty () )
151
+ {
152
+ mVectorFileFilters += fileVectorFilters;
153
+ }
154
+ else
155
+ {
156
+ QgsDebug ( QString (" No vector file filters for " + pKey ()).ascii () );
157
+ }
158
+ }
177
159
else
178
160
{
179
- cout << myLib->library ().data ()
180
- << " Unable to find one of the required provider functions:\n\t providerKey() or description()"
181
- << endl;
161
+ QgsDebug ( " Unable to invoke fileVectorFilters()" );
182
162
}
163
+ }
164
+ else
165
+ {
166
+ cout << myLib->library ().data ()
167
+ << " Unable to find one of the required provider functions:\n\t providerKey() or description()"
168
+ << endl;
169
+ }
183
170
}
171
+ }
172
+ else
173
+ {
174
+ QgsDebug ( " Unable to invoke fileVectorFilters()" );
175
+ }
176
+ }
177
+ else
178
+ {
179
+ cout << myLib->library ().data ()
180
+ << " Unable to find one of the required provider functions:\n\t providerKey() or description()"
181
+ << endl;
182
+ }
183
+ }
184
184
185
- // ++it;
185
+ // ++it;
186
186
187
- delete myLib;
188
- }
187
+ delete myLib;
189
188
}
189
+ }
190
190
191
191
} // QgsProviderRegistry ctor
192
192
@@ -203,29 +203,29 @@ static
203
203
QgsProviderMetadata * findMetadata_ ( QgsProviderRegistry::Providers const & metaData,
204
204
QString const & providerKey )
205
205
{
206
- QgsProviderRegistry::Providers::const_iterator i =
207
- metaData.find ( providerKey );
206
+ QgsProviderRegistry::Providers::const_iterator i =
207
+ metaData.find ( providerKey );
208
208
209
- if ( i != metaData.end () )
210
- {
211
- return i->second ;
212
- }
209
+ if ( i != metaData.end () )
210
+ {
211
+ return i->second ;
212
+ }
213
213
214
- return 0x0 ;
214
+ return 0x0 ;
215
215
} // findMetadata_
216
216
217
217
218
218
219
219
QString QgsProviderRegistry::library (QString const & providerKey) const
220
220
{
221
- QgsProviderMetadata * md = findMetadata_ ( mProviders , providerKey );
221
+ QgsProviderMetadata * md = findMetadata_ ( mProviders , providerKey );
222
222
223
- if (md)
224
- {
225
- return md->library ();
226
- }
223
+ if (md)
224
+ {
225
+ return md->library ();
226
+ }
227
227
228
- return QString ();
228
+ return QString ();
229
229
}
230
230
231
231
@@ -236,32 +236,33 @@ QString QgsProviderRegistry::pluginList(bool asHTML) const
236
236
237
237
if ( mProviders .empty () )
238
238
{
239
- list = QObject::tr (" No data provider plugins are available. No vector layers can be loaded" );
239
+ list = QObject::tr (" No data provider plugins are available. No vector layers can be loaded" );
240
240
}
241
241
else
242
242
{
243
- if (asHTML)
244
- {
245
- list += " <ol>" ;
246
- }
247
- while (it != mProviders .end ())
248
- {
249
- QgsProviderMetadata *mp = (*it).second ;
250
-
251
- if (asHTML)
252
- {
253
- list += " <li>" + mp->description () + " <br>" ;
254
- } else
255
- {
256
- list += mp->description () + " \n " ;
257
- }
243
+ if (asHTML)
244
+ {
245
+ list += " <ol>" ;
246
+ }
247
+ while (it != mProviders .end ())
248
+ {
249
+ QgsProviderMetadata *mp = (*it).second ;
258
250
259
- it++;
260
- }
261
251
if (asHTML)
262
252
{
263
- list += " </ol>" ;
253
+ list += " <li>" + mp->description () + " <br>" ;
254
+ }
255
+ else
256
+ {
257
+ list += mp->description () + " \n " ;
264
258
}
259
+
260
+ it++;
261
+ }
262
+ if (asHTML)
263
+ {
264
+ list += " </ol>" ;
265
+ }
265
266
}
266
267
267
268
return list;
0 commit comments