+
+/*!
+ \brief Start/stop this resource manager watching the user materials database file.
+ \internal
+*/
+void Material_ResourceMgr::watchUserFile( bool on )
+{
+ if ( on ) {
+ if ( !myWatcher ) {
+ myWatcher = new QFileSystemWatcher( this );
+ QFileInfo ufile = userFileName( appName() );
+ if ( ufile.exists() ) {
+ myWatcher->addPath( ufile.filePath() );
+ }
+ connect( myWatcher, SIGNAL( fileChanged( QString ) ), this, SLOT( update() ) );
+ }
+ }
+ else {
+ if ( myWatcher ) {
+ delete myWatcher;
+ myWatcher = 0;
+ }
+ }
+}
+
+/*!
+ \brief This function is called after user configuration file is saved.
+ \internal
+*/
+void Material_ResourceMgr::saved()
+{
+ if ( resourceMgr() != this ) {
+ resourceMgr()->saved();
+ }
+ else if ( myWatcher ) {
+ QStringList files = myWatcher->files();
+ QFileInfo ufile = userFileName( appName() );
+ if ( ufile.exists() && !files.contains( ufile.filePath() ) ) {
+ myWatcher->addPath( ufile.filePath() );
+ update();
+ }
+ }
+}
+
+/*!
+ \brief Update user database slot
+ \internal
+*/
+void Material_ResourceMgr::update()
+{
+ Updater( this ).wait();
+ emit changed();
+}