Skip to content

Commit

Permalink
use QgsBrowserTreeView in qbrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Jan 21, 2015
1 parent 4549a38 commit f0a7a1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
41 changes: 9 additions & 32 deletions src/browser/qgsbrowser.cpp
Expand Up @@ -78,15 +78,8 @@ QgsBrowser::QgsBrowser( QWidget *parent, Qt::WindowFlags flags )

mapCanvas->setCanvasColor( Qt::white );

QSettings settings;
QString lastPath = settings.value( "/Browser/lastExpanded" ).toString();
QgsDebugMsg( "lastPath = " + lastPath );
if ( !lastPath.isEmpty() )
{
expandPath( lastPath );
}

//Set the icon size of for all the toolbars created in the future.
QSettings settings;
int size = settings.value( "/IconSize", QGIS_ICON_SIZE ).toInt();
setIconSize( QSize( size, size ) );

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

void QgsBrowser::itemExpanded( const QModelIndex& index )
{
QSettings settings;
QgsDataItem *item = mModel->dataItem( index );
if ( !item )
return;

#if 0
if ( item->mType == QgsDataItem::Directory || item->mType == QgsDataItem::Collection )
{
QgsDirectoryItem *i = qobject_cast<QgsDirectoryItem*>( item );
settings.setValue( "/Browser/lastExpandedDir", i->mPath );
}
#endif

// TODO: save separately each type (FS, WMS)
settings.setValue( "/Browser/lastExpanded", item->path() );
QgsDebugMsg( "last expanded: " + item->path() );
}

void QgsBrowser::newVectorLayer()
{
// Set file dialog to last selected dir
QSettings settings;
QString lastPath = settings.value( "/Browser/lastExpanded" ).toString();
if ( !lastPath.isEmpty() )
QModelIndex selectedIndex = treeView->selectionModel()->currentIndex();
if ( selectedIndex.isValid() )
{
settings.setValue( "/UI/lastVectorFileFilterDir", lastPath );
QgsDirectoryItem * dirItem = qobject_cast<QgsDirectoryItem *>( mModel->dataItem( selectedIndex ) );
if ( dirItem )
{
QSettings settings;
settings.setValue( "/UI/lastVectorFileFilterDir", dirItem->dirPath() );
}
}

QString fileName = QgsNewVectorLayerDialog::runAndCreateLayer( this );
Expand Down
1 change: 0 additions & 1 deletion src/browser/qgsbrowser.h
Expand Up @@ -41,7 +41,6 @@ class QgsBrowser : public QMainWindow, private Ui::QgsBrowserBase
public slots:
void itemClicked( const QModelIndex& index );
void itemDoubleClicked( const QModelIndex& index );
void itemExpanded( const QModelIndex& index );
void on_mActionSetProjection_triggered();
void on_mActionWmsConnections_triggered();
void on_mActionRefresh_triggered();
Expand Down
2 changes: 1 addition & 1 deletion src/browser/qgsbrowserbase.ui
Expand Up @@ -41,7 +41,7 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeView" name="treeView">
<widget class="QgsBrowserTreeView" name="treeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>1</horstretch>
Expand Down

0 comments on commit f0a7a1c

Please sign in to comment.