Commit a9679a11 authored by Scott Wheeler's avatar Scott Wheeler

Make sure that we have default values, otherwise this is a bit bad the first

time that you use it.  Also moved some variables into local scopes; even though
it's slighly less effecient, that's hardly a bottleneck in this code and it
makes it easier to read.

svn path=/trunk/kdemultimedia/juk/; revision=359724
parent f0d7ce69
......@@ -121,6 +121,13 @@ ConfigCategoryReader::ConfigCategoryReader() : CategoryReaderInterface(),
m_separator = config.readEntry("Separator", " - ");
checkedSeparators = config.readIntListEntry("CategoryOrder");
// Set a default:
if(checkedSeparators.isEmpty())
checkedSeparators << Artist << Album << Title << Track;
for(it = checkedSeparators.begin(); it != checkedSeparators.end(); ++it)
m_categoryOrder.append(static_cast<TagType>(*it));
}
......@@ -771,19 +778,18 @@ QString FileRenamer::fileName(const CategoryReaderInterface &interface)
const QRegExp closeBracket("[])}]\\s*$");
const QRegExp openBracket("^\\s*[[({]");
TagType category;
unsigned i = 0;
QString value;
QStringList list;
for(QValueList<TagType>::ConstIterator it = categoryOrder.begin(); it != categoryOrder.end(); ++it) {
category = static_cast<TagType>(*it);
TagType category = static_cast<TagType>(*it);
if(interface.isDisabled(category)) {
++i;
continue;
}
value = interface.value(category);
QString value = interface.value(category);
if(i < (NumTypes - 1) && interface.hasFolderSeparator(i))
value.append("/");
......@@ -797,6 +803,7 @@ QString FileRenamer::fileName(const CategoryReaderInterface &interface)
// '/' specially
QString result;
for(QStringList::ConstIterator it = list.begin(); it != list.end(); /* Empty */) {
result += *it;
if((*it).find(closeBracket) != -1) {
......@@ -812,6 +819,10 @@ QString FileRenamer::fileName(const CategoryReaderInterface &interface)
result += separator;
}
}
// ??? This simplify whitespace here seems bogus to me. That could
// potentially break the folder name "My Music" which though odd wouldn't
// be invalid in any way.
return QString(folder + QDir::separator() + result).simplifyWhiteSpace();
}
......
......@@ -40,7 +40,7 @@ class QVBox;
class PlaylistItem;
// Used to decide what direction the FileRenamerWidget will move rows in.
typedef enum { MoveUp, MoveDown } MovementDirection;
enum MovementDirection { MoveUp, MoveDown };
/**
* This is used by FileRenamerWidget to store information about a particular
......
......@@ -43,6 +43,22 @@ TagRenamerOptions::TagRenamerOptions(const TagRenamerOptions &other) :
TagRenamerOptions::TagRenamerOptions(TagType category)
: m_category(category)
{
// Set some defaults
bool disabled;
switch(category) {
case Title:
case Artist:
case Album:
case Track:
disabled = false;
kdDebug(65432) << "not disabled!!!" << endl;
break;
default:
disabled = true;
}
// Make sure we don't use translated strings for the config file keys.
const QString typeKey = getTagTypeText(category, false);
......@@ -63,7 +79,7 @@ TagRenamerOptions::TagRenamerOptions(TagType category)
setEmptyText(config.readEntry(QString("%1EmptyText").arg(typeKey)));
setTrackWidth(config.readUnsignedNumEntry(QString("%1TrackWidth").arg(typeKey)));
setDisabled(config.readBoolEntry(QString("%1Disabled").arg(typeKey)));
setDisabled(config.readBoolEntry(QString("%1Disabled").arg(typeKey), disabled));
}
QString TagRenamerOptions::getTagTypeText(TagType type, bool translate)
......
......@@ -72,9 +72,9 @@ public:
return getTagTypeText(category(), translate);
}
/**
* This saves the options to the global KConfig object.
*/
/**
* This saves the options to the global KConfig object.
*/
void saveConfig() const;
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment