Permalink
Browse files

Speed up sorting by string in MythGenericTree and allow for custom so…

…rt strings

This fixes a regression causing the MythMusic playlist editor screen to take
several seconds to show.

This will also in the future allow more intelligent sorting of for example the
Artist list in the playlist editor.

NOTE: bumps the ABI so plugins need to be recompiled etc.
  • Loading branch information...
1 parent bf523e8 commit 1ead1cf9f3d3a6ca6983c0dae2f12a106ab1d9d8 @paul-h paul-h committed Apr 4, 2013
@@ -31,6 +31,8 @@ MusicGenericTree::MusicGenericTree(MusicGenericTree *parent,
m_action = action;
m_showArrow = showArrow;
+ SetSortText(name.toLower());
+
if (!action.isEmpty() && !action.isNull())
setSelectable(true);
@@ -12,7 +12,7 @@
/// Update this whenever the plug-in ABI changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods in exported headers.
-#define MYTH_BINARY_VERSION "0.27.20130329-1"
+#define MYTH_BINARY_VERSION "0.27.20130404-1"
/** \brief Increment this whenever the MythTV network protocol changes.
*
@@ -19,7 +19,7 @@ class SortableMythGenericTreeList : public QList<MythGenericTree*>
static bool sortByString(MythGenericTree *one, MythGenericTree *two)
{
- return one->GetText().toLower() < two->GetText().toLower();
+ return one->GetSortText() < two->GetSortText();
}
static int sortBySelectable(MythGenericTree *one, MythGenericTree *two)
@@ -67,6 +67,8 @@ MythGenericTree::MythGenericTree(const QString &a_string, int an_int,
m_selectedSubnode = NULL;
m_text = a_string;
+ m_sortText = a_string;
+
m_int = an_int;
m_data = 0;
@@ -85,8 +87,19 @@ MythGenericTree* MythGenericTree::addNode(const QString &a_string, int an_int,
bool selectable_flag, bool visible)
{
MythGenericTree *new_node = new MythGenericTree(a_string.simplified(),
- an_int, selectable_flag);
+ an_int, selectable_flag);
new_node->SetVisible(visible);
+ return addNode(new_node);
+}
+
+MythGenericTree* MythGenericTree::addNode(const QString &a_string,
+ const QString &sortText, int an_int, bool
+ selectable_flag, bool visible)
+{
+ MythGenericTree *new_node = new MythGenericTree(a_string.simplified(),
+ an_int, selectable_flag);
+ new_node->SetVisible(visible);
+ new_node->SetSortText(sortText);
return addNode(new_node);
}
@@ -514,7 +527,10 @@ void MythGenericTree::SetText(const QString &text, const QString &name,
m_strings.insert(name, textprop);
}
else
+ {
m_text = text;
+ m_sortText = text;
+ }
}
void MythGenericTree::SetTextFromMap(InfoMap &infoMap,
@@ -22,11 +22,13 @@ class MUI_PUBLIC MythGenericTree
public:
MythGenericTree(const QString &a_string = "", int an_int = 0,
- bool selectable_flag = false);
+ bool selectable_flag = false);
virtual ~MythGenericTree();
MythGenericTree *addNode(const QString &a_string, int an_int = 0,
- bool selectable_flag = false, bool visible = true);
+ bool selectable_flag = false, bool visible = true);
+ MythGenericTree *addNode(const QString &a_string, const QString &sortText = "",
+ int an_int = 0, bool selectable_flag = false, bool visible = true);
MythGenericTree *addNode(MythGenericTree *child);
/// Detach this node/branch from it's parent without deleting it, it can
@@ -68,6 +70,9 @@ class MUI_PUBLIC MythGenericTree
void SetTextFromMap(InfoMap &infoMap, const QString &state="");
QString GetText(const QString &name="") const;
+ QString GetSortText() const { return m_sortText; }
+ void SetSortText(const QString &text) { m_sortText = text; }
+
void SetImage(const QString &filename, const QString &name="");
void SetImageFromMap(InfoMap &infoMap);
QString GetImage(const QString &name="") const;
@@ -110,6 +115,7 @@ class MUI_PUBLIC MythGenericTree
void reorderSubnodes(void);
QString m_text;
+ QString m_sortText;
QMap<QString, TextProperties> m_strings;
InfoMap m_imageFilenames;
InfoMap m_states;

0 comments on commit 1ead1cf

Please sign in to comment.