diff --git a/CMakeLists.txt b/CMakeLists.txt index 7536a45..f017f4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,40 +1,58 @@ cmake_minimum_required(VERSION 2.8.3) project(Miro) -if (${CATKIN_TOPLEVEL}) +################################### +## catkin ## +################################### +if (CATKIN_DEVEL_PREFIX) find_package(catkin REQUIRED COMPONENTS irg_cmake + qt_gui_cpp ) -endif(${CATKIN_TOPLEVEL}) - -if (catkin_FOUND) -################################### -## catkin specific configuration ## -################################### -catkin_package( - INCLUDE_DIRS src - LIBRARIES miroCore miroBase miroParams miroXml - ) -else (catkin_FOUND) -## set up some defaults -set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) - -include( SetArchitecture ) -include( SetupBuildSwitch ) -include( SetupConfigureFile ) -include( SetupInstall ) -include( SetupRPATH ) -include( SetupUtilities ) -include( UserOptions ) -include( SetupWarnLevel ) -endif(catkin_FOUND) +endif(CATKIN_DEVEL_PREFIX) + +if(NOT catkin_FOUND) + ## set up some defaults + set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) + + include( SetArchitecture ) + include( SetupBuildSwitch ) + include( SetupConfigureFile ) + include( SetupInstall ) + include( SetupRPATH ) + include( SetupUtilities ) + include( UserOptions ) + include( SetupWarnLevel ) +endif(NOT catkin_FOUND) add_build_var( WITH_TAO BUILD_DEFAULT_TRUE ) add_build_var( WITH_JSON BUILD_DEFAULT_TRUE ) -find_package( ACE ) -find_package( Qt4 ) +if("${qt_gui_cpp_USE_QT_MAJOR_VERSION} " STREQUAL "5 ") + message(STATUS "FOUND QT 5") + find_package(Qt5Widgets REQUIRED) + find_package(Qt5Xml REQUIRED) + if (Qt5_POSITION_INDEPENDENT_CODE) + SET(CMAKE_POSITION_INDEPENDENT_CODE ON) + endif() + include_directories(SYSTEM "${Qt5Widgets_INCLUDE_DIRS}") + include_directories(SYSTEM "${Qt5Xml_INCLUDE_DIRS}") + set(QT_QTXML_LIBRARY Qt5::Xml) + set(QT_QTCORE_LIBRARY Qt5::Widgets) + add_build_var( WITH_QT4 BUILD_DEFAULT_FALSE ) + add_build_var( WITH_QT5 BUILD_DEFAULT_TRUE ) +else() + message(STATUS "FOUND QT 4") + find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED) + include(${QT_USE_FILE}) + include_directories(SYSTEM "${QT_INCLUDE_DIR}") + include_directories(SYSTEM "${QT_QTXML_INCLUDE_DIR}") + include_directories(SYSTEM "${QT_QTCORE_INCLUDE_DIR}") + add_build_var( WITH_QT4 BUILD_DEFAULT_TRUE ) + add_build_var( WITH_QT5 BUILD_DEFAULT_FALSE ) +endif() +find_package( ACE ) find_package_if( TAO MIRO_BUILD_WITH_TAO ) find_package_if( JsonCpp MIRO_BUILD_WITH_JSON ) @@ -44,7 +62,33 @@ build_with_var( WITH_JSON JSONCPP_FOUND ) ## if we don't have the following components, ## we cannot continue ##----------------------------------------------- -minimum_requirements( ACE_FOUND QT4_FOUND QT_QT3SUPPORT_FOUND ) +minimum_requirements( ACE_FOUND ) + +if (catkin_FOUND) +################################### +## catkin specific configuration ## +################################### + set(MIRO_CATKIN_DEPENDS ACE ) + if(MIRO_BUILD_WITH_TAO) + set(MIRO_CATKIN_DEPENDS ${MIRO_CATKIN_DEPENDS} TAO) + endif(MIRO_BUILD_WITH_TAO) + if(MIRO_BUILD_WITH_JSON) + set(MIRO_CATKIN_DEPENDS ${MIRO_CATKIN_DEPENDS} JSONCPP) + endif(MIRO_BUILD_WITH_JSON) + + catkin_package( + INCLUDE_DIRS src + LIBRARIES miroCore miroBase miroParams miroXml + CFG_EXTRAS Miro-extras.cmake + DEPENDS ${MIRO_CATKIN_DEPENDS} + ) + ## set variable with full path of extras file so we can append library info + set_cfg_extras_file() + + # add devel/include - this should add to persistent catkin metadata + list(APPEND ${PROJECT_NAME}_INCLUDE_DIRS ${CATKIN_DEVEL_PREFIX}/include) + +endif(catkin_FOUND) set( MIRO_SOVERSION_MAJOR 3 ) # epoch set( MIRO_SOVERSION_MINOR 2 ) # revision @@ -57,20 +101,19 @@ set( MIRO_SOVERSION "${MIRO_SOVERSION_MAJOR}.${MIRO_SOVERSION_MINOR}.${M include( GenerateMiroMakeParams ) # we need to tell the macro where to find the executable # because it isn't "installed" yet... -if (${CATKIN_TOPLEVEL}) +if (CATKIN_DEVEL_PREFIX) set( MIRO_MAKEPARAMS_EXECUTABLE ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION}/MakeParams ) -else (${CATKIN_TOPLEVEL}) +else (CATKIN_DEVEL_PREFIX) set( MIRO_MAKEPARAMS_EXECUTABLE ${PROJECT_BINARY_DIR}/src/makeParams/${CMAKE_CFG_INTDIR}/MakeParams ) -endif (${CATKIN_TOPLEVEL}) +endif (CATKIN_DEVEL_PREFIX) ## add in and out of source dirs to include path ##----------------------------------------------- include_directories( - ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/src - ${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}/src + ${CATKIN_DEVEL_PREFIX}/include ) ## Set up RPATH and *Config.h @@ -88,20 +131,10 @@ include_directories( ${TAO_INCLUDE_DIRS} ) -# everything needs to link to Qt, so set it -# up at the top level for convinience -##----------------------------------------------- -include_directories( - ${QT_INCLUDE_DIR} - ${QT_QT_INCLUDE_DIR} - ${QT_QTXML_INCLUDE_DIR} - ${QT_QTCORE_INCLUDE_DIR} -) - # always build these #---------------------- add_subdirectory( src ) -add_build_switch( utils BUILD_DEFAULT_TRUE ) +add_subdirectory( utils ) add_build_switch( examples BUILD_DEFAULT_TRUE ) add_build_switch( tests BUILD_DEFAULT_TRUE ) @@ -111,11 +144,38 @@ install_export() # package script #------------------------------------ -if (NOT ${CATKIN_TOPLEVEL}) +if (NOT CATKIN_DEVEL_PREFIX) include( CMakePack.txt ) -endif (NOT ${CATKIN_TOPLEVEL}) +endif (NOT CATKIN_DEVEL_PREFIX) #------------------------------------ print_build_switches() message(STATUS "Miro version is ${MIRO_SOVERSION}") + +############################################### +## We deviate from the standard usage of catkin's CFG_EXTRAS because +## that must run before targets are added, but we want this to run +## after targets are added (so we have a list of exported libraries +## that is consistent with the build switches). +## I"M PRETTY SURE THIS WILL BREAK WHEN BUILDING INSTALLSPACE +## installation will be tricky. For now, we just acknowledge its +## probably broken and carry on... +if( Miro_CFG_EXTRAS_FILE ) + # copy the develspace extras to the one that will go into installspace + execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${Miro_CFG_EXTRAS_FILE} ${Miro_CFG_EXTRAS_FILE}-install) + + file( APPEND ${Miro_CFG_EXTRAS_FILE} "\n#-- Executables -----\n" ) + file( APPEND ${Miro_CFG_EXTRAS_FILE} "set( MIRO_MAKEPARAMS_EXECUTABLE ${MIRO_MAKEPARAMS_EXECUTABLE} )\n" ) + + # install file + ## there is not a consistent ordering of installation if install is called + ## at this level. Therefore, we create a cmake/postinstall subdirectory and make the + ## call there. The last subdirectory added will have its install commands exectued last. + file( APPEND ${Miro_CFG_EXTRAS_FILE}-install "\n#-- Executables -----\n" ) + file( APPEND ${Miro_CFG_EXTRAS_FILE}-install "set( MIRO_MAKEPARAMS_EXECUTABLE ${CMAKE_INSTALL_PREFIX}/bin/MakeParams )\n" ) + add_subdirectory( cmake/postinstall ) + +endif( Miro_CFG_EXTRAS_FILE ) +############################################### + diff --git a/cmake/Miro-extras.cmake.develspace.in b/cmake/Miro-extras.cmake.develspace.in new file mode 100644 index 0000000..8b299dd --- /dev/null +++ b/cmake/Miro-extras.cmake.develspace.in @@ -0,0 +1,12 @@ +# source: Miro-extras.cmake.develspace.in + +include( GenerateMiroMakeParams ) + +## we have to add devel/include to catkin_INCLUDE_DIRS +## so generated MakeParams include files can be seen +set( MIRO_INCLUDE_DIR @CATKIN_DEVEL_PREFIX@/include ) + +set( catkin_INCLUDE_DIRS ${catkin_INCLUDE_DIRS} ${MIRO_INCLUDE_DIR} ) + +set( MIRO_BUILD_WITH_QT4 @MIRO_BUILD_WITH_QT4@ ) +set( MIRO_BUILD_WITH_QT5 @MIRO_BUILD_WITH_QT5@ ) diff --git a/cmake/Miro-extras.cmake.installspace.in b/cmake/Miro-extras.cmake.installspace.in new file mode 100644 index 0000000..70883b6 --- /dev/null +++ b/cmake/Miro-extras.cmake.installspace.in @@ -0,0 +1,11 @@ +## +## Miro-extras.cmake.installspace.in +## +## NOTE: This file is not used - it is here to trick catkin into thinking it +## should install a Miro-extras.cmake file. What we actually install is +## a modified Miro-extras.cmake.develspace.in which has the install +## destination for MIRO_MAKEPARAMS_EXECUTABLE. +## Prior to installing, the file is stored in develspace as +## devel/share/Miro/cmake/Miro-extras.cmake-install +## + diff --git a/cmake/Modules/FindACE.cmake b/cmake/Modules/FindACE.cmake index 75fa81e..f51ff62 100644 --- a/cmake/Modules/FindACE.cmake +++ b/cmake/Modules/FindACE.cmake @@ -50,9 +50,9 @@ if( ACE_ROOT_DIR ) # FIXME - do a proper header search if( EXISTS ${ACE_ROOT_DIR}/ace/ACE.h ) set( ACE_INCLUDE_DIR ${ACE_ROOT_DIR} CACHE PATH "ACE include path" ) - else( EXISTS ${ACE_ROOT_DIR}/ace/ACE.h ) + elseif( EXISTS ${ACE_ROOT_DIR}/ace/ACE.h ) set( ACE_INCLUDE_DIR ${ACE_ROOT_DIR}/include CACHE PATH "ACE include path" ) - else( EXISTS ${ACE_ROOT_DIR}/include/ace/ACE.h ) + elseif( EXISTS ${ACE_ROOT_DIR}/include/ace/ACE.h ) set( ACE_INCLUDE_DIR ${ACE_ROOT_DIR}/include CACHE PATH "ACE include path" ) endif( EXISTS ${ACE_ROOT_DIR}/ace/ACE.h ) diff --git a/cmake/postinstall/CMakeLists.txt b/cmake/postinstall/CMakeLists.txt new file mode 100644 index 0000000..23df71b --- /dev/null +++ b/cmake/postinstall/CMakeLists.txt @@ -0,0 +1,2 @@ +install( CODE "message( STATUS \"#### Do the install of Miro_CFG_EXTRAS_FILE in postinstall to make sure it's the last thing executed\") ####" ) +install( FILES ${Miro_CFG_EXTRAS_FILE}-install DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake RENAME ${PROJECT_NAME}-extras.cmake ) diff --git a/examples/params/convertParams.cpp b/examples/params/convertParams.cpp index f908ad5..7ec3225 100644 --- a/examples/params/convertParams.cpp +++ b/examples/params/convertParams.cpp @@ -55,7 +55,7 @@ SimpleSurveyParameters readJson(const string& jsonName) Json::Reader reader; bool success = reader.parse(jsonStream, root); if (!success) { - cerr << reader.getFormatedErrorMessages() << endl; + cerr << reader.getFormattedErrorMessages() << endl; exit(1); } jsonStream.close(); @@ -88,7 +88,7 @@ SimpleSurveyParameters readXml(const string& xmlName) QFile xmlFile(xmlName.c_str()); if (!xmlFile.open(QIODevice::ReadOnly)) { cerr << "couldn't open " << xmlName << " for reading: " - << ((const char*) xmlFile.errorString().toAscii()) << endl; + << ((const char*) xmlFile.errorString().toLatin1()) << endl; exit(1); } @@ -116,7 +116,7 @@ void writeXml(const string& xmlName, const SimpleSurveyParameters& params) QFile xmlFile(xmlName.c_str()); if (!xmlFile.open(QIODevice::WriteOnly)) { cerr << "couldn't open " << xmlName << " for writing: " - << ((const char*) xmlFile.errorString().toAscii()) << endl; + << ((const char*) xmlFile.errorString().toLatin1()) << endl; exit(1); } QTextStream ts(&xmlFile); diff --git a/src/makeParams/MakeParams.cpp b/src/makeParams/MakeParams.cpp index f7c8a26..a4c2abf 100644 --- a/src/makeParams/MakeParams.cpp +++ b/src/makeParams/MakeParams.cpp @@ -28,7 +28,9 @@ #include "params/Generator.h" #include "params/TextErrorHandler.h" -#include +#include + +#include #include #include @@ -152,7 +154,7 @@ main(int argc, char * argv[]) QString headerFilename(baseName + "." + headerExtension); ofstream headerFile(qPrintable(headerFilename)); - generator.generateSource(sourceFile); + generator.generateSource(sourceFile, exportDirective); generator.generateHeader(headerFile, exportDirective); } else { diff --git a/src/miro/ConfigDocument.cpp b/src/miro/ConfigDocument.cpp index eae693f..91288dc 100644 --- a/src/miro/ConfigDocument.cpp +++ b/src/miro/ConfigDocument.cpp @@ -57,7 +57,7 @@ namespace Miro delete document_; } - void ConfigDocument::init(QDomDocument * _document) throw(Exception) + void ConfigDocument::init(QDomDocument * _document) //throw(Exception) { delete document_; document_ = _document; @@ -65,7 +65,7 @@ namespace Miro void ConfigDocument::init(std::string const& _fileName, SearchPaths const& _paths) - throw(Exception) + //throw(Exception) { delete document_; document_ = NULL; diff --git a/src/miro/ConfigDocument.h b/src/miro/ConfigDocument.h index 7400344..fa5bcab 100644 --- a/src/miro/ConfigDocument.h +++ b/src/miro/ConfigDocument.h @@ -49,9 +49,9 @@ namespace Miro ~ConfigDocument(); void init(std::string const& _defaultName = std::string(""), - SearchPaths const& _paths = SearchPaths()) - throw(Exception); - void init(QDomDocument * _document) throw(Exception); + SearchPaths const& _paths = SearchPaths()); + //throw(Exception); + void init(QDomDocument * _document);// throw(Exception); void fini(); diff --git a/src/miro/Configuration.cpp b/src/miro/Configuration.cpp index 98fa75b..94addf1 100644 --- a/src/miro/Configuration.cpp +++ b/src/miro/Configuration.cpp @@ -48,7 +48,7 @@ namespace Miro { Singleton Configuration::document; - void Configuration::init(int& argc, char * argv[], const std::string& etcPath) throw(Exception) + void Configuration::init(int& argc, char * argv[], const std::string& etcPath) //throw(Exception) { if (initialized) return; @@ -99,3 +99,5 @@ namespace Miro initialized = true; } } + +MIRO_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton, Miro::ConfigDocument, ACE_SYNCH_RECURSIVE_MUTEX); diff --git a/src/miro/Configuration.h b/src/miro/Configuration.h index 0607eac..853399b 100644 --- a/src/miro/Configuration.h +++ b/src/miro/Configuration.h @@ -38,7 +38,7 @@ namespace Miro * Loading the document from default location if not overridden * by command line parameter -MiroConfigFile (-MCF). */ - static void init(int& argc, char * argv[], const std::string& etcPath = "") throw(Exception); + static void init(int& argc, char * argv[], const std::string& etcPath = "");// throw(Exception); //! Singleton accesor for the robots configuation document. static Singleton document; }; diff --git a/src/miro/Enumeration.cpp b/src/miro/Enumeration.cpp index 3eb6b67..8f8ab3d 100644 --- a/src/miro/Enumeration.cpp +++ b/src/miro/Enumeration.cpp @@ -27,7 +27,7 @@ namespace Miro { using namespace std; - Enumeration::Enumeration(string const& _enum, string const& _values) throw(EInvalid, EDuplicates) + Enumeration::Enumeration(string const& _enum, string const& _values) //throw(EInvalid, EDuplicates) { // tokenize input values int pos = 0; @@ -46,15 +46,15 @@ namespace Miro } - Enumeration::Enumeration(string const& _enum, vector const& _values) throw(EInvalid, EDuplicates) : - values_(_values) + Enumeration::Enumeration(string const& _enum, vector const& _values) //throw(EInvalid, EDuplicates) + : values_(_values) { makeSet(); value(_enum); } void - Enumeration::value(string const& _value) throw(EInvalid, EDuplicates) + Enumeration::value(string const& _value) //throw(EInvalid, EDuplicates) { StringVector::const_iterator i; @@ -66,7 +66,7 @@ namespace Miro } void - Enumeration::makeSet() throw(EDuplicates) + Enumeration::makeSet() //throw(EDuplicates) { sort(values_.begin(), values_.end()); StringVector::iterator i = unique(values_.begin(), values_.end()); diff --git a/src/miro/Enumeration.h b/src/miro/Enumeration.h index bb58e86..0b7f298 100644 --- a/src/miro/Enumeration.h +++ b/src/miro/Enumeration.h @@ -41,17 +41,17 @@ namespace Miro typedef std::vector StringVector; - Enumeration(std::string const& _enum, std::string const& _values) - throw(EInvalid, EDuplicates); - Enumeration(std::string const &_enum, std::vector const& _values) - throw(EInvalid, EDuplicates); + Enumeration(std::string const& _enum, std::string const& _values); + //throw(EInvalid, EDuplicates); + Enumeration(std::string const &_enum, std::vector const& _values); + //throw(EInvalid, EDuplicates); - void value(std::string const& _value) throw(EInvalid, EDuplicates); + void value(std::string const& _value); //throw(EInvalid, EDuplicates); std::string const& value() const throw(); StringVector const& assortment() const throw(); private: - void makeSet() throw(EDuplicates); + void makeSet(); //throw(EDuplicates); StringVector::const_iterator enum_; StringVector values_; diff --git a/src/miro/EnumerationMultiple.cpp b/src/miro/EnumerationMultiple.cpp index 42e68c7..1293778 100644 --- a/src/miro/EnumerationMultiple.cpp +++ b/src/miro/EnumerationMultiple.cpp @@ -32,8 +32,8 @@ namespace Miro { EnumerationMultiple::EnumerationMultiple(string const& _enum, string const& _values) - throw(EInvalid, EDuplicates) : - enum_(tokenizer(_enum)), + //throw(EInvalid, EDuplicates) : + : enum_(tokenizer(_enum)), values_(tokenizer(_values)) { makeSet(enum_); @@ -44,8 +44,8 @@ namespace Miro EnumerationMultiple::EnumerationMultiple(vector const& _enum, vector const& _values) - throw(EInvalid, EDuplicates) : - enum_(_enum), + //throw(EInvalid, EDuplicates) : + : enum_(_enum), values_(_values) { makeSet(enum_); @@ -55,7 +55,7 @@ namespace Miro void - EnumerationMultiple::value(string const& _value) throw(EInvalid, EDuplicates) + EnumerationMultiple::value(string const& _value) //throw(EInvalid, EDuplicates) { StringVector v(tokenizer(_value)); makeSet(v); @@ -66,7 +66,7 @@ namespace Miro void - EnumerationMultiple::value(vector const& _value) throw(EInvalid, EDuplicates) + EnumerationMultiple::value(vector const& _value) //throw(EInvalid, EDuplicates) { StringVector v(_value); makeSet(v); @@ -94,7 +94,7 @@ namespace Miro } void - EnumerationMultiple::makeSet(vector& v) throw(EDuplicates) + EnumerationMultiple::makeSet(vector& v) //throw(EDuplicates) { sort(v.begin(), v.end()); StringVector::iterator i = unique(v.begin(), v.end()); @@ -103,7 +103,7 @@ namespace Miro } void - EnumerationMultiple::checkAvailability(vector const& v) throw(EInvalid) + EnumerationMultiple::checkAvailability(vector const& v) //throw(EInvalid) { if (!includes(values_.begin(), values_.end(), v.begin(), v.end())) { throw EInvalid("Enumeration: tried to set value not in list of available values"); diff --git a/src/miro/EnumerationMultiple.h b/src/miro/EnumerationMultiple.h index 122383e..4eae54d 100644 --- a/src/miro/EnumerationMultiple.h +++ b/src/miro/EnumerationMultiple.h @@ -41,22 +41,22 @@ namespace Miro typedef std::vector StringVector; - EnumerationMultiple(std::string const& _enum, std::string const& _values) - throw(EInvalid, EDuplicates); - EnumerationMultiple(std::vector const& _enum, std::vector const& _values) - throw(EInvalid, EDuplicates); + EnumerationMultiple(std::string const& _enum, std::string const& _values); + //throw(EInvalid, EDuplicates); + EnumerationMultiple(std::vector const& _enum, std::vector const& _values); + //throw(EInvalid, EDuplicates); - void value(std::string const& _value) throw(EInvalid, EDuplicates); - void value(std::vector const& _value) throw(EInvalid, EDuplicates); + void value(std::string const& _value); //throw(EInvalid, EDuplicates); + void value(std::vector const& _value); //throw(EInvalid, EDuplicates); std::vector const& value() const throw(); std::vector const& assortment() const throw(); private: - static void makeSet(std::vector& v) throw(EDuplicates); + static void makeSet(std::vector& v); //throw(EDuplicates); static std::vector tokenizer(std::string const& _values); - void checkAvailability(std::vector const& v) throw(EInvalid); + void checkAvailability(std::vector const& v); //throw(EInvalid); std::vector enum_; std::vector values_; diff --git a/src/miro/JsonParse.cpp b/src/miro/JsonParse.cpp index 7f05f15..d485a32 100644 --- a/src/miro/JsonParse.cpp +++ b/src/miro/JsonParse.cpp @@ -52,7 +52,7 @@ namespace Miro throw Miro::Exception("expected char"); #if QT_VERSION >= 0x040000 - lhs = value[0].toAscii(); + lhs = value[0].toLatin1(); #else lhs = value[0].latin1(); #endif diff --git a/src/miro/JsonParseAce.cpp b/src/miro/JsonParseAce.cpp index daf6d90..6301b76 100644 --- a/src/miro/JsonParseAce.cpp +++ b/src/miro/JsonParseAce.cpp @@ -71,7 +71,7 @@ namespace Miro us.setNum(lhs.usec()); QString all = s + "." + zero.left(6 - us.length()) + us; #if QT_VERSION >= 0x040000 - _node = std::string(all.toAscii()); + _node = std::string(all.toLatin1()); #else _node = std::string(all.latin1()); #endif diff --git a/src/miro/Repository.h b/src/miro/Repository.h index aff0dd5..4d856a4 100644 --- a/src/miro/Repository.h +++ b/src/miro/Repository.h @@ -88,11 +88,11 @@ namespace Miro //! Empty the repository. void clear() throw(); //! Register an instance at the repository. - void add(std::string const& name, Type * type) throw(EAlreadyRegistered); + void add(std::string const& name, Type * type);// throw(EAlreadyRegistered); //! Look up an instance by name. - Type * get(std::string const& name) throw(ENotRegistered); + Type * get(std::string const& name);// throw(ENotRegistered); //! Remove instance from the repository, deleting it. - void remove(std::string const& name) throw(ENotRegistered); + void remove(std::string const& name);// throw(ENotRegistered); //! Get read-only access to the whole repository. InstanceMap const& getMap() const throw() { return instances_; @@ -181,7 +181,7 @@ namespace Miro template void Repository::add(std::string const& _name, T * _instance) - throw(EAlreadyRegistered) + //throw(EAlreadyRegistered) { if (instances_.find(_name) == instances_.end()) { instances_.insert(std::make_pair(_name, _instance)); @@ -197,7 +197,7 @@ namespace Miro */ template T * - Repository::get(const std::string& _name) throw(ENotRegistered) + Repository::get(const std::string& _name) //throw(ENotRegistered) { typename InstanceMap::const_iterator i = instances_.find(_name); if (i != instances_.end()) @@ -211,7 +211,7 @@ namespace Miro */ template void - Repository::remove(const std::string& _name) throw(ENotRegistered) + Repository::remove(const std::string& _name) //throw(ENotRegistered) { typename InstanceMap::iterator i = instances_.find(_name); if (i != instances_.end()) { @@ -280,12 +280,12 @@ namespace Miro //! Clean up the repository. ~UnmanagedRepository() throw(); //! Register an instance at the repository. - void add(std::string const& name, Type * type) throw(EAlreadyRegistered); + void add(std::string const& name, Type * type);// throw(EAlreadyRegistered); //! Look up an instance by name. - Type * get(std::string const& name) throw(ENotRegistered); + Type * get(std::string const& name);// throw(ENotRegistered); //! Remove instance from the repository, deleting it. /** An empty repository will delete itself. */ - void remove(std::string const& name) throw(ENotRegistered); + void remove(std::string const& name);// throw(ENotRegistered); //-------------------------------------------------------------------------- // public data @@ -361,7 +361,7 @@ namespace Miro template void UnmanagedRepository::add(std::string const& _name, T * _instance) - throw(EAlreadyRegistered) + //throw(EAlreadyRegistered) { if (instances_.find(_name) == instances_.end()) { instances_.insert(std::make_pair(_name, _instance)); @@ -377,7 +377,7 @@ namespace Miro */ template T * - UnmanagedRepository::get(const std::string& _name) throw(ENotRegistered) + UnmanagedRepository::get(const std::string& _name) //throw(ENotRegistered) { typename InstanceMap::const_iterator i = instances_.find(_name); if (i != instances_.end()) @@ -391,7 +391,7 @@ namespace Miro */ template void - UnmanagedRepository::remove(const std::string& _name) throw(ENotRegistered) + UnmanagedRepository::remove(const std::string& _name) //throw(ENotRegistered) { typename InstanceMap::iterator i = instances_.find(_name); if (i != instances_.end()) { diff --git a/src/miro/SearchPaths.cpp b/src/miro/SearchPaths.cpp index 7e22595..dbda5e9 100644 --- a/src/miro/SearchPaths.cpp +++ b/src/miro/SearchPaths.cpp @@ -115,14 +115,14 @@ namespace Miro { QFileInfo f(name.c_str()); if (m_currentPath && f.exists()) - return f.absoluteFilePath().toAscii().data(); + return f.absoluteFilePath().toLatin1().data(); } for (first = m_paths.rbegin(); first != last; ++first) { fullName = *first + "/" + name; QFileInfo f(fullName.c_str()); if (f.exists()) - return f.absoluteFilePath().toAscii().data(); + return f.absoluteFilePath().toLatin1().data(); } for (first = m_paths.rbegin(); first != last; ++first) { @@ -131,3 +131,5 @@ namespace Miro return string(); } } + +MIRO_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton, Miro::SearchPaths::StringList, ACE_SYNCH_RECURSIVE_MUTEX); diff --git a/src/miro/Singleton.h b/src/miro/Singleton.h index 67ac4f8..659dde2 100644 --- a/src/miro/Singleton.h +++ b/src/miro/Singleton.h @@ -24,6 +24,20 @@ #include #include +#ifdef ACE_SINGLETON_TEMPLATE_INSTANTIATE +# define MIRO_SINGLETON_TEMPLATE_INSTANTIATE(SINGLETON_TYPE, CLASS, LOCK) \ + ACE_SINGLETON_TEMPLATE_INSTANTIATE(SINGLETON_TYPE, CLASS, LOCK) +#else +#define MIRO_SINGLETON_TEMPLATE_INSTANTIATE(SINGLETON_TYPE, CLASS, LOCK) +#endif + + #ifdef ACE_SINGLETON_TEMPLATE_INSTANTIATION +# define MIRO_SINGLETON_TEMPLATE_INSTANTIATION(T) \ + ACE_SINGLETON_TEMPLATE_INSTANTIATION(T) +#else +# define MIRO_SINGLETON_TEMPLATE_INSTANTIATION(T) +#endif + namespace Miro { //! Templated implementation of the singleton pattern. @@ -50,7 +64,7 @@ namespace Miro */ template < class TYPE, class LOCK = ACE_Recursive_Thread_Mutex, - template class ACE_SINGLETON = ACE_Singleton > + template class ACE_SINGLETON = ACE_Singleton > class Singleton { public: @@ -65,7 +79,7 @@ namespace Miro //-------------------------------------------------------------------------- template < class TYPE, class LOCK, - template class ACE_SINGLETON > + template class ACE_SINGLETON > inline TYPE * Singleton::operator()() diff --git a/src/miro/XmlParse.cpp b/src/miro/XmlParse.cpp index 24ff201..31ae1d2 100644 --- a/src/miro/XmlParse.cpp +++ b/src/miro/XmlParse.cpp @@ -134,7 +134,7 @@ namespace Miro throwException(node, value, "char"); #if QT_VERSION >= 0x040000 - lhs = value[0].toAscii(); + lhs = value[0].toLatin1(); #else lhs = value[0].latin1(); #endif @@ -250,7 +250,7 @@ namespace Miro QString value = e.text(); Miro::Robot::substitute(value); - lhs = string(value.toAscii()); + lhs = string(value.toLatin1()); } } } diff --git a/src/params/Generator.cpp b/src/params/Generator.cpp index e796c32..c4888c1 100644 --- a/src/params/Generator.cpp +++ b/src/params/Generator.cpp @@ -235,7 +235,7 @@ namespace Miro } void - Generator::generateSource(std::ostream& ostr) const + Generator::generateSource(std::ostream& ostr, const QString& exportDirective) { if (fileName_.isEmpty()) throw QString("No file name specified."); @@ -293,6 +293,21 @@ namespace Miro ostr << spaces.left(indent) << "}" << std::endl; } + if (!exportDirective.isEmpty()) { + QString namespaceQualifier; + QStringVector::const_iterator f, l = namespace_.end(); + for (f = namespace_.begin(); f != l; ++f) { + namespaceQualifier += *f; + namespaceQualifier += "::"; + } + TypeVector::const_iterator first, last = type_.end(); + for (first = type_.begin(); first != last; ++first) { + if (first != type_.begin()) + ostr << std::endl; + if (!first->isDummy()) + first->generateSingletonSource(ostr, indent, namespaceQualifier); + } + } } QStringVector diff --git a/src/params/Generator.h b/src/params/Generator.h index e98d9a0..62f2ea1 100644 --- a/src/params/Generator.h +++ b/src/params/Generator.h @@ -63,7 +63,7 @@ namespace Miro void addType(const QString& _group, const Type& _class); void generateHeader(std::ostream& ostr, const QString& exportDirective = QString::null) const; - void generateSource(std::ostream& ostr) const; + void generateSource (std::ostream& ostr, const QString& exportDirective); QStringVector groups() const; void getGroupedTypes(const QString& _group, diff --git a/src/params/Parser.cpp b/src/params/Parser.cpp index 62a80ae..6a569bf 100644 --- a/src/params/Parser.cpp +++ b/src/params/Parser.cpp @@ -467,6 +467,7 @@ namespace Miro type_.setUnmanagedInstance(); } if (instance_ && userSingleton_) { + generator_.addInclude("miro/Singleton.h"); // MIRO_SINGLETON_INSTANCE macros type_.setUserInstance(userSingletonName_); } if (string_) diff --git a/src/params/Type.cpp b/src/params/Type.cpp index bfe3d4f..476b52c 100644 --- a/src/params/Type.cpp +++ b/src/params/Type.cpp @@ -336,6 +336,43 @@ namespace Miro } + void + Type::generateSingletonSource(std::ostream& ostr, unsigned int indent, + QString const& namespaceQualifier) const + { + // add instance declarations + + switch (instance_) { + case INSTANCE_MANAGED: + ostr << spaces.left (indent) + << "MIRO_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton, " + << namespaceQualifier << name_ + << "Parameters, ACE_SYNCH_RECURSIVE_MUTEX);" << std::endl; + break; + + case INSTANCE_UNMANAGED: + ostr << spaces.left (indent) + << "MIRO_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Unmanaged_Singleton, " + << namespaceQualifier << name_ + << "Parameters, ACE_SYNCH_RECURSIVE_MUTEX);" << std::endl; + break; + + case INSTANCE_USER: + ostr << spaces.left (indent) + << "MIRO_SINGLETON_TEMPLATE_INSTANTIATION(" << userSingleton_ << "< " + << namespaceQualifier << name_ + << "Parameters >);" << std::endl; + break; + + case INSTANCE_DLL: + case INSTANCE_NONE: + break; + } + + } + + + void Type::generateSource(std::ostream& ostr, unsigned int _indent) const { diff --git a/src/params/Type.h b/src/params/Type.h index 0a00221..916e543 100644 --- a/src/params/Type.h +++ b/src/params/Type.h @@ -120,6 +120,8 @@ namespace Miro void generateSingleton(std::ostream& ostr, unsigned int _indent, QString const& namespaceQualifier, QString const& exportDirective) const; + void generateSingletonSource(std::ostream& ostr, unsigned int indent, + QString const& namespaceQualifier) const; //! Generate source file code. void generateSource(std::ostream& ostr, unsigned int _indent) const; diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 354043d..d46a474 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,28 +1,19 @@ set( UTILS_BIN_DIR /bin ) -include_directories( - ${QT_QTGUI_INCLUDE_DIR} - ${QT_QT3SUPPORT_INCLUDE_DIR} -) - -link_libraries( - ${QT_QTGUI_LIBRARY} - ${QT_QT3SUPPORT_LIBRARY} - # Qt3Support also requires the following libs... - ${QT_QTSQL_LIBRARY} - ${QT_QTNETWORK_LIBRARY} -) - include_directories( ${PROJECT_SOURCE_DIR}/utils ) -add_definitions( -DQT3_SUPPORT ) +if (MIRO_BUILD_WITH_QT4) + link_libraries( + ${QT_QTGUI_LIBRARY} + ) +endif (MIRO_BUILD_WITH_QT4) add_subdirectory( miroWidgets ) add_subdirectory( ConfigEditor ) if ( TAO_FOUND ) - add_subdirectory( LogPlayer ) + add_build_switch( LogPlayer MIRO_BUILD_WITH_QT4 ) endif ( TAO_FOUND ) diff --git a/utils/ConfigEditor/ConfigDocumentXML.cpp b/utils/ConfigEditor/ConfigDocumentXML.cpp index df33f30..0908600 100644 --- a/utils/ConfigEditor/ConfigDocumentXML.cpp +++ b/utils/ConfigEditor/ConfigDocumentXML.cpp @@ -46,7 +46,7 @@ const QString ConfigDocumentXML::XML_TAG("config"); ConfigDocumentXML::ConfigDocumentXML(QDomDocument const& _document, QTreeWidget * _treeWidget, - QObject * _parent, const char * _name) : + QObject * _parent, QString const& _name) : Super(_document, _treeWidget, _parent, _name), menuAddSection_(NULL) { @@ -124,21 +124,22 @@ ConfigDocumentXML::contextMenu(QMenu& _menu) // This class doesn't have a handle to any window. QWidget * const pActionParent = NULL; QAction * const pAction = new QAction(name, pActionParent); - connect(pAction, SIGNAL(activated(int)), this, SLOT(onAddSection(int))); // Add the Action to the Menu menuAddSection_->addAction(pAction); } + connect(menuAddSection_, SIGNAL(triggered(QAction *)), this, SLOT(onAddSection(QAction *))); } //---------------------------------------------------------------------------- // public slots void -ConfigDocumentXML::onAddSection(int _n) +ConfigDocumentXML::onAddSection(QAction * _action) { + QString actionText = _action->text(); QDomElement config = document_.documentElement(); QDomElement e = document_.createElement(Section::XML_TAG); - e.setAttribute(Section::XML_ATTRIBUTE_KEY, menuAddSection_->text(_n)); + e.setAttribute(Section::XML_ATTRIBUTE_KEY, actionText); QDomNode n = config.firstChild(); QDomNode newChild; @@ -154,7 +155,7 @@ ConfigDocumentXML::onAddSection(int _n) treeWidgetItem(), // QTreeWidget for the ConfigDocumentXML NULL, this, // parent QObject - menuAddSection_->text(_n)); + actionText); setModified(); } diff --git a/utils/ConfigEditor/ConfigDocumentXML.h b/utils/ConfigEditor/ConfigDocumentXML.h index f1528a9..891e87c 100644 --- a/utils/ConfigEditor/ConfigDocumentXML.h +++ b/utils/ConfigEditor/ConfigDocumentXML.h @@ -26,6 +26,7 @@ // forward declarations class QTreeWidget; +class QAction; /** The document Item for a ConfigEditor document. */ class ConfigDocumentXML : public DocumentXML @@ -51,7 +52,7 @@ class ConfigDocumentXML : public DocumentXML ConfigDocumentXML(QDomDocument const& _document, QTreeWidget * _treeWidget, QObject * _parent = NULL, - const char * _name = NULL); + QString const& _name = QString()); /** The destructor has nothing to do. */ virtual ~ConfigDocumentXML(); @@ -88,7 +89,7 @@ public slots: * menu. * Create the Section and insert it before the clicked Section, if any. */ - void onAddSection(int); + void onAddSection(QAction * _action); protected: //---------------------------------------------------------------------------- diff --git a/utils/ConfigEditor/ConfigEditor.cpp b/utils/ConfigEditor/ConfigEditor.cpp index fb97297..7a88d13 100644 --- a/utils/ConfigEditor/ConfigEditor.cpp +++ b/utils/ConfigEditor/ConfigEditor.cpp @@ -100,7 +100,7 @@ main(int argc, char * argv[]) if (argc == 2) mainWindow.view()->openDocument(argv[1]); - app.setMainWidget(&mainWindow); +// app.setMainWidget(&mainWindow); mainWindow.show(); app.exec(); } diff --git a/utils/ConfigEditor/MainWindow.cpp b/utils/ConfigEditor/MainWindow.cpp index 0b9bfa9..e382c62 100644 --- a/utils/ConfigEditor/MainWindow.cpp +++ b/utils/ConfigEditor/MainWindow.cpp @@ -51,7 +51,7 @@ namespace } MainWindow::MainWindow() : - Super(NULL, "MainWindow"), + Super(NULL), config_(ConfigFile::instance()), view_(new DocumentView(this, "config_list")), document_(QDomDocument(ConfigDocumentXML::XML_DOCTYPE), view_), diff --git a/utils/ConfigEditor/ParameterInstance.cpp b/utils/ConfigEditor/ParameterInstance.cpp index 4967fab..155d4e6 100644 --- a/utils/ConfigEditor/ParameterInstance.cpp +++ b/utils/ConfigEditor/ParameterInstance.cpp @@ -32,7 +32,7 @@ QString const ParameterInstance::XML_ATTRIBUTE_TYPE = "type"; ParameterInstance::ParameterInstance(QTreeWidgetItem * _treeWidgetItem, QTreeWidgetItem * _pre, QDomNode const& _node, - QObject * _parent, const char * _name) : + QObject * _parent, QString const& _name) : Super(type(_node, XML_ATTRIBUTE_TYPE), _node, _treeWidgetItem, _pre, _parent, _name) diff --git a/utils/ConfigEditor/ParameterInstance.h b/utils/ConfigEditor/ParameterInstance.h index e90c68b..aa796ac 100644 --- a/utils/ConfigEditor/ParameterInstance.h +++ b/utils/ConfigEditor/ParameterInstance.h @@ -61,7 +61,7 @@ class ParameterInstance : public CompoundParameter QTreeWidgetItem * _pre, QDomNode const& _node, QObject * _parent, - const char * _name); + QString const& _name); //---------------------------------------------------------------------------- // public inherited methods diff --git a/utils/ConfigEditor/ParameterSingleton.cpp b/utils/ConfigEditor/ParameterSingleton.cpp index 09e71a6..b07680c 100644 --- a/utils/ConfigEditor/ParameterSingleton.cpp +++ b/utils/ConfigEditor/ParameterSingleton.cpp @@ -28,7 +28,7 @@ ParameterSingleton::ParameterSingleton(QTreeWidgetItem * _treeWidgetItem, QTreeWidgetItem * _pre, QDomNode const& _node, QObject * _parent, - const char * _name) : + QString const& _name) : Super(type(_node, XML_ATTRIBUTE_KEY), _node, _treeWidgetItem, _pre, _parent, _name) diff --git a/utils/ConfigEditor/ParameterSingleton.h b/utils/ConfigEditor/ParameterSingleton.h index 7bfd841..c5d3bc6 100644 --- a/utils/ConfigEditor/ParameterSingleton.h +++ b/utils/ConfigEditor/ParameterSingleton.h @@ -60,7 +60,7 @@ class ParameterSingleton : public CompoundParameter QTreeWidgetItem * _pre, QDomNode const& _node, QObject * _parent, - const char * _name); + QString const& _name); //---------------------------------------------------------------------------- // public inherited methods diff --git a/utils/ConfigEditor/Section.cpp b/utils/ConfigEditor/Section.cpp index 767cdf7..b29bb51 100644 --- a/utils/ConfigEditor/Section.cpp +++ b/utils/ConfigEditor/Section.cpp @@ -42,12 +42,12 @@ const QString Section::XML_TAG("section"); Section::Section(QDomNode const& _node, QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, - QObject * _parent, const char * _name) : + QObject * _parent, QString const& _name) : Super(_node, _parentItem, _pre, _parent, _name), menuAddParameter_(NULL), menuAddInstance_(NULL) { - treeWidgetItem()->setText(2, className()); + treeWidgetItem()->setText(2, metaObject()->className()); assert(!node_.isNull()); @@ -120,19 +120,19 @@ Section::contextMenu(QMenu& _menu) std::sort(instanceList.begin(), instanceList.end()); QStringVector::const_iterator first, last = paramsList.end(); for (first = paramsList.begin(); first != last; ++first) { - menuAddParameter_->insertItem(*first); + menuAddParameter_->addAction(*first); } last = instanceList.end(); for (first = instanceList.begin(); first != last; ++first) { - menuAddInstance_->insertItem(*first); + menuAddInstance_->addAction(*first); } } - connect(menuAddInstance_, SIGNAL(activated(int)), - this, SLOT(onAddInstance(int))); - connect(menuAddParameter_, SIGNAL(activated(int)), - this, SLOT(onAddParameter(int))); + connect(menuAddInstance_, SIGNAL(triggered(QAction *)), + this, SLOT(onAddInstance(QAction *))); + connect(menuAddParameter_, SIGNAL(triggered(QAction *)), + this, SLOT(onAddParameter(QAction *))); _menu.addSeparator(); @@ -153,19 +153,19 @@ Section::contextMenu(QMenu& _menu) } void -Section::onAddInstance(int _n) +Section::onAddInstance(QAction * _action) { bool ok = false; - QString name = QInputDialog::getText(tr( "Parameter Instance" ), + QString name = QInputDialog::getText(NULL, tr( "Parameter Instance" ), tr( "Instance name:" ), - QLineEdit::Normal, NULL, &ok, NULL ); + QLineEdit::Normal, NULL, &ok); if ( ok && !name.isEmpty()) { QDomDocument document = node_.ownerDocument(); QDomElement e = document.createElement(ParameterInstance::XML_TAG); e.setAttribute(ParameterInstance::XML_ATTRIBUTE_KEY, name); e.setAttribute(ParameterInstance::XML_ATTRIBUTE_TYPE, - menuAddInstance_->text(_n)); + _action->text()); QDomNode n = node_.firstChild(); QDomNode newChild = node_.insertBefore(e, n); @@ -185,11 +185,12 @@ Section::onAddInstance(int _n) } void -Section::onAddParameter(int _n) +Section::onAddParameter(QAction * _action) { + QString actionText = _action->text(); QDomDocument document = node_.ownerDocument(); QDomElement e = document.createElement(ParameterXML::XML_TAG); - e.setAttribute(ParameterXML::XML_ATTRIBUTE_KEY, menuAddParameter_->text(_n)); + e.setAttribute(ParameterXML::XML_ATTRIBUTE_KEY, actionText); QDomNode n = node_.firstChild(); QDomNode newChild = node_.insertBefore(e, n); @@ -197,7 +198,7 @@ Section::onAddParameter(int _n) assert(!newChild.isNull()); try { new ParameterSingleton(treeWidgetItem(), NULL, newChild, - this, menuAddParameter_->text(_n)); + this, actionText); } catch (QString const& e) { QMessageBox::warning(NULL, diff --git a/utils/ConfigEditor/Section.h b/utils/ConfigEditor/Section.h index 9a36694..0e11bfb 100644 --- a/utils/ConfigEditor/Section.h +++ b/utils/ConfigEditor/Section.h @@ -29,6 +29,7 @@ // Forward declarations class QTreeWidgetItem; +class QAction; /** * A Section is a partition of a document, used for organizing. Sections are @@ -63,7 +64,7 @@ class Section : public ItemXML QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); //---------------------------------------------------------------------------- // inherited public methods @@ -95,7 +96,7 @@ protected slots: * QMessageBox with a warning message. * @param[in] _n a serial enumerator that becomes the DOM tree node's key */ - void onAddInstance(int _n); + void onAddInstance(QAction * _action); /** * Add a default instance of a parameter. @@ -105,7 +106,7 @@ protected slots: * QMessageBox with a warning message. * @param[in] _n a serial enumerator that becomes the DOM tree node's key */ - void onAddParameter(int _n); + void onAddParameter(QAction * _action); protected: diff --git a/utils/LogPlayer/CMakeLists.txt b/utils/LogPlayer/CMakeLists.txt index 421c760..23e7a38 100644 --- a/utils/LogPlayer/CMakeLists.txt +++ b/utils/LogPlayer/CMakeLists.txt @@ -24,9 +24,22 @@ set( MOC_HEADERS MainForm.h ) +include_directories( + ${QT_QT3SUPPORT_INCLUDE_DIR} +) + +add_definitions( -DQT3_SUPPORT ) + qt_wrap_cpp(${EXEC} MOC_FILES ${MOC_HEADERS}) link_libraries( miro miroParams miroWidgets ) +link_libraries( + ${QT_QTGUI_LIBRARY} + ${QT_QT3SUPPORT_LIBRARY} + # Qt3Support also requires the following libs... + ${QT_QTSQL_LIBRARY} + ${QT_QTNETWORK_LIBRARY} +) add_executable( ${EXEC} ${SOURCES} diff --git a/utils/miroWidgets/CompoundParameter.cpp b/utils/miroWidgets/CompoundParameter.cpp index d380821..fa6f2ff 100644 --- a/utils/miroWidgets/CompoundParameter.cpp +++ b/utils/miroWidgets/CompoundParameter.cpp @@ -40,7 +40,7 @@ CompoundParameter::CompoundParameter(Miro::CFG::Type const& _type, QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : + QString const& _name) : Super(_node, _parentItem, _pre, _parent, _name), type_(_type) { @@ -55,7 +55,7 @@ CompoundParameter::CompoundParameter(Miro::CFG::Type const& _type, QTreeWidget * _list, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : + QString const& _name) : Super(_node, _list, _pre, _parent, _name), type_(_type) { @@ -81,13 +81,13 @@ CompoundParameter::init() ParameterXML * newParam = NULL; if (!e.hasAttribute(ParameterXML::XML_ATTRIBUTE_KEY)) throw Miro::Exception(QString("Parameter tag without name in compound (" + - type_.fullName() + ") " + name())); + type_.fullName() + ") " + objectName()).toStdString()); QString p = e.attribute(ParameterXML::XML_ATTRIBUTE_KEY); QString pLower = p; // we need a lower case first letter version for comparison - pLower[0] = p[0].lower(); + pLower[0] = p[0].toLower(); Miro::CFG::ParameterVector::const_iterator i, last = params.end(); for (i = params.begin(); i != last; ++i) { if (i->name_ == pLower) { @@ -96,19 +96,19 @@ CompoundParameter::init() } if (i == last) throw Miro::Exception(QString("Parameter " + p + " unknown in compound (" + - type_.fullName() + ") " + name())); + type_.fullName() + ") " + objectName()).toStdString()); if (SimpleParameter::typeFromName(i->type_) != SimpleParameter::NONE) { - QTreeWidgetItem * const pTreeWidgetItem = treeWidgetItem(); + QTreeWidgetItem * pTreeWidgetItem = treeWidgetItem(); assert(pTreeWidgetItem != NULL); newParam = new SimpleParameter(*i, n, pTreeWidgetItem, pre, this, p); } else if (ParameterList::typeFromName(i->type_) != ParameterList::NONE) { - QTreeWidgetItem * const pTreeWidgetItem = treeWidgetItem(); + QTreeWidgetItem * pTreeWidgetItem = treeWidgetItem(); assert(pTreeWidgetItem != NULL); - newParam = new ParameterList(*i, n, pTreeWidgetItem, pre, this, p); + newParam = new ParameterList(*i, n, pTreeWidgetItem, pre, this, p); } else { Miro::CFG::Type const * const t = @@ -122,7 +122,7 @@ CompoundParameter::init() else throw Miro::Exception(QString("Type " + i->type_ + " of parameter " + p + " unknown in compound (" + - type_.fullName() + ") " + name())); + type_.fullName() + ") " + objectName()).toStdString()); } if (newParam != NULL) newParam->init(); @@ -137,7 +137,7 @@ CompoundParameter::setParameters() ParameterDialog dialog(type_, node_.parentNode(), node_, NULL, this, - NULL, name()); + NULL, objectName()); int rc = dialog.exec(); if (rc == QDialog::Accepted) { @@ -162,7 +162,7 @@ CompoundParameter::type(QDomNode const& _node, if (parameterType == NULL) { throw Miro::Exception(QString("Parameter description for " + typeName + - " not found.\nCheck whether the relevant description file is loaded (5).")); + " not found.\nCheck whether the relevant description file is loaded (5).").toStdString()); } return *parameterType; } diff --git a/utils/miroWidgets/CompoundParameter.h b/utils/miroWidgets/CompoundParameter.h index 6c424de..e587f8d 100644 --- a/utils/miroWidgets/CompoundParameter.h +++ b/utils/miroWidgets/CompoundParameter.h @@ -72,7 +72,7 @@ class miroWidgets_Export CompoundParameter : public ParameterXML QTreeWidgetItem * _treeWidgetItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); /** * Initializing constructor used when the parent of the QTreeWidgetItem is * a QTreeWidget (top level). @@ -90,7 +90,7 @@ class miroWidgets_Export CompoundParameter : public ParameterXML CompoundParameter(Miro::CFG::Type const& _type, QDomNode const& _node, QTreeWidget * _list, QTreeWidgetItem * _pre, - QObject * _parent, const char * _name); + QObject * _parent, QString const& _name); //---------------------------------------------------------------------------- // public inherited methods diff --git a/utils/miroWidgets/ConfigFile.cpp b/utils/miroWidgets/ConfigFile.cpp index e8066dc..67695f4 100644 --- a/utils/miroWidgets/ConfigFile.cpp +++ b/utils/miroWidgets/ConfigFile.cpp @@ -170,7 +170,7 @@ ConfigFile::parseDescriptionFiles() // Always remove the pathname of the nonexistent file. // Do this unconditionally before calling writeConfigFile() and // before break; - descriptionFiles_.remove(first); + descriptionFiles_.erase(first); // For why this QMessageBox is built in this way, see // http://qt-project.org/doc/qt-4.8/qmessagebox.html#the-property-based-api // where it says: "Using the property-based API is recommended." @@ -187,7 +187,7 @@ ConfigFile::parseDescriptionFiles() } break; } - QXmlInputSource source( xmlFile ); + QXmlInputSource source( &xmlFile ); QXmlSimpleReader reader; Miro::CFG::TextErrorHandler errorHandler; @@ -199,7 +199,7 @@ ConfigFile::parseDescriptionFiles() fileName + "\n" + errorHandler.errorString()); QMessageBox::information(0, "Policy Editor", infoText); - descriptionFiles_.remove(first); + descriptionFiles_.erase(first); break; } } @@ -210,3 +210,5 @@ ConfigFile::parseDescriptionFiles() // cout << *generator_ << endl; } } + +MIRO_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton, ConfigFile, ACE_SYNCH_RECURSIVE_MUTEX); diff --git a/utils/miroWidgets/DeferredParameterEdit.cpp b/utils/miroWidgets/DeferredParameterEdit.cpp index 205afa7..8160999 100644 --- a/utils/miroWidgets/DeferredParameterEdit.cpp +++ b/utils/miroWidgets/DeferredParameterEdit.cpp @@ -96,7 +96,7 @@ DeferredParameterEdit::DeferredParameterEdit(EditType _type, ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name) : + QString const& _name) : Super(_parameter, _parentNode, _node, _parentItem, _item, _parent, _name), @@ -104,7 +104,7 @@ DeferredParameterEdit::DeferredParameterEdit(EditType _type, modified_(false), tmpDocument_("MiroConfigDocument") { - editWidget_ = new QPushButton(_parameter.type_, _parent, "edit button"); + editWidget_ = new QPushButton(_parameter.type_, _parent); connect(editWidget_, SIGNAL(clicked()), this, SLOT(deferredEdit())); // create a copy of the parameters xml tree @@ -112,7 +112,7 @@ DeferredParameterEdit::DeferredParameterEdit(EditType _type, tmpDocument_.appendChild(tmpParentNode_); QDomElement e = tmpDocument_.createElement(XML_TAG_PARAMETER); - e.setAttribute(XML_ATTRIBUTE_KEY, name()); + e.setAttribute(XML_ATTRIBUTE_KEY, objectName()); QDomNode tmpNode = e; if (!node_.isNull()) { tmpNode = node_.cloneNode(); @@ -143,7 +143,7 @@ DeferredParameterEdit::deferredEdit() dialog = new ParameterDialog(*parameterType, tmpParentNode_, tmpNode, NULL, NULL, - NULL, name()); + NULL, objectName()); } else if (type_ == VECTOR) { @@ -163,7 +163,6 @@ DeferredParameterEdit::deferredEdit() parameter.measure_ = parameter_.measure_; parameter.description_ = parameter_.description_; - dialog = new ParameterListDialog(ParameterList::VECTOR, parameter, tmpParentNode_, tmpNode, @@ -188,12 +187,11 @@ DeferredParameterEdit::deferredEdit() parameter.measure_ = parameter_.measure_; parameter.description_ = parameter_.description_; - dialog = new ParameterListDialog(ParameterList::SET, parameter, tmpParentNode_, tmpNode, NULL, NULL, - NULL, parameter.name_); + NULL, parameter.name_); } printElements(tmpParentNode_, 0); @@ -241,7 +239,7 @@ DeferredParameterEdit::setXML() assert(!parentNode_.ownerDocument().isNull()); QDomElement e = parentNode_.ownerDocument().createElement(XML_TAG_PARAMETER); - e.setAttribute(XML_ATTRIBUTE_KEY, name()); + e.setAttribute(XML_ATTRIBUTE_KEY, objectName()); node_ = parentNode_.appendChild(e); assert(!node_.isNull()); @@ -291,14 +289,14 @@ DeferredParameterEdit::setXML() if (parameterType == NULL) { // The Item is a CompoundParameter throw Miro::Exception(QString("Parameter description for " + typeName + - " not found.\nCheck whether the relevant description file is loaded (4).")); + " not found.\nCheck whether the relevant description file is loaded (4).").toStdString()); } pParameterXML = new CompoundParameter(*parameterType, node, parentItem_->treeWidgetItem(), pre, - parentItem_, name()); + parentItem_, objectName()); assert(pParameterXML != 0); } else if (type_ == VECTOR || @@ -308,7 +306,7 @@ DeferredParameterEdit::setXML() new ParameterList(parameter_, node, parentItem_->treeWidgetItem(), pre, - parentItem_, name()); + parentItem_, objectName()); assert(pParameterXML != 0); } else diff --git a/utils/miroWidgets/DeferredParameterEdit.h b/utils/miroWidgets/DeferredParameterEdit.h index c970702..4c34b79 100644 --- a/utils/miroWidgets/DeferredParameterEdit.h +++ b/utils/miroWidgets/DeferredParameterEdit.h @@ -64,7 +64,7 @@ class miroWidgets_Export DeferredParameterEdit : public ParameterEdit Miro::CFG::Parameter const& _parameter, QDomNode& _parentNode, QDomNode& _node, ItemXML * _parentItem, ItemXML * _item, - QWidget * _parent, const char * _name); + QWidget * _parent, QString const& _name); //! Inherited method. virtual void setXML(); diff --git a/utils/miroWidgets/DialogXML.cpp b/utils/miroWidgets/DialogXML.cpp index e92d976..d34e90b 100644 --- a/utils/miroWidgets/DialogXML.cpp +++ b/utils/miroWidgets/DialogXML.cpp @@ -23,7 +23,7 @@ DialogXML::DialogXML(QDomNode const& _parentNode, QDomNode const& _node, ItemXML * _parentItem, ItemXML * _item, - QWidget * _parent, const char * _name, bool _modal) : + QWidget * _parent, QString const& _name, bool _modal) : Super(_parent, _name, _modal), parentNode_(_parentNode), node_(_node), diff --git a/utils/miroWidgets/DialogXML.h b/utils/miroWidgets/DialogXML.h index 7eb35a4..3840c35 100644 --- a/utils/miroWidgets/DialogXML.h +++ b/utils/miroWidgets/DialogXML.h @@ -50,7 +50,7 @@ class DialogXML : public OkCancelDialog //! Initializing constructor. DialogXML(QDomNode const& _parentNode, QDomNode const& _node, ItemXML * _parentItem, ItemXML * _item, - QWidget * _parent, const char * _name, bool _modal = true); + QWidget * _parent, QString const& _name, bool _modal = true); virtual void setXML() = 0; diff --git a/utils/miroWidgets/DocumentView.cpp b/utils/miroWidgets/DocumentView.cpp index 88d8f5b..5eea02b 100644 --- a/utils/miroWidgets/DocumentView.cpp +++ b/utils/miroWidgets/DocumentView.cpp @@ -40,7 +40,7 @@ namespace }; } -DocumentView::DocumentView(QWidget * _parent, char const * _name, Qt::WFlags _f) : +DocumentView::DocumentView(QWidget * _parent, char const * _name) : Super(_parent), titleBar_(NULL), statusBar_(NULL), @@ -103,7 +103,7 @@ DocumentView::saveIfModified() int rc = QMessageBox::warning(this, "Save if Modified", - QString("The document ") + document_->name() + " has been modified\n" + + QString("The document ") + document_->objectName() + " has been modified\n" + "Do you want to save it?", "&Save...", "&Dont't Save", "&Cancel", 0, 2); @@ -148,7 +148,7 @@ DocumentView::openDocument(const QString& _name) document_->parse(); // set new caption and status bar - setTitle(document_->name()); + setTitle(document_->objectName()); QString message(_name + " opened."); setMessage(message, 3000); update(); @@ -192,12 +192,12 @@ DocumentView::saveDocument() assert(document_ != NULL); bool procede = true; - if (QString(document_->name()).isEmpty()) { + if (QString(document_->objectName()).isEmpty()) { procede = saveDocumentAs(); } if (procede) { document_->saveXML(); - QString message(QString(document_->name()) + " saved."); + QString message(QString(document_->objectName()) + " saved."); setMessage(message, 3000); } return procede; @@ -228,7 +228,7 @@ DocumentView::saveDocumentAs() // append file extension if none is given QFileInfo file(filename); - if (file.extension(false).isEmpty()) { + if (file.suffix().isEmpty()) { filename.append(".xml"); file.setFile(filename); } @@ -364,12 +364,12 @@ void DocumentView::setMessage(QString const& _message, int _ms) { if (statusBar_) - statusBar_->message(_message, _ms); + statusBar_->showMessage(_message, _ms); } void DocumentView::setTitle(QString const& _title) { if (titleBar_) - titleBar_->setCaption(_title); + titleBar_->setWindowTitle(_title); } diff --git a/utils/miroWidgets/DocumentView.h b/utils/miroWidgets/DocumentView.h index b91eac9..c2fe86a 100644 --- a/utils/miroWidgets/DocumentView.h +++ b/utils/miroWidgets/DocumentView.h @@ -59,7 +59,7 @@ class miroWidgets_Export DocumentView : public QTreeWidget //---------------------------------------------------------------------------- //! Initializing constructor. - DocumentView(QWidget * _parent = 0, char const * _name = 0, Qt::WFlags _f = 0); + DocumentView(QWidget * _parent = 0, char const * _name = 0); //! Virtual destructor. virtual ~DocumentView(); diff --git a/utils/miroWidgets/DocumentXML.cpp b/utils/miroWidgets/DocumentXML.cpp index a84c94d..e146b29 100644 --- a/utils/miroWidgets/DocumentXML.cpp +++ b/utils/miroWidgets/DocumentXML.cpp @@ -39,8 +39,8 @@ DocumentXML::DocumentXML(QDomDocument const& _document, QTreeWidget * _treeWidget, QObject * _parent, - const char * _name) : - Super(_document, _treeWidget, NULL, _parent, ""), + QString const& _name) : + Super(_document, _treeWidget, NULL, _parent, _name), document_(_document) {} @@ -86,7 +86,7 @@ DocumentXML::initXML(QString const& _xml) QString l, c; l.setNum(line); c.setNum(column); - throw Miro::Exception(QString("XML parsing error!\n" + error + "in line " + l + ", column " + c)); + throw Miro::Exception(QString("XML parsing error!\n" + error + "in line " + l + ", column " + c).toStdString()); } const bool modified = false; @@ -117,8 +117,8 @@ DocumentXML::clear() void DocumentXML::setName(const QString& _name) { - if (name() != _name) { - Super::setName(_name); + if (objectName() != _name) { + Super::setObjectName(_name); setModified(true); } } @@ -131,21 +131,21 @@ DocumentXML::loadXML(const QString& _name) QFile f(_name); if (!f.open(QIODevice::ReadOnly)) { - throw Miro::Exception(QString("DocumentXML::loadXML: Error: file not found!")); + throw Miro::Exception(QString("DocumentXML::loadXML: Error: file not found!").toStdString()); } if (!document_.setContent(&f)) { - throw Miro::Exception(QString("DocumentXML::loadXML: Error: XML parsing error!")); + throw Miro::Exception(QString("DocumentXML::loadXML: Error: XML parsing error!").toStdString()); } - Super::setName(_name); + Super::setObjectName(_name); } void DocumentXML::saveXML() { - QFile f(name() ); + QFile f(objectName() ); if (!f.open(QIODevice::WriteOnly)) { - throw Miro::Exception(QString("DocumentXML::loadXML: Error: file error!")); + throw Miro::Exception(QString("DocumentXML::loadXML: Error: file error!").toStdString()); } QTextStream ts(&f); document_.save(ts, 2); diff --git a/utils/miroWidgets/DocumentXML.h b/utils/miroWidgets/DocumentXML.h index 2cffa00..9cb0214 100644 --- a/utils/miroWidgets/DocumentXML.h +++ b/utils/miroWidgets/DocumentXML.h @@ -61,7 +61,7 @@ class miroWidgets_Export DocumentXML : public ItemXML DocumentXML(QDomDocument const& _document, QTreeWidget * _treeWidget, QObject * _parent = NULL, - const char * _name = NULL); + QString const& _name = QString()); /** * Virtual destructor. diff --git a/utils/miroWidgets/FileListDialog.cpp b/utils/miroWidgets/FileListDialog.cpp index ad6b13a..58c75e9 100644 --- a/utils/miroWidgets/FileListDialog.cpp +++ b/utils/miroWidgets/FileListDialog.cpp @@ -37,14 +37,14 @@ FileListDialog::FileListDialog(QWidget* parent, QString const& _dialogTitle, QString const& _listTitle, char const * _filters[]) : - QDialog(parent, "FileListDialog", TRUE), // TRUE = modal dialog + QDialog(parent/*, QString("FileListDialog"), true*/), // TRUE = modal dialog list_(NULL), delButton_(NULL), fileDialog_(NULL), modified_(false) { resize(300, 200); - setCaption(_dialogTitle); + setWindowTitle(_dialogTitle); // Create and configure the layout for the FileListDialog QVBoxLayout * const pFileListDialogLayout = createLayout(); diff --git a/utils/miroWidgets/Item.cpp b/utils/miroWidgets/Item.cpp index 79c3544..d9f1d61 100644 --- a/utils/miroWidgets/Item.cpp +++ b/utils/miroWidgets/Item.cpp @@ -34,29 +34,31 @@ Item::ItemMap Item::itemMap_; Item::Item(QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : - Super(_parent, _name), + QString const& _name) : + Super(_parent), treeWidgetItem_(new QTreeWidgetItem(_parentItem, _pre)) { + setObjectName(_name); // Label the QTreeWidgetItem with the Item's name - treeWidgetItem()->setText(0, name()); + treeWidgetItem()->setText(0, _name); // Map the QTreeWidgetItem to the Item that it represents itemMap_.insert(std::make_pair(treeWidgetItem_, this)); } Item::Item(QTreeWidget * _view, QTreeWidgetItem * _pre, - QObject * _parent, const char * _name) : - Super(_parent, _name), + QObject * _parent, QString const& _name) : + Super(_parent), treeWidgetItem_(new QTreeWidgetItem(_view, _pre)) { - treeWidgetItem()->setText(0, name()); + setObjectName(_name); + treeWidgetItem()->setText(0, _name); // Map the QTreeWidgetItem to the Item that it represents itemMap_.insert(std::make_pair(treeWidgetItem_, this)); } Item::~Item() { - // cout << name() << " deleting children" << endl; + // cout << objectName() << " deleting children" << endl; if (!children().isEmpty()) { QObjectList childList = children(); @@ -65,13 +67,13 @@ Item::~Item() } } - // cout << name() << " deleting listviewitem" << endl; + // cout << objectName() << " deleting listviewitem" << endl; delete treeWidgetItem_; // Remove the QTreeWidgetItem from the map to Item itemMap_.erase(treeWidgetItem_); - // cout << name() << " deleting" << endl; + // cout << objectName() << " deleting" << endl; } void diff --git a/utils/miroWidgets/Item.h b/utils/miroWidgets/Item.h index 9aa8766..b9b457c 100644 --- a/utils/miroWidgets/Item.h +++ b/utils/miroWidgets/Item.h @@ -70,13 +70,13 @@ class miroWidgets_Export Item : public QObject Item(QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre = NULL, QObject * _parent = NULL, - const char * _name = NULL); + QString const& _name = NULL); //! Initializing constructor, creating a QTreeWidget toplevel item. Item(QTreeWidget * _view, QTreeWidgetItem * _pre = NULL, QObject * _parent = NULL, - const char * _name = NULL); + QString const& _name = NULL); //! Virtual destructor. virtual ~Item(); diff --git a/utils/miroWidgets/ItemXML.cpp b/utils/miroWidgets/ItemXML.cpp index 6a59a69..e5c099f 100644 --- a/utils/miroWidgets/ItemXML.cpp +++ b/utils/miroWidgets/ItemXML.cpp @@ -37,7 +37,7 @@ ItemXML::ItemXML(QDomNode const& _node, QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : + QString const& _name) : Super(_parentItem, _pre, _parent, _name), node_(_node), widget_(NULL), @@ -50,7 +50,7 @@ ItemXML::ItemXML(QDomNode const& _node, QTreeWidget * _view, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : + QString const& _name) : Super(_view, _pre, _parent, _name), node_(_node), widget_(NULL), @@ -114,13 +114,13 @@ ItemXML::slotRename() bool ok = false; QString text = - QInputDialog::getText(tr( "Rename Entry" ), + QInputDialog::getText(NULL, tr( "Rename Entry" ), tr( "New name:" ), QLineEdit::Normal, - name(), &ok, NULL); + objectName(), &ok); if (ok && !text.isEmpty() && - text != name()) { + text != objectName()) { rename(text); } } @@ -230,7 +230,7 @@ ItemXML::rename(QString const& _name) if (name != _name) { // rename element element.setAttribute(XML_ATTRIBUTE_KEY, _name); - setName(_name.latin1()); + setObjectName(_name); treeWidgetItem()->setText(0, _name); setModified(); } diff --git a/utils/miroWidgets/ItemXML.h b/utils/miroWidgets/ItemXML.h index e1e275c..be3f105 100644 --- a/utils/miroWidgets/ItemXML.h +++ b/utils/miroWidgets/ItemXML.h @@ -77,7 +77,7 @@ class miroWidgets_Export ItemXML : public Item QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre = NULL, QObject * _parent = NULL, - const char * _name = NULL); + QString const& _name = QString()); /** * Initializing constructor used when the parent of the QTreeWidgetItem is @@ -95,7 +95,7 @@ class miroWidgets_Export ItemXML : public Item QTreeWidget * _view, QTreeWidgetItem * _pre = NULL, QObject * _parent = NULL, - const char * _name = NULL); + QString const& _name = QString()); /** * Virtual destructor. diff --git a/utils/miroWidgets/OkCancelDialog.cpp b/utils/miroWidgets/OkCancelDialog.cpp index e55f100..ba841d3 100644 --- a/utils/miroWidgets/OkCancelDialog.cpp +++ b/utils/miroWidgets/OkCancelDialog.cpp @@ -34,16 +34,16 @@ // The C++ Standard Library #include -OkCancelDialog::OkCancelDialog(QWidget * _parent, const char * _name, bool _modal) : - Super(_parent, _name, _modal), +OkCancelDialog::OkCancelDialog(QWidget * _parent, QString const& _name, bool _modal) : + Super(_parent/*, _name, _modal*/), frame_(NULL), modified_(false), accept_(0) { // Capitalize the _name member variable and use this as the caption QString n = _name; - n[0] = n[0].upper(); - setCaption(n); + n[0] = n[0].toUpper(); + setWindowTitle(n); QVBoxLayout * const pTopBoxLayout = createLayout(); createFrame(); diff --git a/utils/miroWidgets/OkCancelDialog.h b/utils/miroWidgets/OkCancelDialog.h index f77cec4..d1514ea 100644 --- a/utils/miroWidgets/OkCancelDialog.h +++ b/utils/miroWidgets/OkCancelDialog.h @@ -54,7 +54,7 @@ class miroWidgets_Export OkCancelDialog : public QDialog //---------------------------------------------------------------------------- //! Initializing constructor. - OkCancelDialog(QWidget * _parent, const char * _name, bool _modal = true); + OkCancelDialog(QWidget * _parent, QString const& _name, bool _modal = true); bool modified() const; diff --git a/utils/miroWidgets/ParameterDialog.cpp b/utils/miroWidgets/ParameterDialog.cpp index c22155a..1de8dce 100644 --- a/utils/miroWidgets/ParameterDialog.cpp +++ b/utils/miroWidgets/ParameterDialog.cpp @@ -48,7 +48,7 @@ ParameterDialog::ParameterDialog(Miro::CFG::Type const& _parameterType, QDomNode const& _node, ItemXML * _parentItem, ItemXML * _item, - QWidget * _parent, const char * _name) : + QWidget * _parent, QString const& _name) : Super(_parentNode, _node, _parentItem, _item, _parent, _name), config_(ConfigFile::instance()), parameterType_(_parameterType), @@ -133,7 +133,7 @@ ParameterDialog::initDialog() // Add the label to the Layout QLabel * name = new QLabel(frame_); QString n = first->name_; - n[0] = n[0].upper(); + n[0] = n[0].toUpper(); name->setText(n); gridLayout->addWidget(name, i, 0); @@ -193,13 +193,13 @@ ParameterDialog::initDialog() item_, childItem, frame_, - n.latin1()); + n); // add measure QLabel * measure = new QLabel(frame_); if (!first->measure_.isEmpty()) { measure->setText(first->measure_); - QToolTip::add(measure, (first->type_ != "angle")? first->type_ : QString("double")); + measure->setToolTip((first->type_ != "angle")? first->type_ : QString("double")); } else measure->setText(first->type_); @@ -216,7 +216,7 @@ ParameterDialog::initDialog() item_, childItem, frame_, - n.latin1()); + n); } gridLayout->addWidget(value->editWidget(), i, 1); diff --git a/utils/miroWidgets/ParameterDialog.h b/utils/miroWidgets/ParameterDialog.h index 1a685df..ff3ed7c 100644 --- a/utils/miroWidgets/ParameterDialog.h +++ b/utils/miroWidgets/ParameterDialog.h @@ -64,7 +64,7 @@ class miroWidgets_Export ParameterDialog : public DialogXML ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name); + QString const& _name); //! Update the xml tree according to the dialog entries. virtual void setXML(); diff --git a/utils/miroWidgets/ParameterEdit.cpp b/utils/miroWidgets/ParameterEdit.cpp index d5c068b..dbae08f 100644 --- a/utils/miroWidgets/ParameterEdit.cpp +++ b/utils/miroWidgets/ParameterEdit.cpp @@ -39,8 +39,8 @@ ParameterEdit::ParameterEdit(Miro::CFG::Parameter const& _parameter, ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name) : - Super(_parent, _name), + QString const& _name) : + Super(_parent), parameter_(_parameter), parentNode_(_parentNode), node_(_node), @@ -48,4 +48,5 @@ ParameterEdit::ParameterEdit(Miro::CFG::Parameter const& _parameter, item_(_item) { assert(!parentNode_.isNull()); + setObjectName(_name); } diff --git a/utils/miroWidgets/ParameterEdit.h b/utils/miroWidgets/ParameterEdit.h index 6dc809d..22e704c 100644 --- a/utils/miroWidgets/ParameterEdit.h +++ b/utils/miroWidgets/ParameterEdit.h @@ -61,7 +61,7 @@ class miroWidgets_Export ParameterEdit : public QObject ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name); + QString const& _name); QWidget * editWidget(); //! Updates the xml tree with the data provided in the edit field. diff --git a/utils/miroWidgets/ParameterList.cpp b/utils/miroWidgets/ParameterList.cpp index 29adeec..b6a8c7f 100644 --- a/utils/miroWidgets/ParameterList.cpp +++ b/utils/miroWidgets/ParameterList.cpp @@ -63,7 +63,7 @@ ParameterList::ParameterList(Miro::CFG::Parameter const& _param, QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : + QString const& _name) : Super(_node, _parentItem, _pre, _parent, _name), param_(_param), type_(typeFromName(_param.type_)) @@ -89,7 +89,7 @@ ParameterList::ParameterList(Miro::CFG::Parameter const& _param, QDomNode const& _node, QTreeWidget * _list, QTreeWidgetItem * _pre, - QObject * _parent, const char * _name) : + QObject * _parent, QString const& _name) : Super(_node, _list, _pre, _parent, _name), param_(_param), type_(typeFromName(_param.type_)) @@ -127,7 +127,7 @@ ParameterList::init() if (nestedType == NULL) { throw Miro::Exception(QString("Parameter description for " + nestedTypeName_ + - " not found.\nCheck whether the relevant description file is loaded (2).")); + " not found.\nCheck whether the relevant description file is loaded (2).").toStdString()); } } @@ -157,7 +157,7 @@ ParameterList::init() if (!e.hasAttribute(SimpleParameter::XML_ATTRIBUTE_VALUE)) throw Miro::Exception(QString("Parameter tag without value in (" + - param_.type_ + ") " + name())); + param_.type_ + ") " + objectName()).toStdString()); QString value = e.attribute(SimpleParameter::XML_ATTRIBUTE_VALUE); diff --git a/utils/miroWidgets/ParameterList.h b/utils/miroWidgets/ParameterList.h index 2e7d67e..d87eace 100644 --- a/utils/miroWidgets/ParameterList.h +++ b/utils/miroWidgets/ParameterList.h @@ -97,7 +97,7 @@ class miroWidgets_Export ParameterList : public ParameterXML QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); /** * Initializing constructor used when the parent of the QTreeWidgetItem is @@ -119,7 +119,7 @@ class miroWidgets_Export ParameterList : public ParameterXML QTreeWidget * _list, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); //---------------------------------------------------------------------------- // public inherited methods diff --git a/utils/miroWidgets/ParameterListDialog.cpp b/utils/miroWidgets/ParameterListDialog.cpp index 0e91e6b..9756f94 100644 --- a/utils/miroWidgets/ParameterListDialog.cpp +++ b/utils/miroWidgets/ParameterListDialog.cpp @@ -47,10 +47,10 @@ ParameterListDialog::ParameterListDialog(ParameterList::Type _type, ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name) : + QString const& _name) : Super(_parentNode, _node, _parentItem, _item, - _parent, _name, TRUE), // TRUE = modal dialog + _parent, _name, true), // TRUE = modal dialog type_(_type), parameter_(_parameter), nestedCompound_(true), @@ -68,7 +68,7 @@ ParameterListDialog::ParameterListDialog(ParameterList::Type _type, tmpDocument_.appendChild(tmpParentNode_); QDomElement e = tmpDocument_.createElement(ParameterXML::XML_TAG); - e.setAttribute(ParameterXML::XML_ATTRIBUTE_KEY, name()); + e.setAttribute(ParameterXML::XML_ATTRIBUTE_KEY, objectName()); tmpNode_ = e; if (!node_.isNull()) tmpNode_ = node_.cloneNode(); @@ -150,7 +150,7 @@ ParameterListDialog::ParameterListDialog(ParameterList::Type _type, if (nestedType_ == NULL) { throw Miro::Exception(QString("Parameter description for " + parameter_.type_ + - " not found.\nCheck whether the relevant description file is loaded (1).")); + " not found.\nCheck whether the relevant description file is loaded (1).").toStdString()); } // It is a CompoundParameter } @@ -179,7 +179,7 @@ ParameterListDialog::ParameterListDialog(ParameterList::Type _type, // The tag must have a "value" attribute if (!e.hasAttribute(SimpleParameter::XML_ATTRIBUTE_VALUE)) throw Miro::Exception(QString("Parameter tag without value in (" + - parameter_.type_ + ") " + name())); + parameter_.type_ + ") " + objectName()).toStdString()); /// @todo This variable is not used; remove it QString value = e.attribute(SimpleParameter::XML_ATTRIBUTE_VALUE); @@ -269,7 +269,7 @@ ParameterListDialog::setXML() assert(!parentNode_.ownerDocument().isNull()); QDomElement e = parentNode_.ownerDocument().createElement(ParameterXML::XML_TAG); - e.setAttribute(ParameterXML::XML_ATTRIBUTE_KEY, name()); + e.setAttribute(ParameterXML::XML_ATTRIBUTE_KEY, objectName()); node_ = parentNode_.appendChild(e); assert(!node_.isNull()); @@ -429,12 +429,12 @@ ParameterListDialog::add() if (!nestedCompound_) { dialog = new SingleParameterDialog(parameter_, newChild, - item_, NULL, NULL, name()); + item_, NULL, NULL, objectName()); } else { dialog = new ParameterDialog(*nestedType_, newChild.parentNode(), newChild, - item_, NULL, NULL, name()); + item_, NULL, NULL, objectName()); } int rc = dialog->exec(); if (rc == QDialog::Accepted) { diff --git a/utils/miroWidgets/ParameterListDialog.h b/utils/miroWidgets/ParameterListDialog.h index 95e77d0..373448b 100644 --- a/utils/miroWidgets/ParameterListDialog.h +++ b/utils/miroWidgets/ParameterListDialog.h @@ -78,7 +78,7 @@ class miroWidgets_Export ParameterListDialog : public DialogXML ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name = NULL); + QString const& _name = QString()); void setXML(); diff --git a/utils/miroWidgets/ParameterXML.cpp b/utils/miroWidgets/ParameterXML.cpp index 50c44d0..cfbf741 100644 --- a/utils/miroWidgets/ParameterXML.cpp +++ b/utils/miroWidgets/ParameterXML.cpp @@ -36,7 +36,7 @@ ParameterXML::ParameterXML(QDomNode const& _node, QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : + QString const& _name) : Super(_node, _parentItem, _pre, _parent, _name), config_(ConfigFile::instance()) { @@ -47,7 +47,7 @@ ParameterXML::ParameterXML(QDomNode const& _node, QTreeWidget * _view, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name) : + QString const& _name) : Super(_node, _view, _pre, _parent, _name), config_(ConfigFile::instance()) { diff --git a/utils/miroWidgets/ParameterXML.h b/utils/miroWidgets/ParameterXML.h index 6f553ea..2fb761f 100644 --- a/utils/miroWidgets/ParameterXML.h +++ b/utils/miroWidgets/ParameterXML.h @@ -77,7 +77,7 @@ class miroWidgets_Export ParameterXML : public ItemXML QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); /** * Initializing constructor used when the parent of the QTreeWidgetItem is @@ -95,7 +95,7 @@ class miroWidgets_Export ParameterXML : public ItemXML QTreeWidget * _view, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); //---------------------------------------------------------------------------- // public inherited methods diff --git a/utils/miroWidgets/SimpleParameter.cpp b/utils/miroWidgets/SimpleParameter.cpp index 5932251..f65d68d 100644 --- a/utils/miroWidgets/SimpleParameter.cpp +++ b/utils/miroWidgets/SimpleParameter.cpp @@ -83,7 +83,7 @@ SimpleParameter::SimpleParameter(Miro::CFG::Parameter const& _param, QDomNode const& _node, QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, - QObject * _parent, const char * _name) : + QObject * _parent, QString const& _name) : Super(_node, _parentItem, _pre, _parent, _name), param_(_param) { @@ -113,7 +113,7 @@ SimpleParameter::SimpleParameter(Miro::CFG::Parameter const& _param, QDomNode const& _node, QTreeWidget * _list, QTreeWidgetItem * _pre, - QObject * _parent, const char * _name) : + QObject * _parent, QString const& _name) : Super(_node, _list, _pre, _parent, _name), param_(_param) { @@ -143,7 +143,7 @@ SimpleParameter::setParameters() { SingleParameterDialog dialog(param_, node_, - NULL, this, NULL, name()); + NULL, this, NULL, objectName()); int rc = dialog.exec(); if (rc == QDialog::Accepted) { dialog.setXML(); diff --git a/utils/miroWidgets/SimpleParameter.h b/utils/miroWidgets/SimpleParameter.h index 5b3be3b..339b69a 100644 --- a/utils/miroWidgets/SimpleParameter.h +++ b/utils/miroWidgets/SimpleParameter.h @@ -93,7 +93,7 @@ class miroWidgets_Export SimpleParameter : public ParameterXML QTreeWidgetItem * _parentItem, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); /** * Initializing constructor used when the parent of the QTreeWidgetItem is @@ -114,7 +114,7 @@ class miroWidgets_Export SimpleParameter : public ParameterXML QTreeWidget * _list, QTreeWidgetItem * _pre, QObject * _parent, - const char * _name); + QString const& _name); //---------------------------------------------------------------------------- // public inherited methods diff --git a/utils/miroWidgets/SimpleParameterEdit.cpp b/utils/miroWidgets/SimpleParameterEdit.cpp index cfa56d5..6611384 100644 --- a/utils/miroWidgets/SimpleParameterEdit.cpp +++ b/utils/miroWidgets/SimpleParameterEdit.cpp @@ -69,7 +69,7 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name) : + QString const& _name) : Super(_parameter, _parentNode, _node, _parentItem, _item, _parent, _name), @@ -84,7 +84,7 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, { if (parameter_.type_ == "Miro::Enumeration" || parameter_.type_ == "Enumeration") { - typeBox_ = new QComboBox(_parent, "type_box"); + typeBox_ = new QComboBox(_parent); editWidget_ = typeBox_; } else if (parameter_.type_ == "Miro::EnumerationMultiple" || parameter_.type_ == "EnumerationMultiple") { @@ -102,12 +102,12 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, editWidget_ = listBox_; } else if (parameter_.type_ == "Miro::Text" || parameter_.type_ == "Text") { - textEdit_ = new QTextEdit(_parent, "text_edit"); + textEdit_ = new QTextEdit(_parent); textEdit_->setAcceptRichText(false); textEdit_->setAutoFormatting(QTextEdit::AutoNone); editWidget_ = textEdit_; } else { - lineEdit_ = new QLineEdit(_parent, "line_edit"); + lineEdit_ = new QLineEdit(_parent); editWidget_ = lineEdit_; } @@ -190,7 +190,7 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, // add default as tooltip if (!parameter_.default_.isEmpty()) { - QToolTip::add(lineEdit_, QString("default: ") + parameter_.default_); + lineEdit_->setToolTip(QString("default: ") + parameter_.default_); } // set current value @@ -202,14 +202,14 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, } // set lineEdit to unedited - lineEdit_->setEdited(false); + lineEdit_->setModified(false); } else if (textEdit_ != NULL) { QDomElement e = node_.toElement(); if (!e.isNull()) { QDomNodeList l = e.childNodes(); - unsigned int i; - for (i = 0; i < l.length(); ++i) { + int i; + for (i = 0; i < (int)l.length(); ++i) { if (l.item(i).isText()) { QDomText t = l.item(i).toText(); textEditText_ = t.data(); @@ -224,26 +224,35 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, switch (_type) { case SimpleParameter::ENUMERATION: + { // init combo box - typeBox_->setEditable(FALSE); + typeBox_->setEditable(false); stringvec = fullDef2StringVector(parameter_.fullDefault_); for (vector::const_iterator i= stringvec.begin(); i!=stringvec.end(); ++i) - typeBox_->insertItem(i->c_str()); + typeBox_->insertItem(-1, i->c_str()); // set current value + QString text = parameter_.default_; if (!node_.isNull()) { QDomElement e = node_.toElement(); - if (!e.isNull() && e.hasAttribute("value")) { - typeBox_->setCurrentText(e.attribute("value")); - } - } else { - typeBox_->setCurrentText(parameter_.default_); + if (!e.isNull() && e.hasAttribute("value")) { + text = e.attribute("value"); + } + } + int i = typeBox_->findText(text); + if (i != -1) { + typeBox_->setCurrentIndex(i); + } + else if (typeBox_->isEditable()) { + typeBox_->setEditText(text); + } + else { + typeBox_->setItemText(typeBox_->currentIndex(), text); } - // connect to function, so we recognize, if value is changed connect(typeBox_, SIGNAL(activated(const QString&)), this, SLOT(typeBoxModified())); break; - + } case SimpleParameter::ENUMERATIONMULTIPLE: // init list box // For each selected element of @@ -262,7 +271,7 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, QDomElement e = node_.toElement(); if (!e.isNull() && e.hasAttribute("value")) { QString tmp1 = e.attribute("value"); - std::vector tmp2 = tokenizer(std::string(tmp1.latin1())); + std::vector tmp2 = tokenizer(tmp1.toStdString()); for (std::vector::const_iterator i=tmp2.begin(); i!=tmp2.end(); ++i) { /// @todo Unify repeated code // Cache the string to avoid repeated lookups and construction @@ -282,7 +291,7 @@ SimpleParameterEdit::SimpleParameterEdit(SimpleParameter::Type _type, } } } else { - std::vector tmp2 = tokenizer(std::string(parameter_.default_.latin1())); + std::vector tmp2 = tokenizer(parameter_.default_.toStdString()); for (std::vector::const_iterator i=tmp2.begin(); i!=tmp2.end(); ++i) { /// @todo Unify repeated code // Cache the string to avoid repeated lookups and construction @@ -316,7 +325,7 @@ void SimpleParameterEdit::setXML() { // no edit -> nothing to be done - if (lineEdit_ && !lineEdit_->edited()) + if (lineEdit_ && !lineEdit_->isModified()) return; // delete entry if edit field is empty @@ -335,7 +344,7 @@ SimpleParameterEdit::setXML() } else { if (lineEdit_) - lineEdit_->setEdited(false); + lineEdit_->setModified(false); else if (textEdit_) textEditText_ = textEdit_->toPlainText(); else if (typeBox_) @@ -353,7 +362,7 @@ SimpleParameterEdit::setXML() assert(!parentNode_.ownerDocument().isNull()); QDomElement e = parentNode_.ownerDocument().createElement(XML_TAG_PARAMETER); - e.setAttribute(XML_ATTRIBUTE_KEY, name()); + e.setAttribute(XML_ATTRIBUTE_KEY, objectName()); node_ = parentNode_.appendChild(e); assert(!node_.isNull()); @@ -365,7 +374,7 @@ SimpleParameterEdit::setXML() new SimpleParameter(parameter_, node_, parentItem_->treeWidgetItem(), NULL, - parentItem_, name()); + parentItem_, objectName()); newParam->init(); item_ = newParam; } @@ -383,15 +392,15 @@ SimpleParameterEdit::setXML() item_->treeWidgetItem()->setText(1, e.attribute(XML_ATTRIBUTE_VALUE)); } else { - lineEdit_->setEdited(false); + lineEdit_->setModified(false); } } else if (textEdit_) { // if already existing, replace text QDomNodeList l = e.childNodes(); - unsigned int i; - for (i = 0; i < l.length(); ++i) { + int i; + for (i = 0; i < (int)l.length(); ++i) { if (l.item(i).isText()) { QDomText t = l.item(i).toText(); t.setNodeValue(textEdit_->toPlainText()); @@ -399,7 +408,7 @@ SimpleParameterEdit::setXML() } } // otherwise create text node and add text - if (i == l.length()) { + if (i == (int)l.length()) { std::cout << "ping" << std::endl; QDomText t = parentNode_.ownerDocument().createTextNode(textEdit_->toPlainText()); e.appendChild(t); @@ -465,7 +474,7 @@ bool SimpleParameterEdit::modified() const { if (lineEdit_) - return lineEdit_->edited(); + return lineEdit_->isModified(); else if (textEdit_) return textEdit_->toPlainText() != textEditText_; else if (typeBox_) diff --git a/utils/miroWidgets/SimpleParameterEdit.h b/utils/miroWidgets/SimpleParameterEdit.h index f1556f0..c576fc7 100644 --- a/utils/miroWidgets/SimpleParameterEdit.h +++ b/utils/miroWidgets/SimpleParameterEdit.h @@ -63,7 +63,7 @@ class miroWidgets_Export SimpleParameterEdit : public ParameterEdit ItemXML * _parentItem, ItemXML * _item, QWidget * _parent, - const char * _name); + QString const& _name); //! Inherited interface. virtual void setXML(); diff --git a/utils/miroWidgets/SingleParameterDialog.cpp b/utils/miroWidgets/SingleParameterDialog.cpp index f99c486..ab304a5 100644 --- a/utils/miroWidgets/SingleParameterDialog.cpp +++ b/utils/miroWidgets/SingleParameterDialog.cpp @@ -50,7 +50,7 @@ SingleParameterDialog(Miro::CFG::Parameter const& _parameter, QDomNode const& _node, ItemXML * _parentItem, ItemXML * _item, - QWidget * _parent, const char * _name) : + QWidget * _parent, QString const& _name) : Super(_node.parentNode(), _node, _parentItem, _item, _parent, _name), @@ -69,7 +69,7 @@ SingleParameterDialog(Miro::CFG::Parameter const& _parameter, // add parameter struct: QLabel * name = new QLabel(frame_); QString n = parameter_.name_; - n[0] = n[0].upper(); + n[0] = n[0].toUpper(); name->setText(n); gridLayout->addWidget(name, 0, 0); @@ -100,13 +100,13 @@ SingleParameterDialog(Miro::CFG::Parameter const& _parameter, parentItem_, item_, frame_, - n.latin1()); + n); // add measure QLabel * measure = new QLabel(frame_); if (!parameter_.measure_.isEmpty()) { measure->setText(parameter_.measure_); - QToolTip::add(measure, (parameter_.type_ != "angle")? parameter_.type_ : QString("double")); + measure->setToolTip((parameter_.type_ != "angle")? parameter_.type_ : QString("double")); } else measure->setText(parameter_.type_); diff --git a/utils/miroWidgets/SingleParameterDialog.h b/utils/miroWidgets/SingleParameterDialog.h index df0b7f2..e93bbef 100644 --- a/utils/miroWidgets/SingleParameterDialog.h +++ b/utils/miroWidgets/SingleParameterDialog.h @@ -54,7 +54,7 @@ class miroWidgets_Export SingleParameterDialog : public DialogXML QDomNode const& _node, ItemXML * _parentItem, ItemXML * _item, - QWidget * _parent, const char * _name); + QWidget * _parent, QString const& _name); //! Inherited method. virtual void setXML(); diff --git a/utils/miroWidgets/Validators.cpp b/utils/miroWidgets/Validators.cpp index 2f8b3aa..a990892 100644 --- a/utils/miroWidgets/Validators.cpp +++ b/utils/miroWidgets/Validators.cpp @@ -22,16 +22,20 @@ #include -MyIntValidator::MyIntValidator(QObject * parent, const char *name) : - Super(parent, name), +MyIntValidator::MyIntValidator(QObject * parent, QString const& name) : + Super(parent), accepted_(true) -{} +{ + setObjectName(name); +} MyIntValidator::MyIntValidator(int bottom, int top, - QObject * parent, const char *name) : - Super(bottom, top, parent, name), + QObject * parent, QString const& name) : + Super(bottom, top, parent), accepted_(true) -{} +{ + setObjectName(name); +} QValidator::State MyIntValidator::validate( QString & input, int & pos) const @@ -46,17 +50,21 @@ MyIntValidator::validate( QString & input, int & pos) const return s; } -MyFloatValidator::MyFloatValidator(QObject * parent, const char *name) : +MyFloatValidator::MyFloatValidator(QObject * parent, QString const& name) : - Super(parent, name), + Super(parent), accepted_(true) -{} +{ + setObjectName(name); +} MyFloatValidator::MyFloatValidator(float bottom, float top, int decimals, - QObject * parent, const char *name) : - Super(bottom, top, decimals, parent, name), + QObject * parent, QString const& name) : + Super(bottom, top, decimals, parent), accepted_(true) -{} +{ + setObjectName(name); +} QValidator::State MyFloatValidator::validate( QString & input, int & pos) const @@ -72,16 +80,20 @@ MyFloatValidator::validate( QString & input, int & pos) const return s; } -MyDoubleValidator::MyDoubleValidator(QObject * parent, const char *name) : - Super(parent, name), +MyDoubleValidator::MyDoubleValidator(QObject * parent, QString const& name) : + Super(parent), accepted_(true) -{} +{ + setObjectName(name); +} MyDoubleValidator::MyDoubleValidator(double bottom, double top, int decimals, - QObject * parent, const char *name) : - Super(bottom, top, decimals, parent, name), + QObject * parent, QString const& name) : + Super(bottom, top, decimals, parent), accepted_(true) -{} +{ + setObjectName(name); +} QValidator::State MyDoubleValidator::validate( QString & input, int & pos) const @@ -97,10 +109,12 @@ MyDoubleValidator::validate( QString & input, int & pos) const return s; } -MyBoolValidator::MyBoolValidator(QObject * parent, const char *name) : - Super(parent, name), +MyBoolValidator::MyBoolValidator(QObject * parent, QString const& name) : + Super(parent), accepted_(true) -{} +{ + setObjectName(name); +} QValidator::State MyBoolValidator::validate( QString & input, int &) const diff --git a/utils/miroWidgets/Validators.h b/utils/miroWidgets/Validators.h index 10e0904..163345f 100644 --- a/utils/miroWidgets/Validators.h +++ b/utils/miroWidgets/Validators.h @@ -34,10 +34,10 @@ class miroWidgets_Export MyIntValidator : public QIntValidator public: //! Inherited method. - MyIntValidator(QObject * parent, const char *name = 0); + MyIntValidator(QObject * parent, QString const& name = QString()); //! Inherited method. MyIntValidator(int bottom, int top, - QObject * parent, const char *name = 0); + QObject * parent, QString const& name = QString()); //! Inherited method. QValidator::State validate(QString &, int &) const; @@ -59,10 +59,10 @@ class MyFloatValidator : public QDoubleValidator public: //! Inherited method. - MyFloatValidator(QObject * parent, const char *name = 0); + MyFloatValidator(QObject * parent, QString const& name = QString()); //! Inherited method. MyFloatValidator(float bottom, float top, int decimals, - QObject * parent, const char *name = 0); + QObject * parent, QString const& name = QString()); //! Inherited method. QValidator::State validate(QString &, int &) const; @@ -84,10 +84,10 @@ class MyDoubleValidator : public QDoubleValidator public: //! Inherited method. - MyDoubleValidator(QObject * parent, const char *name = 0); + MyDoubleValidator(QObject * parent, QString const& name = QString()); //! Inherited method. MyDoubleValidator(double bottom, double top, int decimals, - QObject * parent, const char *name = 0); + QObject * parent, QString const& name = QString()); //! Inherited method. QValidator::State validate(QString &, int &) const; @@ -109,7 +109,7 @@ class MyBoolValidator : public QValidator public: //! Inherited method. - MyBoolValidator(QObject * parent, const char *name = 0); + MyBoolValidator(QObject * parent, QString const& name = QString()); //! Inherited method. QValidator::State validate(QString &, int &) const;