Hi,
Am Donnerstag, 6. Dezember 2007 18:07 schrieb Michael Riepe:
> If they both modify the same files (e.g. dvbcut.cpp), it's probably
> better to send me the whole bunch as a single diff. Otherwise, I prefer
> separate diffs.

Both change dvbcut.cpp... at least with the new -format switch!

> > I tried checking waitpid but this returned nothing special when the
> > executable is not found!
>
> Checking the exit status with wait/waitpid is a little tricky. You need
> to evaluate the `status' argument to find out what happened. But I can
> add that myself.

OK, that twould be nice... 
But AFAIR status didn't change in that case...!?!

>
> > So the 'which'-version is working for me, but maybe neither "universal"
> > nor "elegant" ... the QFileInfo-Version is better concerning this but not
> > making use of $PATH, so one has to specify the full path for the pipe
> > commands...
>
> Nah, that's not so good in my opinion. You should be able to use the
> same command that you would type at your shell prompt.

FullACK, that was the reason why I implemented the 'which'-check, but maybe 
that's no more necessary if you're checking the status now... ;-)

> > Another option would be just to stick with the current export dialog
> > (with pipes integrated) and implement a proper Settings-Menu, which we
> > need anyow and then (among other stuff) also allows to edit / configure
> > the pipes!
>
> Since we have so many settings already, it's about time to build a
> configuration dialog.

Yeah, guess so... but that would mean "fiddling with that stupid 
designer"... ;-)

> > But we need  a -format switch to select the output type... guess that
> > fit's into my above mentioned CLI-patch! ;-)
>
> Okay... but that should not change the current settings.

You mean not changing the settings().export_format variable?

But currently settings().export_format is is used also in CLI mode as 
default!!! That would mean GUI mode can change the default format used by the 
CLI but not vice versa? 

I think it's better the CLI always uses 0 as default, changable now by -format
(but not written to the settings)! OK?
Would be no good if the behavoir of CLI without -format dependens on 
the type of previous GUI runs!

> > But we could also have something like:
> >
> > recentfiles/0/0=/tmp/topf/test.rec_01
> > recentfiles/0/1=/tmp/topf/test.rec_02
> > recentfiles/0/idx=/tmp/topf/test.rec.idx
> >
> > and break with the current format!
>
> I think that would be the best way to do it. By the way: You should also 
> add the name of the bookmark (*.app?) file if there is one.

You mean *.add?
Hmmm, ... at the moment there is no way to specify one (no dialog like for the 
index, where we need a default value and where it can be changed)! 
Its name is determined from the first input file (in tsfile.cpp) which also 
works if opening happens via recentfiles... 

Maybe we can add such an dialog & recentfiles entry later if there are more 
receivers using such a file...?

The attached patch now contains also backward compatibility for the 
old recent file format, old entries will be automatically converted to new 
format on output.

The CLI now understands a -format switch (normal muxers: 0-3, but of course 
also pipe formats are possible, with 4 doing the default dvdauthor 
titleset+postprocessing) and the specified input files can alternatively also 
stand in front of the options since all argument parsing is now done in the 
beginning of main.cpp.

ciao
Ralph

PS: Sorry for the overlapping patches...
diff -Naur svn/ChangeLog  r107-recentfiles/ChangeLog
--- svn/ChangeLog       2007-12-06 16:44:12.000000000 +0100
+++ r107-recentfiles/ChangeLog  2007-12-06 21:56:23.000000000 +0100
@@ -1,5 +1,20 @@
 2007-12-06  Ralph Glasstetter  <[EMAIL PROTECTED]>  (mr)

+        * src/settings.cpp
+        * src/settings.h
+        * src/dvbcut.cpp
+        * src/dvbcut.h
+                New recent files format which allows for storing
+                multiple splitted input files
+
+        * src/dvbcut.cpp
+        * src/dvbcut.h
+        * src/main.cpp
+                Input file names can come before CLI switches
+                New -format switch
+
+2007-12-06  Ralph Glasstetter  <[EMAIL PROTECTED]>  (mr)
+
        * src/settings.cpp:
        * src/settings.h:
                New pipe command settings.
diff -Naur svn/src/dvbcut.cpp r107-recentfiles/src/dvbcut.cpp
--- svn/src/dvbcut.cpp	2007-12-06 16:44:12.000000000 +0100
+++ r107-recentfiles/src/dvbcut.cpp	2007-12-06 21:32:15.000000000 +0100
@@ -506,7 +506,7 @@
   }
 
   std::auto_ptr<exportdialog> expd(new exportdialog(expfilen,this));
-  expd->muxercombo->insertItem("DVD (DVBCUT multiplexer)");
+  expd->muxercombo->insertItem("MPEG program stream/DVD (DVBCUT multiplexer)");
   expd->muxercombo->insertItem("MPEG program stream (DVBCUT multiplexer)");
   expd->muxercombo->insertItem("MPEG program stream/DVD (libavformat)");
   expd->muxercombo->insertItem("MPEG transport stream (libavformat)");
@@ -527,18 +527,21 @@
     expd->audiolist->setSelected(a,true);
   }
 
+  int expfmt = 0;
   if (!nogui) {
     expd->show();
     if (!expd->exec())
       return;
 
     settings().export_format = expd->muxercombo->currentItem();
+    expfmt = expd->muxercombo->currentItem();
 
     expfilen=(const char *)(expd->filenameline->text());
     if (expfilen.empty())
       return;
     expd->hide();
-  }
+  } else if (exportformat > 0 && exportformat < expd->muxercombo->count()) 
+    expfmt = exportformat;  
 
   // create usable chapter lists 
   std::string chapterstring, chaptercolumn;
@@ -574,8 +577,9 @@
   // check for piped output
   std::string expcmd;
   size_t pos;
-  int ip=settings().export_format-pipe_items_start; 
+  int ip=expfmt-pipe_items_start; 
   if(ip>=0) {
+    expfmt=settings().pipe_format[ip];
     if (settings().pipe_command[ip].find('|')==-1) 
       expcmd = "|"+std::string(settings().pipe_command[ip].ascii());
     else 
@@ -655,14 +659,6 @@
   std::string out_file = (child_pid < 0) ? expfilen :
     std::string("pipe:") + (const char*)QString::number(pipe_fds[1]);
 
-  int expfmt;
-#ifndef __WIN32__
-  if (ip>=0)
-    expfmt=settings().pipe_format[ip];
-  else  
-#endif
-    expfmt=settings().export_format;
-
   switch(expfmt) {
     case 1:
       mux=std::auto_ptr<muxer>(new mpegmuxer(audiostreammask,*mpg,out_file.c_str(),false,0));
@@ -1468,19 +1464,20 @@
 void dvbcut::abouttoshowrecentfiles()
 {
   recentfilespopup->clear();
-  int id=0;
-  for(std::vector<std::pair<std::string,std::string> >::iterator it=settings().recentfiles.begin();
-      it!=settings().recentfiles.end();++it)
-    recentfilespopup->insertItem(it->first,id++);
+  QString menuitem;
+  for(unsigned int id=0; id<settings().recentfiles.size(); id++) {
+    menuitem=QString(settings().recentfiles[id].first.front());
+    if(settings().recentfiles[id].first.size()>1)
+      menuitem += " ... (+" + QString::number(settings().recentfiles[id].first.size()-1) + ")";
+    recentfilespopup->insertItem(menuitem,(signed)id);    
+  }   
 }
 
 void dvbcut::loadrecentfile(int id)
 {
   if (id<0 || id>=(signed)settings().recentfiles.size())
     return;
-  std::list<std::string> dummy_list;
-  dummy_list.push_back(settings().recentfiles[id].first);
-  open(dummy_list, settings().recentfiles[id].second);
+  open(settings().recentfiles[(unsigned)id].first, settings().recentfiles[(unsigned)id].second);
 }
 
 // **************************************************************************
@@ -1800,9 +1797,12 @@
   expfilen=expfilename;
   picfilen=QString::null;
   if (prjfilen.empty())
-    addtorecentfiles(mpgfilen.front(),idxfilen);
-  else
-    addtorecentfiles(prjfilen);
+    addtorecentfiles(mpgfilen,idxfilen);
+  else {
+    std::list<std::string> dummy_list;
+    dummy_list.push_back(prjfilen);
+    addtorecentfiles(dummy_list);
+  }
 
   firstpts=(*mpg)[0].getpts();
   timeperframe=(*mpg)[1].getpts()-(*mpg)[0].getpts();
@@ -1926,17 +1926,18 @@
 // **************************************************************************
 // ***  protected functions
 
-void dvbcut::addtorecentfiles(const std::string &filename, const std::string &idxfilename)
+void dvbcut::addtorecentfiles(const std::list<std::string> &filenames, const std::string &idxfilename)
 {
 
-  for(std::vector<std::pair<std::string,std::string> >::iterator it=settings().recentfiles.begin();
+  for(std::vector<std::pair<std::list<std::string>,std::string> >::iterator it=settings().recentfiles.begin();
       it!=settings().recentfiles.end();)
-    if (it->first==filename)
+    // checking the size and the first/last filename should be enough... but maybe I'm to lazy! ;-)
+    if (it->first.size()==filenames.size() && it->first.front()==filenames.front() && it->first.back()==filenames.back())
       it=settings().recentfiles.erase(it);
-  else
-    ++it;
+    else
+      ++it;
 
-  settings().recentfiles.insert(settings().recentfiles.begin(),std::pair<std::string,std::string>(filename,idxfilename));
+  settings().recentfiles.insert(settings().recentfiles.begin(),std::pair<std::list<std::string>,std::string>(filenames,idxfilename));
 
   while (settings().recentfiles.size()>settings().recentfiles_max)
     settings().recentfiles.pop_back();
diff -Naur svn/src/dvbcut.h r107-recentfiles/src/dvbcut.h
--- svn/src/dvbcut.h	2007-11-28 16:12:51.000000000 +0100
+++ r107-recentfiles/src/dvbcut.h	2007-12-06 20:19:19.000000000 +0100
@@ -97,11 +97,12 @@
   int viewscalefactor;
   int currentaudiotrack;
   bool nogui;
+  int exportformat; 
 
 protected:
   //   QPixmap getpixmap(int picture, bool allgop=false);
   void exportvideo(const char *fmt);
-  void addtorecentfiles(const std::string &filename, const std::string &idxfilename=std::string());
+  void addtorecentfiles(const std::list<std::string> &filenames, const std::string &idxfilename=std::string());
   void setviewscalefactor(int factor);
 
   // special event handling (mouse wheel)
@@ -132,6 +133,7 @@
             std::string idxfilename=std::string(), std::string expfilename=std::string());
   void setbusy(bool b=true);
   void batchmode(bool b=true) { nogui = b; }
+  void setexportformat(int ef=0) { exportformat = ef; }
   // static dvbcut *New(std::string filename=std::string(), std::string idxfilename=std::string());
   void addStartStopItems(std::vector<int>);
   int getTimePerFrame() { return timeperframe>0 && timeperframe<5000 ? timeperframe : 3003; };
diff -Naur svn/src/main.cpp r107-recentfiles/src/main.cpp
--- svn/src/main.cpp	2007-10-30 15:14:10.000000000 +0100
+++ r107-recentfiles/src/main.cpp	2007-12-06 21:30:41.000000000 +0100
@@ -54,7 +54,7 @@
   fprintf(stderr,
     "Usage ("VERSION_STRING"):\n"
     "  %s -generateidx [-idx <idxfilename>] [<mpgfilename> ...]\n"
-    "  %s -batch [-cut AR|TS|<list>] [-exp <expfilename>] <prjfilename> | <mpgfilename> ...\n\n",
+    "  %s -batch [-cut AR|TS|<list>] [-exp <expfilename>] [-format <num>] <prjfilename> | <mpgfilename> ...\n\n",
     argv0, argv0);
   fprintf(stderr,
     "If no input files are specified, `dvbcut -generateidx' reads from\n"
@@ -67,6 +67,9 @@
     "a given list of frame numbers / time stamps (use ',-|;' as separators).\n" 
     "Without any (valid) cut markers the whole file will be converted!\n\n");
   fprintf(stderr,
+    "The -exp switch specifies the name of the exported file, with -format\n"
+    "the default export format (0=MPEG program stream/DVD) can be canged.\n\n");
+  fprintf(stderr,
     "Options may be abbreviated as long as they remain unambiguous.\n\n");
   exit(rv);
 }
@@ -76,8 +79,10 @@
   argv0=argv[0];
   bool generateidx=false;
   bool batchmode=false;
+  int exportformat=0;
   std::string idxfilename, expfilename;
   std::vector<std::string> cutlist;
+  std::list<std::string> filenames;
   int i;
 
   setlocale(LC_ALL, "");
@@ -85,29 +90,38 @@
   /*
    * process arguments
    */
-  for (i = 1; i < argc && argv[i][0] == '-'; ++i) {
-    size_t n = strlen(argv[i]);
-    if (n == 2 && argv[i][1] == '-') {	// POSIX argument separator
-      ++i;
-      break;
-    }
-    else if (strncmp(argv[i], "-batch", n) == 0)
-      batchmode = true;
-    else if (strncmp(argv[i], "-generateidx", n) == 0)
-      generateidx = true;
-    else if (strncmp(argv[i], "-idx", n) == 0 && ++i < argc)
-      idxfilename = argv[i];
-    else if (strncmp(argv[i], "-exp", n) == 0 && ++i < argc)
-      expfilename = argv[i];
-    else if (strncmp(argv[i], "-cut", n) == 0 && ++i < argc) {
-      char *pch = strtok(argv[i],",-|;");
-      while(pch) {
-        if(strlen(pch))
-          cutlist.push_back((std::string)pch);    
-        pch = strtok(NULL,",-|;");                 
-      } 
-    } else 
-      usage_exit(); 
+  for (i = 1; i < argc; ++i) {
+    if (argv[i][0] == '-') {
+      // process switches / options
+      size_t n = strlen(argv[i]);
+      if (n == 2 && argv[i][1] == '-') {	// POSIX argument separator
+        ++i;
+        break;
+      }
+      else if (strncmp(argv[i], "-batch", n) == 0)
+        batchmode = true;
+      else if (strncmp(argv[i], "-generateidx", n) == 0)
+        generateidx = true;
+      else if (strncmp(argv[i], "-idx", n) == 0 && ++i < argc)
+        idxfilename = argv[i];
+      else if (strncmp(argv[i], "-exp", n) == 0 && ++i < argc)
+        expfilename = argv[i];
+      else if (strncmp(argv[i], "-format", n) == 0 && ++i < argc)
+        exportformat = atoi(argv[i]);
+      else if (strncmp(argv[i], "-cut", n) == 0 && ++i < argc) {
+        char *pch = strtok(argv[i],",-|;");
+        while(pch) {
+          if(strlen(pch))
+            cutlist.push_back((std::string)pch);    
+          pch = strtok(NULL,",-|;");                 
+        } 
+      } else 
+        usage_exit(); 
+    } else
+      // process input files 
+      // (that way files also can come first / options last and 
+      // argument processing only happens once and only in this loop!)
+      filenames.push_back(std::string(argv[i])); 
   }
 
   /*
@@ -124,18 +138,17 @@
     std::string errormessage;
     inbuffer buf(8 << 20, 128 << 20);
     bool okay = true;
-    if (i >= argc) {
+    if (filenames.empty()) {
       // no filenames given, read from stdin
       okay = buf.open(STDIN_FILENO, &errormessage);
     }
     else {
-      mpgfilename = argv[i];	// use first one (for now)
+      mpgfilename = filenames.front();  // use first one (for now) 
       if (idxfilename.empty())
-	idxfilename = mpgfilename + ".idx";
-      while (okay && i < argc) {
-	okay = buf.open(argv[i], &errormessage);
-	++i;
-      }
+        idxfilename = mpgfilename + ".idx"; 
+      for(std::list<std::string>::iterator it = filenames.begin(); 
+                                    okay && it != filenames.end(); it++)	
+	okay = buf.open(*it, &errormessage);
     }
     if (!okay) {
       fprintf(stderr, "%s: %s\n", argv0, errormessage.c_str());
@@ -183,16 +196,11 @@
 #endif // HAVE_LIB_AO
 
   av_register_all();
-  std::list<std::string> filenames;
 
   int rv=1;
   dvbcut *main=new dvbcut;
   main->batchmode(batchmode);
-
-  while (i < argc) {
-    filenames.push_back(std::string(argv[i]));
-    ++i;
-  }
+  main->setexportformat(exportformat);
 
   if (batchmode) {
     if (filenames.empty())	// must provide at least one filename
diff -Naur svn/src/settings.cpp r107-recentfiles/src/settings.cpp
--- svn/src/settings.cpp	2007-12-06 16:44:12.000000000 +0100
+++ r107-recentfiles/src/settings.cpp	2007-12-06 21:20:50.000000000 +0100
@@ -21,6 +21,8 @@
 #include <string>
 #include <vector>
 
+#include <qstringlist.h>
+
 #include <assert.h>
 
 #include "defines.h"
@@ -109,14 +111,36 @@
   beginGroup("/recentfiles");
     recentfiles_max = readNumEntry("/max", 5);
     recentfiles.clear();
+    std::list<std::string> filenames;
+    QStringList keys = entryList("/");
     for (unsigned int i = 0; i < recentfiles_max; ++i) {
       QString key = "/" + QString::number(i);
-      QString filename = readEntry(key);
-      if (filename.isEmpty())
-	continue;
-      QString idxfilename = readEntry(key + "-idx", "");
-      recentfiles.push_back(
-	std::pair<std::string,std::string>(filename, idxfilename));
+      if(keys.size()>1) {      // OLD format (2 keys per input file, NO subkeys!)
+        QString filename = readEntry(key);
+        if (filename.isEmpty())
+ 	  continue;
+        filenames.clear();
+        filenames.push_back(filename);
+        QString idxfilename = readEntry(key + "-idx", "");
+        recentfiles.push_back(
+        std::pair<std::list<std::string>,std::string>(filenames, idxfilename));
+      } else {                // NEW format with subkeys and multiple files!
+      beginGroup(key);
+        QString filename = readEntry("/0");
+        if (!filename.isEmpty()) {
+          // multiple input files?  
+          int j=0;
+          filenames.clear();
+          while(!filename.isEmpty()) {
+            filenames.push_back(filename);
+            filename = readEntry("/" + QString::number(++j), "");
+          }  
+          QString idxfilename = readEntry("/idx", "");
+          recentfiles.push_back(
+	    std::pair<std::list<std::string>,std::string>(filenames, idxfilename));
+        }
+      endGroup();	// key
+      }
     }
   endGroup();	// recentfiles
   beginGroup("/labels");
@@ -158,9 +182,9 @@
       pipe_format.push_back(format);
       QString key = "/" + QString::number(++i);
       beginGroup(key);
-	command = readEntry("/command");
-	post = readEntry("/post");
-	label = readEntry("/label");
+        command = readEntry(key + "-command", "");
+        post = readEntry(key + "-post", "");
+        label = readEntry(key + "-label", "");
 	format = readNumEntry("/format", 0);
       endGroup();	// key
     }
@@ -187,17 +211,29 @@
   writeEntry("/loadfilter", loadfilter);
   writeEntry("/export_format", export_format);
   beginGroup("/recentfiles");
+    // first remove any OLD recentfiles entries to clean the settings file (<revision 108)!!!
+    QStringList keys = entryList("/");
+    for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) 
+      removeEntry("/" + *it);
+    // then remove ALL new recentfiles entries!!!
+    // (otherwise it would be a mess with erased&inserted muliple file entries of different size)
+    QStringList subkeys = subkeyList("/");
+    for ( QStringList::Iterator its = subkeys.begin(); its != subkeys.end(); ++its ) {
+      QStringList keys = entryList("/" + *its);
+      for ( QStringList::Iterator itk = keys.begin(); itk != keys.end(); ++itk ) 
+        removeEntry("/"  + *its + "/" + *itk);
+    }    
     writeEntry("/max", int(recentfiles_max));
-    for (unsigned int i = 0; i < recentfiles_max; ++i) {
+    // and NOW write the updated list from scratch!!!
+    for (unsigned int i = 0; i < recentfiles.size(); ++i) {
       QString key = "/" + QString::number(i);
-      if (i < recentfiles.size()) {
-	writeEntry(key, recentfiles[i].first);
-	writeEntry(key + "-idx", recentfiles[i].second);
-      }
-      else {
-	removeEntry(key);
-	removeEntry(key + "-idx");
-      }
+      beginGroup(key);
+        int j=0;
+        for(std::list<std::string>::iterator it=settings().recentfiles[i].first.begin();
+                                             it!=settings().recentfiles[i].first.end(); it++, j++) 
+          writeEntry("/" + QString::number(j), *it);
+        writeEntry("/idx", recentfiles[i].second);
+      endGroup();	// key
     }
   endGroup();	// recentfiles
   beginGroup("/labels");
diff -Naur svn/src/settings.h r107-recentfiles/src/settings.h
--- svn/src/settings.h	2007-12-06 16:44:12.000000000 +0100
+++ r107-recentfiles/src/settings.h	2007-12-06 17:57:15.000000000 +0100
@@ -48,7 +48,7 @@
   QString idxfilter;
   QString prjfilter;
   QString loadfilter;
-  std::vector<std::pair<std::string,std::string> > recentfiles;
+  std::vector<std::pair<std::list<std::string>,std::string> > recentfiles;
   unsigned int recentfiles_max;
   int viewscalefactor;
   int wheel_increments[WHEEL_INCR_num];
-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to