Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ProjectManagerAdapter Class Referenceabstract

Project manager adapter class. More...

#include <projectmanageradapter.h>

+ Inheritance diagram for ProjectManagerAdapter:
+ Collaboration diagram for ProjectManagerAdapter:

Classes

struct  FileDialogResult
 

Public Types

enum  Results { R_CANCELED, R_YES, R_NO, R_ACCEPTED }
 Enumeration of the possible outcomes of a typical mouse button. More...
 

Public Member Functions

 ProjectManagerAdapter ()
 Constructor. More...
 
virtual ~ProjectManagerAdapter ()
 Empty destructor. More...
 
void init (Core *core)
 Initialize the project management adapter. More...
 
void setCallback (FileChangesCallback *cb)
 Set a callback function for file changes. More...
 
bool hasChangesInFile () const
 
const std::string & getCurrentFilePath () const
 
Results onNewFile ()
 New-file menu response. More...
 
Results onSaveFile ()
 
Results onSaveFileAs ()
 
Results onOpenFile ()
 
bool onQuit ()
 
Results onEditFile ()
 
Results onShare ()
 
Results onExport ()
 
Results saveFile (const std::string &path, piano::FileType type)
 
Results openFile (const std::string &path, bool cached=false)
 
- Public Member Functions inherited from MessageListener
 MessageListener (bool defaultActivation=true)
 
virtual ~MessageListener ()
 
bool isMessageListenerActive () const
 
void activateMessageListener ()
 
void deactivateMessageListener ()
 

Protected Member Functions

virtual Results editFile ()=0
 edit a project file More...
 
virtual Results askForSaving ()=0
 asks the user whether to save the current project file More...
 
virtual FileDialogResult getSavePath (int fileType)=0
 get a path were to save the file More...
 
virtual FileDialogResult getOpenPath (int fileType)=0
 get a path to a file to open More...
 
virtual Results share ()=0
 shares the current file with the actual device More...
 
virtual void fillNew (Piano &piano)=0
 function to fill the piano data with the current new settings More...
 
virtual void showOpenError ()=0
 Show a message box that an error occurred during the open process. More...
 
virtual void showSaveError ()=0
 Show a message box that an error occurred during the save process. More...
 
virtual void handleMessage (MessagePtr m) override
 message listener callback More...
 
void setChangesInFile (bool b)
 change the state of mChangesInFile and notify the listener More...
 

Protected Attributes

CoremCore
 the core More...
 
PianoFile mPianoFile
 the piano file More...
 

Private Member Functions

Results checkForNoChanges ()
 

Private Attributes

bool mChangesInFile
 stores whether there are unsaved changes in the current file More...
 
FileChangesCallbackmCallback = nullptr
 callback if mChangesInFileChanged More...
 
std::string mCurrentFilePath
 current file path More...
 

Detailed Description

Project manager adapter class.

This class provides the interface between the core and the GUI for project management, i.e. loading and saving ept files, and keeping track of possible changes.

Definition at line 55 of file projectmanageradapter.h.

Member Enumeration Documentation

Enumeration of the possible outcomes of a typical mouse button.

Enumerator
R_CANCELED 
R_YES 
R_NO 
R_ACCEPTED 

Definition at line 59 of file projectmanageradapter.h.

Constructor & Destructor Documentation

ProjectManagerAdapter::ProjectManagerAdapter ( )

Constructor.

Definition at line 48 of file projectmanageradapter.cpp.

virtual ProjectManagerAdapter::~ProjectManagerAdapter ( )
inlinevirtual

Empty destructor.

Definition at line 80 of file projectmanageradapter.h.

Member Function Documentation

virtual Results ProjectManagerAdapter::askForSaving ( )
protectedpure virtual

asks the user whether to save the current project file

Returns
true if save is wanted

Implemented in ProjectManagerForQt.

ProjectManagerAdapter::Results ProjectManagerAdapter::checkForNoChanges ( )
private

Definition at line 267 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

virtual Results ProjectManagerAdapter::editFile ( )
protectedpure virtual

