Skip to content

Commit

Permalink
Prevent removal of last curve for #294. Renamed classes from curve ad…
Browse files Browse the repository at this point in the history
…d/remove to curve list
  • Loading branch information
markummitchell-tu committed Oct 25, 2018
1 parent d886597 commit 76387ac
Show file tree
Hide file tree
Showing 16 changed files with 143 additions and 142 deletions.
8 changes: 4 additions & 4 deletions engauge.pro
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ HEADERS += \
src/Cmd/CmdSettingsAxesChecker.h \
src/Cmd/CmdSettingsColorFilter.h \
src/Cmd/CmdSettingsCoords.h \
src/Cmd/CmdSettingsCurveAddRemove.h \
src/Cmd/CmdSettingsCurveList.h \
src/Cmd/CmdSettingsCurveProperties.h \
src/Cmd/CmdSettingsDigitizeCurve.h \
src/Cmd/CmdSettingsExportFormat.h \
Expand Down Expand Up @@ -214,7 +214,7 @@ HEADERS += \
src/Dlg/DlgSettingsAxesChecker.h \
src/Dlg/DlgSettingsColorFilter.h \
src/Dlg/DlgSettingsCoords.h \
src/Dlg/DlgSettingsCurveAddRemove.h \
src/Dlg/DlgSettingsCurveList.h \
src/Dlg/DlgSettingsCurveProperties.h \
src/Dlg/DlgSettingsDigitizeCurve.h \
src/Dlg/DlgSettingsExportFormat.h \
Expand Down Expand Up @@ -476,7 +476,7 @@ SOURCES += \
src/Cmd/CmdSettingsAxesChecker.cpp \
src/Cmd/CmdSettingsColorFilter.cpp \
src/Cmd/CmdSettingsCoords.cpp \
src/Cmd/CmdSettingsCurveAddRemove.cpp \
src/Cmd/CmdSettingsCurveList.cpp \
src/Cmd/CmdSettingsCurveProperties.cpp \
src/Cmd/CmdSettingsDigitizeCurve.cpp \
src/Cmd/CmdSettingsExportFormat.cpp \
Expand Down Expand Up @@ -569,7 +569,7 @@ SOURCES += \
src/Dlg/DlgSettingsAxesChecker.cpp \
src/Dlg/DlgSettingsColorFilter.cpp \
src/Dlg/DlgSettingsCoords.cpp \
src/Dlg/DlgSettingsCurveAddRemove.cpp \
src/Dlg/DlgSettingsCurveList.cpp \
src/Dlg/DlgSettingsCurveProperties.cpp \
src/Dlg/DlgSettingsDigitizeCurve.cpp \
src/Dlg/DlgSettingsExportFormat.cpp \
Expand Down
12 changes: 6 additions & 6 deletions src/Cmd/CmdFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "CmdSettingsAxesChecker.h"
#include "CmdSettingsColorFilter.h"
#include "CmdSettingsCoords.h"
#include "CmdSettingsCurveAddRemove.h"
#include "CmdSettingsCurveList.h"
#include "CmdSettingsCurveProperties.h"
#include "CmdSettingsDigitizeCurve.h"
#include "CmdSettingsExportFormat.h"
Expand Down Expand Up @@ -128,11 +128,11 @@ CmdAbstract *CmdFactory::createCmd (MainWindow &mainWindow,
document,
cmdDescription,
reader);
} else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_ADD_REMOVE) {
cmd = new CmdSettingsCurveAddRemove (mainWindow,
document,
cmdDescription,
reader);
} else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_LIST) {
cmd = new CmdSettingsCurveList (mainWindow,
document,
cmdDescription,
reader);
} else if (cmdType == DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_PROPERTIES) {
cmd = new CmdSettingsCurveProperties (mainWindow,
document,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
******************************************************************************************************/

#include "CmdSettingsCurveAddRemove.h"
#include "CmdSettingsCurveList.h"
#include "CurveNameList.h"
#include "Document.h"
#include "DocumentSerialize.h"
Expand All @@ -13,16 +13,16 @@
#include <QXmlStreamReader>
#include "Xml.h"

const QString CMD_DESCRIPTION ("Curve add/remove");
const QString CMD_DESCRIPTION ("Curve list");

CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove(MainWindow &mainWindow,
Document &document,
const CurveNameList &modelCurves) :
CmdSettingsCurveList::CmdSettingsCurveList(MainWindow &mainWindow,
Document &document,
const CurveNameList &modelCurves) :
CmdAbstract(mainWindow,
document,
CMD_DESCRIPTION)
{
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove";
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::CmdSettingsCurveList";

m_curvesGraphsBefore = document.curvesGraphs ();

Expand Down Expand Up @@ -55,15 +55,15 @@ CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove(MainWindow &mainWindow,
}
}

CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove (MainWindow &mainWindow,
Document &document,
const QString &cmdDescription,
QXmlStreamReader &reader) :
CmdSettingsCurveList::CmdSettingsCurveList (MainWindow &mainWindow,
Document &document,
const QString &cmdDescription,
QXmlStreamReader &reader) :
CmdAbstract (mainWindow,
document,
cmdDescription)
{
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove";
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::CmdSettingsCurveList";

bool success = true;

Expand Down Expand Up @@ -102,34 +102,34 @@ CmdSettingsCurveAddRemove::CmdSettingsCurveAddRemove (MainWindow &mainWindow,
}
}

CmdSettingsCurveAddRemove::~CmdSettingsCurveAddRemove ()
CmdSettingsCurveList::~CmdSettingsCurveList ()
{
}

void CmdSettingsCurveAddRemove::cmdRedo ()
void CmdSettingsCurveList::cmdRedo ()
{
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveAddRemove::cmdRedo";
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::cmdRedo";

saveOrCheckPreCommandDocumentStateHash (document ());
mainWindow().updateSettingsCurveAddRemove(m_curvesGraphsAfter);
mainWindow().updateSettingsCurveList(m_curvesGraphsAfter);
mainWindow().updateAfterCommand();
saveOrCheckPostCommandDocumentStateHash (document ());
}

void CmdSettingsCurveAddRemove::cmdUndo ()
void CmdSettingsCurveList::cmdUndo ()
{
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveAddRemove::cmdUndo";
LOG4CPP_INFO_S ((*mainCat)) << "CmdSettingsCurveList::cmdUndo";

saveOrCheckPostCommandDocumentStateHash (document ());
mainWindow().updateSettingsCurveAddRemove(m_curvesGraphsBefore);
mainWindow().updateSettingsCurveList(m_curvesGraphsBefore);
mainWindow().updateAfterCommand();
saveOrCheckPreCommandDocumentStateHash (document ());
}

void CmdSettingsCurveAddRemove::saveXml (QXmlStreamWriter &writer) const
void CmdSettingsCurveList::saveXml (QXmlStreamWriter &writer) const
{
writer.writeStartElement(DOCUMENT_SERIALIZE_CMD);
writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_ADD_REMOVE);
writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_TYPE, DOCUMENT_SERIALIZE_CMD_SETTINGS_CURVE_LIST);
writer.writeAttribute(DOCUMENT_SERIALIZE_CMD_DESCRIPTION, QUndoCommand::text ());
m_curvesGraphsBefore.saveXml(writer);
m_curvesGraphsAfter.saveXml(writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
******************************************************************************************************/

#ifndef CMD_SETTINGS_CURVE_ADD_REMOVE_H
#define CMD_SETTINGS_CURVE_ADD_REMOVE_H
#ifndef CMD_SETTINGS_CURVE_LIST_H
#define CMD_SETTINGS_CURVE_LIST_H

#include "CmdAbstract.h"
#include "CurvesGraphs.h"

class CurveNameList;
class QXmlStreamReader;

/// Command for DlgSettingsCurveAddRemove
class CmdSettingsCurveAddRemove : public CmdAbstract
/// Command for DlgSettingsCurveList
class CmdSettingsCurveList : public CmdAbstract
{
public:
/// Constructor for normal creation
CmdSettingsCurveAddRemove(MainWindow &mainWindow,
Document &document,
const CurveNameList &modelCurves);
CmdSettingsCurveList(MainWindow &mainWindow,
Document &document,
const CurveNameList &modelCurves);

/// Constructor for parsing error report file xml
CmdSettingsCurveAddRemove(MainWindow &mainWindow,
Document &document,
const QString &cmdDescription,
QXmlStreamReader &reader);
CmdSettingsCurveList(MainWindow &mainWindow,
Document &document,
const QString &cmdDescription,
QXmlStreamReader &reader);

virtual ~CmdSettingsCurveAddRemove();
virtual ~CmdSettingsCurveList();

virtual void cmdRedo ();
virtual void cmdUndo ();
virtual void saveXml (QXmlStreamWriter &writer) const;

private:
CmdSettingsCurveAddRemove();
CmdSettingsCurveList();

CurvesGraphs m_curvesGraphsBefore;
CurvesGraphs m_curvesGraphsAfter;
};

#endif // CMD_SETTINGS_CURVE_ADD_REMOVE_H
#endif // CMD_SETTINGS_CURVE_LIST_H
10 changes: 5 additions & 5 deletions src/Create/CreateActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,11 @@ void CreateActions::createSettings (MainWindow &mw)
"Coordinate settings determine how the graph coordinates are mapped to the pixels in the image"));
connect (mw.m_actionSettingsCoords, SIGNAL (triggered ()), &mw, SLOT (slotSettingsCoords ()));

