summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2019-06-07 17:54:36 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2019-06-07 17:54:36 +0900
commitc393eecadbc73e8db1d63fdc29c907d0340bb80c (patch)
treef2bc7d9a70f45d570886d3e374e344c6ea7dd852 /tdeioslave/media
parent1cf8018d1c583e13baf269078de99690c4457933 (diff)
downloadtdebase-c393eecadbc73e8db1d63fdc29c907d0340bb80c.tar.gz
tdebase-c393eecadbc73e8db1d63fdc29c907d0340bb80c.zip
mediamanager: cleaned up use of medium name map.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeioslave/media')
-rw-r--r--tdeioslave/media/mediamanager/medialist.cpp43
1 files changed, 15 insertions, 28 deletions
diff --git a/tdeioslave/media/mediamanager/medialist.cpp b/tdeioslave/media/mediamanager/medialist.cpp
index 09ff198d9..d9c4f0eb3 100644
--- a/tdeioslave/media/mediamanager/medialist.cpp
+++ b/tdeioslave/media/mediamanager/medialist.cpp
@@ -69,38 +69,22 @@ TQString MediaList::addMedium(Medium *medium, bool allowNotification)
{
kdDebug(1219) << "MediaList::addMedium(@" << medium->id() << ")" << endl;
- TQString id = medium->id();
- if ( m_idMap.contains(id) ) return TQString::null;
-
- m_media.append( medium );
- m_idMap[id] = medium;
-
TQString name = medium->name();
- if ( !m_nameMap.contains(name) )
+ if (!m_nameMap.contains(name))
{
m_nameMap[name] = medium;
-
- kdDebug(1219) << "MediaList emits mediumAdded(" << id << ", "
- << name << ")" << endl;
- emit mediumAdded(id, name, allowNotification);
-
- return name;
}
- TQString base_name = name+"_";
- int i = 1;
-
- while ( m_nameMap.contains(base_name+TQString::number(i)) )
+ TQString id = medium->id();
+ if (m_idMap.contains(id))
{
- i++;
+ return TQString::null;
}
- name = base_name+TQString::number(i);
- medium->setName(name);
- m_nameMap[name] = medium;
+ m_media.append(medium);
+ m_idMap[id] = medium;
- kdDebug(1219) << "MediaList emits mediumAdded(" << id << ", "
- << name << ")" << endl;
+ kdDebug(1219) << "MediaList emits mediumAdded(" << id << ", " << name << ")" << endl;
emit mediumAdded(id, name, allowNotification);
return name;
}
@@ -109,14 +93,17 @@ bool MediaList::removeMedium(const TQString &id, bool allowNotification)
{
kdDebug(1219) << "MediaList::removeMedium(" << id << ")" << endl;
- if ( !m_idMap.contains(id) ) return false;
+ if (!m_idMap.contains(id))
+ {
+ return false;
+ }
Medium *medium = m_idMap[id];
- TQString name = medium->name();
-
m_idMap.remove(id);
- m_nameMap.remove( medium->name() );
- m_media.remove( medium );
+ m_nameMap.remove(medium->name());
+
+ TQString name = medium->name();
+ m_media.remove(medium);
emit mediumRemoved(id, name, allowNotification);
return true;