Skip to content

Commit 694c356

Browse files
committedMay 21, 2011
fix windows build
1 parent d85320b commit 694c356

File tree

3 files changed

+350
-297
lines changed

3 files changed

+350
-297
lines changed
 

‎src/browser/qgsbrowsermodel.cpp

100644100755
Lines changed: 84 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,86 +11,89 @@
1111
#include "qgsbrowsermodel.h"
1212

1313

14-
QgsBrowserModel::QgsBrowserModel(QObject *parent) :
15-
QAbstractItemModel(parent)
14+
QgsBrowserModel::QgsBrowserModel( QObject *parent ) :
15+
QAbstractItemModel( parent )
1616
{
1717
QStyle *style = QApplication::style();
1818
mIconDirectory = QIcon( style->standardPixmap( QStyle::SP_DirClosedIcon ) );
1919
mIconDirectory.addPixmap( style->standardPixmap( QStyle::SP_DirOpenIcon ),
2020
QIcon::Normal, QIcon::On );
2121

22-
foreach (QFileInfo drive, QDir::drives())
22+
foreach( QFileInfo drive, QDir::drives() )
2323
{
2424
QString path = drive.absolutePath();
25-
QgsDirectoryItem *item = new QgsDirectoryItem(NULL, path, path);
25+
QgsDirectoryItem *item = new QgsDirectoryItem( NULL, path, path );
2626

27-
connectItem(item);
27+
connectItem( item );
2828
mRootItems << item;
2929
}
3030

3131
// Add non file top level items
32-
foreach ( QString key, QgsProviderRegistry::instance()->providerList() )
32+
foreach( QString key, QgsProviderRegistry::instance()->providerList() )
3333
{
34-
QLibrary *library = QgsProviderRegistry::instance()->getLibrary(key);
34+
QLibrary *library = QgsProviderRegistry::instance()->getLibrary( key );
3535
if ( !library ) continue;
3636

37-
dataCapabilities_t * dataCapabilities = (dataCapabilities_t *) cast_to_fptr( library->resolve ("dataCapabilities") );
38-
if ( !dataCapabilities ) {
39-
QgsDebugMsg ( library->fileName() + " does not have dataCapabilities" );
37+
dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) );
38+
if ( !dataCapabilities )
39+
{
40+
QgsDebugMsg( library->fileName() + " does not have dataCapabilities" );
4041
continue;
4142
}
4243

4344
int capabilities = dataCapabilities();
44-
if ( capabilities == QgsDataProvider::NoDataCapabilities )
45+
if ( capabilities == QgsDataProvider::NoDataCapabilities )
4546
{
46-
QgsDebugMsg ( library->fileName() + " does not have any dataCapabilities" );
47+
QgsDebugMsg( library->fileName() + " does not have any dataCapabilities" );
4748
continue;
4849
}
4950

50-
dataItem_t * dataItem = (dataItem_t *) cast_to_fptr( library->resolve ("dataItem" ) );
51+
dataItem_t * dataItem = ( dataItem_t * ) cast_to_fptr( library->resolve( "dataItem" ) );
5152
if ( ! dataItem )
5253
{
53-
QgsDebugMsg ( library->fileName() + " does not have dataItem" );
54+
QgsDebugMsg( library->fileName() + " does not have dataItem" );
5455
continue;
5556
}
5657

57-
QgsDataItem * item = dataItem ( "", NULL ); // empty path -> top level
58+
QgsDataItem * item = dataItem( "", NULL ); // empty path -> top level
5859
if ( item )
5960
{
60-
QgsDebugMsg ( "Add new top level item : " + item->name() );
61-
connectItem(item);
61+
QgsDebugMsg( "Add new top level item : " + item->name() );
62+
connectItem( item );
6263
mRootItems << item;
6364
}
6465
}
6566
}
6667

6768
QgsBrowserModel::~QgsBrowserModel()
6869
{
69-
foreach (QgsDataItem* item, mRootItems)
70+
foreach( QgsDataItem* item, mRootItems )
71+
{
7072
delete item;
73+
}
7174
}
7275

7376

7477
Qt::ItemFlags QgsBrowserModel::flags( const QModelIndex & index ) const
7578
{
76-
if (!index.isValid())
79+
if ( !index.isValid() )
7780
return 0;
7881

7982
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
8083
}
8184

