diff options
author | Florian Jung <flo@windfisch.org> | 2012-02-14 17:26:03 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2012-02-14 17:26:03 +0000 |
commit | 3ffd0dacdd7447c6c377f95c1fa7fc45a2612d98 (patch) | |
tree | c8fa5ba7569d3001f3304f16f2f4a5c2546db8df /muse2/muse/widgets/header.cpp | |
parent | bca65ae96031f8d6828cb0038ee768ae11c7cff8 (diff) |
- added support for custom controller columns in the tracklist
they are stored in and read from the global config file.
- tracklist header is now saved into global config, not in songfile.
TODO: - allow the user to customize the custom columns
- make recreating the Header work (graphical glitches currently)
Diffstat (limited to 'muse2/muse/widgets/header.cpp')
-rw-r--r-- | muse2/muse/widgets/header.cpp | 90 |
1 files changed, 50 insertions, 40 deletions
diff --git a/muse2/muse/widgets/header.cpp b/muse2/muse/widgets/header.cpp index 968e7f73..a8e98ab5 100644 --- a/muse2/muse/widgets/header.cpp +++ b/muse2/muse/widgets/header.cpp @@ -36,7 +36,6 @@ namespace MusEGui { void Header::readStatus(MusECore::Xml& xml) { - for (;;) { MusECore::Xml::Token token = xml.parse(); const QString& tag = xml.s1(); @@ -45,36 +44,7 @@ void Header::readStatus(MusECore::Xml& xml) case MusECore::Xml::End: return; case MusECore::Xml::Text: - { - QStringList l = tag.split(QString(" "), QString::SkipEmptyParts); - int index = count() -1; - for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { - int logialIdx=abs((*it).toInt()); - bool isHidden = (*it).toInt() < 0 ? true:false; - int section = visualIndex(logialIdx - (isHidden? 1:0)); - moveSection(section, index); - if (isHidden) - hideSection(logialIdx-1); - else - showSection(logialIdx); - --index; - } - - // loop again looking for missing indexes - for (int i =0; i < count(); i++) { - bool foundIt=false; - for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { - int id=((*it).toInt()); - if ( id == i || i == -1 - id ) - foundIt=true; - } - if (foundIt == false) { - int section = visualIndex(i); - moveSection(section, i); - //printf("Adding missing i %d index %d section %d!\n", i, index, section); - } - } - } + setStatus(tag); break; case MusECore::Xml::TagStart: xml.unknown("Header"); @@ -88,25 +58,65 @@ void Header::readStatus(MusECore::Xml& xml) } } +void Header::setStatus(QString status) +{ + QStringList l = status.split(QString(" "), QString::SkipEmptyParts); + int index = count() -1; + for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + int logialIdx=abs((*it).toInt()); + bool isHidden = ((*it).toInt() < 0); + int section = visualIndex(logialIdx - (isHidden? 1:0)); + moveSection(section, index); + if (isHidden) + hideSection(logialIdx-1); + else + showSection(logialIdx); + --index; + } + + // loop again looking for missing indexes + for (int i =0; i < count(); i++) { + bool foundIt=false; + for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) { + int id=((*it).toInt()); + if ( id == i || i == -1 - id ) + foundIt=true; + } + if (foundIt == false) { + int section = visualIndex(i); + moveSection(section, i); + //printf("Adding missing i %d index %d section %d!\n", i, index, section); + } + } +} + //--------------------------------------------------------- // writeStatus //--------------------------------------------------------- void Header::writeStatus(int level, MusECore::Xml& xml) const { - //xml.nput(level, "<%s> ", name()); xml.nput(level, "<%s> ", MusECore::Xml::xmlString(objectName()).toLatin1().constData()); - int n = count(); - for (int i = n-1; i >= 0; --i) { - if (isSectionHidden(logicalIndex(i))) - xml.nput("%d ", -logicalIndex(i)-1); // hidden is stored as negative value starting from -1 - else - xml.nput("%d ", logicalIndex(i)); - } - //xml.put("</%s>", name()); + xml.nput("%s", getStatus().toLatin1().constData()); xml.put("</%s>", MusECore::Xml::xmlString(objectName()).toLatin1().constData()); } +QString Header::getStatus() const +{ + QString temp=""; + + int n = count(); + for (int i = n-1; i >= 0; --i) + { + if (isSectionHidden(logicalIndex(i))) + temp+=QString::number(-logicalIndex(i)-1)+" "; // hidden is stored as negative value starting from -1 + else + temp+=QString::number(logicalIndex(i))+" "; + } + + return temp; +} + //--------------------------------------------------------- // Header //--------------------------------------------------------- |