edit a project file

Returns
R_OK if successful fals if canceled

Implemented in ProjectManagerForQt.

virtual void ProjectManagerAdapter::fillNew ( Piano piano)
protectedpure virtual

function to fill the piano data with the current new settings

Implemented in ProjectManagerForQt.

const std::string& ProjectManagerAdapter::getCurrentFilePath ( ) const
inline

Definition at line 87 of file projectmanageradapter.h.

virtual FileDialogResult ProjectManagerAdapter::getOpenPath ( int  fileType)
protectedpure virtual

get a path to a file to open

Returns
the absolute file path

Implemented in ProjectManagerForQt.

virtual FileDialogResult ProjectManagerAdapter::getSavePath ( int  fileType)
protectedpure virtual

get a path were to save the file

Returns
the absolute file path

Implemented in ProjectManagerForQt.

void ProjectManagerAdapter::handleMessage ( MessagePtr  m)
overrideprotectedvirtual

message listener callback

Implements MessageListener.

Definition at line 287 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

bool ProjectManagerAdapter::hasChangesInFile ( ) const
inline

Definition at line 85 of file projectmanageradapter.h.

void ProjectManagerAdapter::init ( Core core)

Initialize the project management adapter.

Parameters
core: Pointer to the core instance.

Definition at line 64 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::onEditFile ( )

Definition at line 222 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::onExport ( )

Definition at line 252 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::onNewFile ( )

New-file menu response.

Returns

Definition at line 109 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::onOpenFile ( )

Definition at line 172 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

bool ProjectManagerAdapter::onQuit ( )

Definition at line 194 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::onSaveFile ( )

Definition at line 138 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::onSaveFileAs ( )

Definition at line 155 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::onShare ( )

Definition at line 244 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::openFile ( const std::string &  path,
bool  cached = false 
)

Definition at line 334 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

ProjectManagerAdapter::Results ProjectManagerAdapter::saveFile ( const std::string &  path,
piano::FileType  type 
)

Definition at line 308 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

void ProjectManagerAdapter::setCallback ( FileChangesCallback cb)

Set a callback function for file changes.

Like most applications, the entropy piano tuner goes into a state of 'having unsaved changes' as soon as a data element of the current project has been changed. Usually this is indicated in the GUI, e.g. by a little star after the file name in the title bar of the window. In order to inform the GUI about changes, we have to define a suitable callback function.

Parameters
cb: Pointer to the callback function

Definition at line 91 of file projectmanageradapter.cpp.

void ProjectManagerAdapter::setChangesInFile ( bool  b)
protected

change the state of mChangesInFile and notify the listener

Definition at line 300 of file projectmanageradapter.cpp.

+ Here is the call graph for this function:

virtual Results ProjectManagerAdapter::share ( )
protectedpure virtual

shares the current file with the actual device

Returns
R_ACCEPTED if successful

Implemented in ProjectManagerForQt.

virtual void ProjectManagerAdapter::showOpenError ( )
protectedpure virtual

Show a message box that an error occurred during the open process.

Implemented in ProjectManagerForQt.

virtual void ProjectManagerAdapter::showSaveError ( )
protectedpure virtual

Show a message box that an error occurred during the save process.

Implemented in ProjectManagerForQt.

Member Data Documentation

FileChangesCallback* ProjectManagerAdapter::mCallback = nullptr
private

callback if mChangesInFileChanged

Definition at line 157 of file projectmanageradapter.h.

bool ProjectManagerAdapter::mChangesInFile
private

stores whether there are unsaved changes in the current file

Definition at line 154 of file projectmanageradapter.h.

Core* ProjectManagerAdapter::mCore
protected

the core

Definition at line 147 of file projectmanageradapter.h.

std::string ProjectManagerAdapter::mCurrentFilePath
private

current file path

Definition at line 160 of file projectmanageradapter.h.

PianoFile ProjectManagerAdapter::mPianoFile
protected

the piano file

Definition at line 150 of file projectmanageradapter.h.


The documentation for this class was generated from the following files: