Added save and set scroll bars value when user change current scene.

This commit is contained in:
dismine 2013-09-17 21:13:02 +03:00
parent ba1433e83f
commit 6229e4f6bd
3 changed files with 51 additions and 3 deletions

View File

@ -620,8 +620,20 @@ void MainWindow::keyPressEvent ( QKeyEvent * event ){
void MainWindow::ActionDraw(bool checked){
if(checked){
ui->actionDetails->setChecked(false);
/*Save scroll bars value for previous scene.*/
QScrollBar *horScrollBar = view->horizontalScrollBar();
currentScene->setHorScrollBar(horScrollBar->value());
QScrollBar *verScrollBar = view->verticalScrollBar();
currentScene->setVerScrollBar(verScrollBar->value());
currentScene = sceneDraw;
view->setScene(currentScene);
/*Set value for current scene scroll bar.*/
horScrollBar = view->horizontalScrollBar();
horScrollBar->setValue(currentScene->getHorScrollBar());
verScrollBar = view->verticalScrollBar();
verScrollBar->setValue(currentScene->getVerScrollBar());
mode = Draw::Calculation;
doc->setCurrentData();
} else {
@ -632,8 +644,19 @@ void MainWindow::ActionDraw(bool checked){
void MainWindow::ActionDetails(bool checked){
if(checked){
ui->actionDraw->setChecked(false);
/*Save scroll bars value for previous scene.*/
QScrollBar *horScrollBar = view->horizontalScrollBar();
currentScene->setHorScrollBar(horScrollBar->value());
QScrollBar *verScrollBar = view->verticalScrollBar();
currentScene->setVerScrollBar(verScrollBar->value());
currentScene = sceneDetails;
view->setScene(sceneDetails);
/*Set value for current scene scroll bar.*/
horScrollBar = view->horizontalScrollBar();
horScrollBar->setValue(currentScene->getHorScrollBar());
verScrollBar = view->verticalScrollBar();
verScrollBar->setValue(currentScene->getVerScrollBar());
mode = Draw::Modeling;
} else {
ui->actionDetails->setChecked(true);

View File

@ -4,11 +4,11 @@
#include <QScrollBar>
#include <QGraphicsItem>
VMainGraphicsScene::VMainGraphicsScene():QGraphicsScene(){
VMainGraphicsScene::VMainGraphicsScene():QGraphicsScene(), horScrollBar(0), verScrollBar(0){
}
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent):QGraphicsScene ( sceneRect, parent ){
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent):
QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0){
}
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event){
@ -28,3 +28,19 @@ void VMainGraphicsScene::ChoosedItem(qint64 id, Scene::Type type){
void VMainGraphicsScene::RemoveTool(QGraphicsItem *tool){
this->removeItem(tool);
}
qint32 VMainGraphicsScene::getVerScrollBar() const{
return verScrollBar;
}
void VMainGraphicsScene::setVerScrollBar(const qint32 &value){
verScrollBar = value;
}
qint32 VMainGraphicsScene::getHorScrollBar() const{
return horScrollBar;
}
void VMainGraphicsScene::setHorScrollBar(const qint32 &value){
horScrollBar = value;
}

View File

@ -12,6 +12,12 @@ class VMainGraphicsScene : public QGraphicsScene
public:
VMainGraphicsScene();
VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = 0);
qint32 getHorScrollBar() const;
void setHorScrollBar(const qint32 &value);
qint32 getVerScrollBar() const;
void setVerScrollBar(const qint32 &value);
public slots:
void ChoosedItem(qint64 id, Scene::Type type);
void RemoveTool(QGraphicsItem *tool);
@ -22,6 +28,9 @@ signals:
void mouseMove(QPointF scenePos);
void mousePress(QPointF scenePos);
void ChoosedObject(qint64 id, Scene::Type type);
private:
qint32 horScrollBar;
qint32 verScrollBar;
};
#endif // VMAINGRAPHICSSCENE_H