[mythtv] [PATCH] Updated MythVideo MediaMonitor support
Matt Porter
mporter at kernel.crashing.org
Tue Jun 29 14:10:37 EDT 2004
Updated from my first patch that is based on Xavier's videotree
media support. Now that MediaMonitor is a singleton, it grabs
the instance directly rather than from MythContext in the
previous patches.
-Matt
-------------- next part --------------
Index: mythvideo/main.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/main.cpp,v
retrieving revision 1.31
diff -u -r1.31 main.cpp
--- mythvideo/main.cpp 12 Jun 2004 17:35:12 -0000 1.31
+++ mythvideo/main.cpp 29 Jun 2004 18:06:00 -0000
@@ -29,6 +29,7 @@
#include <mythtv/themedmenu.h>
#include <mythtv/mythcontext.h>
#include <mythtv/mythplugin.h>
+#include <mythtv/mythmedia.h>
enum VideoFileLocation
{
@@ -54,6 +55,10 @@
void runVideoBrowser(void);
void runVideoTree(void);
void runVideoGallery(void);
+void runMediaHandle(void)
+{
+ runVideoTree();
+}
void setupKeys(void)
{
@@ -74,7 +79,7 @@
REG_KEY("Video","INCPARENT","Increase Parental Level","Right");
REG_KEY("Video","DECPARENT","Decrease Parental Level","Left");
-
+ REG_MEDIA_HANDLER("MythVideo Removable Media handler","","",runMediaHandle,MEDIATYPE_DATA);
}
Index: mythvideo/videotree.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/videotree.cpp,v
retrieving revision 1.28
diff -u -r1.28 videotree.cpp
--- mythvideo/videotree.cpp 10 Apr 2004 18:52:28 -0000 1.28
+++ mythvideo/videotree.cpp 29 Jun 2004 18:06:05 -0000
@@ -12,6 +12,8 @@
#include <mythtv/mythwidgets.h>
#include <mythtv/uitypes.h>
#include <mythtv/util.h>
+#include <mythtv/mythmedia.h>
+#include <mythtv/mythmediamonitor.h>
VideoTree::VideoTree(MythMainWindow *parent, QSqlDatabase *ldb,
QString window_name, QString theme_filename,
@@ -30,7 +32,6 @@
wireUpTheme();
video_tree_root = new GenericTree("video root", -2, false);
- video_tree_data = video_tree_root->addNode("videos", -2, false);
buildVideoList();
@@ -38,8 +39,13 @@
// Tell the tree list to highlight the
// first entry and then display it
//
-
- video_tree_list->setCurrentNode(video_tree_data);
+ for (int i=0; i < video_tree_root->childCount();i++){
+ video_tree_data = video_tree_root->getChildAt(i,0);
+ if ((video_tree_data->childCount()>0)
+ && (video_tree_data->getChildAt(0,0)->getString() !=
+ tr("No files found"))) break;
+ }
+ video_tree_list->setCurrentNode(video_tree_data);
if(video_tree_data->childCount() > 0)
{
video_tree_list->setCurrentNode(video_tree_data->getChildAt(0, 0));
@@ -262,21 +268,51 @@
// Fill metadata from directory structure
//
- buildFileList(gContext->GetSetting("VideoStartupDir"));
+ QStringList nodesname;
+ QStringList nodespath;
+ nodespath.append(gContext->GetSetting("VideoStartupDir"));
+ nodesname.append("videos");
+ QValueList<MythMediaDevice*> medias = MediaMonitor::getMediaMonitor()->getMedias(MEDIATYPE_DATA);
+ QValueList<MythMediaDevice*>::Iterator itr = medias.begin();
+ MythMediaDevice * pDev;
+ while (itr != medias.end())
+ {
+ pDev = *itr;
+ if (pDev){
+ QString path = pDev->getMountPath();
+ QString name = path.right(path.length()-path.findRev("/")-1);
+ cout << "adding " << path << " as " << name << endl;
+ nodespath.append(path);
+ nodesname.append(name);
+ }
+ itr++;
+ }
+ for (uint j=0;j<nodesname.count();j++){
+ video_tree_data = video_tree_root->addNode(nodesname[j], -2, false);
+ buildFileList(nodespath[j]);
+ }
+ uint mainnodeindex=0;
+ QString prefix = nodespath[mainnodeindex];
+ GenericTree *where_to_add = video_tree_root->getChildAt(mainnodeindex);
for(uint i=0; i < browser_mode_files.count(); i++)
{
QString file_string = *(browser_mode_files.at(i));
- QString prefix = gContext->GetSetting("VideoStartupDir");
- if(prefix.length() < 1)
+
+ if (prefix.compare(file_string.left(prefix.length()))!=0){
+ mainnodeindex++;
+ }
+ if (mainnodeindex < nodespath.count()){
+ prefix = nodespath[mainnodeindex];
+ where_to_add = video_tree_root->getChildAt(mainnodeindex );
+ }
+ if(prefix.length() < 1)
{
cerr << "videotree.o: Seems unlikely that this is going to work" << endl;
}
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)
@@ -319,6 +355,8 @@
// widget that handles navigation
//
+ video_tree_data = video_tree_root->addNode("videos", -2, false);
+
QSqlQuery query("SELECT intid FROM videometadata ;", db);
Metadata *myData;
More information about the mythtv-dev
mailing list