8285
QVariant QgsBrowserModel::data( const QModelIndex & index, int role ) const
8386
{
84-
if (!index.isValid())
87+
if ( !index.isValid() )
8588
return QVariant();
8689

87-
QgsDataItem* ptr = (QgsDataItem*) index.internalPointer();
90+
QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
8891

89-
if (role == Qt::DisplayRole)
92+
if ( role == Qt::DisplayRole )
9093
{
91-
return QVariant(ptr->name());
94+
return QVariant( ptr->name() );
9295
}
93-
else if (role == Qt::DecorationRole && index.column() == 0)
96+
else if ( role == Qt::DecorationRole && index.column() == 0 )
9497
{
9598
return QVariant( ptr->icon() );
9699
}
@@ -101,49 +104,47 @@ QVariant QgsBrowserModel::data( const QModelIndex & index, int role ) const
101104

102105
QVariant QgsBrowserModel::headerData( int section, Qt::Orientation orientation, int role ) const
103106
{
104-
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
107+
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
105108
{
106-
return QVariant("header");
109+
return QVariant( "header" );
107110
}
108111

109112
return QVariant();
110113
}
111114

112115
int QgsBrowserModel::rowCount( const QModelIndex & parent ) const
113116
{
114-
//qDebug("rowCount: idx: (valid %d) %d %d", parent.isValid(), parent.row(), parent.column());
117+
//qDebug("rowCount: idx: (valid %d) %d %d", parent.isValid(), parent.row(), parent.column());
115118

116-
if (!parent.isValid())
117-
{
118-
// root item: its children are top level items
119-
return mRootItems.count(); // mRoot
120-
}
121-
else
122-
{
123-
// ordinary item: number of its children
124-
QgsDataItem* ptr = (QgsDataItem*) parent.internalPointer();
119+
if ( !parent.isValid() )
120+
{
121+
// root item: its children are top level items
122+
return mRootItems.count(); // mRoot
123+
}
124+
else
125+
{
126+
// ordinary item: number of its children
127+
QgsDataItem* ptr = ( QgsDataItem* ) parent.internalPointer();
125128

126-
return ptr->rowCount();
127-
}
129+
return ptr->rowCount();
130+
}
128131
}
129132

130-
bool QgsBrowserModel::hasChildren ( const QModelIndex & parent ) const
133+
bool QgsBrowserModel::hasChildren( const QModelIndex & parent ) const
131134
{
132-
if (!parent.isValid())
135+
if ( !parent.isValid() )
133136
{
134137
return true; // root item: its children are top level items
135138
}
136139
else
137140
{
138-
QgsDataItem* ptr = (QgsDataItem*) parent.internalPointer();
141+
QgsDataItem* ptr = ( QgsDataItem* ) parent.internalPointer();
139142

140143
return ptr->hasChildren();
141144
}
142-
143-
return false;
144145
}
145146

146-
int QgsBrowserModel::columnCount ( const QModelIndex & parent ) const
147+
int QgsBrowserModel::columnCount( const QModelIndex & parent ) const
147148
{
148149
return 1;
149150
}
@@ -152,28 +153,28 @@ QModelIndex QgsBrowserModel::index( int row, int column, const QModelIndex & par
152153
{
153154
//qDebug("index: idx: (valid %d) %d %d", parent.isValid(), parent.row(), parent.column());
154155

155-
if (!parent.isValid())
156+
if ( !parent.isValid() )
156157
{
157158
// this is the root item, parent of the top level items
158-
Q_ASSERT(column == 0 && row >= 0 && row < mRootItems.count());
159-
return createIndex(row,column, mRootItems[row]);
159+
Q_ASSERT( column == 0 && row >= 0 && row < mRootItems.count() );
160+
return createIndex( row, column, mRootItems[row] );
160161
}
161162
else
162163
{
163164
// this is ordinary item: return a valid index if the requested child exists
164-
QgsDataItem* ptr = (QgsDataItem*) parent.internalPointer();
165-
if (ptr->type() == QgsDataItem::Directory || ptr->type() == QgsDataItem::Collection)
165+
QgsDataItem* ptr = ( QgsDataItem* ) parent.internalPointer();
166+
if ( ptr->type() == QgsDataItem::Directory || ptr->type() == QgsDataItem::Collection )
166167
{
167168
// this is a directory: get index of its subdir!
168-
QgsDirectoryItem* di = (QgsDirectoryItem*) ptr;
169-
return createIndex(row, column, di->children().at(row));
169+
QgsDirectoryItem* di = ( QgsDirectoryItem* ) ptr;
170+
return createIndex( row, column, di->children().at( row ) );
170171
}
171-
if (ptr->type() == QgsDataItem::Layer)
172+
if ( ptr->type() == QgsDataItem::Layer )
172173
{
173174
return QModelIndex(); // has no children
174175
}
175176

176-
Q_ASSERT(false && "unknown item in index()");
177+
Q_ASSERT( false && "unknown item in index()" );
177178
}
178179

179180
return QModelIndex(); // if the child does not exist
@@ -196,7 +197,7 @@ QModelIndex QgsBrowserModel::index( QgsDataItem *item )
196197
break;
197198
}
198199
}
199-
QgsDebugMsg( QString ( "row = %1").arg(row) );
200+
QgsDebugMsg( QString( "row = %1" ).arg( row ) );
200201
Q_ASSERT( row >= 0 );
201202
index = createIndex( row, 0, item );
202203

@@ -205,51 +206,51 @@ QModelIndex QgsBrowserModel::index( QgsDataItem *item )
205206

206207
QModelIndex QgsBrowserModel::parent( const QModelIndex & index ) const
207208
{
208-
if (!index.isValid())
209+
if ( !index.isValid() )
209210
return QModelIndex();
210211

211212
// return QModelInde of parent, i.e. where the parent is within its parent :-)
212213

213214
//qDebug("parent of: %d %d", index.row(), index.column());
214215

215-
QgsDataItem* ptr = (QgsDataItem*) index.internalPointer();
216+
QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
216217
QgsDataItem* parentItem = ptr->parent();
217218

218-
if (parentItem == NULL)
219+
if ( parentItem == NULL )
219220
{
220221
// parent of our root is invalid index
221222
return QModelIndex();
222223
}
223224

224225
const QVector<QgsDataItem*>& children =
225-
parentItem->parent() ? ((QgsDirectoryItem*)parentItem->parent())->children() : mRootItems;
226-
Q_ASSERT(children.count() > 0);
226+
parentItem->parent() ? (( QgsDirectoryItem* )parentItem->parent() )->children() : mRootItems;
227+
Q_ASSERT( children.count() > 0 );
227228

228-
for (int i = 0; i < children.count(); i++)
229+
for ( int i = 0; i < children.count(); i++ )
229230
{
230-
if (children[i] == parentItem)
231-
return createIndex(i, 0, parentItem);
231+
if ( children[i] == parentItem )
232+
return createIndex( i, 0, parentItem );
232233
}
233234

234-
Q_ASSERT(false && "parent not found!");
235+
Q_ASSERT( false && "parent not found!" );
235236
return QModelIndex();
236237
}
237238

238239
/* Refresh dir path */
239240
void QgsBrowserModel::refresh( QString path, const QModelIndex& theIndex )
240241
{
241-
QStringList paths = path.split('/');
242-
for ( int i = 0; i < rowCount(theIndex); i++ )
242+
QStringList paths = path.split( '/' );
243+
for ( int i = 0; i < rowCount( theIndex ); i++ )
243244
{
244-
QModelIndex idx = index(i, 0, theIndex);
245-
QgsDataItem* ptr = (QgsDataItem*) idx.internalPointer();
245+
QModelIndex idx = index( i, 0, theIndex );
246+
QgsDataItem* ptr = ( QgsDataItem* ) idx.internalPointer();
246247
if ( ptr->path() == path )
247248
{
248249
QgsDebugMsg( "Arrived " + ptr->path() );
249250
ptr->refresh();
250251
return;
251252
}
252-
if ( path.indexOf ( ptr->path() ) == 0 )
253+
if ( path.indexOf( ptr->path() ) == 0 )
253254
{
254255
refresh( path, idx );
255256
break;
@@ -260,13 +261,13 @@ void QgsBrowserModel::refresh( QString path, const QModelIndex& theIndex )
260261
/* Refresh item */
261262
void QgsBrowserModel::refresh( const QModelIndex& theIndex )
262263
{
263-
if ( !theIndex.isValid () ) // root
264+
if ( !theIndex.isValid() ) // root
264265
{
265266
// Nothing to do I believe, mRootItems are always the same
266267
}
267268
else
268269
{
269-
QgsDataItem* ptr = (QgsDataItem*) theIndex.internalPointer();
270+
QgsDataItem* ptr = ( QgsDataItem* ) theIndex.internalPointer();
270271
QgsDebugMsg( "Refresh " + ptr->path() );
271272
ptr->refresh();
272273
}
@@ -277,13 +278,13 @@ void QgsBrowserModel::beginInsertItems( QgsDataItem* parent, int first, int last
277278
QgsDebugMsg( "parent mPath = " + parent->path() );
278279
QModelIndex idx = index( parent );
279280
if ( !idx.isValid() ) return;
280-
QgsDebugMsg( "valid");
281+
QgsDebugMsg( "valid" );
281282
beginInsertRows( idx, first, last );
282-
QgsDebugMsg( "end");
283+
QgsDebugMsg( "end" );
283284
}
284285
void QgsBrowserModel::endInsertItems()
285286
{
286-
QgsDebugMsg( "Entered");
287+
QgsDebugMsg( "Entered" );
287288
endInsertRows();
288289
}
289290
void QgsBrowserModel::beginRemoveItems( QgsDataItem* parent, int first, int last )
@@ -295,17 +296,17 @@ void QgsBrowserModel::beginRemoveItems( QgsDataItem* parent, int first, int last
295296
}
296297
void QgsBrowserModel::endRemoveItems()
297298
{
298-
QgsDebugMsg( "Entered");
299+
QgsDebugMsg( "Entered" );
299300
endRemoveRows();
300301
}
301-
void QgsBrowserModel::connectItem ( QgsDataItem* item )
302+
void QgsBrowserModel::connectItem( QgsDataItem* item )
302303
{
303-
connect ( item, SIGNAL(beginInsertItems ( QgsDataItem*, int, int )),
304-
this, SLOT(beginInsertItems( QgsDataItem*, int, int )) );
305-
connect ( item, SIGNAL(endInsertItems ()),
306-
this, SLOT(endInsertItems()) );
307-
connect ( item, SIGNAL(beginRemoveItems ( QgsDataItem*, int, int )),
308-
this, SLOT(beginRemoveItems( QgsDataItem*, int, int )) );
309-
connect ( item, SIGNAL(endRemoveItems ()),
310-
this, SLOT(endRemoveItems()) );
304+
connect( item, SIGNAL( beginInsertItems( QgsDataItem*, int, int ) ),
305+
this, SLOT( beginInsertItems( QgsDataItem*, int, int ) ) );
306+
connect( item, SIGNAL( endInsertItems() ),
307+
this, SLOT( endInsertItems() ) );
308+
connect( item, SIGNAL( beginRemoveItems( QgsDataItem*, int, int ) ),
309+
this, SLOT( beginRemoveItems( QgsDataItem*, int, int ) ) );
310+
connect( item, SIGNAL( endRemoveItems() ),
311+
this, SLOT( endRemoveItems() ) );
311312
}

‎src/core/qgsdataitem.cpp

100644100755
Lines changed: 188 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,79 @@
3434
#include "qgsapplication.h"
3535
#include "qgsdataitem.h"
3636

37-
#include "qgsdataprovider.h"
38-
#include "qgslogger.h"
39-
#include "qgsproviderregistry.h"
37+
#include "qgsdataprovider.h"
38+
#include "qgslogger.h"
39+
#include "qgsproviderregistry.h"
4040

4141
// 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" ) );
4488

89+
return icon;
90+
}
4591

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 )
48110
{
49111
}
50112

@@ -70,15 +132,15 @@ QPixmap QgsDataItem::getThemePixmap( const QString theName )
70132

71133
void QgsDataItem::emitBeginInsertItems( QgsDataItem* parent, int first, int last )
72134
{
73-
emit beginInsertItems ( parent, first, last );
135+
emit beginInsertItems( parent, first, last );
74136
}
75137
void QgsDataItem::emitEndInsertItems()
76138
{
77139
emit endInsertItems();
78140
}
79141
void QgsDataItem::emitBeginRemoveItems( QgsDataItem* parent, int first, int last )
80142
{
81-
emit beginRemoveItems ( parent, first, last );
143+
emit beginRemoveItems( parent, first, last );
82144
}
83145
void QgsDataItem::emitEndRemoveItems()
84146
{
@@ -94,123 +156,113 @@ QVector<QgsDataItem*> QgsDataItem::createChildren( )
94156
void QgsDataItem::populate()
95157
{
96158
QVector<QgsDataItem*> children = createChildren( );
97-
foreach ( QgsDataItem *child, children )
159+
foreach( QgsDataItem *child, children )
98160
{
99161
// initialization, do not refresh! That would result in infinite loop (beginInsertItems->rowCount->populate)
100-
addChildItem ( child);
162+
addChildItem( child );
101163
}
102164
mPopulated = true;
103165
}
104166

105167
int QgsDataItem::rowCount()
106168
{
107-
if (!mPopulated) populate();
169+
if ( !mPopulated ) populate();
108170
return mChildren.size();
109171
}
110172
bool QgsDataItem::hasChildren()
111173
{
112-
return ( mPopulated ? mChildren.count() > 0 : true);
174+
return ( mPopulated ? mChildren.count() > 0 : true );
113175
}
114176

115-
void QgsDataItem::addChildItem ( QgsDataItem * child, bool refresh )
177+
void QgsDataItem::addChildItem( QgsDataItem * child, bool refresh )
116178
{
117-
QgsDebugMsg( "mName = " + child->mName );
179+
QgsDebugMsg( "mName = " + child->mName );
118180
int i;
119181
for ( i = 0; i < mChildren.size(); i++ )
120182
{
121-
if ( mChildren[i]->mName.localeAwareCompare ( child->mName ) >= 0 ) break;
183+
if ( mChildren[i]->mName.localeAwareCompare( child->mName ) >= 0 ) break;
122184
}
123185

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 );
126188

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() ) );
135197

136198
if ( refresh ) emit endInsertItems();
137199

138200
}
139-
void QgsDataItem::deleteChildItem ( QgsDataItem * child )
201+
void QgsDataItem::deleteChildItem( QgsDataItem * child )
140202
{
141-
QgsDebugMsg( "mName = " + child->mName );
203+
QgsDebugMsg( "mName = " + child->mName );
142204
int i = mChildren.indexOf( child );
143205
Q_ASSERT( i >= 0 );
144-
emit beginRemoveItems ( this, i, i );
145-
mChildren.remove(i);
206+
emit beginRemoveItems( this, i, i );
207+
mChildren.remove( i );
146208
delete child;
147-
emit endRemoveItems ();
209+
emit endRemoveItems();
148210
}
149211

150-
int QgsDataItem::findItem ( QVector<QgsDataItem*> items, QgsDataItem * item )
212+
int QgsDataItem::findItem( QVector<QgsDataItem*> items, QgsDataItem * item )
151213
{
152214
for ( int i = 0; i < items.size(); i++ )
153215
{
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;
156218
}
157219
return -1;
158220
}
159221

160222
void QgsDataItem::refresh()
161223
{
162-
QgsDebugMsg ( "mPath = " + mPath );
224+
QgsDebugMsg( "mPath = " + mPath );
163225

164226
QVector<QgsDataItem*> items = createChildren( );
165227

166228
// Remove no more present items
167229
QVector<QgsDataItem*> remove;
168-
foreach ( QgsDataItem *child, mChildren )
230+
foreach( QgsDataItem *child, mChildren )
169231
{
170-
if ( findItem(items, child ) >= 0 ) continue;
171-
remove.append ( child );
232+
if ( findItem( items, child ) >= 0 ) continue;
233+
remove.append( child );
172234
}
173-
foreach ( QgsDataItem *child, remove )
235+
foreach( QgsDataItem *child, remove )
174236
{
175-
deleteChildItem ( child );
237+
deleteChildItem( child );
176238
}
177239

178240
// Add new items
179-
foreach ( QgsDataItem *item, items )
241+
foreach( QgsDataItem *item, items )
180242
{
181243
// Is it present in childs?
182-
if ( findItem ( mChildren, item ) >= 0 )
244+
if ( findItem( mChildren, item ) >= 0 )
183245
{
184246
delete item;
185247
continue;
186248
}
187-
addChildItem ( item, true );
249+
addChildItem( item, true );
188250
}
189251
}
190252

191253
// ---------------------------------------------------------------------
192254

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 )
196258
{
197-
if (sIconPoint.isNull())
259+
switch ( layerType )
198260
{
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;
214266
}
215267
}
216268

