Skip to content

Commit f0a7a1c

Browse files
committedJan 21, 2015
use QgsBrowserTreeView in qbrowser
1 parent 4549a38 commit f0a7a1c

File tree

3 files changed

+10
-34
lines changed

3 files changed

+10
-34
lines changed
 

‎src/browser/qgsbrowser.cpp

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,8 @@ QgsBrowser::QgsBrowser( QWidget *parent, Qt::WindowFlags flags )
7878

7979
mapCanvas->setCanvasColor( Qt::white );
8080

81-
QSettings settings;
82-
QString lastPath = settings.value( "/Browser/lastExpanded" ).toString();
83-
QgsDebugMsg( "lastPath = " + lastPath );
84-
if ( !lastPath.isEmpty() )
85-
{
86-
expandPath( lastPath );
87-
}
88-
8981
//Set the icon size of for all the toolbars created in the future.
82+
QSettings settings;
9083
int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt();
9184
setIconSize( QSize( size, size ) );
9285

@@ -258,34 +251,18 @@ void QgsBrowser::itemDoubleClicked( const QModelIndex& index )
258251
QgsDebugMsg( QString( "%1 %2 %3" ).arg( index.row() ).arg( index.column() ).arg( item->name() ) );
259252
}
260253

261-
void QgsBrowser::itemExpanded( const QModelIndex& index )
262-
{
263-
QSettings settings;
264-
QgsDataItem *item = mModel->dataItem( index );
265-
if ( !item )
266-
return;
267-
268-
#if 0
269-
if ( item->mType == QgsDataItem::Directory || item->mType == QgsDataItem::Collection )
270-
{
271-
QgsDirectoryItem *i = qobject_cast<QgsDirectoryItem*>( item );
272-
settings.setValue( "/Browser/lastExpandedDir", i->mPath );
273-
}
274-
#endif
275-
276-
// TODO: save separately each type (FS, WMS)
277-
settings.setValue( "/Browser/lastExpanded", item->path() );
278-
QgsDebugMsg( "last expanded: " + item->path() );
279-
}
280-
281254
void QgsBrowser::newVectorLayer()
282255
{
283256
// Set file dialog to last selected dir
284-
QSettings settings;
285-
QString lastPath = settings.value( "/Browser/lastExpanded" ).toString();
286-
if ( !lastPath.isEmpty() )
257+
QModelIndex selectedIndex = treeView->selectionModel()->currentIndex();
258+
if ( selectedIndex.isValid() )
287259
{
288-
settings.setValue( "/UI/lastVectorFileFilterDir", lastPath );
260+
QgsDirectoryItem * dirItem = qobject_cast<QgsDirectoryItem *>( mModel->dataItem( selectedIndex ) );
261+
if ( dirItem )
262+
{
263+
QSettings settings;
264+
settings.setValue( "/UI/lastVectorFileFilterDir", dirItem->dirPath() );
265+
}
289266
}
290267

291268
QString fileName = QgsNewVectorLayerDialog::runAndCreateLayer( this );

‎src/browser/qgsbrowser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class QgsBrowser : public QMainWindow, private Ui::QgsBrowserBase
4141
public slots:
4242
void itemClicked( const QModelIndex& index );
4343
void itemDoubleClicked( const QModelIndex& index );
44-
void itemExpanded( const QModelIndex& index );
4544
void on_mActionSetProjection_triggered();
4645
void on_mActionWmsConnections_triggered();
4746
void on_mActionRefresh_triggered();

‎src/browser/qgsbrowserbase.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<property name="orientation">
4242
<enum>Qt::Horizontal</enum>
4343
</property>
44-
<widget class="QTreeView" name="treeView">
44+
<widget class="QgsBrowserTreeView" name="treeView">
4545
<property name="sizePolicy">
4646
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
4747
<horstretch>1</horstretch>

0 commit comments

Comments
 (0)