Skip to content

Commit 48e7e20

Browse files
committedNov 4, 2018
Move some browser directory action handling from core/gui to app
1 parent c9f9374 commit 48e7e20

15 files changed

+344
-130
lines changed
 

‎python/core/auto_generated/qgsbrowsermodel.sip.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ Removes a favorite directory from its corresponding model index.
184184
.. versionadded:: 3.0
185185
%End
186186

187+
187188
void updateProjectHome();
188189

189190
void hidePath( QgsDataItem *item );

‎python/core/auto_generated/qgsdataitem.sip.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,10 +597,6 @@ Constructor.
597597
Check if the given path is hidden from the browser model
598598
%End
599599

600-
virtual QList<QAction *> actions( QWidget *parent );
601-
602-
603-
604600
public slots:
605601
virtual void childrenCreated();
606602

‎python/gui/auto_generated/qgsbrowserdockwidget.sip.in

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,23 @@ false if the index is not a map layer or could not be loaded.
7171
Show context menu
7272
%End
7373

74-
void addFavorite();
74+
void addFavorite() /Deprecated/;
7575
%Docstring
76-
Add current item to favorite
76+
Add current item to favorite.
77+
78+
.. deprecated:: will be removed in QGIS 4.0 - use the methods in QgsBrowserModel instead
7779
%End
80+
7881
void addFavoriteDirectory();
7982
%Docstring
8083
Add directory from file dialog to favorite
8184
%End
82-
void removeFavorite();
85+
86+
void removeFavorite() /Deprecated/;
8387
%Docstring
84-
Remove from favorite
88+
Remove from favorite.
89+
90+
.. deprecated:: will be removed in QGIS 4.0 - use the methods in QgsBrowserModel instead
8591
%End
8692

8793
void refresh();
@@ -126,11 +132,15 @@ Show the layer properties
126132
%Docstring
127133
Hide current item
128134
%End
129-
void toggleFastScan();
135+
136+
void toggleFastScan() /Deprecated/;
130137
%Docstring
131138
Toggle fast scan
139+
140+
.. deprecated:: will be removed in QGIS 4.0
132141
%End
133142

143+
134144
void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
135145
%Docstring
136146
Selection has changed

