Skip to content
Permalink
Browse files

[bookmarks] switch spatial bookmarks dialog to dockwidget with toolbar

  • Loading branch information
slarosa committed Jun 19, 2015
1 parent 513cfad commit f79d74739447bce4a7ba21c1a2680fc45f35fc12
Showing with 141 additions and 125 deletions.
  1. +12 −2 src/app/qgisapp.cpp
  2. +2 −0 src/app/qgisapp.h
  3. +17 −45 src/app/qgsbookmarks.cpp
  4. +10 −11 src/app/qgsbookmarks.h
  5. +100 −67 src/ui/qgsbookmarksbase.ui
@@ -603,6 +603,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
mStatisticalSummaryDockWidget = new QgsStatisticalSummaryDockWidget( this );
mStatisticalSummaryDockWidget->setObjectName( "StatistalSummaryDockWidget" );

// Bookmarks dock
mBookMarksDockWidget = new QgsBookmarks( this );
mBookMarksDockWidget->setObjectName( "BookmarksDockWidget" );

mSnappingUtils = new QgsMapCanvasSnappingUtils( mMapCanvas, this );
mMapCanvas->setSnappingUtils( mSnappingUtils );
connect( QgsProject::instance(), SIGNAL( snapSettingsChanged() ), mSnappingUtils, SLOT( readConfigFromProject() ) );
@@ -650,6 +654,9 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
addDockWidget( Qt::LeftDockWidgetArea, mStatisticalSummaryDockWidget );
mStatisticalSummaryDockWidget->hide();

addDockWidget( Qt::LeftDockWidgetArea, mBookMarksDockWidget );
mBookMarksDockWidget->hide();

QMainWindow::addDockWidget( Qt::BottomDockWidgetArea, mUserInputDockWidget );
mUserInputDockWidget->setFloating( true );

@@ -925,6 +932,7 @@ QgisApp::QgisApp()
, mBrowserWidget2( 0 )
, mAdvancedDigitizingDockWidget( 0 )
, mStatisticalSummaryDockWidget( 0 )
, mBookMarksDockWidget( 0 )
, mSnappingDialog( 0 )
, mPluginManager( 0 )
, mComposerManager( 0 )
@@ -10044,12 +10052,14 @@ void QgisApp::customProjection()

void QgisApp::newBookmark()
{
QgsBookmarks::newBookmark();
showBookmarks();
mBookMarksDockWidget->addClicked();
}

void QgisApp::showBookmarks()
{
QgsBookmarks::showBookmarks();
mBookMarksDockWidget->show();
mBookMarksDockWidget->raise();
}

// Slot that gets called when the project file was saved with an older
@@ -103,6 +103,7 @@ class QgsTileScaleWidget;
#include "qgssnappingdialog.h"
#include "qgspluginmanager.h"
#include "qgsmessagebar.h"
#include "qgsbookmarks.h"

#include "ui_qgisapp.h"

@@ -1620,6 +1621,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

QgsAdvancedDigitizingDockWidget *mAdvancedDigitizingDockWidget;
QgsStatisticalSummaryDockWidget* mStatisticalSummaryDockWidget;
QgsBookmarks* mBookMarksDockWidget;

QgsSnappingDialog *mSnappingDialog;

@@ -14,58 +14,51 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsbookmarks.h"
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgsbookmarks.h"
#include "qgscontexthelp.h"
#include "qgsmapcanvas.h"
#include "qgsmaprenderer.h"
#include "qgsproject.h"

#include "qgslogger.h"

#include <QFileInfo>
#include <QFileDialog>
#include <QFileInfo>
#include <QMessageBox>
#include <QSettings>
#include <QPushButton>
#include <QSqlTableModel>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlTableModel>

QgsBookmarks *QgsBookmarks::sInstance = 0;