@@ -220,69 +272,62 @@ QgsMapLayer::LayerType QgsLayerItem::mapLayerType()
220272
return QgsMapLayer::VectorLayer;
221273
}
222274

223-
bool QgsLayerItem::equal(const QgsDataItem *other)
275+
bool QgsLayerItem::equal( const QgsDataItem *other )
224276
{
225277
//QgsDebugMsg ( mPath + " x " + other->mPath );
226278
if ( type() != other->type() )
227279
{
228280
return false;
229281
}
230282
//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 );
232284
return ( mPath == o->mPath && mName == o->mName && mUri == o->mUri && mProviderKey == o->mProviderKey );
233285
}
234286

235287
// ---------------------------------------------------------------------
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 )
238290
{
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-
}
248291
}
292+
249293
QgsDataCollectionItem::~QgsDataCollectionItem()
250294
{
251-
foreach (QgsDataItem* i, mChildren)
252-
delete i;
295+
foreach( QgsDataItem* i, mChildren )
296+
delete i;
253297
}
254298

255299
//-----------------------------------------------------------------------
256300
QVector<QgsDataProvider*> QgsDirectoryItem::mProviders = QVector<QgsDataProvider*>();
257301
QVector<QLibrary*> QgsDirectoryItem::mLibraries = QVector<QLibrary*>();
258302

