Skip to content

Commit 107df1f

Browse files
committedJun 2, 2011
browser changes:
- use empty string as default wms style - update wms preview when render caching is enabled - some cleanups
1 parent 9ae32d3 commit 107df1f

File tree

4 files changed

+174
-179
lines changed

4 files changed

+174
-179
lines changed
 

‎src/browser/qgsbrowser.cpp

Lines changed: 75 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@
3434

3535

3636
QgsBrowser::QgsBrowser( QWidget *parent, Qt::WFlags flags )
37-
: QMainWindow( parent, flags ),
38-
mDirtyMetadata( true ), mDirtyPreview( true ), mDirtyAttributes( true ),
39-
mLayer( 0 ), mParamWidget( 0 )
37+
: QMainWindow( parent, flags )
38+
, mDirtyMetadata( true )
39+
, mDirtyPreview( true )
40+
, mDirtyAttributes( true )
41+
, mLayer( 0 )
42+
, mParamWidget( 0 )
4043
{
4144
setupUi( this );
4245

@@ -86,9 +89,9 @@ void QgsBrowser::expand( QString path, const QModelIndex& index )
8689
for ( int i = 0; i < mModel->rowCount( index ); i++ )
8790
{
8891
QModelIndex idx = mModel->index( i, 0, index );
89-
QgsDataItem* ptr = ( QgsDataItem* ) idx.internalPointer();
92+
QgsDataItem *item = mModel->dataItem( idx );
9093

91-
if ( path.indexOf( ptr->path() ) == 0 )
94+
if ( item && path.indexOf( item->path() ) == 0 )
9295
{
9396
treeView->expand( idx );
9497
treeView->scrollTo( idx, QAbstractItemView::PositionAtTop );
@@ -102,7 +105,9 @@ void QgsBrowser::itemClicked( const QModelIndex& index )
102105
{
103106
mIndex = index;
104107

105-
QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
108+
QgsDataItem *item = mModel->dataItem( index );
109+
if ( !item )
110+
return;
106111

107112
// Disable preview, attributes tab
108113

@@ -135,20 +140,18 @@ void QgsBrowser::itemClicked( const QModelIndex& index )
135140
mLayer = 0;
136141

137142
// this should probably go to the model and only emit signal when a layer is clicked
138-
139-
140-
mParamWidget = ptr->paramWidget();
143+
mParamWidget = item->paramWidget();
141144
if ( mParamWidget )
142145
{
143146
paramLayout->addWidget( mParamWidget );
144147
mParamWidget->show();
145148
paramEnable = true;
146149
}
147150

148-
if ( ptr->type() == QgsDataItem::Layer )
151+
QgsLayerItem *layerItem = qobject_cast<QgsLayerItem*>( mModel->dataItem( index ) );
152+
if ( layerItem )
149153
{
150-
QgsLayerItem* item = static_cast<QgsLayerItem*>( ptr );
151-
bool res = layerClicked( item );
154+
bool res = layerClicked( layerItem );
152155

153156
if ( res )
154157
{
@@ -169,9 +172,9 @@ void QgsBrowser::itemClicked( const QModelIndex& index )
169172
updateCurrentTab();
170173

171174
int selected = -1;
172-
if ( mLastTab.contains( ptr->metaObject()->className() ) )
175+
if ( mLastTab.contains( item->metaObject()->className() ) )
173176
{
174-
selected = mLastTab[ ptr->metaObject()->className() ];
177+
selected = mLastTab[ item->metaObject()->className()];
175178
}
176179

177180
// Enabling tabs call tabChanged !
@@ -183,22 +186,25 @@ void QgsBrowser::itemClicked( const QModelIndex& index )
183186
// select tab according last selection for this data item
184187
if ( selected >= 0 )
185188
{
186-
qDebug( "set tab %s %d", ptr->metaObject()->className(), selected );
189+
QgsDebugMsg( QString( "set tab %1 %2" ).arg( item->metaObject()->className() ).arg( selected ) );
187190
tabWidget->setCurrentIndex( selected );
188191
}
189192

190-
qDebug( "clicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data() );
193+
QgsDebugMsg( QString( "clicked: %1 %2 %3" ).arg( index.row() ).arg( index.column() ).arg( item->name() ) );
191194
}
192195

193-
bool QgsBrowser::layerClicked( QgsLayerItem* ptr )
196+
bool QgsBrowser::layerClicked( QgsLayerItem *item )
194197
{
195-
mActionSetProjection->setEnabled( ptr->capabilities() & QgsLayerItem::SetCrs );
198+
if ( !item )
199+
return false;
200+
201+
mActionSetProjection->setEnabled( item->capabilities() & QgsLayerItem::SetCrs );
196202

197-
QString uri = ptr->uri();
203+
QString uri = item->uri();
198204
if ( !uri.isEmpty() )
199205
{
200-
QgsMapLayer::LayerType type = ptr->mapLayerType();
201-
QString providerKey = ptr->providerKey();
206+
QgsMapLayer::LayerType type = item->mapLayerType();
207+
QString providerKey = item->providerKey();
202208

203209
QgsDebugMsg( providerKey + " : " + uri );
204210
if ( type == QgsMapLayer::VectorLayer )
@@ -253,26 +259,32 @@ bool QgsBrowser::layerClicked( QgsLayerItem* ptr )
253259

254260
void QgsBrowser::itemDoubleClicked( const QModelIndex& index )
255261
{
256-
QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
262+
QgsDataItem *item = mModel->dataItem( index );
263+
if ( !item )
264+
return;
257265

258266
// Currently doing nothing
259-
qDebug( "doubleclicked: %d %d %s", index.row(), index.column(), ptr->name().toAscii().data() );
267+
QgsDebugMsg( QString( "%1 %2 %3" ).arg( index.row() ).arg( index.column() ).arg( item->name() ) );
260268
}
261269

262270
void QgsBrowser::itemExpanded( const QModelIndex& index )
263271
{
264272
QSettings settings;
265-
QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
266-
/*
267-
if (ptr->mType == QgsDataItem::Directory || ptr->mType == QgsDataItem::Collection )
268-
{
269-
QgsDirectoryItem* i = (QgsDirectoryItem*) ptr;
270-
settings.setValue ( "/Browser/lastExpandedDir", i->mPath );
271-
}
272-
*/
273+
QgsDataItem *item = mModel->dataItem( index );
274+
if ( !item )
275+
return;
276+
277+
#if 0
278+
if ( item->mType == QgsDataItem::Directory || item->mType == QgsDataItem::Collection )
279+
{
280+
QgsDirectoryItem *i = qobject_cast<QgsDirectoryItem*>( item );
281+
settings.setValue( "/Browser/lastExpandedDir", i->mPath );
282+
}
283+
#endif
284+
273285
// TODO: save separately each type (FS, WMS)
274-
settings.setValue( "/Browser/lastExpanded", ptr->path() );
275-
QgsDebugMsg( "last expanded: " + ptr->path() );
286+
settings.setValue( "/Browser/lastExpanded", item->path() );
287+
QgsDebugMsg( "last expanded: " + item->path() );
276288
}
277289

278290
void QgsBrowser::newVectorLayer()
@@ -315,22 +327,26 @@ void QgsBrowser::on_mActionSetProjection_triggered()
315327
{
316328
if ( !mLayer )
317329
return;
330+
318331
QgsGenericProjectionSelector * mySelector = new QgsGenericProjectionSelector( this );
319332
mySelector->setMessage();
320333
mySelector->setSelectedCrsId( mLayer->crs().srsid() );
321334
if ( mySelector->exec() )
322335
{
323336
QgsCoordinateReferenceSystem srs( mySelector->selectedCrsId(), QgsCoordinateReferenceSystem::InternalCrsId );
337+
324338
// TODO: open data source in write mode set crs and save
325-
//mLayer->setCrs( srs );
339+
#if 0
340+
mLayer->setCrs( srs );
326341
// Is this safe?
327342
// selectedIndexes() is protected
343+
#endif
328344

329-
QgsDataItem* ptr = ( QgsDataItem* ) mIndex.internalPointer();
330-
if ( ptr->type() == QgsDataItem::Layer )
345+
QgsDataItem *item = mModel->dataItem( mIndex );
346+
QgsLayerItem *layerItem = qobject_cast<QgsLayerItem*>( item );
347+
if ( layerItem )
331348
{
332-
QgsLayerItem* layerItem = static_cast<QgsLayerItem*>( ptr );
333-
if ( ! layerItem->setCrs( srs ) )
349+
if ( !layerItem->setCrs( srs ) )
334350
{
335351
QMessageBox::critical( this, tr( "CRS" ), tr( "Cannot set layer CRS" ) );
336352
}
@@ -341,6 +357,7 @@ void QgsBrowser::on_mActionSetProjection_triggered()
341357
{
342358
QApplication::restoreOverrideCursor();
343359
}
360+
344361
delete mySelector;
345362
}
346363

@@ -452,6 +469,13 @@ void QgsBrowser::updateCurrentTab()
452469
fullExtent.scale( 1.05 ); // add some border
453470
mapCanvas->setExtent( fullExtent );
454471
mapCanvas->refresh();
472+
473+
QgsRasterLayer *rlayer = qobject_cast< QgsRasterLayer * >( mLayer );
474+
if ( rlayer )
475+
{
476+
connect( rlayer->dataProvider(), SIGNAL( dataChanged() ), rlayer, SLOT( clearCacheImage() ) );
477+
connect( rlayer->dataProvider(), SIGNAL( dataChanged() ), mapCanvas, SLOT( refresh() ) );
478+
}
455479
}
456480
mDirtyPreview = false;
457481
}
@@ -479,9 +503,12 @@ void QgsBrowser::tabChanged()
479503
// Store last selected tab for selected data item
480504
if ( mIndex.isValid() )
481505
{
482-
QObject* ptr = ( QObject* ) mIndex.internalPointer();
483-
QgsDebugMsg( QString( "save last tab %1 : %2" ).arg( ptr->metaObject()->className() ).arg( tabWidget->currentIndex() ) );
484-
mLastTab[ ptr->metaObject()->className() ] = tabWidget->currentIndex();
506+
QgsDataItem *item = mModel->dataItem( mIndex );
507+
if ( !item )
508+
return;
509+
510+
QgsDebugMsg( QString( "save last tab %1 : %2" ).arg( item->metaObject()->className() ).arg( tabWidget->currentIndex() ) );
511+
mLastTab[ item->metaObject()->className()] = tabWidget->currentIndex();
485512
}
486513
}
487514

@@ -496,10 +523,15 @@ void QgsBrowser::refresh( const QModelIndex& index )
496523
QgsDebugMsg( "Entered" );
497524
if ( index.isValid() )
498525
{
499-
QgsDataItem* item = ( QgsDataItem* ) index.internalPointer();
500-
QgsDebugMsg( "path = " + item->path() );
526+
QgsDataItem *item = mModel->dataItem( index );
527+
if ( item )
528+
QgsDebugMsg( "path = " + item->path() );
529+
else
530+
QgsDebugMsg( "invalid item" );
501531
}
532+
502533
mModel->refresh( index );
534+
503535
for ( int i = 0 ; i < mModel->rowCount( index ); i++ )
504536
{
505537
QModelIndex idx = mModel->index( i, 0, index );

‎src/browser/qgsbrowsermodel.cpp

Lines changed: 76 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ QgsBrowserModel::QgsBrowserModel( QObject *parent ) :
4343
}
4444

4545
int capabilities = dataCapabilities();
46-
if ( capabilities == QgsDataProvider::NoDataCapabilities )
46+
if ( capabilities == QgsDataProvider::NoDataCapabilities )
4747
{
4848
QgsDebugMsg( library->fileName() + " does not have any dataCapabilities" );
4949
continue;
5050
}
5151

5252
dataItem_t * dataItem = ( dataItem_t * ) cast_to_fptr( library->resolve( "dataItem" ) );
53-
if ( ! dataItem )
53+
if ( !dataItem )
5454
{
5555
QgsDebugMsg( library->fileName() + " does not have dataItem" );
5656
continue;
5757
}
5858

59-
QgsDataItem * item = dataItem( "", NULL ); // empty path -> top level
59+
QgsDataItem *item = dataItem( "", NULL ); // empty path -> top level
6060
if ( item )
6161
{
6262
QgsDebugMsg( "Add new top level item : " + item->name() );
@@ -83,24 +83,29 @@ Qt::ItemFlags QgsBrowserModel::flags( const QModelIndex & index ) const
8383
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
8484
}
8585

86-
QVariant QgsBrowserModel::data( const QModelIndex & index, int role ) const
86+
QVariant QgsBrowserModel::data( const QModelIndex &index, int role ) const
8787
{
8888
if ( !index.isValid() )
8989
return QVariant();
9090

91-
QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
92-
93-
if ( role == Qt::DisplayRole )
91+
QgsDataItem *item = dataItem( index );
92+
if ( !item )
9493
{
95-
return QVariant( ptr->name() );
94+
return QVariant();
95+
}
96+
else if ( role == Qt::DisplayRole )
97+
{
98+
return item->name();
9699
}
97100
else if ( role == Qt::DecorationRole && index.column() == 0 )
98101
{
99-
return QVariant( ptr->icon() );
102+
return item->icon();
103+
}
104+
else
105+
{
106+
// unsupported role
107+
return QVariant();
100108
}
101-
102-
// unsupported role
103-
return QVariant();
104109
}
105110

106111
QVariant QgsBrowserModel::headerData( int section, Qt::Orientation orientation, int role ) const
@@ -113,7 +118,7 @@ QVariant QgsBrowserModel::headerData( int section, Qt::Orientation orientation,
113118
return QVariant();
114119
}
115120

116-
int QgsBrowserModel::rowCount( const QModelIndex & parent ) const
121+
int QgsBrowserModel::rowCount( const QModelIndex &parent ) const
117122
{
118123
//qDebug("rowCount: idx: (valid %d) %d %d", parent.isValid(), parent.row(), parent.column());
119124

@@ -125,159 +130,100 @@ int QgsBrowserModel::rowCount( const QModelIndex & parent ) const
125130
else
126131
{
127132
// ordinary item: number of its children
128-
QgsDataItem* ptr = ( QgsDataItem* ) parent.internalPointer();
129-
130-
return ptr->rowCount();
133+
QgsDataItem *item = dataItem( parent );
134+
return item ? item->rowCount() : 0;
131135
}
132136
}
133137

134138
bool QgsBrowserModel::hasChildren( const QModelIndex & parent ) const
135139
{
136140
if ( !parent.isValid() )
137-
{
138141
return true; // root item: its children are top level items
139-
}
140-
else
141-
{
142-
QgsDataItem* ptr = ( QgsDataItem* ) parent.internalPointer();
143142

144-
return ptr->hasChildren();
145-
}
143+
QgsDataItem *item = dataItem( parent );
144+
return item && item->hasChildren();
146145
}
147146

148147
int QgsBrowserModel::columnCount( const QModelIndex & parent ) const
149148
{
150149
return 1;
151150
}
152151

153-
QModelIndex QgsBrowserModel::index( int row, int column, const QModelIndex & parent ) const
152+
/* Refresh dir path */
153+
void QgsBrowserModel::refresh( QString path, const QModelIndex &theIndex )
154154
{
155-
//qDebug("index: idx: (valid %d) %d %d", parent.isValid(), parent.row(), parent.column());
156-
157-
if ( !parent.isValid() )
158-
{
159-
// this is the root item, parent of the top level items
160-
Q_ASSERT( column == 0 && row >= 0 && row < mRootItems.count() );
161-
return createIndex( row, column, mRootItems[row] );
162-
}
163-
else
155+
QStringList paths = path.split( '/' );
156+
for ( int i = 0; i < rowCount( theIndex ); i++ )
164157
{
165-
// this is ordinary item: return a valid index if the requested child exists
166-
QgsDataItem* ptr = ( QgsDataItem* ) parent.internalPointer();
167-
if ( ptr->type() == QgsDataItem::Directory || ptr->type() == QgsDataItem::Collection )
168-
{
169-
// this is a directory: get index of its subdir!
170-
QgsDirectoryItem* di = ( QgsDirectoryItem* ) ptr;
171-
return createIndex( row, column, di->children().at( row ) );
172-
}
173-
if ( ptr->type() == QgsDataItem::Layer )
158+
QModelIndex idx = index( i, 0, theIndex );
159+
QgsDataItem *item = dataItem( idx );
160+
if ( !item )
161+
break;
162+
163+
if ( item->path() == path )
174164
{
175-
return QModelIndex(); // has no children
165+
QgsDebugMsg( "Arrived " + item->path() );
166+
item->refresh();
167+
return;
176168
}
177169

178-
Q_ASSERT( false && "unknown item in index()" );
179-
}
180-
181-
return QModelIndex(); // if the child does not exist
182-
}
183-
184-
QModelIndex QgsBrowserModel::index( QgsDataItem *item )
185-
{
186-
// Item index
187-
QModelIndex index = QModelIndex();
188-
189-
const QVector<QgsDataItem*>& children = item->parent() ? item->parent()->children() : mRootItems;
190-
191-
Q_ASSERT( children.size() > 0 );
192-
int row = -1;
193-
for ( int i = 0; i < children.size(); i++ )
194-
{
195-
if ( item == children[i] )
170+
if ( path.indexOf( item->path() ) == 0 )
196171
{
197-
row = i;
172+
refresh( path, idx );
198173
break;
199174
}
200175
}
201-
QgsDebugMsg( QString( "row = %1" ).arg( row ) );
202-
Q_ASSERT( row >= 0 );
203-
index = createIndex( row, 0, item );
176+
}
204177

205-
return index;
178+
QModelIndex QgsBrowserModel::index( int row, int column, const QModelIndex &parent ) const
179+
{
180+
QgsDataItem *p = dataItem( parent );
181+
const QVector<QgsDataItem*> &items = p ? p->children() : mRootItems;
182+
QgsDataItem *item = items.value( row, 0 );
183+
return item ? createIndex( row, column, item ) : QModelIndex();
206184
}
207185

208-
QModelIndex QgsBrowserModel::parent( const QModelIndex & index ) const
186+
QModelIndex QgsBrowserModel::parent( const QModelIndex &index ) const
209187
{
210-
if ( !index.isValid() )
188+
QgsDataItem *item = dataItem( index );
189+
if ( !item )
211190
return QModelIndex();
212191

213-
// return QModelInde of parent, i.e. where the parent is within its parent :-)
214-
215-
//qDebug("parent of: %d %d", index.row(), index.column());
192+
return findItem( item->parent() );
193+
}
216194

217-
QgsDataItem* ptr = ( QgsDataItem* ) index.internalPointer();
218-
QgsDataItem* parentItem = ptr->parent();
195+
QModelIndex QgsBrowserModel::findItem( QgsDataItem *item, QgsDataItem *parent ) const
196+
{
197+
const QVector<QgsDataItem*> &items = parent ? parent->children() : mRootItems;
219198

220-
if ( parentItem == NULL )
199+
for ( int i = 0; i < items.size(); i++ )
221200
{
222-
// parent of our root is invalid index
223-
return QModelIndex();
224-
}
225-
226-
const QVector<QgsDataItem*>& children =
227-
parentItem->parent() ? (( QgsDirectoryItem* )parentItem->parent() )->children() : mRootItems;
228-
Q_ASSERT( children.count() > 0 );
201+
if ( items[i] == item )
202+
return createIndex( i, 0, item );
229203

230-
for ( int i = 0; i < children.count(); i++ )
231-
{
232-
if ( children[i] == parentItem )
233-
return createIndex( i, 0, parentItem );
204+
QModelIndex childIndex = findItem( item, items[i] );
205+
if ( childIndex.isValid() )
206+
return childIndex;
234207
}
235208

236-
Q_ASSERT( false && "parent not found!" );
237209
return QModelIndex();
238210
}
239211

240-
/* Refresh dir path */
241-
void QgsBrowserModel::refresh( QString path, const QModelIndex& theIndex )
242-
{
243-
QStringList paths = path.split( '/' );
244-
for ( int i = 0; i < rowCount( theIndex ); i++ )
245-
{
246-
QModelIndex idx = index( i, 0, theIndex );
247-
QgsDataItem* ptr = ( QgsDataItem* ) idx.internalPointer();
248-
if ( ptr->path() == path )
249-
{
250-
QgsDebugMsg( "Arrived " + ptr->path() );
251-
ptr->refresh();
252-
return;
253-
}
254-
if ( path.indexOf( ptr->path() ) == 0 )
255-
{
256-
refresh( path, idx );
257-
break;
258-
}
259-
}
260-
}
261-
262212
/* Refresh item */
263213
void QgsBrowserModel::refresh( const QModelIndex& theIndex )
264214
{
265-
if ( !theIndex.isValid() ) // root
266-
{
267-
// Nothing to do I believe, mRootItems are always the same
268-
}
269-
else
270-
{
271-
QgsDataItem* ptr = ( QgsDataItem* ) theIndex.internalPointer();
272-
QgsDebugMsg( "Refresh " + ptr->path() );
273-
ptr->refresh();
274-
}
215+
QgsDataItem *item = dataItem( theIndex );
216+
if ( !item )
217+
return;
218+
219+
QgsDebugMsg( "Refresh " + item->path() );
220+
item->refresh();
275221
}
276222

277-
void QgsBrowserModel::beginInsertItems( QgsDataItem* parent, int first, int last )
223+
void QgsBrowserModel::beginInsertItems( QgsDataItem *parent, int first, int last )
278224
{
279225
QgsDebugMsg( "parent mPath = " + parent->path() );
280-
QModelIndex idx = index( parent );
226+
QModelIndex idx = findItem( parent );
281227
if ( !idx.isValid() )
282228
return;
283229
QgsDebugMsg( "valid" );
@@ -289,10 +235,10 @@ void QgsBrowserModel::endInsertItems()
289235
QgsDebugMsg( "Entered" );
290236
endInsertRows();
291237
}
292-
void QgsBrowserModel::beginRemoveItems( QgsDataItem* parent, int first, int last )
238+
void QgsBrowserModel::beginRemoveItems( QgsDataItem *parent, int first, int last )
293239
{
294240
QgsDebugMsg( "parent mPath = " + parent->path() );
295-
QModelIndex idx = index( parent );
241+
QModelIndex idx = findItem( parent );
296242
if ( !idx.isValid() )
297243
return;
298244
beginRemoveRows( idx, first, last );
@@ -313,3 +259,11 @@ void QgsBrowserModel::connectItem( QgsDataItem* item )
313259
connect( item, SIGNAL( endRemoveItems() ),
314260
this, SLOT( endRemoveItems() ) );
315261
}
262+
263+
QgsDataItem *QgsBrowserModel::dataItem( const QModelIndex &idx ) const
264+
{
265+
void *v = idx.internalPointer();
266+
QgsDataItem *d = reinterpret_cast<QgsDataItem*>( v );
267+
Q_ASSERT( !v || d );
268+
return d;
269+
}

‎src/browser/qgsbrowsermodel.h

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class QgsBrowserModel : public QAbstractItemModel
1010
{
1111
Q_OBJECT
12+
1213
public:
1314
explicit QgsBrowserModel( QObject *parent = 0 );
1415
~QgsBrowserModel();
@@ -17,49 +18,57 @@ class QgsBrowserModel : public QAbstractItemModel
1718

1819
/** Used by other components to obtain information about each item provided by the model.
1920
In many models, the combination of flags should include Qt::ItemIsEnabled and Qt::ItemIsSelectable. */
20-
virtual Qt::ItemFlags flags( const QModelIndex & index ) const;
21+
virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
22+
2123
/** Used to supply item data to views and delegates. Generally, models only need to supply data
2224
for Qt::DisplayRole and any application-specific user roles, but it is also good practice
2325
to provide data for Qt::ToolTipRole, Qt::AccessibleTextRole, and Qt::AccessibleDescriptionRole.
2426
See the Qt::ItemDataRole enum documentation for information about the types associated with each role. */
25-
virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
27+
virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
28+
2629
/** Provides views with information to show in their headers. The information is only retrieved
2730
by views that can display header information. */
2831
virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
2932

3033
/** Provides the number of rows of data exposed by the model. */
31-
virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
34+
virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const;
35+
3236
/** Provides the number of columns of data exposed by the model. List models do not provide this function
3337
because it is already implemented in QAbstractListModel. */
34-
virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
38+
virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const;
3539

3640
/** Returns the index of the item in the model specified by the given row, column and parent index. */
3741
virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
3842

39-
QModelIndex index( QgsDataItem *item );
43+
QModelIndex findItem( QgsDataItem *item, QgsDataItem *parent = 0 ) const;
4044

41-
/** Returns the parent of the model item with the given index. If the item has no parent, an invalid QModelIndex is returned. */
42-
virtual QModelIndex parent( const QModelIndex & index ) const;
45+
/** Returns the parent of the model item with the given index.
46+
* If the item has no parent, an invalid QModelIndex is returned.
47+
*/
48+
virtual QModelIndex parent( const QModelIndex &index ) const;
4349

50+
QgsDataItem *dataItem( const QModelIndex &idx ) const;
4451

45-
bool hasChildren( const QModelIndex & parent = QModelIndex() ) const;
52+
bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
4653

4754
// Refresh item specified by path
48-
void refresh( QString path, const QModelIndex& index = QModelIndex() );
55+
void refresh( QString path, const QModelIndex &index = QModelIndex() );
56+
4957
// Refresh item childs
50-
void refresh( const QModelIndex& index = QModelIndex() );
58+
void refresh( const QModelIndex &index = QModelIndex() );
59+
60+
void connectItem( QgsDataItem *item );
5161

52-
void connectItem( QgsDataItem * item );
5362
signals:
5463

5564
public slots:
5665
//void removeItems( QgsDataItem * parent, QVector<QgsDataItem *>items );
5766
//void addItems( QgsDataItem * parent, QVector<QgsDataItem *>items );
5867
//void refreshItems( QgsDataItem * parent, QVector<QgsDataItem *>items );
5968

60-
void beginInsertItems( QgsDataItem* parent, int first, int last );
69+
void beginInsertItems( QgsDataItem *parent, int first, int last );
6170
void endInsertItems();
62-
void beginRemoveItems( QgsDataItem* parent, int first, int last );
71+
void beginRemoveItems( QgsDataItem *parent, int first, int last );
6372
void endRemoveItems();
6473

6574
protected:

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@ QString QgsWMSLayerItem::createUri()
31843184
}
31853185
else
31863186
{
3187-
styles << "default"; // TODO: use loadDefaultStyleFlag
3187+
styles << ""; // TODO: use loadDefaultStyleFlag
31883188
}
31893189

31903190
QString format;

0 commit comments

Comments
 (0)
Please sign in to comment.