summaryrefslogtreecommitdiffstats
path: root/tdeioslave/media/mediamanager
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:58:11 +0900
commit70569ea1ff1865055459bc73b8215f39ac9a9d3d (patch)
treeeb8c2b115c8a32a1a15389ccfef3548a6fcefee4 /tdeioslave/media/mediamanager
parent66b6ab6574fff507700a32f891c8754ceec30375 (diff)
downloadtdebase-70569ea1ff1865055459bc73b8215f39ac9a9d3d.tar.gz
tdebase-70569ea1ff1865055459bc73b8215f39ac9a9d3d.zip
mediamanager: cleaned up use of medium name map.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit c393eecadbc73e8db1d63fdc29c907d0340bb80c)
Diffstat (limited to 'tdeioslave/media/mediamanager')
-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;