259303

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 )
262306
{
263307
mType = Directory;
264-
mIcon = sDirIcon;
308+
mIcon = iconDir();
265309

266-
if ( mLibraries.size() == 0 ) {
310+
if ( mLibraries.size() == 0 )
311+
{
267312
QStringList keys = QgsProviderRegistry::instance()->providerList();
268313
QStringList::const_iterator i;
269-
for ( i = keys.begin(); i != keys.end(); ++i)
314+
for ( i = keys.begin(); i != keys.end(); ++i )
270315
{
271-
QString k(*i);
316+
QString k( *i );
272317
// some providers hangs with empty uri (Postgis) etc...
273318
// -> using libraries directly
274-
QLibrary *library = QgsProviderRegistry::instance()->getLibrary(k);
319+
QLibrary *library = QgsProviderRegistry::instance()->getLibrary( k );
275320
if ( library )
276321
{
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 )
279324
{
280-
QgsDebugMsg ( library->fileName() + " does not have dataCapabilities" );
325+
QgsDebugMsg( library->fileName() + " does not have dataCapabilities" );
281326
continue;
282327
}
283-
if ( dataCapabilities() == QgsDataProvider::NoDataCapabilities )
328+
if ( dataCapabilities() == QgsDataProvider::NoDataCapabilities )
284329
{
285-
QgsDebugMsg ( library->fileName() + " does not have File capability" );
330+
QgsDebugMsg( library->fileName() + " does not have File capability" );
286331
continue;
287332
}
288333
mLibraries.append( library );
@@ -302,43 +347,43 @@ QgsDirectoryItem::~QgsDirectoryItem()
302347
QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
303348
{
304349
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 )
308353
{
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() );
311356

312-
QgsDirectoryItem *item = new QgsDirectoryItem(this, subdir, subdirPath);
357+
QgsDirectoryItem *item = new QgsDirectoryItem( this, subdir, subdirPath );
313358
// propagate signals up to top
314359

315360
children.append( item );
316361
}
317362

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 )
320365
{
321366
QString path = dir.absoluteFilePath( name );
322-
foreach ( QLibrary *library, mLibraries )
367+
foreach( QLibrary *library, mLibraries )
323368
{
324369
// we could/should create separate list of providers for each purpose
325370

326371
// 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" ) );
328373
if ( !dataCapabilities ) continue;
329374

330375
int capabilities = dataCapabilities();
331376

332-
if ( ! (capabilities & QgsDataProvider::File) ) continue;
377+
if ( !( capabilities & QgsDataProvider::File ) ) continue;
333378

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 )
336381
{
337-
QgsDebugMsg ( library->fileName() + " does not have dataItem" );
382+
QgsDebugMsg( library->fileName() + " does not have dataItem" );
338383
continue;
339384
}
340385

341-
QgsDataItem * item = dataItem ( path, this );
386+
QgsDataItem * item = dataItem( path, this );
342387
if ( item )
343388
{
344389
children.append( item );
@@ -348,7 +393,7 @@ QVector<QgsDataItem*> QgsDirectoryItem::createChildren( )
348393
return children;
349394
}
350395

351-
bool QgsDirectoryItem::equal(const QgsDataItem *other)
396+
bool QgsDirectoryItem::equal( const QgsDataItem *other )
352397
{
353398
//QgsDebugMsg ( mPath + " x " + other->mPath );
354399
if ( type() != other->type() )
@@ -360,19 +405,19 @@ bool QgsDirectoryItem::equal(const QgsDataItem *other)
360405

361406
QWidget * QgsDirectoryItem::paramWidget()
362407
{
363-
return new QgsDirectoryParamWidget(mPath);
408+
return new QgsDirectoryParamWidget( mPath );
364409
}
365410

366-
QgsDirectoryParamWidget::QgsDirectoryParamWidget(QString path, QWidget* parent)
367-
: QTreeWidget(parent)
411+
QgsDirectoryParamWidget::QgsDirectoryParamWidget( QString path, QWidget* parent )
412+
: QTreeWidget( parent )
368413
{
369-
setRootIsDecorated(false);
414+
setRootIsDecorated( false );
370415

371416
// name, size, date, permissions, owner, group, type
372-
setColumnCount (7);
417+
setColumnCount( 7 );
373418
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 );
376421

377422
QStyle* style = QApplication::style();
378423
QIcon iconDirectory = QIcon( style->standardPixmap( QStyle::SP_DirClosedIcon ) );
@@ -381,28 +426,28 @@ QgsDirectoryParamWidget::QgsDirectoryParamWidget(QString path, QWidget* parent)
381426

382427
QList<QTreeWidgetItem *> items;
383428

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 )
387432
{
388-
QFileInfo fi ( dir.absoluteFilePath(name) );
433+
QFileInfo fi( dir.absoluteFilePath( name ) );
389434
QStringList texts;
390435
texts << name;
391436
QString size;
392-
if ( fi.size() > 1024 )
437+
if ( fi.size() > 1024 )
393438
{
394-
size = size.sprintf ( "%.1f KiB", fi.size()/1024.0 );
439+
size = size.sprintf( "%.1f KiB", fi.size() / 1024.0 );
395440
}
396-
else if ( fi.size() > 1.048576e6 )
441+
else if ( fi.size() > 1.048576e6 )
397442
{
398-
size = size.sprintf ( "%.1f MiB", fi.size()/1.048576e6 );
443+
size = size.sprintf( "%.1f MiB", fi.size() / 1.048576e6 );
399444
}
400445
else
401446
{
402447
size = QString( "%1 B" ).arg( fi.size() );
403448
}
404449
texts << size;
405-
texts << fi.lastModified().toString (Qt::SystemLocaleShortDate);
450+
texts << fi.lastModified().toString( Qt::SystemLocaleShortDate );
406451
QString perm;
407452
perm += fi.permission( QFile::ReadOwner ) ? 'r' : '-';
408453
perm += fi.permission( QFile::WriteOwner ) ? 'w' : '-';
@@ -423,53 +468,53 @@ QgsDirectoryParamWidget::QgsDirectoryParamWidget(QString path, QWidget* parent)
423468
QIcon icon;
424469
if ( fi.isDir() )
425470
{
426-
type = tr ( "folder" );
471+
type = tr( "folder" );
427472
icon = iconDirectory;
428473
}
429474
else if ( fi.isFile() )
430475
{
431-
type = tr ( "file" );
476+
type = tr( "file" );
432477
icon = iconFile;
433478
}
434479
else if ( fi.isSymLink() )
435480
{
436-
type = tr ( "link" );
481+
type = tr( "link" );
437482
icon = iconLink;
438483
}
439484

440485
texts << type;
441486

442-
QTreeWidgetItem *item = new QTreeWidgetItem (texts);
443-
item->setIcon(0, icon);
487+
QTreeWidgetItem *item = new QTreeWidgetItem( texts );
488+
item->setIcon( 0, icon );
444489
items << item;
445490
}
446491

447-
addTopLevelItems(items);
492+
addTopLevelItems( items );
448493

449494
// hide columns that are not requested
450495
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 )
453498
{
454499
setColumnHidden( colVariant.toInt(), true );
455500
}
456501
}
457502

458-
void QgsDirectoryParamWidget::mousePressEvent(QMouseEvent* event)
503+
void QgsDirectoryParamWidget::mousePressEvent( QMouseEvent* event )
459504
{
460505
if ( event->button() == Qt::RightButton )
461506
{
462507
// show the popup menu
463508
QMenu popupMenu;
464509

465510
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++ )
468513
{
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 ) );
473518
}
474519

