close view when closing last sub-view unless this view is the last view

This commit is contained in:
Marc Zinnschlag 2014-10-25 18:13:56 +02:00
parent a9f5632afd
commit aad13e6bff
11 changed files with 25 additions and 22 deletions

View file

@ -35,3 +35,8 @@ void CSVDoc::SubView::closeEvent (QCloseEvent *event)
if(mParent)
mParent->updateSubViewIndicies(this);
}
void CSVDoc::SubView::closeRequest()
{
emit closeRequest (this);
}

View file

@ -57,6 +57,12 @@ namespace CSVDoc
void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint);
void closeRequest (SubView *subView);
protected slots:
void closeRequest();
public slots:
virtual void updateUserSetting
(const QString &, const QStringList &);

View file

@ -518,6 +518,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
view,
SLOT (updateUserSetting (const QString &, const QStringList &)));
connect (view, SIGNAL (closeRequest (SubView *)), this, SLOT (closeRequest (SubView *)));
view->show();
}
@ -761,3 +763,11 @@ void CSVDoc::View::stop()
{
mDocument->stopRunning();
}
void CSVDoc::View::closeRequest (SubView *subView)
{
if (mSubViews.size()>1 || mViewTotal<=1)
subView->deleteLater();
else if (mViewManager.closeRequest (this))
mViewManager.removeDocAndView (mDocument);
}

View file

@ -222,6 +222,8 @@ namespace CSVDoc
void run (const std::string& profile, const std::string& startupInstruction = "");
void stop();
void closeRequest (SubView *subView);
};
}

View file

@ -52,11 +52,6 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
void CSVWorld::PreviewSubView::closeRequest()
{
deleteLater();
}
void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id)
{
if (id.empty())

View file

@ -29,8 +29,6 @@ namespace CSVWorld
private slots:
void closeRequest();
void referenceableIdChanged (const std::string& id);
};
}

View file

@ -150,11 +150,6 @@ void CSVWorld::SceneSubView::useHint (const std::string& hint)
mScene->useViewHint (hint);
}
void CSVWorld::SceneSubView::closeRequest()
{
deleteLater();
}
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::UniversalId& id)
{
setUniversalId(id);

View file

@ -75,8 +75,6 @@ namespace CSVWorld
private slots:
void closeRequest();
void cellSelectionChanged (const CSMWorld::CellSelection& selection);
void cellSelectionChanged (const CSMWorld::UniversalId& id);

View file

@ -81,6 +81,6 @@ void CSVWorld::ScriptSubView::rowsAboutToBeRemoved (const QModelIndex& parent, i
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
if (!parent.isValid() && index.row()>=start && index.row()<=end)
deleteLater();
emit closeRequest();
}

View file

@ -153,7 +153,3 @@ bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event)
return false;
}
void CSVWorld::TableSubView::closeRequest()
{
deleteLater();
}

View file

@ -63,8 +63,6 @@ namespace CSVWorld
void cloneRequest (const CSMWorld::UniversalId& toClone);
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types,
Qt::DropAction action);
void closeRequest();
};
}