Skip to content

Commit 185dede

Browse files
committed
bookmark edit func-ty done
1 parent 84c9ffc commit 185dede

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

src/libGUI/MainWindow.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,26 @@ void MainWindow::onMoveBookmark(const QModelIndex &index)
289289
m_bookmarkWidget->setCurrentIndex(index);
290290
}
291291

292+
void MainWindow::onApplyStateBookmark(const QModelIndex &index)
293+
{
294+
/* get current state set */
295+
osg::ref_ptr<entity::SceneState> state = m_rootScene->createSceneState();
296+
if (!state.get()){
297+
qWarning("Could not create scene state from root scene data");
298+
return;
299+
}
300+
if (state->isEmpty()){
301+
qWarning("Scene state is empty");
302+
return;
303+
}
304+
305+
/* replace the bookmark's state set on the obtained one */
306+
if (m_rootScene->getUserScene()->getBookmarksModel()->replaceSceneState(index.row(), state.get()))
307+
this->statusBar()->showMessage(tr("Bookmark stateset has changed successfully."));
308+
else
309+
this->statusBar()->showMessage(tr("Bookmark stateset has changed successfully."));
310+
}
311+
292312
void MainWindow::onBookmarkAddedToWidget(const QModelIndex &, int first, int last)
293313
{
294314
qDebug("onBookmarkAddedToWidget");
@@ -1434,6 +1454,10 @@ void MainWindow::initializeCallbacks()
14341454
this, SLOT(onDeleteBookmark(QModelIndex)),
14351455
Qt::UniqueConnection);
14361456

1457+
QObject::connect(m_bookmarkWidget->getBookmarkDelegate(), SIGNAL(clickedApplyState(QModelIndex)),
1458+
this, SLOT(onApplyStateBookmark(QModelIndex)),
1459+
Qt::UniqueConnection);
1460+
14371461
QObject::connect(m_bookmarkWidget->getBookmarkDelegate(), SIGNAL(clickedMove(QModelIndex)),
14381462
this, SLOT(onMoveBookmark(QModelIndex)),
14391463
Qt::UniqueConnection);

src/libGUI/MainWindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ public slots:
134134
/*! Slot called when user changed order of bookmarks within BookmarkWidget. */
135135
void onMoveBookmark(const QModelIndex &index);
136136

137+
/*! Slot called when user presses on cog icon to change the state set of the bookmark. */
138+
void onApplyStateBookmark(const QModelIndex& index);
139+
137140
/*! Slot called when BookmarkWidget content had changed, i.e., new row was inserted. */
138141
void onBookmarkAddedToWidget(const QModelIndex &, int first, int last);
139142

src/libSGEntities/Bookmarks.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ entity::SceneState *entity::Bookmarks::getSceneState(int row)
9898
return dynamic_cast<entity::SceneState*>(this->getChild(row));
9999
}
100100

101+
bool entity::Bookmarks::replaceSceneState(int row, entity::SceneState *state)
102+
{
103+
if (!state) return false;
104+
105+
entity::SceneState* old = this->getSceneState(row);
106+
if (!old) return false;
107+
108+
return this->replaceChild(old, state);
109+
}
110+
101111
entity::SceneState *entity::Bookmarks::getLastSceneState()
102112
{
103113
int num = this->getNumBookmarks();

src/libSGEntities/Bookmarks.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ class Bookmarks : public QObject, public osg::Group
9393
/*! A method to extract scene state given a row index of the BookmarkWidget. */
9494
entity::SceneState* getSceneState(int row);
9595

96+
/*! A method to replace the scene state with a given row onto a new one. */
97+
bool replaceSceneState(int row, entity::SceneState* state);
98+
9699
/*! A method to obtain lastly added child of a scene state. */
97100
entity::SceneState* getLastSceneState();
98101

0 commit comments

Comments
 (0)