475520
popupMenu.exec( event->globalPos() );
@@ -478,20 +523,20 @@ void QgsDirectoryParamWidget::mousePressEvent(QMouseEvent* event)
478523

479524
void QgsDirectoryParamWidget::showHideColumn()
480525
{
481-
QAction* action = qobject_cast<QAction*>(sender());
482-
if (!action)
526+
QAction* action = qobject_cast<QAction*>( sender() );
527+
if ( !action )
483528
return; // something is wrong
484529

485530
int columnIndex = action->objectName().toInt();
486-
setColumnHidden(columnIndex, !isColumnHidden(columnIndex));
531+
setColumnHidden( columnIndex, !isColumnHidden( columnIndex ) );
487532

488533
// save in settings
489534
QSettings settings;
490535
QList<QVariant> lst;
491-
for (int i = 0; i < columnCount(); i++)
536+
for ( int i = 0; i < columnCount(); i++ )
492537
{
493-
if (isColumnHidden(i))
494-
lst.append(QVariant(i));
538+
if ( isColumnHidden( i ) )
539+
lst.append( QVariant( i ) );
495540
}
496-
settings.setValue("/dataitem/directoryHiddenColumns", lst);
541+
settings.setValue( "/dataitem/directoryHiddenColumns", lst );
497542
}