mw.m_actionSettingsCurveAddRemove = new QAction (tr ("Curve List..."), &mw);
mw.m_actionSettingsCurveAddRemove->setStatusTip (tr ("Edit Curve List settings."));
mw.m_actionSettingsCurveAddRemove->setWhatsThis (tr ("Curve List\n\n"
"Curve list settings add, rename and/or remove curves in the current document"));
connect (mw.m_actionSettingsCurveAddRemove, SIGNAL (triggered ()), &mw, SLOT (slotSettingsCurveAddRemove ()));
mw.m_actionSettingsCurveList = new QAction (tr ("Curve List..."), &mw);
mw.m_actionSettingsCurveList->setStatusTip (tr ("Edit Curve List settings."));
mw.m_actionSettingsCurveList->setWhatsThis (tr ("Curve List\n\n"
"Curve list settings add, rename and/or remove curves in the current document"));
connect (mw.m_actionSettingsCurveList, SIGNAL (triggered ()), &mw, SLOT (slotSettingsCurveList ()));

mw.m_actionSettingsCurveProperties = new QAction (tr ("Curve Properties..."), &mw);
mw.m_actionSettingsCurveProperties->setStatusTip (tr ("Edit Curve Properties settings."));
Expand Down
2 changes: 1 addition & 1 deletion src/Create/CreateMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void CreateMenus::create(MainWindow &mw)

