Skip to content
Permalink
Browse files

[bugfix] Bookmark project sync

Fixes #17584 Spatial Bookmarks checkbox is not synced with project status
  • Loading branch information
elpaso committed Nov 30, 2017
1 parent f6acf37 commit 042fd33db790dd1cbe9ac1eaa69c812b1bf42967
Showing with 15 additions and 7 deletions.
  1. +13 −4 src/app/qgsbookmarks.cpp
  2. +2 −3 src/app/qgsbookmarks.h
@@ -509,11 +509,10 @@ QgsMergedBookmarksTableModel::QgsMergedBookmarksTableModel( QAbstractTableModel
: mQgisTableModel( qgisTableModel )
, mProjectTableModel( projectTableModel )
, mTreeView( treeView )
, mProjectOpen( false )
{
connect(
QgisApp::instance(), &QgisApp::projectRead,
this, &QgsMergedBookmarksTableModel::projectRead );
QgsProject::instance(), &QgsProject::fileNameChanged,
this, &QgsMergedBookmarksTableModel::projectFileNameChanged );

connect(
&mQgisTableModel, &QAbstractTableModel::layoutChanged,
@@ -620,7 +619,7 @@ Qt::ItemFlags QgsMergedBookmarksTableModel::flags( const QModelIndex &index ) co
Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
if ( index.column() == mQgisTableModel.columnCount() )
{
if ( !mProjectOpen )
if ( !projectAvailable() )
{
return Qt::ItemIsSelectable;
}
@@ -679,6 +678,11 @@ QAbstractTableModel *QgsMergedBookmarksTableModel::qgisModel()
return &mQgisTableModel;
}

bool QgsMergedBookmarksTableModel::projectAvailable() const
{
return ! QgsProject::instance()->fileName().isEmpty();
}

void QgsMergedBookmarksTableModel::moveBookmark( QAbstractTableModel &modelFrom, QAbstractTableModel &modelTo, int row )
{
QSqlTableModel *qgisModel = dynamic_cast<QSqlTableModel *>( &modelTo );
@@ -719,3 +723,8 @@ void QgsMergedBookmarksTableModel::moveBookmark( QAbstractTableModel &modelFrom,
modelFrom.removeRows( row, 1 );
}
}

void QgsMergedBookmarksTableModel::projectFileNameChanged()
{
emit layoutChanged();
}
@@ -79,12 +79,11 @@ class QgsMergedBookmarksTableModel: public QAbstractTableModel
QAbstractTableModel &mQgisTableModel;
QAbstractTableModel &mProjectTableModel;
QTreeView *mTreeView = nullptr;
bool mProjectOpen;

bool projectAvailable() const;
void moveBookmark( QAbstractTableModel &modelFrom, QAbstractTableModel &modelTo, int row );

private slots:
void projectRead() { mProjectOpen = true; }
void projectFileNameChanged();
void allLayoutChanged()
{
emit layoutChanged();

0 comments on commit 042fd33

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