‎src/core/qgsdataitem.h

100644100755
Lines changed: 78 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ class QgsDataItem;
3434

3535
// TODO: bad place, where to put this? qgsproviderregistry.h?
3636
typedef int dataCapabilities_t();
37-
typedef QgsDataItem * dataItem_t(QString, QgsDataItem*);
37+
typedef QgsDataItem * dataItem_t( QString, QgsDataItem* );
3838

3939

4040
/** base class for all items in the model */
4141
class CORE_EXPORT QgsDataItem : public QObject
4242
{
43-
Q_OBJECT
43+
Q_OBJECT
4444
public:
4545
enum Type
4646
{
@@ -49,7 +49,7 @@ class CORE_EXPORT QgsDataItem : public QObject
4949
Layer,
5050
};
5151

52-
QgsDataItem(QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path);
52+
QgsDataItem( QgsDataItem::Type type, QgsDataItem* parent, QString name, QString path );
5353
virtual ~QgsDataItem() {}
5454

5555
bool hasChildren();
@@ -68,12 +68,12 @@ class CORE_EXPORT QgsDataItem : public QObject
6868

6969
// Insert new child using alphabetical order based on mName, emits necessary signal to model before and after, sets parent and connects signals
7070
// refresh - refresh populated item, emit signals to model
71-
virtual void addChildItem ( QgsDataItem * child, bool refresh = false );
71+
virtual void addChildItem( QgsDataItem * child, bool refresh = false );
7272

7373
// remove and delete child item, signals to browser are emited
74-
virtual void deleteChildItem ( QgsDataItem * child );
74+
virtual void deleteChildItem( QgsDataItem * child );
7575

76-
virtual bool equal(const QgsDataItem *other) { return false; }
76+
virtual bool equal( const QgsDataItem *other ) { return false; }
7777

7878
virtual QWidget * paramWidget() { return 0; }
7979

@@ -86,7 +86,7 @@ class CORE_EXPORT QgsDataItem : public QObject
8686
};
8787

