[mythtv] [patch] add mediamonitor to context and use in mythvideo
Leo Weppelman
leo at wau.mis.ah.nl
Thu Aug 26 04:58:19 EDT 2004
Attached are 2 patches derived from patches previously posted by
Xavier Hervy. The first patch adds SetMediaMonitor/GetMedias
functions to the context and the second patch uses this to add
files from removable devices to the videotree.
Leo.
-------------- next part --------------
Index: mythtv/libs/libmyth/mythcontext.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.cpp,v
retrieving revision 1.130
diff -u -r1.130 mythcontext.cpp
--- mythtv/libs/libmyth/mythcontext.cpp 19 Aug 2004 02:04:36 -0000 1.130
+++ mythtv/libs/libmyth/mythcontext.cpp 26 Aug 2004 08:16:12 -0000
@@ -94,6 +94,8 @@
QMap<QString,QString> lastLogStrings;
bool screensaverEnabled;
+
+ MediaMonitor * media_monitor;
};
MythContextPrivate::MythContextPrivate(MythContext *lparent)
@@ -1260,7 +1262,18 @@
d->m_settings->SetSetting(key, newValue);
}
+void MythContext::SetMediaMonitor(MediaMonitor * lmediamonitor)
+{
+ d->media_monitor = lmediamonitor;
+}
+QValueList <MythMediaDevice*> MythContext::GetMedias(MediaType mediatype)
+{
+ QValueList <MythMediaDevice*> medias;
+ if (d->media_monitor != NULL)
+ medias = d->media_monitor->getMedias(mediatype);
+ return medias;
+}
bool MythContext::SendReceiveStringList(QStringList &strlist, bool quickTimeout)
{
Index: mythtv/libs/libmyth/mythcontext.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.h,v
retrieving revision 1.160
diff -u -r1.160 mythcontext.h
--- mythtv/libs/libmyth/mythcontext.h 19 Aug 2004 02:04:36 -0000 1.160
+++ mythtv/libs/libmyth/mythcontext.h 26 Aug 2004 08:16:12 -0000
@@ -16,6 +16,8 @@
#include <iostream>
#include <vector>
+#include <mythmediamonitor.h>
+#include <mythmedia.h>
using namespace std;
@@ -166,6 +168,9 @@
void SetSetting(const QString &key, const QString &newValue);
+ void SetMediaMonitor(MediaMonitor * lmediamonitor);
+ QValueList <MythMediaDevice*> GetMedias(MediaType mediatype);
+
QFont GetBigFont();
QFont GetMediumFont();
QFont GetSmallFont();
Index: mythtv/libs/libmyth/mythmediamonitor.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythmediamonitor.cpp,v
retrieving revision 1.10
diff -u -r1.10 mythmediamonitor.cpp
--- mythtv/libs/libmyth/mythmediamonitor.cpp 7 Aug 2004 13:08:32 -0000 1.10
+++ mythtv/libs/libmyth/mythmediamonitor.cpp 26 Aug 2004 08:16:13 -0000
@@ -52,6 +52,7 @@
{
theMonitor = new MediaMonitor(NULL, 500, true);
theMonitor->addFSTab();
+ gContext->SetMediaMonitor(theMonitor);
}
}
-------------- next part --------------
Index: mythvideo/mythvideo/videotree.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythvideo/mythvideo/videotree.cpp,v
retrieving revision 1.31
diff -u -r1.31 videotree.cpp
--- mythvideo/mythvideo/videotree.cpp 22 Aug 2004 18:16:32 -0000 1.31
+++ mythvideo/mythvideo/videotree.cpp 26 Aug 2004 08:16:23 -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>
#include "videofilter.h"
const long WATCHED_WATERMARK = 10000; // Less than this and the chain of videos will
@@ -39,7 +41,6 @@
wireUpTheme();
video_tree_root = new GenericTree("video root", -2, false);
- video_tree_data = video_tree_root->addNode("videos", -2, false);
currentVideoFilter = new VideoFilterSettings(db, true);
@@ -285,21 +286,69 @@
// Fill metadata from directory structure
//
- buildFileList(gContext->GetSetting("VideoStartupDir"));
+ QStringList nodesname;
+ QStringList nodespath;
+
+ nodespath.append(gContext->GetSetting("VideoStartupDir"));
+ nodesname.append("videos");
+
+
+ //
+ // See if there are removable media available, so we can add them
+ // to the tree.
+ //
+ QValueList <MythMediaDevice*> medias =
+ gContext->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);
+ 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]);
+ }
+
+ unsigned int 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.compare(file_string.left(prefix.length())) != 0)
+ {
+ if (mainnodeindex++ < nodespath.count()) {
+ prefix = nodespath[mainnodeindex];
+ }
+ else {
+ cerr << "videotree.o: mainnodeindex out of bounds" << endl;
+ break;
+ }
+ }
+ where_to_add = video_tree_root->getChildAt(mainnodeindex);
if(prefix.length() < 1)
{
- cerr << "videotree.o: Seems unlikely that this is going to work" << endl;
+ cerr << "videotree.o: weird prefix.lenght" << endl;
+ break;
}
+
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)
@@ -308,7 +357,6 @@
{
QString title = (*an_it);
where_to_add->addNode(title.section(".",0,-2), i, true);
-
}
else
{
More information about the mythtv-dev
mailing list