Skip to content

Commit

Permalink
Refs #10491 Change IReflPresenter flag type to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Jeffery committed Nov 4, 2014
1 parent b62214b commit 22e991a
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 169 deletions.
Expand Up @@ -40,12 +40,31 @@ namespace MantidQt
{
public:
virtual ~IReflPresenter() {};

enum Flag
{
SaveFlag,
SaveAsFlag,
AppendRowFlag,
PrependRowFlag,
DeleteRowFlag,
ProcessFlag,
GroupRowsFlag,
OpenTableFlag,
NewTableFlag,
TableUpdatedFlag,
ExpandSelectionFlag,
OptionsDialogFlag,
ClearSelectedFlag,
CopySelectedFlag,
CutSelectedFlag,
PasteSelectedFlag,
};

//Tell the presenter something happened
virtual void notify(int flag) = 0;
virtual void notify(IReflPresenter::Flag flag) = 0;
virtual const std::map<std::string,QVariant>& options() const = 0;
virtual void setOptions(const std::map<std::string,QVariant>& options) = 0;
private:

};
}
}
Expand Down
Expand Up @@ -70,24 +70,6 @@ namespace MantidQt
virtual std::string getClipboard() const = 0;

virtual boost::shared_ptr<IReflPresenter> getPresenter() const = 0;

static const int NoFlags = 0;
static const int SaveFlag = 1;
static const int SaveAsFlag = 2;
static const int AppendRowFlag = 3;
static const int PrependRowFlag = 4;
static const int DeleteRowFlag = 5;
static const int ProcessFlag = 6;
static const int GroupRowsFlag = 7;
static const int OpenTableFlag = 8;
static const int NewTableFlag = 9;
static const int TableUpdatedFlag = 10;
static const int ExpandSelectionFlag = 11;
static const int OptionsDialogFlag = 12;
static const int ClearSelectedFlag = 13;
static const int CopySelectedFlag = 14;
static const int CutSelectedFlag = 15;
static const int PasteSelectedFlag = 16;
};
}
}
Expand Down
Expand Up @@ -45,7 +45,7 @@ namespace MantidQt
public:
ReflMainViewPresenter(ReflMainView* view);
virtual ~ReflMainViewPresenter();
virtual void notify(int flag);
virtual void notify(IReflPresenter::Flag flag);
virtual const std::map<std::string,QVariant>& options() const;
virtual void setOptions(const std::map<std::string,QVariant>& options);
//Public for the purposes of unit testing
Expand Down
32 changes: 16 additions & 16 deletions Code/Mantid/MantidQt/CustomInterfaces/src/QtReflMainView.cpp
Expand Up @@ -59,7 +59,7 @@ namespace MantidQt
void QtReflMainView::setModel(QString name)
{
m_toOpen = name.toStdString();
m_presenter->notify(OpenTableFlag);
m_presenter->notify(IReflPresenter::OpenTableFlag);
}

/**
Expand Down Expand Up @@ -101,111 +101,111 @@ namespace MantidQt
*/
void QtReflMainView::on_actionSaveTable_triggered()
{
m_presenter->notify(SaveFlag);
m_presenter->notify(IReflPresenter::SaveFlag);
}

/**
This slot notifies the presenter that the "save as" button has been pressed
*/
void QtReflMainView::on_actionSaveTableAs_triggered()
{
m_presenter->notify(SaveAsFlag);
m_presenter->notify(IReflPresenter::SaveAsFlag);
}

/**
This slot notifies the presenter that the "append row" button has been pressed
*/
void QtReflMainView::on_actionAppendRow_triggered()
{
m_presenter->notify(AppendRowFlag);
m_presenter->notify(IReflPresenter::AppendRowFlag);
}

/**
This slot notifies the presenter that the "prepend row" button has been pressed
*/
void QtReflMainView::on_actionPrependRow_triggered()
{
m_presenter->notify(PrependRowFlag);
m_presenter->notify(IReflPresenter::PrependRowFlag);
}

/**
This slot notifies the presenter that the "delete" button has been pressed
*/
void QtReflMainView::on_actionDeleteRow_triggered()
{
m_presenter->notify(DeleteRowFlag);
m_presenter->notify(IReflPresenter::DeleteRowFlag);
}

/**
This slot notifies the presenter that the "process" button has been pressed
*/
void QtReflMainView::on_actionProcess_triggered()
{
m_presenter->notify(ProcessFlag);
m_presenter->notify(IReflPresenter::ProcessFlag);
}

/**
This slot notifies the presenter that the "group rows" button has been pressed
*/
void QtReflMainView::on_actionGroupRows_triggered()
{
m_presenter->notify(GroupRowsFlag);
m_presenter->notify(IReflPresenter::GroupRowsFlag);
}

/**
This slot notifies the presenter that the "clear selected" button has been pressed
*/
void QtReflMainView::on_actionClearSelected_triggered()
{
m_presenter->notify(ClearSelectedFlag);
m_presenter->notify(IReflPresenter::ClearSelectedFlag);
}

/**
This slot notifies the presenter that the "copy selection" button has been pressed
*/
void QtReflMainView::on_actionCopySelected_triggered()
{
m_presenter->notify(CopySelectedFlag);
m_presenter->notify(IReflPresenter::CopySelectedFlag);
}

/**
This slot notifies the presenter that the "cut selection" button has been pressed
*/
void QtReflMainView::on_actionCutSelected_triggered()
{
m_presenter->notify(CutSelectedFlag);
m_presenter->notify(IReflPresenter::CutSelectedFlag);
}

