35 #ifndef __QGoDBNameDescEntityManager_h
36 #define __QGoDBNameDescEntityManager_h
39 #include <QMessageBox>
40 #include "vtkMySQLDatabase.h"
62 std::string iEntityName =
"",
int iImgSessionID = 0);
66 typedef std::vector< std::pair< std::string, std::string > >
76 std::string
AddAnEntity(vtkMySQLDatabase *iDatabaseConnector);
85 vtkMySQLDatabase *iDatabaseConnector);
95 virtual bool DeleteEntity(vtkMySQLDatabase *iDatabaseConnector);
109 int GetTheEntityID(std::string iName, vtkMySQLDatabase *iDatabaseConnector);
122 std::string iName, std::string iDescription) = 0;
131 std::vector< std::string > iVectorNamesEntitiesToDelete);
164 template<
typename T >
167 std::string
Name = iNewEntity.GetMapValue(
"Name");
169 if ( iNewEntity.DoesThisEntityAlreadyExistsAndReturnName(
170 this->m_DatabaseConnector, Name) != -1 )
174 tr(
"This %1 already exists, its name is: ' %2 ' ")
176 .arg( Name.c_str() ) );
195 template<
typename T >
198 ioNewEntity.SetField(
"Name", iName);
199 ioNewEntity.SetField(
"Description", iDescription);
200 if ( ioNewEntity.DoesThisNameAlreadyExists(
201 this->m_DatabaseConnector) != -1 )
vtkMySQLDatabase * m_DatabaseConnector
NamesDescrContainerType GetListExistingEntities(vtkMySQLDatabase *iDatabaseConnector)
return the list of all the existing entities stored in the database
std::string m_NameNewEntity
void DeleteEntitiesFromList(std::vector< std::string > iVectorNamesEntitiesToDelete)
Delete in the database the entities with the names contained in the vector.
~QGoDBNameDescEntityManager()
virtual void ValidateName(std::string iName, std::string iDescription)=0
Pure Virtual method : check that the name doesn't already exists in the database, if so...
QGoDBNameDescEntityManager(QWidget *iParent=0, std::string iEntityName="", int iImgSessionID=0)
void ValidateNameTemplate(T &ioNewEntity, std::string iName, std::string iDescription)
check if the name already exists for this entity in the database, if yes, let the user know...
int GetTheEntityID(std::string iName, vtkMySQLDatabase *iDatabaseConnector)
get the ID of the entity based on the name
QGoNameDescriptionInputDialog * m_NameDescDialog
QString tr(const char *sourceText, const char *disambiguation, int n)
bool CheckEntityAlreadyExists(T iNewEntity)
check if the entity already exists in the database, if yes, give the name of the existing entity to t...
Abstract class : the QGoDBNameDescEntityManager manages the interactions between the user and the dat...
virtual bool DeleteEntity(vtkMySQLDatabase *iDatabaseConnector)
show the list of the existing entities so the user can choose the ones he wants to delete...
void setText(const QString &text)
std::string GetNameNewEntity()
return the name of the new entity added
virtual void SaveNewEntityInDB()=0
Pure Virtual method : save the new entity in the database, the m_DatabaseConnectorForNewEntity needs ...
std::vector< std::pair< std::string, std::string > > NamesDescrContainerType
std::vector< std::string > GetNameExistingEntities(vtkMySQLDatabase *iDatabaseConnector)
return the names of all the entities stored in the database
std::string AddAnEntity(vtkMySQLDatabase *iDatabaseConnector)
execute the dialog asking the user to enter a name and a description, validates the name...