[mythtv] [PATCH] mythvideo: video list tree alphabetical sorting
mythtv at ratin.org
mythtv at ratin.org
Thu Aug 26 11:33:46 EDT 2004
The following patch sorts the video tree alphabetically
(0->9A->Za->z). Directories are sorted first and files (videos) are
sorted within. This is helpful in the mode where the tree is built
based on the database metadata, the mode I use all the
time. Hopefully, you will find it useful.
I have not tested it extensively, but it works for me.
This patch is against mythvideo-0.15.1 download (as opposed to latest
cvs). Please tell me if it needs to be against cvs in the future.
(thanks for the replies on how to submit the patch).
-------------- next part --------------
--- mythvideo-0.15.1-org/mythvideo/videotree.cpp 2004-04-10 14:52:28.000000000 -0400
+++ mythvideo-0.15.1/mythvideo/videotree.cpp 2004-08-26 09:05:40.864597371 -0400
@@ -313,13 +313,58 @@
else
{
//
+ // First, build the directory tree based on the database structure
+ //
+
+ QSqlQuery dir_query("SELECT filename FROM videometadata ORDER BY filename;", db);
+ if(!dir_query.isActive())
+ {
+ cerr << "videotree.o: Your database sucks" << endl;
+ }
+ if (dir_query.numRowsAffected() > 0)
+ {
+ QString prefix = gContext->GetSetting("VideoStartupDir");
+ if(prefix.length() < 1)
+ {
+ cerr << "videotree.o: Seems unlikely that this is going to work" << endl;
+ }
+ while (dir_query.next())
+ {
+ QString file_string = dir_query.value(0).toString();
+
+ file_string.remove(0, prefix.length());
+ QStringList list(QStringList::split("/", file_string));
+
+ GenericTree *where_to_add;
+ where_to_add = video_tree_data;
+ int a_counter = 0;
+ QStringList::Iterator an_it = list.begin();
+ for( ; an_it != list.end(); ++an_it)
+ {
+ if(a_counter + 1 < (int) list.count())
+ {
+ QString dirname = *an_it + "/";
+ GenericTree *sub_node;
+ sub_node = where_to_add->getChildByName(dirname);
+ if(!sub_node)
+ {
+ sub_node = where_to_add->addNode(dirname, -1, false);
+ }
+ where_to_add = sub_node;
+ }
+ ++a_counter;
+ }
+ }
+ }
+
+ //
// This just asks the database for a list
// of metadata, builds it into a tree and
// passes that tree structure to the GUI
// widget that handles navigation
//
- QSqlQuery query("SELECT intid FROM videometadata ;", db);
+ QSqlQuery query("SELECT intid FROM videometadata ORDER BY title;", db);
Metadata *myData;
if(!query.isActive())
More information about the mythtv-dev
mailing list