‎src/app/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ SET(QGIS_APP_SRCS
173173
qgsmaptoolregularpolygoncenterpoint.cpp
174174
qgsmaptoolregularpolygoncentercorner.cpp
175175

176+
browser/qgsinbuiltdataitemproviders.cpp
177+
176178
layout/qgslayoutaddpagesdialog.cpp
177179
layout/qgslayoutapputils.cpp
178180
layout/qgslayoutatlaswidget.cpp
@@ -398,6 +400,8 @@ SET (QGIS_APP_MOC_HDRS
398400
qgsmapthemes.h
399401
qgshandlebadlayers.h
400402

403+
browser/qgsinbuiltdataitemproviders.h
404+
401405
layout/qgslayoutaddpagesdialog.h
402406
layout/qgslayoutappmenuprovider.h
403407
layout/qgslayoutatlaswidget.h
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
/***************************************************************************
2+
qgsinbuiltdataitemproviders.cpp
3+
----------------------------
4+
begin : October 2018
5+
copyright : (C) 2018 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
19+
#include "qgsinbuiltdataitemproviders.h"
20+
#include "qgsdataitem.h"
21+
#include "qgssettings.h"
22+
#include "qgsgui.h"
23+
#include "qgsnative.h"
24+
#include "qgisapp.h"
25+
#include "qgsnewnamedialog.h"
26+
#include "qgsbrowsermodel.h"
27+
#include "qgsbrowserdockwidget_p.h"
28+
#include <QMenu>
29+
#include <QInputDialog>
30+
#include <QMessageBox>
31+
#include <QDesktopServices>
32+
33+
QgsAppDirectoryItemGuiProvider::QgsAppDirectoryItemGuiProvider()
34+
{
35+
36+
}
37+
38+
QString QgsAppDirectoryItemGuiProvider::name()
39+
{
40+
return QStringLiteral( "directory_items" );
41+
}
42+
43+
void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &, QgsDataItemGuiContext )
44+
{
45+
if ( item->type() != QgsDataItem::Directory )
46+
return;
47+
48+
QgsDirectoryItem *directoryItem = qobject_cast< QgsDirectoryItem * >( item );
49+
50+
QgsSettings settings;
51+
52+
53+
QAction *createFolder = new QAction( tr( "New Directory…" ), menu );
54+
connect( createFolder, &QAction::triggered, this, [ = ]
55+
{
56+
bool ok = false;
57+
58+
const QString name = QInputDialog::getText( QgisApp::instance(), tr( "Create Directory" ), tr( "Directory name" ), QLineEdit::Normal, QString(), &ok );
59+
if ( ok && !name.isEmpty() )
60+
{
61+
QDir dir( directoryItem->dirPath() );
62+
if ( QFileInfo::exists( dir.absoluteFilePath( name ) ) )
63+
{
64+
QMessageBox::critical( QgisApp::instance(), tr( "Create Directory" ), tr( "The path “%1” already exists." ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
65+
}
66+
else if ( !dir.mkdir( name ) )
67+
{
68+
QMessageBox::critical( QgisApp::instance(), tr( "Create Directory" ), tr( "Could not create directory “%1”." ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
69+
}
70+
else
71+
{
72+
directoryItem->refresh();
73+
}
74+
}
75+
} );
76+
menu->addAction( createFolder );
77+
78+
menu->addSeparator();
79+
80+
bool inFavDirs = item->parent() && item->parent()->type() == QgsDataItem::Favorites;
81+
if ( item->parent() && !inFavDirs )
82+
{
83+
// only non-root directories can be added as favorites
84+
QAction *addAsFavorite = new QAction( tr( "Add as a Favorite" ), menu );
85+
addAsFavorite->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFavourites.svg" ) ) );
86+
menu->addAction( addAsFavorite );
87+
connect( addAsFavorite, &QAction::triggered, this, [ = ]
88+
{
89+
addFavorite( directoryItem );
90+
} );
91+
}
92+
else if ( inFavDirs )
93+
{
94+
if ( QgsFavoriteItem *favoriteItem = qobject_cast< QgsFavoriteItem * >( item ) )
95+
{
96+
QAction *actionRename = new QAction( tr( "Rename Favorite…" ), menu );
97+
connect( actionRename, &QAction::triggered, this, [ = ]
98+
{
99+
renameFavorite( favoriteItem );
100+
} );
101+
menu->addAction( actionRename );
102+
menu->addSeparator();
103+
QAction *removeFavoriteAction = new QAction( tr( "Remove Favorite" ), menu );
104+
connect( removeFavoriteAction, &QAction::triggered, this, [ = ]
105+
{
106+
removeFavorite( favoriteItem );
107+
} );
108+
menu->addAction( removeFavoriteAction );
109+
menu->addSeparator();
110+
}
111+
}
112+
QAction *hideAction = new QAction( tr( "Hide from Browser" ), menu );
113+
connect( hideAction, &QAction::triggered, this, [ = ]
114+
{
115+
hideDirectory( directoryItem );
116+
} );
117+
menu->addAction( hideAction );
118+
119+
QAction *fastScanAction = new QAction( tr( "Fast Scan this Directory" ), menu );
120+
connect( fastScanAction, &QAction::triggered, this, [ = ]
121+
{
122+
toggleFastScan( directoryItem );
123+
} );
124+
menu->addAction( fastScanAction );
125+
fastScanAction->setCheckable( true );
126+
fastScanAction->setChecked( settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
127+
QStringList() ).toStringList().contains( item->path() ) );
128+
129+
menu->addSeparator();
130+
131+
QAction *openFolder = new QAction( tr( "Open Directory…" ), menu );
132+
connect( openFolder, &QAction::triggered, this, [ = ]
133+
{
134+
QDesktopServices::openUrl( QUrl::fromLocalFile( directoryItem->dirPath() ) );
135+
} );
136+
menu->addAction( openFolder );
137+
138+
QAction *propertiesAction = new QAction( tr( "Properties…" ), menu );
139+
connect( propertiesAction, &QAction::triggered, this, [ = ]
140+
{
141+
showProperties( directoryItem );
142+
} );
143+
menu->addAction( propertiesAction );
144+
145+
if ( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeFilePropertiesDialog )
146+
{
147+
if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem * >( item ) )
148+
{
149+
QAction *action = menu->addAction( tr( "Directory Properties…" ) );
150+
connect( action, &QAction::triggered, dirItem, [ dirItem ]
151+
{
152+
QgsGui::nativePlatformInterface()->showFileProperties( dirItem->dirPath() );
153+
} );
154+
}
155+
}
156+
}
157+
158+
void QgsAppDirectoryItemGuiProvider::addFavorite( QgsDirectoryItem *item )
159+
{
160+
if ( !item )
161+
return;
162+
163+
QgisApp::instance()->browserModel()->addFavoriteDirectory( item->dirPath() );
164+
}
165+
166+
void QgsAppDirectoryItemGuiProvider::removeFavorite( QgsFavoriteItem *favorite )
167+
{
168+
QgisApp::instance()->browserModel()->removeFavorite( favorite );
169+
}
170+
171+
void QgsAppDirectoryItemGuiProvider::renameFavorite( QgsFavoriteItem *favorite )
172+
{
173+
QgsNewNameDialog dlg( tr( "favorite “%1”" ).arg( favorite->name() ), favorite->name() );
174+
dlg.setWindowTitle( tr( "Rename Favorite" ) );
175+
if ( dlg.exec() != QDialog::Accepted || dlg.name() == favorite->name() )
176+
return;
177+
178+
favorite->rename( dlg.name() );
179+
}
180+
181+
void QgsAppDirectoryItemGuiProvider::hideDirectory( QgsDirectoryItem *item )
182+
{
183+
if ( ! item )
184+
return;
185+
186+
QgisApp::instance()->browserModel()->hidePath( item );
187+
}
188+
189+
void QgsAppDirectoryItemGuiProvider::toggleFastScan( QgsDirectoryItem *item )
190+
{
191+
QgsSettings settings;
192+
QStringList fastScanDirs = settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
193+
QStringList() ).toStringList();
194+
int idx = fastScanDirs.indexOf( item->path() );
195+
if ( idx != -1 )
196+
{
197+
fastScanDirs.removeAt( idx );
198+
}
199+
else
200+
{
201+
fastScanDirs << item->path();
202+
}
203+
settings.setValue( QStringLiteral( "qgis/scanItemsFastScanUris" ), fastScanDirs );
204+
}
205+
206+
void QgsAppDirectoryItemGuiProvider::showProperties( QgsDirectoryItem *item )
207+
{
208+
if ( ! item )
209+
return;
210+
211+
QgsBrowserPropertiesDialog *dialog = new QgsBrowserPropertiesDialog( QStringLiteral( "browser" ), QgisApp::instance() );
212+
dialog->setAttribute( Qt::WA_DeleteOnClose );
213+
214+
dialog->setItem( item );
215+
dialog->show();
216+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/***************************************************************************
2+
qgsinbuiltdataitemproviders.h
3+
--------------------------
4+
begin : October 2018
5+
copyright : (C) 2018 by Nyall Dawson
6+
email : nyall dot dawson at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSINBUILTDATAITEMPROVIDERS_H
19+
#define QGSINBUILTDATAITEMPROVIDERS_H
20+
21+
#include "qgis_app.h"
22+
#include "qgsdataitemguiprovider.h"
23+
#include <QObject>
24+
25+
class QgsDirectoryItem;
26+
class QgsFavoriteItem;
27+
28+
class QgsAppDirectoryItemGuiProvider : public QObject, public QgsDataItemGuiProvider
29+
{
30+
Q_OBJECT
31+
32+
public:
33+
34+
QgsAppDirectoryItemGuiProvider();
35+
36+
QString name() override;
37+
38+
void populateContextMenu( QgsDataItem *item, QMenu *menu,
39+
const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context ) override;
40+
41+
private:
42+
43+
void addFavorite( QgsDirectoryItem *item );
44+
void removeFavorite( QgsFavoriteItem *favorite );
45+
void renameFavorite( QgsFavoriteItem *favorite );
46+
void hideDirectory( QgsDirectoryItem *item );
47+
void toggleFastScan( QgsDirectoryItem *item );
48+
void showProperties( QgsDirectoryItem *item );
49+
};
50+
51+
52+
53+
#endif // QGSINBUILTDATAITEMPROVIDERS_H
54+
55+

‎src/app/qgisapp.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
167167
#include "qgscustomlayerorderwidget.h"
168168
#include "qgscustomprojectiondialog.h"
169169
#include "qgsdataitemproviderregistry.h"
170+
#include "qgsdataitemguiproviderregistry.h"
170171
#include "qgsdatasourceuri.h"
171172
#include "qgsdatumtransformdialog.h"
172173
#include "qgsdoublespinbox.h"
@@ -329,6 +330,8 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
329330
#include "qgsuserprofilemanager.h"
330331
#include "qgsuserprofile.h"
331332

333+
#include "browser/qgsinbuiltdataitemproviders.h"
334+
332335
#include "qgssublayersdialog.h"
333336
#include "ogr/qgsvectorlayersaveasdialog.h"
334337

@@ -1022,6 +1025,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
10221025
mBrowserWidget->setObjectName( QStringLiteral( "Browser" ) );
10231026
mBrowserWidget->setMessageBar( mInfoBar );
10241027

1028+
QgsGui::instance()->dataItemGuiProviderRegistry()->addProvider( new QgsAppDirectoryItemGuiProvider() );
1029+
10251030
QShortcut *showBrowserDock = new QShortcut( QKeySequence( tr( "Ctrl+2" ) ), this );
10261031
connect( showBrowserDock, &QShortcut::activated, mBrowserWidget, &QgsDockWidget::toggleUserVisible );
10271032
showBrowserDock->setObjectName( QStringLiteral( "ShowBrowserPanel" ) );
@@ -1865,6 +1870,11 @@ void QgisApp::dataSourceManager( const QString &pageName )
18651870
}
18661871
}
18671872

1873+
QgsBrowserModel *QgisApp::browserModel()
1874+
{
1875+
return mBrowserModel;
1876+
}
1877+
18681878
QgisAppStyleSheet *QgisApp::styleSheetBuilder()
18691879
{
18701880
Q_ASSERT( mStyleSheetBuilder );

‎src/app/qgisapp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
902902
*/
903903
void dataSourceManager( const QString &pageName = QString() );
904904

905+
/**
906+
* Returns the shared application browser model.
907+
*/
908+
QgsBrowserModel *browserModel();
909+
905910
/**
906911
* Add a raster layer directly without prompting user for location
907912
The caller must provide information compatible with the provider plugin

‎src/core/qgsbrowsermodel.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,14 @@ void QgsBrowserModel::removeFavorite( const QModelIndex &index )
635635
mFavorites->removeDirectory( item );
636636
}
637637

638+
void QgsBrowserModel::removeFavorite( QgsFavoriteItem *favorite )
639+
{
640+
if ( !favorite )
641+
return;
642+
643+
mFavorites->removeDirectory( favorite );
644+
}
645+
638646
void QgsBrowserModel::hidePath( QgsDataItem *item )
639647
{
640648
QgsSettings settings;

‎src/core/qgsbrowsermodel.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,14 @@ class CORE_EXPORT QgsBrowserModel : public QAbstractItemModel
195195
*/
196196
void removeFavorite( const QModelIndex &index );
197197

198+
/**
199+
* Removes a \a favorite item.
200+
* \see addFavoriteDirectory()
201+
* \note Not available in Python bindings
202+
* \since QGIS 3.6
203+
*/
204+
void removeFavorite( QgsFavoriteItem *favorite ) SIP_SKIP;
205+
198206
void updateProjectHome();
199207

200208
//! Hide the given path in the browser model

‎src/core/qgsdataitem.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
#include <QTreeWidgetItem>
2828
#include <QVector>
2929
#include <QStyle>
30-
#include <QDesktopServices>
3130
#include <QFileDialog>
32-
#include <QInputDialog>
33-
#include <QMessageBox>
3431
#include <mutex>
3532

3633
#include "qgis.h"
@@ -986,53 +983,6 @@ bool QgsDirectoryItem::hiddenPath( const QString &path )
986983
return ( idx > -1 );
987984
}
988985

989-
QList<QAction *> QgsDirectoryItem::actions( QWidget *parent )
990-
{
991-
QList<QAction *> result;
992-
993-
QAction *createFolder = new QAction( tr( "New Directory…" ), parent );
994-
connect( createFolder, &QAction::triggered, this, [ = ]
995-
{
996-
bool ok = false;
997-
998-
QWidget *parentWindow = parent;
999-
while ( parentWindow->parentWidget() )
1000-
parentWindow = parentWindow->parentWidget();
1001-
1002-
const QString name = QInputDialog::getText( parentWindow, tr( "Create Directory" ), tr( "Directory name" ), QLineEdit::Normal, QString(), &ok );
1003-
if ( ok && !name.isEmpty() )
1004-
{
1005-
QDir dir( mDirPath );
1006-
if ( QFileInfo::exists( dir.absoluteFilePath( name ) ) )
1007-
{
1008-
QMessageBox::critical( parentWindow, tr( "Create Directory" ), tr( "The path “%1” already exists." ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
1009-
}
1010-
else if ( !dir.mkdir( name ) )
1011-
{
1012-
QMessageBox::critical( parentWindow, tr( "Create Directory" ), tr( "Could not create directory “%1”." ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
1013-
}
1014-
else
1015-
{
1016-
refresh();
1017-
}
1018-
}
1019-
} );
1020-
result << createFolder;
1021-
1022-
QAction *sep = new QAction( parent );
1023-
sep->setSeparator( true );
1024-
result << sep;
1025-
1026-
QAction *openFolder = new QAction( tr( "Open Directory…" ), parent );
1027-
connect( openFolder, &QAction::triggered, this, [ = ]
1028-
{
1029-
QDesktopServices::openUrl( QUrl::fromLocalFile( mDirPath ) );
1030-
} );
1031-
result << openFolder;
1032-
return result;
1033-
}
1034-
1035-
1036986
void QgsDirectoryItem::childrenCreated()
1037987
{
1038988
QgsDebugMsgLevel( QStringLiteral( "mRefreshLater = %1" ).arg( mRefreshLater ), 3 );

‎src/core/qgsdataitem.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,6 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
605605
//! Check if the given path is hidden from the browser model
606606
static bool hiddenPath( const QString &path );
607607

608-
QList<QAction *> actions( QWidget *parent ) override;
609-
610-
611608
public slots:
612609
void childrenCreated() override;
613610
void directoryChanged();

‎src/gui/qgsbrowserdockwidget.cpp

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,6 @@ void QgsBrowserDockWidget::itemDoubleClicked( const QModelIndex &index )
185185
}
186186
}
187187

188-
void QgsBrowserDockWidget::renameFavorite()
189-
{
190-
QgsDataItem *dataItem = mModel->dataItem( mProxyModel->mapToSource( mBrowserView->currentIndex() ) );
191-
if ( !dataItem )
192-
return;
193-
194-
QgsFavoriteItem *favorite = qobject_cast< QgsFavoriteItem * >( dataItem );
195-
if ( !favorite )
196-
return;
197-
198-
QgsNewNameDialog dlg( tr( "favorite “%1”" ).arg( favorite->name() ), favorite->name() );
199-
dlg.setWindowTitle( tr( "Rename Favorite" ) );
200-
if ( dlg.exec() != QDialog::Accepted || dlg.name() == favorite->name() )
201-
return;
202-
203-
favorite->rename( dlg.name() );
204-
}
205-
206188
void QgsBrowserDockWidget::showContextMenu( QPoint pt )
207189
{
208190
QModelIndex index = mProxyModel->mapToSource( mBrowserView->indexAt( pt ) );
@@ -221,48 +203,7 @@ void QgsBrowserDockWidget::showContextMenu( QPoint pt )
221203

222204
QMenu *menu = new QMenu( this );
223205

224-
if ( item->type() == QgsDataItem::Directory )
225-
{
226-
QgsSettings settings;
227-
228-
bool inFavDirs = item->parent() && item->parent()->type() == QgsDataItem::Favorites;
229-
if ( item->parent() && !inFavDirs )
230-
{
231-
// only non-root directories can be added as favorites
232-
QAction *addAsFavorite = new QAction( tr( "Add as a Favorite" ), this );
233-
addAsFavorite->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFavourites.svg" ) ) );
234-
menu->addAction( addAsFavorite );
235-
connect( addAsFavorite, &QAction::triggered, this, &QgsBrowserDockWidget::addFavorite );
236-
}
237-
else if ( inFavDirs )
238-
{
239-
QAction *actionRename = new QAction( tr( "Rename Favorite…" ), this );
240-
connect( actionRename, &QAction::triggered, this, &QgsBrowserDockWidget::renameFavorite );
241-
menu->addAction( actionRename );
242-
menu->addSeparator();
243-
menu->addAction( tr( "Remove Favorite" ), this, SLOT( removeFavorite() ) );
244-
menu->addSeparator();
245-
}
246-
menu->addAction( tr( "Hide from Browser" ), this, SLOT( hideItem() ) );
247-
QAction *action = menu->addAction( tr( "Fast Scan this Directory" ), this, SLOT( toggleFastScan() ) );
248-
action->setCheckable( true );
249-
action->setChecked( settings.value( QStringLiteral( "qgis/scanItemsFastScanUris" ),
250-
QStringList() ).toStringList().contains( item->path() ) );
251-
252-
menu->addAction( tr( "Properties…" ), this, SLOT( showProperties() ) );
253-
if ( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeFilePropertiesDialog )
254-
{
255-
if ( QgsDirectoryItem *dirItem = qobject_cast< QgsDirectoryItem * >( item ) )
256-
{
257-
QAction *action = menu->addAction( tr( "Directory Properties…" ) );
258-
connect( action, &QAction::triggered, dirItem, [ dirItem ]
259-
{
260-
QgsGui::nativePlatformInterface()->showFileProperties( dirItem->dirPath() );
261-
} );
262-
}
263-
}
264-
}
265-
else if ( item->type() == QgsDataItem::Layer )
206+
if ( item->type() == QgsDataItem::Layer )
266207
{
267208
QgsLayerItem *layerItem = qobject_cast<QgsLayerItem *>( item );
268209
if ( layerItem && ( layerItem->mapLayerType() == QgsMapLayer::VectorLayer ||

‎src/gui/qgsbrowserdockwidget.h

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,20 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBro
8989
//! Show context menu
9090
void showContextMenu( QPoint );
9191

92-
//! Add current item to favorite
93-
void addFavorite();
92+
/**
93+
* Add current item to favorite.
94+
* \deprecated will be removed in QGIS 4.0 - use the methods in QgsBrowserModel instead
95+
*/
96+
Q_DECL_DEPRECATED void addFavorite() SIP_DEPRECATED;
97+
9498
//! Add directory from file dialog to favorite
9599
void addFavoriteDirectory();
96-
//! Remove from favorite
97-
void removeFavorite();
100+
101+
/**
102+
* Remove from favorite.
103+
* \deprecated will be removed in QGIS 4.0 - use the methods in QgsBrowserModel instead
104+
*/
105+
Q_DECL_DEPRECATED void removeFavorite() SIP_DEPRECATED;
98106

99107
//! Refresh browser view model (and view)
100108
void refresh();
@@ -118,8 +126,14 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBro
118126
void showProperties();
119127
//! Hide current item
120128
void hideItem();
121-
//! Toggle fast scan
122-
void toggleFastScan();
129+
130+
/**
131+
* Toggle fast scan
132+
* \deprecated will be removed in QGIS 4.0
133+
*/
134+
Q_DECL_DEPRECATED void toggleFastScan() SIP_DEPRECATED;
135+
136+
// TODO QGIS 4.0: make these private
123137

124138
//! Selection has changed
125139
void selectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
@@ -140,7 +154,6 @@ class GUI_EXPORT QgsBrowserDockWidget : public QgsDockWidget, private Ui::QgsBro
140154

141155
private slots:
142156
void itemDoubleClicked( const QModelIndex &index );
143-
void renameFavorite();
144157

145158
private:
146159
//! Refresh the model

‎src/gui/qgsbrowserdockwidget_p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class QgsBrowserDirectoryProperties : public QgsBrowserPropertiesWidget, private
156156
/**
157157
* The QgsBrowserPropertiesDialog class
158158
*/
159-
class QgsBrowserPropertiesDialog : public QDialog, private Ui::QgsBrowserPropertiesDialogBase
159+
class GUI_EXPORT QgsBrowserPropertiesDialog : public QDialog, private Ui::QgsBrowserPropertiesDialogBase
160160
{
161161
Q_OBJECT
162162
public:

0 commit comments

Comments
 (0)
Please sign in to comment.