7 #include "fwGui/dialog/ILocationDialog.hpp" 9 #include <fwData/location/Folder.hpp> 10 #include <fwData/location/SingleFile.hpp> 12 #include <fwPreferences/helper.hpp> 14 #include <fwServices/IService.hpp> 15 #include <fwServices/registry/ObjectService.hpp> 24 const std::string ILocationDialog::SOFTWARE_UI =
"SOFTWARE_UI";
25 const std::string ILocationDialog::DLG_DEFAULT_LOCATION =
"DLG_DEFAULT_LOCATION";
29 ILocationDialog::ILocationDialog()
35 ILocationDialog::~ILocationDialog()
57 ::fwData::location::SingleFile::csptr singleFile = ::fwData::location::SingleFile::dynamicConstCast(loc);
58 ::fwData::location::Folder::csptr folder = ::fwData::location::Folder::dynamicConstCast(loc);
59 SLM_FATAL_IF(
"Unsupported location", !singleFile && !folder );
60 m_defaultLocaction = loc;
67 ::boost::filesystem::path defaultPath;
68 ::fwData::Composite::sptr prefUI = this->getPreferenceUI();
69 ::fwData::location::ILocation::sptr location;
72 if ( prefUI->find( ILocationDialog::DLG_DEFAULT_LOCATION ) != prefUI->end() )
74 location = ::fwData::location::ILocation::dynamicCast( (*prefUI)[ ILocationDialog::DLG_DEFAULT_LOCATION ] );
81 location = m_defaultLocaction;
84 ::fwData::location::SingleFile::csptr singleFile = ::fwData::location::SingleFile::dynamicConstCast(location);
85 ::fwData::location::Folder::csptr folder = ::fwData::location::Folder::dynamicConstCast(location);
88 defaultPath = singleFile->getPath();
92 defaultPath = folder->getFolder();
102 ::fwData::Composite::sptr prefUI = this->getPreferenceUI();
105 (*prefUI)[ ILocationDialog::DLG_DEFAULT_LOCATION ] = loc;
111 ::fwData::Composite::sptr ILocationDialog::getPreferenceUI()
113 ::fwData::Composite::sptr prefUI;
116 ::fwData::Composite::sptr prefs = ::fwPreferences::getPreferences();
119 ::fwData::Composite::sptr framesUI;
121 if ( prefs->find( ILocationDialog::SOFTWARE_UI ) != prefs->end() )
123 framesUI = ::fwData::Composite::dynamicCast( (*prefs)[ ILocationDialog::SOFTWARE_UI ]);
127 framesUI = ::fwData::Composite::New();
128 (*prefs)[ ILocationDialog::SOFTWARE_UI ] = framesUI;
131 if ( framesUI->find( this->getTitle() ) != framesUI->end() )
133 prefUI = ::fwData::Composite::dynamicCast( (*framesUI)[ this->
getTitle() ] );
137 prefUI = ::fwData::Composite::New();
138 (*framesUI)[ this->
getTitle() ] = prefUI;
virtual FWGUI_API void setDefaultLocation(::fwData::location::ILocation::sptr loc)
set the initial location for the dialog
The namespace fwGui contains the base interface for IHM services.
virtual FWGUI_APIconst::boost::filesystem::path getDefaultLocation()
get the default location for the dialog (from preferences or specified by user)
virtual FWGUI_API void setTitle(const std::string &title)
set the title for the dialog
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
static FWGUI_API const FactoryRegistryKeyType REGISTRY_KEY
this unique key should be used for all factory for specific LocationDialog(qt,wx,...)
#define SLM_FATAL_IF(message, cond)
virtual FWGUI_API void saveDefaultLocation(::fwData::location::ILocation::sptr loc)
save the specified default location for the dialog in preferences (if available)
virtual FWGUI_API const std::string & getTitle()
returns the title for the dialog