34
34
#include " qgsapplication.h"
35
35
#include " qgsdataitem.h"
36
36
37
- #include " qgsdataprovider.h"
38
- #include " qgslogger.h"
39
- #include " qgsproviderregistry.h"
37
+ #include " qgsdataprovider.h"
38
+ #include " qgslogger.h"
39
+ #include " qgsproviderregistry.h"
40
40
41
41
// shared icons
42
- QIcon QgsLayerItem::sIconPoint , QgsLayerItem::sIconLine , QgsLayerItem::sIconPolygon , QgsLayerItem::sIconTable , QgsLayerItem::sIconDefault ;
43
- QIcon QgsDataCollectionItem::sDirIcon ;
42
+ const QIcon &QgsLayerItem::iconPoint ()
43
+ {
44
+ static QIcon icon;
45
+
46
+ if ( icon.isNull () )
47
+ icon = QIcon ( getThemePixmap ( " /mIconPointLayer.png" ) );
48
+
49
+ return icon;
50
+ }
51
+
52
+ const QIcon &QgsLayerItem::iconLine ()
53
+ {
54
+ static QIcon icon;
55
+
56
+ if ( icon.isNull () )
57
+ icon = QIcon ( getThemePixmap ( " /mIconLineLayer.png" ) );
58
+
59
+ return icon;
60
+ }
61
+
62
+ const QIcon &QgsLayerItem::iconPolygon ()
63
+ {
64
+ static QIcon icon;
65
+
66
+ if ( icon.isNull () )
67
+ icon = QIcon ( getThemePixmap ( " /mIconPolygonLayer.png" ) );
68
+
69
+ return icon;
70
+ }
71
+
72
+ const QIcon &QgsLayerItem::iconTable ()
73
+ {
74
+ static QIcon icon;
75
+
76
+ if ( icon.isNull () )
77
+ icon = QIcon ( getThemePixmap ( " /mIconTableLayer.png" ) );
78
+
79
+ return icon;
80
+ }
81
+
82
+ const QIcon &QgsLayerItem::iconDefault ()
83
+ {
84
+ static QIcon icon;
85
+
86
+ if ( icon.isNull () )
87
+ icon = QIcon ( getThemePixmap ( " /mIconLayer.png" ) );
44
88
89
+ return icon;
90
+ }
45
91
46
- QgsDataItem::QgsDataItem (QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path)
47
- : QObject(parent), mType(type), mParent(parent), mPopulated(false ), mName(name), mPath(path)
92
+ const QIcon &QgsDataCollectionItem::iconDir ()
93
+ {
94
+ static QIcon icon;
95
+
96
+ if ( !icon.isNull () )
97
+ {
98
+ // initialize shared icons
99
+ QStyle *style = QApplication::style ();
100
+ icon = QIcon ( style->standardPixmap ( QStyle::SP_DirClosedIcon ) );
101
+ icon.addPixmap ( style->standardPixmap ( QStyle::SP_DirOpenIcon ),
102
+ QIcon::Normal, QIcon::On );
103
+ }
104
+
105
+ return icon;
106
+ }
107
+
108
+ QgsDataItem::QgsDataItem ( QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path )
109
+ : QObject( parent ), mType( type ), mParent( parent ), mPopulated( false ), mName( name ), mPath( path )
48
110
{
49
111
}
50
112
@@ -70,15 +132,15 @@ QPixmap QgsDataItem::getThemePixmap( const QString theName )
70
132
71
133
void QgsDataItem::emitBeginInsertItems ( QgsDataItem* parent, int first, int last )
72
134
{
73
- emit beginInsertItems ( parent, first, last );
135
+ emit beginInsertItems ( parent, first, last );
74
136
}
75
137
void QgsDataItem::emitEndInsertItems ()
76
138
{
77
139
emit endInsertItems ();
78
140
}
79
141
void QgsDataItem::emitBeginRemoveItems ( QgsDataItem* parent, int first, int last )
80
142
{
81
- emit beginRemoveItems ( parent, first, last );
143
+ emit beginRemoveItems ( parent, first, last );
82
144
}
83
145
void QgsDataItem::emitEndRemoveItems ()
84
146
{
@@ -94,123 +156,113 @@ QVector<QgsDataItem*> QgsDataItem::createChildren( )
94
156
void QgsDataItem::populate ()
95
157
{
96
158
QVector<QgsDataItem*> children = createChildren ( );
97
- foreach ( QgsDataItem *child, children )
159
+ foreach ( QgsDataItem *child, children )
98
160
{
99
161
// initialization, do not refresh! That would result in infinite loop (beginInsertItems->rowCount->populate)
100
- addChildItem ( child);
162
+ addChildItem ( child );
101
163
}
102
164
mPopulated = true ;
103
165
}
104
166
105
167
int QgsDataItem::rowCount ()
106
168
{
107
- if (!mPopulated ) populate ();
169
+ if ( !mPopulated ) populate ();
108
170
return mChildren .size ();
109
171
}
110
172
bool QgsDataItem::hasChildren ()
111
173
{
112
- return ( mPopulated ? mChildren .count () > 0 : true );
174
+ return ( mPopulated ? mChildren .count () > 0 : true );
113
175
}
114
176
115
- void QgsDataItem::addChildItem ( QgsDataItem * child, bool refresh )
177
+ void QgsDataItem::addChildItem ( QgsDataItem * child, bool refresh )
116
178
{
117
- QgsDebugMsg ( " mName = " + child->mName );
179
+ QgsDebugMsg ( " mName = " + child->mName );
118
180
int i;
119
181
for ( i = 0 ; i < mChildren .size (); i++ )
120
182
{
121
- if ( mChildren [i]->mName .localeAwareCompare ( child->mName ) >= 0 ) break ;
183
+ if ( mChildren [i]->mName .localeAwareCompare ( child->mName ) >= 0 ) break ;
122
184
}
123
185
124
- if ( refresh ) emit beginInsertItems ( this , i, i );
125
- mChildren .insert ( i, child );
186
+ if ( refresh ) emit beginInsertItems ( this , i, i );
187
+ mChildren .insert ( i, child );
126
188
127
- connect ( child, SIGNAL (beginInsertItems ( QgsDataItem*, int , int )),
128
- this , SLOT (emitBeginInsertItems ( QgsDataItem*, int , int )) );
129
- connect ( child, SIGNAL (endInsertItems () ),
130
- this , SLOT (emitEndInsertItems ()) );
131
- connect ( child, SIGNAL (beginRemoveItems ( QgsDataItem*, int , int )),
132
- this , SLOT (emitBeginRemoveItems ( QgsDataItem*, int , int )) );
133
- connect ( child, SIGNAL (endRemoveItems () ),
134
- this , SLOT (emitEndRemoveItems ()) );
189
+ connect ( child, SIGNAL ( beginInsertItems ( QgsDataItem*, int , int ) ),
190
+ this , SLOT ( emitBeginInsertItems ( QgsDataItem*, int , int ) ) );
191
+ connect ( child, SIGNAL ( endInsertItems () ),
192
+ this , SLOT ( emitEndInsertItems () ) );
193
+ connect ( child, SIGNAL ( beginRemoveItems ( QgsDataItem*, int , int ) ),
194
+ this , SLOT ( emitBeginRemoveItems ( QgsDataItem*, int , int ) ) );
195
+ connect ( child, SIGNAL ( endRemoveItems () ),
196
+ this , SLOT ( emitEndRemoveItems () ) );
135
197
136
198
if ( refresh ) emit endInsertItems ();
137
199
138
200
}
139
- void QgsDataItem::deleteChildItem ( QgsDataItem * child )
201
+ void QgsDataItem::deleteChildItem ( QgsDataItem * child )
140
202
{
141
- QgsDebugMsg ( " mName = " + child->mName );
203
+ QgsDebugMsg ( " mName = " + child->mName );
142
204
int i = mChildren .indexOf ( child );
143
205
Q_ASSERT ( i >= 0 );
144
- emit beginRemoveItems ( this , i, i );
145
- mChildren .remove (i );
206
+ emit beginRemoveItems ( this , i, i );
207
+ mChildren .remove ( i );
146
208
delete child;
147
- emit endRemoveItems ();
209
+ emit endRemoveItems ();
148
210
}
149
211
150
- int QgsDataItem::findItem ( QVector<QgsDataItem*> items, QgsDataItem * item )
212
+ int QgsDataItem::findItem ( QVector<QgsDataItem*> items, QgsDataItem * item )
151
213
{
152
214
for ( int i = 0 ; i < items.size (); i++ )
153
215
{
154
- QgsDebugMsg ( QString::number (i ) + " : " + items[i]->mPath + " x " + item->mPath );
155
- if ( items[i]->equal ( item ) ) return i;
216
+ QgsDebugMsg ( QString::number ( i ) + " : " + items[i]->mPath + " x " + item->mPath );
217
+ if ( items[i]->equal ( item ) ) return i;
156
218
}
157
219
return -1 ;
158
220
}
159
221
160
222
void QgsDataItem::refresh ()
161
223
{
162
- QgsDebugMsg ( " mPath = " + mPath );
224
+ QgsDebugMsg ( " mPath = " + mPath );
163
225
164
226
QVector<QgsDataItem*> items = createChildren ( );
165
227
166
228
// Remove no more present items
167
229
QVector<QgsDataItem*> remove;
168
- foreach ( QgsDataItem *child, mChildren )
230
+ foreach ( QgsDataItem *child, mChildren )
169
231
{
170
- if ( findItem (items, child ) >= 0 ) continue ;
171
- remove.append ( child );
232
+ if ( findItem ( items, child ) >= 0 ) continue ;
233
+ remove.append ( child );
172
234
}
173
- foreach ( QgsDataItem *child, remove )
235
+ foreach ( QgsDataItem *child, remove )
174
236
{
175
- deleteChildItem ( child );
237
+ deleteChildItem ( child );
176
238
}
177
239
178
240
// Add new items
179
- foreach ( QgsDataItem *item, items )
241
+ foreach ( QgsDataItem *item, items )
180
242
{
181
243
// Is it present in childs?
182
- if ( findItem ( mChildren , item ) >= 0 )
244
+ if ( findItem ( mChildren , item ) >= 0 )
183
245
{
184
246
delete item;
185
247
continue ;
186
248
}
187
- addChildItem ( item, true );
249
+ addChildItem ( item, true );
188
250
}
189
251
}
190
252
191
253
// ---------------------------------------------------------------------
192
254
193
- QgsLayerItem::QgsLayerItem (QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType, QString providerKey)
194
- : QgsDataItem(Layer, parent, name, path), mUri(uri), mLayerType(layerType),
195
- mProviderKey(providerKey)
255
+ QgsLayerItem::QgsLayerItem ( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType, QString providerKey )
256
+ : QgsDataItem( Layer, parent, name, path ), mUri( uri ), mLayerType( layerType ),
257
+ mProviderKey( providerKey )
196
258
{
197
- if ( sIconPoint . isNull () )
259
+ switch ( layerType )
198
260
{
199
- // initialize shared icons
200
- sIconPoint = QIcon ( getThemePixmap ( " /mIconPointLayer.png" ) );
201
- sIconLine = QIcon ( getThemePixmap ( " /mIconLineLayer.png" ) );
202
- sIconPolygon = QIcon ( getThemePixmap ( " /mIconPolygonLayer.png" ) );
203
- sIconTable = QIcon ( getThemePixmap ( " /mIconTableLayer.png" ) );
204
- sIconDefault = QIcon ( getThemePixmap ( " /mIconLayer.png" ) );
205
- }
206
-
207
- switch (layerType)
208
- {
209
- case Point: mIcon = sIconPoint ; break ;
210
- case Line: mIcon = sIconLine ; break ;
211
- case Polygon: mIcon = sIconPolygon ; break ;
212
- case TableLayer: mIcon = sIconTable ; break ;
213
- default : mIcon = sIconDefault ; break ;
261
+ case Point: mIcon = iconPoint (); break ;
262
+ case Line: mIcon = iconLine (); break ;
263
+ case Polygon: mIcon = iconPolygon (); break ;
264
+ case TableLayer: mIcon = iconTable (); break ;
265
+ default : mIcon = iconDefault (); break ;
214
266
}
215
267
}
216
268
@@ -220,69 +272,62 @@ QgsMapLayer::LayerType QgsLayerItem::mapLayerType()
220
272
return QgsMapLayer::VectorLayer;
221
273
}
222
274
223
- bool QgsLayerItem::equal (const QgsDataItem *other)
275
+ bool QgsLayerItem::equal ( const QgsDataItem *other )
224
276
{
225
277
// QgsDebugMsg ( mPath + " x " + other->mPath );
226
278
if ( type () != other->type () )
227
279
{
228
280
return false ;
229
281
}
230
282
// const QgsLayerItem *o = qobject_cast<const QgsLayerItem *> ( other );
231
- const QgsLayerItem *o = dynamic_cast <const QgsLayerItem *> ( other );
283
+ const QgsLayerItem *o = dynamic_cast <const QgsLayerItem *>( other );
232
284
return ( mPath == o->mPath && mName == o->mName && mUri == o->mUri && mProviderKey == o->mProviderKey );
233
285
}
234
286
235
287
// ---------------------------------------------------------------------
236
- QgsDataCollectionItem::QgsDataCollectionItem ( QgsDataItem* parent, QString name, QString path)
237
- : QgsDataItem( Collection, parent, name, path)
288
+ QgsDataCollectionItem::QgsDataCollectionItem ( QgsDataItem* parent, QString name, QString path )
289
+ : QgsDataItem( Collection, parent, name, path )
238
290
{
239
-
240
- if (sDirIcon .isNull ())
241
- {
242
- // initialize shared icons
243
- QStyle *style = QApplication::style ();
244
- sDirIcon = QIcon ( style->standardPixmap ( QStyle::SP_DirClosedIcon ) );
245
- sDirIcon .addPixmap ( style->standardPixmap ( QStyle::SP_DirOpenIcon ),
246
- QIcon::Normal, QIcon::On );
247
- }
248
291
}
292
+
249
293
QgsDataCollectionItem::~QgsDataCollectionItem ()
250
294
{
251
- foreach ( QgsDataItem* i, mChildren )
252
- delete i;
295
+ foreach ( QgsDataItem* i, mChildren )
296
+ delete i;
253
297
}
254
298
255
299
// -----------------------------------------------------------------------
256
300
QVector<QgsDataProvider*> QgsDirectoryItem::mProviders = QVector<QgsDataProvider*>();
257
301
QVector<QLibrary*> QgsDirectoryItem::mLibraries = QVector<QLibrary*>();
258
302
259
303
260
- QgsDirectoryItem::QgsDirectoryItem (QgsDataItem* parent, QString name, QString path)
261
- : QgsDataCollectionItem(parent, name, path)
304
+ QgsDirectoryItem::QgsDirectoryItem ( QgsDataItem* parent, QString name, QString path )
305
+ : QgsDataCollectionItem( parent, name, path )
262
306
{
263
307
mType = Directory;
264
- mIcon = sDirIcon ;
308
+ mIcon = iconDir () ;
265
309
266
- if ( mLibraries .size () == 0 ) {
310
+ if ( mLibraries .size () == 0 )
311
+ {
267
312
QStringList keys = QgsProviderRegistry::instance ()->providerList ();
268
313
QStringList::const_iterator i;
269
- for ( i = keys.begin (); i != keys.end (); ++i)
314
+ for ( i = keys.begin (); i != keys.end (); ++i )
270
315
{
271
- QString k (*i );
316
+ QString k ( *i );
272
317
// some providers hangs with empty uri (Postgis) etc...
273
318
// -> using libraries directly
274
- QLibrary *library = QgsProviderRegistry::instance ()->getLibrary (k );
319
+ QLibrary *library = QgsProviderRegistry::instance ()->getLibrary ( k );
275
320
if ( library )
276
321
{
277
- dataCapabilities_t * dataCapabilities = (dataCapabilities_t *) cast_to_fptr ( library->resolve ( " dataCapabilities" ) );
278
- if ( !dataCapabilities )
322
+ dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr ( library->resolve ( " dataCapabilities" ) );
323
+ if ( !dataCapabilities )
279
324
{
280
- QgsDebugMsg ( library->fileName () + " does not have dataCapabilities" );
325
+ QgsDebugMsg ( library->fileName () + " does not have dataCapabilities" );
281
326
continue ;
282
327
}
283
- if ( dataCapabilities () == QgsDataProvider::NoDataCapabilities )
328
+ if ( dataCapabilities () == QgsDataProvider::NoDataCapabilities )
284
329
{
285
- QgsDebugMsg ( library->fileName () + " does not have File capability" );
330
+ QgsDebugMsg ( library->fileName () + " does not have File capability" );
286
331
continue ;
287
332
}
288
333
mLibraries .append ( library );
@@ -302,43 +347,43 @@ QgsDirectoryItem::~QgsDirectoryItem()
302
347
QVector<QgsDataItem*> QgsDirectoryItem::createChildren ( )
303
348
{
304
349
QVector<QgsDataItem*> children;
305
- QDir dir (mPath );
306
- QStringList entries = dir.entryList (QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
307
- foreach ( QString subdir, entries)
350
+ QDir dir ( mPath );
351
+ QStringList entries = dir.entryList ( QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
352
+ foreach ( QString subdir, entries )
308
353
{
309
- QString subdirPath = dir.absoluteFilePath (subdir);
310
- qDebug (" creating subdir: %s" , subdirPath.toAscii ().data ());
354
+ QString subdirPath = dir.absoluteFilePath ( subdir );
355
+ qDebug ( " creating subdir: %s" , subdirPath.toAscii ().data () );
311
356
312
- QgsDirectoryItem *item = new QgsDirectoryItem (this , subdir, subdirPath);
357
+ QgsDirectoryItem *item = new QgsDirectoryItem ( this , subdir, subdirPath );
313
358
// propagate signals up to top
314
359
315
360
children.append ( item );
316
361
}
317
362
318
- QStringList fileEntries = dir.entryList ( QDir::Files, QDir::Name);
319
- foreach ( QString name, fileEntries)
363
+ QStringList fileEntries = dir.entryList ( QDir::Files, QDir::Name );
364
+ foreach ( QString name, fileEntries )
320
365
{
321
366
QString path = dir.absoluteFilePath ( name );
322
- foreach ( QLibrary *library, mLibraries )
367
+ foreach ( QLibrary *library, mLibraries )
323
368
{
324
369
// we could/should create separate list of providers for each purpose
325
370
326
371
// TODO: use existing fileVectorFilters(),directoryDrivers() ?
327
- dataCapabilities_t * dataCapabilities = (dataCapabilities_t *) cast_to_fptr ( library->resolve ( " dataCapabilities" ) );
372
+ dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr ( library->resolve ( " dataCapabilities" ) );
328
373
if ( !dataCapabilities ) continue ;
329
374
330
375
int capabilities = dataCapabilities ();
331
376
332
- if ( ! ( capabilities & QgsDataProvider::File) ) continue ;
377
+ if ( !( capabilities & QgsDataProvider::File ) ) continue ;
333
378
334
- dataItem_t * dataItem = (dataItem_t *) cast_to_fptr ( library->resolve ( " dataItem" ) );
335
- if ( ! dataItem )
379
+ dataItem_t * dataItem = ( dataItem_t * ) cast_to_fptr ( library->resolve ( " dataItem" ) );
380
+ if ( ! dataItem )
336
381
{
337
- QgsDebugMsg ( library->fileName () + " does not have dataItem" );
382
+ QgsDebugMsg ( library->fileName () + " does not have dataItem" );
338
383
continue ;
339
384
}
340
385
341
- QgsDataItem * item = dataItem ( path, this );
386
+ QgsDataItem * item = dataItem ( path, this );
342
387
if ( item )
343
388
{
344
389
children.append ( item );
@@ -348,7 +393,7 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
348
393
return children;
349
394
}
350
395
351
- bool QgsDirectoryItem::equal (const QgsDataItem *other)
396
+ bool QgsDirectoryItem::equal ( const QgsDataItem *other )
352
397
{
353
398
// QgsDebugMsg ( mPath + " x " + other->mPath );
354
399
if ( type () != other->type () )
@@ -360,19 +405,19 @@ bool QgsDirectoryItem::equal(const QgsDataItem *other)
360
405
361
406
QWidget * QgsDirectoryItem::paramWidget ()
362
407
{
363
- return new QgsDirectoryParamWidget (mPath );
408
+ return new QgsDirectoryParamWidget ( mPath );
364
409
}
365
410
366
- QgsDirectoryParamWidget::QgsDirectoryParamWidget (QString path, QWidget* parent)
367
- : QTreeWidget(parent)
411
+ QgsDirectoryParamWidget::QgsDirectoryParamWidget ( QString path, QWidget* parent )
412
+ : QTreeWidget( parent )
368
413
{
369
- setRootIsDecorated (false );
414
+ setRootIsDecorated ( false );
370
415
371
416
// name, size, date, permissions, owner, group, type
372
- setColumnCount ( 7 );
417
+ setColumnCount ( 7 );
373
418
QStringList labels;
374
- labels << tr (" Name" ) << tr (" Size" ) << tr (" Date" ) << tr (" Permissions" ) << tr (" Owner" ) << tr (" Group" ) << tr (" Type" );
375
- setHeaderLabels ( labels );
419
+ labels << tr ( " Name" ) << tr ( " Size" ) << tr ( " Date" ) << tr ( " Permissions" ) << tr ( " Owner" ) << tr ( " Group" ) << tr ( " Type" );
420
+ setHeaderLabels ( labels );
376
421
377
422
QStyle* style = QApplication::style ();
378
423
QIcon iconDirectory = QIcon ( style->standardPixmap ( QStyle::SP_DirClosedIcon ) );
@@ -381,28 +426,28 @@ QgsDirectoryParamWidget::QgsDirectoryParamWidget(QString path, QWidget* parent)
381
426
382
427
QList<QTreeWidgetItem *> items;
383
428
384
- QDir dir (path);
385
- QStringList entries = dir.entryList (QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase);
386
- foreach ( QString name, entries)
429
+ QDir dir ( path );
430
+ QStringList entries = dir.entryList ( QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase );
431
+ foreach ( QString name, entries )
387
432
{
388
- QFileInfo fi ( dir.absoluteFilePath (name) );
433
+ QFileInfo fi ( dir.absoluteFilePath ( name ) );
389
434
QStringList texts;
390
435
texts << name;
391
436
QString size;
392
- if ( fi.size () > 1024 )
437
+ if ( fi.size () > 1024 )
393
438
{
394
- size = size.sprintf ( " %.1f KiB" , fi.size ()/ 1024.0 );
439
+ size = size.sprintf ( " %.1f KiB" , fi.size () / 1024.0 );
395
440
}
396
- else if ( fi.size () > 1.048576e6 )
441
+ else if ( fi.size () > 1.048576e6 )
397
442
{
398
- size = size.sprintf ( " %.1f MiB" , fi.size ()/ 1.048576e6 );
443
+ size = size.sprintf ( " %.1f MiB" , fi.size () / 1.048576e6 );
399
444
}
400
445
else
401
446
{
402
447
size = QString ( " %1 B" ).arg ( fi.size () );
403
448
}
404
449
texts << size;
405
- texts << fi.lastModified ().toString ( Qt::SystemLocaleShortDate);
450
+ texts << fi.lastModified ().toString ( Qt::SystemLocaleShortDate );
406
451
QString perm;
407
452
perm += fi.permission ( QFile::ReadOwner ) ? ' r' : ' -' ;
408
453
perm += fi.permission ( QFile::WriteOwner ) ? ' w' : ' -' ;
@@ -423,53 +468,53 @@ QgsDirectoryParamWidget::QgsDirectoryParamWidget(QString path, QWidget* parent)
423
468
QIcon icon;
424
469
if ( fi.isDir () )
425
470
{
426
- type = tr ( " folder" );
471
+ type = tr ( " folder" );
427
472
icon = iconDirectory;
428
473
}
429
474
else if ( fi.isFile () )
430
475
{
431
- type = tr ( " file" );
476
+ type = tr ( " file" );
432
477
icon = iconFile;
433
478
}
434
479
else if ( fi.isSymLink () )
435
480
{
436
- type = tr ( " link" );
481
+ type = tr ( " link" );
437
482
icon = iconLink;
438
483
}
439
484
440
485
texts << type;
441
486
442
- QTreeWidgetItem *item = new QTreeWidgetItem ( texts);
443
- item->setIcon (0 , icon);
487
+ QTreeWidgetItem *item = new QTreeWidgetItem ( texts );
488
+ item->setIcon ( 0 , icon );
444
489
items << item;
445
490
}
446
491
447
- addTopLevelItems (items);
492
+ addTopLevelItems ( items );
448
493
449
494
// hide columns that are not requested
450
495
QSettings settings;
451
- QList<QVariant> lst = settings.value (" /dataitem/directoryHiddenColumns" ).toList ();
452
- foreach ( QVariant colVariant, lst)
496
+ QList<QVariant> lst = settings.value ( " /dataitem/directoryHiddenColumns" ).toList ();
497
+ foreach ( QVariant colVariant, lst )
453
498
{
454
499
setColumnHidden ( colVariant.toInt (), true );
455
500
}
456
501
}
457
502
458
- void QgsDirectoryParamWidget::mousePressEvent (QMouseEvent* event)
503
+ void QgsDirectoryParamWidget::mousePressEvent ( QMouseEvent* event )
459
504
{
460
505
if ( event->button () == Qt::RightButton )
461
506
{
462
507
// show the popup menu
463
508
QMenu popupMenu;
464
509
465
510
QStringList labels;
466
- labels << tr (" Name" ) << tr (" Size" ) << tr (" Date" ) << tr (" Permissions" ) << tr (" Owner" ) << tr (" Group" ) << tr (" Type" );
467
- for (int i = 0 ; i < labels.count (); i++)
511
+ labels << tr ( " Name" ) << tr ( " Size" ) << tr ( " Date" ) << tr ( " Permissions" ) << tr ( " Owner" ) << tr ( " Group" ) << tr ( " Type" );
512
+ for ( int i = 0 ; i < labels.count (); i++ )
468
513
{
469
- QAction* action = popupMenu.addAction ( labels[i], this , SLOT (showHideColumn ()) );
470
- action->setObjectName (QString::number (i) );
471
- action->setCheckable (true );
472
- action->setChecked ( !isColumnHidden (i ) );
514
+ QAction* action = popupMenu.addAction ( labels[i], this , SLOT ( showHideColumn () ) );
515
+ action->setObjectName ( QString::number ( i ) );
516
+ action->setCheckable ( true );
517
+ action->setChecked ( !isColumnHidden ( i ) );
473
518
}
474
519
475
520
popupMenu.exec ( event->globalPos () );
@@ -478,20 +523,20 @@ void QgsDirectoryParamWidget::mousePressEvent(QMouseEvent* event)
478
523
479
524
void QgsDirectoryParamWidget::showHideColumn ()
480
525
{
481
- QAction* action = qobject_cast<QAction*>(sender ());
482
- if (!action)
526
+ QAction* action = qobject_cast<QAction*>( sender () );
527
+ if ( !action )
483
528
return ; // something is wrong
484
529
485
530
int columnIndex = action->objectName ().toInt ();
486
- setColumnHidden (columnIndex, !isColumnHidden (columnIndex) );
531
+ setColumnHidden ( columnIndex, !isColumnHidden ( columnIndex ) );
487
532
488
533
// save in settings
489
534
QSettings settings;
490
535
QList<QVariant> lst;
491
- for (int i = 0 ; i < columnCount (); i++)
536
+ for ( int i = 0 ; i < columnCount (); i++ )
492
537
{
493
- if (isColumnHidden (i) )
494
- lst.append (QVariant (i) );
538
+ if ( isColumnHidden ( i ) )
539
+ lst.append ( QVariant ( i ) );
495
540
}
496
- settings.setValue (" /dataitem/directoryHiddenColumns" , lst);
541
+ settings.setValue ( " /dataitem/directoryHiddenColumns" , lst );
497
542
}
0 commit comments