8888
// This will _write_ selected crs in data source
89-
virtual bool setCrs ( QgsCoordinateReferenceSystem crs ) { return false; }
89+
virtual bool setCrs( QgsCoordinateReferenceSystem crs ) { return false; }
9090

9191
virtual Capability capabilities() { return NoCapabilities; }
9292

@@ -95,7 +95,7 @@ class CORE_EXPORT QgsDataItem : public QObject
9595
static QPixmap getThemePixmap( const QString theName );
9696

9797
// Find child index in vector of items using '==' operator
98-
static int findItem ( QVector<QgsDataItem*> items, QgsDataItem * item );
98+
static int findItem( QVector<QgsDataItem*> items, QgsDataItem * item );
9999

100100
// members
101101

@@ -132,99 +132,106 @@ class CORE_EXPORT QgsDataItem : public QObject
132132
/** Item that represents a layer that can be opened with one of the providers */
133133
class CORE_EXPORT QgsLayerItem : public QgsDataItem
134134
{
135-
public:
136-
enum LayerType
137-
{
138-
NoType,
139-
Vector,
140-
Raster,
141-
Point,
142-
Line,
143-
Polygon,
144-
TableLayer,
145-
Database,
146-
Table
147-
};
135+
Q_OBJECT
136+
public:
137+
enum LayerType
138+
{
139+
NoType,
140+
Vector,
141+
Raster,
142+
Point,
143+
Line,
144+
Polygon,
145+
TableLayer,
146+
Database,
147+
Table
148+
};
148149

149-
QgsLayerItem(QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType, QString providerKey);
150+
QgsLayerItem( QgsDataItem* parent, QString name, QString path, QString uri, LayerType layerType, QString providerKey );
150151

151-
// --- reimplemented from QgsDataItem ---
152+
// --- reimplemented from QgsDataItem ---
152153

153-
virtual bool equal(const QgsDataItem *other);
154+
virtual bool equal( const QgsDataItem *other );
154155

155-
// --- New virtual methods for layer item derived classes ---
156+
// --- New virtual methods for layer item derived classes ---
156157

157-
// Returns QgsMapLayer::LayerType
158-
QgsMapLayer::LayerType mapLayerType();
158+
// Returns QgsMapLayer::LayerType
159+
QgsMapLayer::LayerType mapLayerType();
159160

160-
// Returns layer uri or empty string if layer cannot be created
161-
QString uri() { return mUri; }
161+
// Returns layer uri or empty string if layer cannot be created
162+
QString uri() { return mUri; }
162163

163-
// Returns provider key
164-
QString providerKey() { return mProviderKey; }
164+
// Returns provider key
165+
QString providerKey() { return mProviderKey; }
165166

166-
protected:
167+
protected:
167168

168-
QString mProviderKey;
169-
QString mUri;
170-
LayerType mLayerType;
169+
QString mProviderKey;
170+
QString mUri;
171+
LayerType mLayerType;
171172

172-
static QIcon sIconPoint, sIconLine, sIconPolygon, sIconTable, sIconDefault;
173+
static const QIcon &iconPoint();
174+
static const QIcon &iconLine();
175+
static const QIcon &iconPolygon();
176+
static const QIcon &iconTable();
177+
static const QIcon &iconDefault();
173178
};
174179