QgsBookmarks::QgsBookmarks( QWidget *parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
QgsBookmarks::QgsBookmarks( QWidget *parent ) : QDockWidget( parent )
{
setupUi( this );
restorePosition();

//
// Create the zoomto and delete buttons and add them to the
// toolbar
//
QPushButton *btnAdd = new QPushButton( tr( "&Add" ) );
QPushButton *btnDelete = new QPushButton( tr( "&Delete" ) );
QPushButton *btnZoomTo = new QPushButton( tr( "&Zoom to" ) );
QPushButton *btnImpExp = new QPushButton( tr( "&Share" ) );

btnZoomTo->setDefault( true );
buttonBox->addButton( btnAdd, QDialogButtonBox::ActionRole );
buttonBox->addButton( btnDelete, QDialogButtonBox::ActionRole );
buttonBox->addButton( btnZoomTo, QDialogButtonBox::ActionRole );
buttonBox->addButton( btnImpExp, QDialogButtonBox::ActionRole );
QToolButton* btnImpExp = new QToolButton;
btnImpExp->setAutoRaise( true );
btnImpExp->setToolTip( tr( "Import/Export Bookmarks" ) );
btnImpExp->setIcon( QgsApplication::getThemeIcon( "/mActionSharing.svg" ) );
btnImpExp->setPopupMode( QToolButton::InstantPopup );

QMenu *share = new QMenu();
QAction *btnExport = share->addAction( tr( "&Export" ) );
QAction *btnImport = share->addAction( tr( "&Import" ) );
btnExport->setIcon( QgsApplication::getThemeIcon( "/mActionSharingExport.svg" ) );
btnImport->setIcon( QgsApplication::getThemeIcon( "/mActionSharingImport.svg" ) );
connect( btnExport, SIGNAL( triggered() ), this, SLOT( exportToXML() ) );
connect( btnImport, SIGNAL( triggered() ), this, SLOT( importFromXML() ) );
btnImpExp->setMenu( share );

connect( btnAdd, SIGNAL( clicked() ), this, SLOT( addClicked() ) );
connect( btnDelete, SIGNAL( clicked() ), this, SLOT( deleteClicked() ) );
connect( btnZoomTo, SIGNAL( clicked() ), this, SLOT( zoomToBookmark() ) );
connect( actionAdd, SIGNAL( triggered() ), this, SLOT( addClicked() ) );
connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteClicked() ) );
connect( actionZoomTo, SIGNAL( triggered() ), this, SLOT( zoomToBookmark() ) );

mBookmarkToolbar->addWidget( btnImpExp );
mBookmarkToolbar->addAction( actionHelp );

// open the database
QSqlDatabase db = QSqlDatabase::addDatabase( "QSQLITE", "bookmarks" );
@@ -111,7 +104,6 @@ QgsBookmarks::QgsBookmarks( QWidget *parent, Qt::WindowFlags fl )
QgsBookmarks::~QgsBookmarks()
{
saveWindowLocation();
sInstance = 0;
}

void QgsBookmarks::restorePosition()
@@ -127,26 +119,6 @@ void QgsBookmarks::saveWindowLocation()
settings.setValue( "/Windows/Bookmarks/headerstate", lstBookmarks->header()->saveState() );
}

void QgsBookmarks::newBookmark()
{
showBookmarks();
sInstance->addClicked();
}

void QgsBookmarks::showBookmarks()
{
if ( !sInstance )
{
sInstance = new QgsBookmarks( QgisApp::instance() );
sInstance->setAttribute( Qt::WA_DeleteOnClose );
}

sInstance->show();
sInstance->raise();
sInstance->setWindowState( sInstance->windowState() & ~Qt::WindowMinimized );
sInstance->activateWindow();
}

void QgsBookmarks::addClicked()
{
QSqlTableModel *model = qobject_cast<QSqlTableModel *>( lstBookmarks->model() );
@@ -16,37 +16,36 @@
***************************************************************************/
#ifndef QGSBOOKMARKS_H
#define QGSBOOKMARKS_H

#include <QDockWidget>

#include "ui_qgsbookmarksbase.h"
#include "qgscontexthelp.h"

#include <QDialog>

class APP_EXPORT QgsBookmarks : public QDialog, private Ui::QgsBookmarksBase
class APP_EXPORT QgsBookmarks : public QDockWidget, private Ui::QgsBookmarksBase
{
Q_OBJECT

public:
static void showBookmarks();
static void newBookmark();
QgsBookmarks( QWidget *parent = 0 );
~QgsBookmarks();

private slots:
public slots:
void addClicked();

private slots:
void deleteClicked();
void zoomToBookmark();
void exportToXML();
void importFromXML();

void on_lstBookmarks_doubleClicked( const QModelIndex & );
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
void on_actionHelp_triggered() { QgsContextHelp::run( metaObject()->className() ); }

private:
QgsBookmarks( QWidget *parent = 0, Qt::WindowFlags fl = 0 );
~QgsBookmarks();

void saveWindowLocation();
void restorePosition();

static QgsBookmarks *sInstance;
};


0 comments on commit f79d747

Please sign in to comment.
You can’t perform that action at this time.