1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 13:23:53 +00:00
openmw/apps/opencs/view/doc/viewmanager.cpp

437 lines
16 KiB
C++
Raw Normal View History

2012-11-22 12:30:02 +00:00
#include "viewmanager.hpp"
2022-10-19 17:02:00 +00:00
#include <algorithm>
#include <cstddef>
#include <filesystem>
2012-11-22 14:09:04 +00:00
#include <map>
2022-10-19 17:02:00 +00:00
#include <type_traits>
#include <utility>
2022-09-22 18:26:05 +00:00
#include <vector>
2012-11-22 14:09:04 +00:00
2022-10-19 17:02:00 +00:00
#include <apps/opencs/model/prefs/category.hpp>
#include <apps/opencs/model/prefs/setting.hpp>
#include <apps/opencs/model/world/columnbase.hpp>
#include <apps/opencs/model/world/universalid.hpp>
#include <apps/opencs/view/doc/loader.hpp>
#include <components/esm3/variant.hpp>
#include <components/files/qtconversion.hpp>
2013-05-08 01:33:42 +00:00
#include <QApplication>
#include <QMessageBox>
#include <QPushButton>
2013-05-08 01:33:42 +00:00
#include "../../model/doc/document.hpp"
#include "../../model/doc/documentmanager.hpp"
2022-08-19 17:19:42 +00:00
#include "../../model/doc/state.hpp"
#include "../../model/world/columns.hpp"
#include "../../model/world/idcompletionmanager.hpp"
2012-11-22 13:10:23 +00:00
#include "../../model/prefs/state.hpp"
2022-09-22 18:26:05 +00:00
#include "../world/colordelegate.hpp"
#include "../world/enumdelegate.hpp"
#include "../world/idcompletiondelegate.hpp"
2022-09-22 18:26:05 +00:00
#include "../world/idtypedelegate.hpp"
#include "../world/recordstatusdelegate.hpp"
#include "../world/util.hpp"
#include "../world/vartypedelegate.hpp"
2012-11-22 12:30:02 +00:00
#include "view.hpp"
2012-11-22 14:09:04 +00:00
void CSVDoc::ViewManager::updateIndices()
{
2022-09-22 18:26:05 +00:00
std::map<CSMDoc::Document*, std::pair<int, int>> documents;
2012-11-22 14:09:04 +00:00
2022-09-22 18:26:05 +00:00
for (std::vector<View*>::const_iterator iter(mViews.begin()); iter != mViews.end(); ++iter)
2012-11-22 14:09:04 +00:00
{
2022-09-22 18:26:05 +00:00
std::map<CSMDoc::Document*, std::pair<int, int>>::iterator document = documents.find((*iter)->getDocument());
2012-11-22 14:09:04 +00:00
2022-09-22 18:26:05 +00:00
if (document == documents.end())
document = documents
.insert(std::make_pair(
(*iter)->getDocument(), std::make_pair(0, countViews((*iter)->getDocument()))))
.first;
2012-11-22 14:09:04 +00:00
2022-09-22 18:26:05 +00:00
(*iter)->setIndex(document->second.first++, document->second.second);
2012-11-22 14:09:04 +00:00
}
}
2022-09-22 18:26:05 +00:00
CSVDoc::ViewManager::ViewManager(CSMDoc::DocumentManager& documentManager)
: mDocumentManager(documentManager)
, mExitOnSaveStateChange(false)
, mUserWarned(false)
2012-11-22 12:30:02 +00:00
{
2013-02-10 16:21:25 +00:00
mDelegateFactories = new CSVWorld::CommandDelegateFactoryCollection;
2022-09-22 18:26:05 +00:00
mDelegateFactories->add(CSMWorld::ColumnBase::Display_GmstVarType,
new CSVWorld::VarTypeDelegateFactory(ESM::VT_None, ESM::VT_String, ESM::VT_Int, ESM::VT_Float));
2013-03-05 10:37:13 +00:00
2022-09-22 18:26:05 +00:00
mDelegateFactories->add(CSMWorld::ColumnBase::Display_GlobalVarType,
new CSVWorld::VarTypeDelegateFactory(ESM::VT_Short, ESM::VT_Long, ESM::VT_Float));
2022-09-22 18:26:05 +00:00
mDelegateFactories->add(CSMWorld::ColumnBase::Display_RecordState, new CSVWorld::RecordStatusDelegateFactory());
2013-05-16 14:27:33 +00:00
2022-09-22 18:26:05 +00:00
mDelegateFactories->add(CSMWorld::ColumnBase::Display_RefRecordType, new CSVWorld::IdTypeDelegateFactory());
2022-09-22 18:26:05 +00:00
mDelegateFactories->add(CSMWorld::ColumnBase::Display_Colour, new CSVWorld::ColorDelegateFactory());
std::vector<CSMWorld::ColumnBase::Display> idCompletionColumns = CSMWorld::IdCompletionManager::getDisplayTypes();
for (std::vector<CSMWorld::ColumnBase::Display>::const_iterator current = idCompletionColumns.begin();
2022-09-22 18:26:05 +00:00
current != idCompletionColumns.end(); ++current)
{
mDelegateFactories->add(*current, new CSVWorld::IdCompletionDelegateFactory());
}
struct Mapping
{
CSMWorld::ColumnBase::Display mDisplay;
CSMWorld::Columns::ColumnId mColumnId;
bool mAllowNone;
};
2022-09-22 18:26:05 +00:00
static const Mapping sMapping[] = {
{ CSMWorld::ColumnBase::Display_Specialisation, CSMWorld::Columns::ColumnId_Specialisation, false },
{ CSMWorld::ColumnBase::Display_Attribute, CSMWorld::Columns::ColumnId_Attribute, true },
{ CSMWorld::ColumnBase::Display_SpellType, CSMWorld::Columns::ColumnId_SpellType, false },
{ CSMWorld::ColumnBase::Display_ApparatusType, CSMWorld::Columns::ColumnId_ApparatusType, false },
{ CSMWorld::ColumnBase::Display_ArmorType, CSMWorld::Columns::ColumnId_ArmorType, false },
{ CSMWorld::ColumnBase::Display_ClothingType, CSMWorld::Columns::ColumnId_ClothingType, false },
{ CSMWorld::ColumnBase::Display_CreatureType, CSMWorld::Columns::ColumnId_CreatureType, false },
{ CSMWorld::ColumnBase::Display_WeaponType, CSMWorld::Columns::ColumnId_WeaponType, false },
{ CSMWorld::ColumnBase::Display_DialogueType, CSMWorld::Columns::ColumnId_DialogueType, false },
{ CSMWorld::ColumnBase::Display_QuestStatusType, CSMWorld::Columns::ColumnId_QuestStatusType, false },
{ CSMWorld::ColumnBase::Display_EnchantmentType, CSMWorld::Columns::ColumnId_EnchantmentType, false },
{ CSMWorld::ColumnBase::Display_BodyPartType, CSMWorld::Columns::ColumnId_BodyPartType, false },
{ CSMWorld::ColumnBase::Display_MeshType, CSMWorld::Columns::ColumnId_MeshType, false },
2014-09-25 09:40:45 +00:00
{ CSMWorld::ColumnBase::Display_Gender, CSMWorld::Columns::ColumnId_Gender, true },
{ CSMWorld::ColumnBase::Display_SoundGeneratorType, CSMWorld::Columns::ColumnId_SoundGeneratorType, false },
{ CSMWorld::ColumnBase::Display_School, CSMWorld::Columns::ColumnId_School, false },
{ CSMWorld::ColumnBase::Display_SkillId, CSMWorld::Columns::ColumnId_Skill, true },
{ CSMWorld::ColumnBase::Display_EffectRange, CSMWorld::Columns::ColumnId_EffectRange, false },
{ CSMWorld::ColumnBase::Display_EffectId, CSMWorld::Columns::ColumnId_EffectId, false },
{ CSMWorld::ColumnBase::Display_PartRefType, CSMWorld::Columns::ColumnId_PartRefType, false },
{ CSMWorld::ColumnBase::Display_AiPackageType, CSMWorld::Columns::ColumnId_AiPackageType, false },
{ CSMWorld::ColumnBase::Display_InfoCondFunc, CSMWorld::Columns::ColumnId_InfoCondFunc, false },
{ CSMWorld::ColumnBase::Display_InfoCondComp, CSMWorld::Columns::ColumnId_InfoCondComp, false },
{ CSMWorld::ColumnBase::Display_IngredEffectId, CSMWorld::Columns::ColumnId_EffectId, true },
{ CSMWorld::ColumnBase::Display_EffectSkill, CSMWorld::Columns::ColumnId_Skill, false },
{ CSMWorld::ColumnBase::Display_EffectAttribute, CSMWorld::Columns::ColumnId_Attribute, false },
{ CSMWorld::ColumnBase::Display_BookType, CSMWorld::Columns::ColumnId_BookType, false },
{ CSMWorld::ColumnBase::Display_BloodType, CSMWorld::Columns::ColumnId_BloodType, false },
{ CSMWorld::ColumnBase::Display_EmitterType, CSMWorld::Columns::ColumnId_EmitterType, false },
{ CSMWorld::ColumnBase::Display_GenderNpc, CSMWorld::Columns::ColumnId_Gender, false },
};
2022-09-22 18:26:05 +00:00
for (std::size_t i = 0; i < sizeof(sMapping) / sizeof(Mapping); ++i)
mDelegateFactories->add(sMapping[i].mDisplay,
new CSVWorld::EnumDelegateFactory(
CSMWorld::Columns::getEnums(sMapping[i].mColumnId), sMapping[i].mAllowNone));
2022-09-22 18:26:05 +00:00
connect(&mDocumentManager, &CSMDoc::DocumentManager::loadRequest, &mLoader, &Loader::add);
2014-04-29 12:17:25 +00:00
2022-09-22 18:26:05 +00:00
connect(&mDocumentManager, &CSMDoc::DocumentManager::loadingStopped, &mLoader, &Loader::loadingStopped);
2014-05-03 11:01:29 +00:00
2022-09-22 18:26:05 +00:00
connect(&mDocumentManager, &CSMDoc::DocumentManager::nextStage, &mLoader, &Loader::nextStage);
2014-05-03 13:33:35 +00:00
2022-09-22 18:26:05 +00:00
connect(&mDocumentManager, &CSMDoc::DocumentManager::nextRecord, &mLoader, &Loader::nextRecord);
2014-05-03 14:44:50 +00:00
2022-09-22 18:26:05 +00:00
connect(&mDocumentManager, &CSMDoc::DocumentManager::loadMessage, &mLoader, &Loader::loadMessage);
2022-09-22 18:26:05 +00:00
connect(&mLoader, &Loader::cancel, &mDocumentManager, &CSMDoc::DocumentManager::cancelLoading);
2022-09-22 18:26:05 +00:00
connect(&mLoader, &Loader::close, &mDocumentManager, &CSMDoc::DocumentManager::removeDocument);
2012-11-22 12:30:02 +00:00
}
CSVDoc::ViewManager::~ViewManager()
{
2013-02-10 16:21:25 +00:00
delete mDelegateFactories;
2022-09-22 18:26:05 +00:00
for (std::vector<View*>::iterator iter(mViews.begin()); iter != mViews.end(); ++iter)
2012-11-22 12:30:02 +00:00
delete *iter;
}
2022-09-22 18:26:05 +00:00
CSVDoc::View* CSVDoc::ViewManager::addView(CSMDoc::Document* document)
2012-11-22 12:30:02 +00:00
{
2022-09-22 18:26:05 +00:00
if (countViews(document) == 0)
{
// new document
2022-09-22 18:26:05 +00:00
connect(document, &CSMDoc::Document::stateChanged, this, &ViewManager::documentStateChanged);
2012-11-23 09:25:34 +00:00
2022-09-22 18:26:05 +00:00
connect(document, qOverload<int, int, int, int, CSMDoc::Document*>(&CSMDoc::Document::progress), this,
&ViewManager::progress);
}
2022-09-22 18:26:05 +00:00
View* view = new View(*this, document, countViews(document) + 1);
2012-11-22 12:30:02 +00:00
2022-09-22 18:26:05 +00:00
mViews.push_back(view);
2012-11-22 12:30:02 +00:00
2022-09-22 18:26:05 +00:00
view->toggleStatusBar(CSMPrefs::get()["Windows"]["show-statusbar"].isTrue());
2012-11-22 12:30:02 +00:00
view->show();
2022-09-22 18:26:05 +00:00
connect(view, &View::newGameRequest, this, &ViewManager::newGameRequest);
connect(view, &View::newAddonRequest, this, &ViewManager::newAddonRequest);
connect(view, &View::loadDocumentRequest, this, &ViewManager::loadDocumentRequest);
connect(view, &View::editSettingsRequest, this, &ViewManager::editSettingsRequest);
connect(view, &View::mergeDocument, this, &ViewManager::mergeDocument);
2012-11-23 13:05:49 +00:00
2012-11-22 14:09:04 +00:00
updateIndices();
2012-11-22 12:30:02 +00:00
return view;
2012-11-22 13:10:23 +00:00
}
2022-09-22 18:26:05 +00:00
CSVDoc::View* CSVDoc::ViewManager::addView(
CSMDoc::Document* document, const CSMWorld::UniversalId& id, const std::string& hint)
{
View* view = addView(document);
view->addSubView(id, hint);
return view;
}
2022-09-22 18:26:05 +00:00
int CSVDoc::ViewManager::countViews(const CSMDoc::Document* document) const
2012-11-22 13:10:23 +00:00
{
int count = 0;
2022-09-22 18:26:05 +00:00
for (std::vector<View*>::const_iterator iter(mViews.begin()); iter != mViews.end(); ++iter)
if ((*iter)->getDocument() == document)
2012-11-22 13:10:23 +00:00
++count;
return count;
}
2022-09-22 18:26:05 +00:00
bool CSVDoc::ViewManager::closeRequest(View* view)
2012-11-22 13:10:23 +00:00
{
2022-09-22 18:26:05 +00:00
std::vector<View*>::iterator iter = std::find(mViews.begin(), mViews.end(), view);
2012-11-22 13:10:23 +00:00
2014-09-09 11:09:37 +00:00
bool continueWithClose = false;
2013-03-02 13:57:41 +00:00
2022-09-22 18:26:05 +00:00
if (iter != mViews.end())
2012-11-22 13:10:23 +00:00
{
2022-09-22 18:26:05 +00:00
bool last = countViews(view->getDocument()) <= 1;
2012-11-22 13:10:23 +00:00
2014-09-07 08:37:33 +00:00
if (last)
2022-09-22 18:26:05 +00:00
continueWithClose = notifySaveOnClose(view);
else
2013-03-02 13:57:41 +00:00
{
2014-09-07 08:37:33 +00:00
(*iter)->deleteLater();
2022-09-22 18:26:05 +00:00
mViews.erase(iter);
2013-03-06 12:41:33 +00:00
updateIndices();
2013-03-02 13:57:41 +00:00
}
}
return continueWithClose;
}
2014-09-09 11:09:37 +00:00
// NOTE: This method assumes that it is called only if the last document
2022-09-22 18:26:05 +00:00
void CSVDoc::ViewManager::removeDocAndView(CSMDoc::Document* document)
{
2022-09-22 18:26:05 +00:00
for (std::vector<View*>::iterator iter(mViews.begin()); iter != mViews.end(); ++iter)
2014-09-09 11:09:37 +00:00
{
// the first match should also be the only match
2022-09-22 18:26:05 +00:00
if ((*iter)->getDocument() == document)
2014-09-09 11:09:37 +00:00
{
mDocumentManager.removeDocument(document);
(*iter)->deleteLater();
2022-09-22 18:26:05 +00:00
mViews.erase(iter);
2014-09-09 11:09:37 +00:00
updateIndices();
return;
}
}
}
2022-09-22 18:26:05 +00:00
bool CSVDoc::ViewManager::notifySaveOnClose(CSVDoc::View* view)
{
bool result = true;
2022-09-22 18:26:05 +00:00
CSMDoc::Document* document = view->getDocument();
2022-09-22 18:26:05 +00:00
// notify user of saving in progress
if ((document->getState() & CSMDoc::State_Saving))
result = showSaveInProgressMessageBox(view);
2022-09-22 18:26:05 +00:00
// notify user of unsaved changes and process response
else if (document->getState() & CSMDoc::State_Modified)
result = showModifiedDocumentMessageBox(view);
return result;
}
2022-09-22 18:26:05 +00:00
bool CSVDoc::ViewManager::showModifiedDocumentMessageBox(CSVDoc::View* view)
2013-03-02 13:57:41 +00:00
{
2014-09-10 04:03:25 +00:00
emit closeMessageBox();
QMessageBox messageBox(view);
2022-09-22 18:26:05 +00:00
CSMDoc::Document* document = view->getDocument();
messageBox.setWindowTitle(Files::pathToQString(document->getSavePath().filename()));
messageBox.setText("The document has been modified.");
messageBox.setInformativeText("Do you want to save your changes?");
messageBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
messageBox.setDefaultButton(QMessageBox::Save);
messageBox.setWindowModality(Qt::NonModal);
2014-09-10 04:03:25 +00:00
messageBox.hide();
messageBox.show();
2013-03-02 13:57:41 +00:00
bool retVal = true;
2022-09-22 18:26:05 +00:00
connect(this, &ViewManager::closeMessageBox, &messageBox, &QMessageBox::close);
2013-03-06 12:41:33 +00:00
2022-09-22 18:26:05 +00:00
connect(document, &CSMDoc::Document::stateChanged, this, &ViewManager::onExitWarningHandler);
2013-03-06 12:41:33 +00:00
mUserWarned = true;
int response = messageBox.exec();
2013-03-06 12:41:33 +00:00
mUserWarned = false;
switch (response)
2013-03-02 13:57:41 +00:00
{
case QMessageBox::Save:
document->save();
mExitOnSaveStateChange = true;
2013-03-06 12:41:33 +00:00
retVal = false;
2022-09-22 18:26:05 +00:00
break;
2013-03-02 13:57:41 +00:00
case QMessageBox::Discard:
2013-03-06 12:41:33 +00:00
2022-09-22 18:26:05 +00:00
disconnect(document, &CSMDoc::Document::stateChanged, this, &ViewManager::onExitWarningHandler);
break;
2013-03-02 13:57:41 +00:00
case QMessageBox::Cancel:
2013-03-06 12:41:33 +00:00
2022-09-22 18:26:05 +00:00
// disconnect to prevent unintended view closures
disconnect(document, &CSMDoc::Document::stateChanged, this, &ViewManager::onExitWarningHandler);
2013-03-02 13:57:41 +00:00
retVal = false;
2022-09-22 18:26:05 +00:00
break;
2013-03-02 13:57:41 +00:00
default:
2022-09-22 18:26:05 +00:00
break;
2013-03-02 13:57:41 +00:00
}
return retVal;
}
2012-11-22 13:10:23 +00:00
2022-09-22 18:26:05 +00:00
bool CSVDoc::ViewManager::showSaveInProgressMessageBox(CSVDoc::View* view)
2013-03-02 13:57:41 +00:00
{
QMessageBox messageBox;
2022-09-22 18:26:05 +00:00
CSMDoc::Document* document = view->getDocument();
2013-03-02 13:57:41 +00:00
2022-09-22 18:26:05 +00:00
messageBox.setText("The document is currently being saved.");
2013-03-06 12:41:33 +00:00
messageBox.setInformativeText("Do you want to close now and abort saving, or wait until saving has completed?");
2022-09-22 18:26:05 +00:00
QPushButton* waitButton = messageBox.addButton(tr("Wait"), QMessageBox::YesRole);
QPushButton* closeButton = messageBox.addButton(tr("Close Now"), QMessageBox::RejectRole);
QPushButton* cancelButton = messageBox.addButton(tr("Cancel"), QMessageBox::NoRole);
2013-03-06 12:41:33 +00:00
2022-09-22 18:26:05 +00:00
messageBox.setDefaultButton(waitButton);
2013-03-02 13:57:41 +00:00
bool retVal = true;
2013-03-02 13:57:41 +00:00
2022-09-22 18:26:05 +00:00
// Connections shut down message box if operation ends before user makes a decision.
connect(document, &CSMDoc::Document::stateChanged, this, &ViewManager::onExitWarningHandler);
connect(this, &ViewManager::closeMessageBox, &messageBox, &QMessageBox::close);
2013-03-02 13:57:41 +00:00
2022-09-22 18:26:05 +00:00
// set / clear the user warned flag to indicate whether or not the message box is currently active.
2013-03-06 12:41:33 +00:00
mUserWarned = true;
messageBox.exec();
mUserWarned = false;
2022-09-22 18:26:05 +00:00
// if closed by the warning handler, defaults to the RejectRole button (closeButton)
2013-03-06 12:41:33 +00:00
if (messageBox.clickedButton() == waitButton)
{
2022-09-22 18:26:05 +00:00
// save the View iterator for shutdown after the save operation ends
mExitOnSaveStateChange = true;
2013-03-06 12:41:33 +00:00
retVal = false;
}
2013-03-02 13:57:41 +00:00
2013-03-06 12:41:33 +00:00
else if (messageBox.clickedButton() == closeButton)
{
2022-09-22 18:26:05 +00:00
// disconnect to avoid segmentation fault
disconnect(document, &CSMDoc::Document::stateChanged, this, &ViewManager::onExitWarningHandler);
view->abortOperation(CSMDoc::State_Saving);
mExitOnSaveStateChange = true;
2013-03-06 12:41:33 +00:00
}
2013-03-02 13:57:41 +00:00
2013-03-06 12:41:33 +00:00
else if (messageBox.clickedButton() == cancelButton)
{
2022-09-22 18:26:05 +00:00
// abort shutdown, allow save to complete
// disconnection to prevent unintended view closures
mExitOnSaveStateChange = false;
2022-09-22 18:26:05 +00:00
disconnect(document, &CSMDoc::Document::stateChanged, this, &ViewManager::onExitWarningHandler);
2013-03-06 12:41:33 +00:00
retVal = false;
2012-11-22 13:10:23 +00:00
}
2013-03-02 13:57:41 +00:00
return retVal;
}
2022-09-22 18:26:05 +00:00
void CSVDoc::ViewManager::documentStateChanged(int state, CSMDoc::Document* document)
{
2022-09-22 18:26:05 +00:00
for (std::vector<View*>::const_iterator iter(mViews.begin()); iter != mViews.end(); ++iter)
if ((*iter)->getDocument() == document)
(*iter)->updateDocumentState();
}
2012-11-23 09:25:34 +00:00
2022-09-22 18:26:05 +00:00
void CSVDoc::ViewManager::progress(int current, int max, int type, int threads, CSMDoc::Document* document)
2012-11-23 09:25:34 +00:00
{
2022-09-22 18:26:05 +00:00
for (std::vector<View*>::const_iterator iter(mViews.begin()); iter != mViews.end(); ++iter)
if ((*iter)->getDocument() == document)
(*iter)->updateProgress(current, max, type, threads);
}
2013-03-06 12:41:33 +00:00
2022-09-22 18:26:05 +00:00
void CSVDoc::ViewManager::onExitWarningHandler(int state, CSMDoc::Document* document)
2013-03-06 12:41:33 +00:00
{
2022-09-22 18:26:05 +00:00
if (!(state & CSMDoc::State_Saving))
2013-03-06 12:41:33 +00:00
{
2022-09-22 18:26:05 +00:00
// if the user is being warned (message box is active), shut down the message box,
// as there is no save operation currently running
if (mUserWarned)
2013-03-06 12:41:33 +00:00
emit closeMessageBox();
2022-09-22 18:26:05 +00:00
// otherwise, the user has closed the message box before the save operation ended.
// exit the application
else if (mExitOnSaveStateChange)
QApplication::instance()->exit();
2013-03-06 12:41:33 +00:00
}
}
2022-09-22 18:26:05 +00:00
bool CSVDoc::ViewManager::removeDocument(CSVDoc::View* view)
{
2022-09-22 18:26:05 +00:00
if (!notifySaveOnClose(view))
2014-09-10 04:40:41 +00:00
return false;
2014-09-07 08:35:50 +00:00
else
{
2014-09-09 11:09:37 +00:00
// don't bother closing views or updating indicies, but remove from mViews
2022-09-22 18:26:05 +00:00
CSMDoc::Document* document = view->getDocument();
std::vector<View*> remainingViews;
std::vector<View*>::const_iterator iter = mViews.begin();
for (; iter != mViews.end(); ++iter)
2014-09-09 11:09:37 +00:00
{
2022-09-22 18:26:05 +00:00
if (document == (*iter)->getDocument())
2014-09-09 11:09:37 +00:00
(*iter)->setVisible(false);
else
remainingViews.push_back(*iter);
}
mDocumentManager.removeDocument(document);
mViews = remainingViews;
2014-09-10 04:40:41 +00:00
}
return true;
}
2014-09-07 08:35:50 +00:00
2022-09-22 18:26:05 +00:00
void CSVDoc::ViewManager::exitApplication(CSVDoc::View* view)
2014-09-10 04:40:41 +00:00
{
2022-09-22 18:26:05 +00:00
if (!removeDocument(view)) // close the current document first
2014-09-10 04:40:41 +00:00
return;
2022-09-22 18:26:05 +00:00
while (!mViews.empty()) // attempt to close all other documents
2014-09-10 04:40:41 +00:00
{
mViews.back()->activateWindow();
mViews.back()->raise(); // raise the window to alert the user
2022-09-22 18:26:05 +00:00
if (!removeDocument(mViews.back()))
2014-09-10 04:40:41 +00:00
return;
2014-09-07 08:35:50 +00:00
}
2014-09-09 00:05:06 +00:00
// Editor exits (via a signal) when the last document is deleted
}