mw.m_menuSettings = mw.menuBar()->addMenu(tr ("Settings"));
mw.m_menuSettings->addAction (mw.m_actionSettingsCoords);
mw.m_menuSettings->addAction (mw.m_actionSettingsCurveAddRemove);
mw.m_menuSettings->addAction (mw.m_actionSettingsCurveList);
mw.m_menuSettings->addAction (mw.m_actionSettingsCurveProperties);
mw.m_menuSettings->addAction (mw.m_actionSettingsDigitizeCurve);
mw.m_menuSettings->addAction (mw.m_actionSettingsExport);
Expand Down
6 changes: 3 additions & 3 deletions src/Create/CreateSettingsDialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "DlgSettingsAxesChecker.h"
#include "DlgSettingsColorFilter.h"
#include "DlgSettingsCoords.h"
#include "DlgSettingsCurveAddRemove.h"
#include "DlgSettingsCurveList.h"
#include "DlgSettingsCurveProperties.h"
#include "DlgSettingsDigitizeCurve.h"
#include "DlgSettingsExportFormat.h"
Expand All @@ -30,7 +30,7 @@ void CreateSettingsDialogs::create (MainWindow & mw)
LOG4CPP_INFO_S ((*mainCat)) << "CreateSettingsDialogs::create";

mw.m_dlgSettingsCoords = new DlgSettingsCoords (mw);
mw.m_dlgSettingsCurveAddRemove = new DlgSettingsCurveAddRemove (mw);
mw.m_dlgSettingsCurveList = new DlgSettingsCurveList (mw);
mw.m_dlgSettingsCurveProperties = new DlgSettingsCurveProperties (mw);
mw.m_dlgSettingsDigitizeCurve = new DlgSettingsDigitizeCurve (mw);
mw.m_dlgSettingsExportFormat = new DlgSettingsExportFormat (mw);
Expand All @@ -44,7 +44,7 @@ void CreateSettingsDialogs::create (MainWindow & mw)
mw.m_dlgSettingsMainWindow = new DlgSettingsMainWindow (mw);

mw.m_dlgSettingsCoords->setVisible (false);
mw.m_dlgSettingsCurveAddRemove->setVisible (false);
mw.m_dlgSettingsCurveList->setVisible (false);
mw.m_dlgSettingsCurveProperties->setVisible (false);
mw.m_dlgSettingsDigitizeCurve->setVisible (false);
mw.m_dlgSettingsExportFormat->setVisible (false);
Expand Down
2 changes: 1 addition & 1 deletion src/Create/CreateToolBars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "DlgSettingsAxesChecker.h"
#include "DlgSettingsColorFilter.h"
#include "DlgSettingsCoords.h"
#include "DlgSettingsCurveAddRemove.h"
#include "DlgSettingsCurveList.h"
#include "DlgSettingsCurveProperties.h"
#include "DlgSettingsDigitizeCurve.h"
#include "DlgSettingsExportFormat.h"
Expand Down
2 changes: 1 addition & 1 deletion src/Curve/CurveNameList.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ enum CurveNameListColumns {
NUMBER_CURVE_NAME_LIST_COLUMNS
};

/// Model for DlgSettingsCurveAddRemove and CmdSettingsCurveAddRemove. This is displayed as a QListView, with visible first column
/// Model for DlgSettingsCurveList and CmdSettingsCurveList. This is displayed as a QListView, with visible first column
/// showing current curve name. Second column is hidden with curve name at the start of editing, or empty if none.
class CurveNameList : public QStandardItemModel
{
Expand Down
Loading

0 comments on commit 76387ac

Please sign in to comment.