175180

176181
/** A Collection: logical collection of layers or subcollections, e.g. GRASS location/mapset, database? wms source? */
177182
class CORE_EXPORT QgsDataCollectionItem : public QgsDataItem
178183
{
179-
public:
180-
QgsDataCollectionItem( QgsDataItem* parent, QString name, QString path =0);
181-
~QgsDataCollectionItem();
184+
Q_OBJECT
185+
public:
186+
QgsDataCollectionItem( QgsDataItem* parent, QString name, QString path = 0 );
187+
~QgsDataCollectionItem();
182188

183-
void setPopulated() { mPopulated = true; }
184-
void addChild( QgsDataItem *item ) { mChildren.append(item); }
189+
void setPopulated() { mPopulated = true; }
190+
void addChild( QgsDataItem *item ) { mChildren.append( item ); }
185191

186-
static QIcon sDirIcon; // shared icon: open/closed directory
192+
static const QIcon &iconDir(); // shared icon: open/closed directory
187193
};
188194

189195
/** A directory: contains subdirectories and layers */
190196
class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
191197
{
192-
public:
193-
enum Column
194-
{
195-
Name,
196-
Size,
197-
Date,
198-
Permissions,
199-
Owner,
200-
Group,
201-
Type
202-
};
203-
QgsDirectoryItem(QgsDataItem* parent, QString name, QString path);
204-
~QgsDirectoryItem();
205-
206-
QVector<QgsDataItem*> createChildren();
207-
208-
virtual bool equal(const QgsDataItem *other);
209-
210-
virtual QWidget * paramWidget();
211-
212-
static QVector<QgsDataProvider*> mProviders;
213-
static QVector<QLibrary*> mLibraries;
198+
Q_OBJECT
199+
public:
200+
enum Column
201+
{
202+
Name,
203+
Size,
204+
Date,
205+
Permissions,
206+
Owner,
207+
Group,
208+
Type
209+
};
210+
QgsDirectoryItem( QgsDataItem* parent, QString name, QString path );
211+
~QgsDirectoryItem();
212+
213+
QVector<QgsDataItem*> createChildren();
214+
215+
virtual bool equal( const QgsDataItem *other );
216+
217+
virtual QWidget * paramWidget();
218+
219+
static QVector<QgsDataProvider*> mProviders;
220+
static QVector<QLibrary*> mLibraries;
214221
};
215222

216223
class QgsDirectoryParamWidget : public QTreeWidget
217224
{
218-
Q_OBJECT
225+
Q_OBJECT
219226

220-
public:
221-
QgsDirectoryParamWidget(QString path, QWidget* parent = NULL);
227+
public:
228+
QgsDirectoryParamWidget( QString path, QWidget* parent = NULL );
222229

223-
protected:
224-
void mousePressEvent(QMouseEvent* event);
230+
protected:
231+
void mousePressEvent( QMouseEvent* event );
225232

226-
public slots:
227-
void showHideColumn();
233+
public slots:
234+
void showHideColumn();
228235
};
229236

230237
#endif // QGSDATAITEM_H

0 commit comments

Comments
 (0)
Please sign in to comment.