16 #include <QApplication>
34 return QString::localeAwareCompare( a->
name(), b->
name() ) < 0;
38 : QAbstractItemModel( parent )
58 emit layoutAboutToBeChanged();
85 QStyle *style = QApplication::style();
86 QIcon homeIcon( style->standardPixmap( QStyle::SP_DirHomeIcon ) );
100 foreach ( QFileInfo drive, QDir::drives() )
102 QString path = drive.absolutePath();
110 QString path = QString(
"/Volumes" );
120 QMap<int, QgsDataItem *> providerMap;
122 foreach ( QString key, providersList )
129 if ( !dataCapabilities )
131 QgsDebugMsg( library->fileName() +
" does not have dataCapabilities" );
135 int capabilities = dataCapabilities();
138 QgsDebugMsg( library->fileName() +
" does not have any dataCapabilities" );
145 QgsDebugMsg( library->fileName() +
" does not have dataItem" );
154 providerMap.insertMulti( capabilities, item );
159 foreach (
int key, providerMap.uniqueKeys() )
161 QList<QgsDataItem *> providerGroup = providerMap.values( key );
162 if ( providerGroup.size() > 1 )
187 if ( !index.isValid() )
190 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
195 flags |= Qt::ItemIsDragEnabled;
198 flags |= Qt::ItemIsDropEnabled;
204 if ( !index.isValid() )
212 else if ( role == Qt::DisplayRole )
216 else if ( role == Qt::ToolTipRole )
220 else if ( role == Qt::DecorationRole && index.column() == 0 )
234 if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
236 return QVariant(
"header" );
246 if ( !parent.isValid() )
261 if ( !parent.isValid() )
276 QModelIndex theIndex;
277 bool foundChild =
true;
283 for (
int i = 0; i <
rowCount( theIndex ); i++ )
285 QModelIndex idx =
index( i, 0, theIndex );
288 return QModelIndex();
290 if ( item->
path() == path )
296 if ( path.startsWith( item->
path() ) )
306 return QModelIndex();
333 return item ? createIndex( row, column, item ) : QModelIndex();
340 return QModelIndex();
349 for (
int i = 0; i < items.size(); i++ )
351 if ( items[i] == item )
352 return createIndex( i, 0, item );
354 QModelIndex childIndex =
findItem( item, items[i] );
355 if ( childIndex.isValid() )
359 return QModelIndex();
376 QModelIndex idx =
findItem( parent );
377 if ( !idx.isValid() )
380 beginInsertRows( idx, first, last );
391 QModelIndex idx =
findItem( parent );
392 if ( !idx.isValid() )
394 beginRemoveRows( idx, first, last );
418 types <<
"application/x-vnd.qgis.qgis.uri";
425 foreach (
const QModelIndex &
index, indexes )
427 if ( index.isValid() )
455 void *v = idx.internalPointer();