/**
This slot notifies the presenter that the "paste selection" button has been pressed
*/
void QtReflMainView::on_actionPasteSelected_triggered()
{
m_presenter->notify(PasteSelectedFlag);
m_presenter->notify(IReflPresenter::PasteSelectedFlag);
}

/**
This slot notifies the presenter that the "new table" button has been pressed
*/
void QtReflMainView::on_actionNewTable_triggered()
{
m_presenter->notify(NewTableFlag);
m_presenter->notify(IReflPresenter::NewTableFlag);
}

/**
This slot notifies the presenter that the "expand selection" button has been pressed
*/
void QtReflMainView::on_actionExpandSelection_triggered()
{
m_presenter->notify(ExpandSelectionFlag);
m_presenter->notify(IReflPresenter::ExpandSelectionFlag);
}

/**
This slot notifies the presenter that the "options..." button has been pressed
*/
void QtReflMainView::on_actionOptionsDialog_triggered()
{
m_presenter->notify(OptionsDialogFlag);
m_presenter->notify(IReflPresenter::OptionsDialogFlag);
}

/**
Expand All @@ -215,7 +215,7 @@ namespace MantidQt
{
Q_UNUSED(topLeft);
Q_UNUSED(bottomRight);
m_presenter->notify(TableUpdatedFlag);
m_presenter->notify(IReflPresenter::TableUpdatedFlag);
}

/**
Expand Down
36 changes: 17 additions & 19 deletions Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainViewPresenter.cpp
Expand Up @@ -840,28 +840,26 @@ namespace MantidQt
/**
Used by the view to tell the presenter something has changed
*/
void ReflMainViewPresenter::notify(int flag)
void ReflMainViewPresenter::notify(IReflPresenter::Flag flag)
{
switch(flag)
{
case ReflMainView::SaveAsFlag: saveTableAs(); break;
case ReflMainView::SaveFlag: saveTable(); break;
case ReflMainView::AppendRowFlag: appendRow(); break;
case ReflMainView::PrependRowFlag: prependRow(); break;
case ReflMainView::DeleteRowFlag: deleteRow(); break;
case ReflMainView::ProcessFlag: process(); break;
case ReflMainView::GroupRowsFlag: groupRows(); break;
case ReflMainView::ClearSelectedFlag: clearSelected(); break;
case ReflMainView::CopySelectedFlag: copySelected(); break;
case ReflMainView::CutSelectedFlag: cutSelected(); break;
case ReflMainView::PasteSelectedFlag: pasteSelected(); break;
case ReflMainView::OpenTableFlag: openTable(); break;
case ReflMainView::NewTableFlag: newTable(); break;
case ReflMainView::TableUpdatedFlag: m_tableDirty = true; break;
case ReflMainView::ExpandSelectionFlag: expandSelection(); break;
case ReflMainView::OptionsDialogFlag: showOptionsDialog(); break;

case ReflMainView::NoFlags: return;
case IReflPresenter::SaveAsFlag: saveTableAs(); break;
case IReflPresenter::SaveFlag: saveTable(); break;
case IReflPresenter::AppendRowFlag: appendRow(); break;
case IReflPresenter::PrependRowFlag: prependRow(); break;
case IReflPresenter::DeleteRowFlag: deleteRow(); break;
case IReflPresenter::ProcessFlag: process(); break;
case IReflPresenter::GroupRowsFlag: groupRows(); break;
case IReflPresenter::OpenTableFlag: openTable(); break;
case IReflPresenter::NewTableFlag: newTable(); break;
case IReflPresenter::TableUpdatedFlag: m_tableDirty = true; break;
case IReflPresenter::ExpandSelectionFlag: expandSelection(); break;
case IReflPresenter::OptionsDialogFlag: showOptionsDialog(); break;
case IReflPresenter::ClearSelectedFlag: clearSelected(); break;
case IReflPresenter::CopySelectedFlag: copySelected(); break;
case IReflPresenter::CutSelectedFlag: cutSelected(); break;
case IReflPresenter::PasteSelectedFlag: pasteSelected(); break;
}
//Not having a 'default' case is deliberate. gcc issues a warning if there's a flag we aren't handling.
}
Expand Down
Expand Up @@ -9,22 +9,6 @@
using namespace MantidQt::CustomInterfaces;
using namespace Mantid::API;

//Clean flag aliases for use within tests.
const int NewTableFlag = ReflMainView::NewTableFlag;
const int OpenTableFlag = ReflMainView::OpenTableFlag;
const int SaveAsFlag = ReflMainView::SaveAsFlag;
const int SaveFlag = ReflMainView::SaveFlag;
const int ProcessFlag = ReflMainView::ProcessFlag;
const int AppendRowFlag = ReflMainView::AppendRowFlag;
const int PrependRowFlag = ReflMainView::PrependRowFlag;
const int DeleteRowFlag = ReflMainView::DeleteRowFlag;
const int GroupRowsFlag = ReflMainView::GroupRowsFlag;
const int ClearSelectedFlag = ReflMainView::ClearSelectedFlag;
const int CopySelectedFlag = ReflMainView::CopySelectedFlag;
const int CutSelectedFlag = ReflMainView::CutSelectedFlag;
const int PasteSelectedFlag = ReflMainView::PasteSelectedFlag;
const int ExpandSelectionFlag = ReflMainView::ExpandSelectionFlag;

//Clean column ids for use within tests
const int RunCol = ReflMainViewPresenter::COL_RUNS;
const int ThetaCol = ReflMainViewPresenter::COL_ANGLE;
Expand Down

0 comments on commit 22e991a

Please sign in to comment.