]> git.sesse.net Git - kdenlive/commitdiff
Export project info (list of clips) to text file
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 23 Oct 2010 19:01:37 +0000 (19:01 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 23 Oct 2010 19:01:37 +0000 (19:01 +0000)
svn path=/trunk/kdenlive/; revision=5036

src/projectsettings.cpp
src/projectsettings.h
src/widgets/projectsettings_ui.ui

index bed29b1e9fe4817ffffe9f3593a4144f71ddb9ee..51e8a461632c76a2046ae09f93b99d08dc7710c1 100644 (file)
@@ -29,6 +29,8 @@
 #include <KDebug>
 #include <kio/directorysizejob.h>
 #include <KIO/NetAccess>
+#include <KTemporaryFile>
+#include <KFileDialog>
 
 #include <QDir>
 #include <kmessagebox.h>
@@ -38,7 +40,7 @@ ProjectSettings::ProjectSettings(ProjectList *projectlist, QStringList lumas, in
 {
     setupUi(this);
 
-    list_search->setListWidget(files_list);
+    list_search->setTreeWidget(files_list);
 
     QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
     QMapIterator<QString, QString> i(profilesInfo);
@@ -76,6 +78,7 @@ ProjectSettings::ProjectSettings(ProjectList *projectlist, QStringList lumas, in
     } else tabWidget->widget(1)->setEnabled(false);
     connect(profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
     connect(project_folder, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButton(const QString &)));
+    connect(button_export, SIGNAL(clicked()), this, SLOT(slotExportToText()));
 }
 
 void ProjectSettings::slotDeleteUnused()
@@ -139,24 +142,75 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
     // images included in slideshow and titles, files in playlist clips
     // TODO: images used in luma transitions, files used for LADSPA effects?
 
-    QStringList allFiles;
+    // Setup categories
+    QTreeWidgetItem *videos = new QTreeWidgetItem(files_list, QStringList() << i18n("Video clips"));
+    videos->setIcon(0, KIcon("video-x-generic"));
+    videos->setExpanded(true);
+    QTreeWidgetItem *sounds = new QTreeWidgetItem(files_list, QStringList() << i18n("Audio clips"));
+    sounds->setIcon(0, KIcon("audio-x-generic"));
+    sounds->setExpanded(true);
+    QTreeWidgetItem *images = new QTreeWidgetItem(files_list, QStringList() << i18n("Image clips"));
+    images->setIcon(0, KIcon("image-x-generic"));
+    images->setExpanded(true);
+    QTreeWidgetItem *slideshows = new QTreeWidgetItem(files_list, QStringList() << i18n("Slideshow clips"));
+    slideshows->setIcon(0, KIcon("image-x-generic"));
+    slideshows->setExpanded(true);
+    QTreeWidgetItem *texts = new QTreeWidgetItem(files_list, QStringList() << i18n("Text clips"));
+    texts->setIcon(0, KIcon("text-plain"));
+    texts->setExpanded(true);
+    QTreeWidgetItem *others = new QTreeWidgetItem(files_list, QStringList() << i18n("Other clips"));
+    others->setIcon(0, KIcon("unknown"));
+    others->setExpanded(true);
+    int count = 0;
     QStringList allFonts;
-    allFiles << m_lumas;
+    foreach(const QString & file, m_lumas) {
+        count++;
+        new QTreeWidgetItem(images, QStringList() << file);
+    }
+
     for (int i = 0; i < list.count(); i++) {
         DocClipBase *clip = list.at(i);
         if (clip->clipType() == SLIDESHOW) {
-            // special case, list all images
-            QStringList files = extractSlideshowUrls(clip->fileURL());
-            allFiles << files;
-        } else if (!clip->fileURL().isEmpty()) allFiles.append(clip->fileURL().path());
+            QStringList subfiles = extractSlideshowUrls(clip->fileURL());
+            foreach(const QString & file, subfiles) {
+                count++;
+                new QTreeWidgetItem(slideshows, QStringList() << file);
+            }
+        } else if (!clip->fileURL().isEmpty()) {
+            //allFiles.append(clip->fileURL().path());
+            switch (clip->clipType()) {
+            case TEXT:
+                new QTreeWidgetItem(texts, QStringList() << clip->fileURL().path());
+                break;
+            case AUDIO:
+                new QTreeWidgetItem(sounds, QStringList() << clip->fileURL().path());
+                break;
+            case IMAGE:
+                new QTreeWidgetItem(images, QStringList() << clip->fileURL().path());
+                break;
+            case UNKNOWN:
+                new QTreeWidgetItem(others, QStringList() << clip->fileURL().path());
+                break;
+            default:
+                new QTreeWidgetItem(videos, QStringList() << clip->fileURL().path());
+                break;
+            }
+            count++;
+        }
         if (clip->clipType() == TEXT) {
-            QStringList images = TitleWidget::extractImageList(clip->getProperty("xmldata"));
+            QStringList imagefiles = TitleWidget::extractImageList(clip->getProperty("xmldata"));
             QStringList fonts = TitleWidget::extractFontList(clip->getProperty("xmldata"));
-            allFiles << images;
+            foreach(const QString & file, imagefiles) {
+                count++;
+                new QTreeWidgetItem(images, QStringList() << file);
+            }
             allFonts << fonts;
         } else if (clip->clipType() == PLAYLIST) {
             QStringList files = extractPlaylistUrls(clip->fileURL().path());
-            allFiles << files;
+            foreach(const QString & file, files) {
+                count++;
+                new QTreeWidgetItem(others, QStringList() << file);
+            }
         }
 
         if (clip->numReferences() == 0) {
@@ -168,12 +222,20 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
         }
     }
 #if QT_VERSION >= 0x040500
-    allFiles.removeDuplicates();
     allFonts.removeDuplicates();
 #endif
-    files_count->setText(QString::number(allFiles.count()));
-    files_list->addItems(allFiles);
+    // Hide unused categories
+    for (int i = 0; i < files_list->topLevelItemCount(); i++) {
+        if (files_list->topLevelItem(i)->childCount() == 0) {
+            files_list->topLevelItem(i)->setHidden(true);
+        }
+    }
+    files_count->setText(QString::number(count));
     fonts_list->addItems(allFonts);
+    if (allFonts.isEmpty()) {
+        fonts_list->setHidden(true);
+        label_fonts->setHidden(true);
+    }
     used_count->setText(QString::number(used));
     used_size->setText(KIO::convertSize(usedSize));
     unused_count->setText(QString::number(unused));
@@ -300,16 +362,64 @@ QStringList ProjectSettings::extractSlideshowUrls(KUrl url)
     QString path = url.directory(KUrl::AppendTrailingSlash);
     QString ext = url.path().section('.', -1);
     QDir dir(path);
-    QStringList filters;
-    filters << "*." + ext;
-    dir.setNameFilters(filters);
-    QStringList result = dir.entryList(QDir::Files);
-    for (int j = 0; j < result.count(); j++) {
-        urls.append(path + result.at(j));
+    if (url.path().contains(".all.")) {
+        // this is a mime slideshow, like *.jpeg
+        QStringList filters;
+        filters << "*." + ext;
+        dir.setNameFilters(filters);
+        QStringList result = dir.entryList(QDir::Files);
+        urls.append(path + filters.at(0) + " (" + i18n("%1 images found", result.count()) + ")");
+    } else {
+        // this is a pattern slideshow, like sequence%4d.jpg
+        QString filter = url.fileName();
+        QString ext = filter.section('.', -1);
+        filter = filter.section('%', 0, -2);
+        QString regexp = "^" + filter + "\\d+\\." + ext + "$";
+        QRegExp rx(regexp);
+        int count = 0;
+        QStringList result = dir.entryList(QDir::Files);
+        foreach(const QString & path, result) {
+            if (rx.exactMatch(path)) count++;
+        }
+        urls.append(url.path() + " (" + i18n("%1 images found", count) + ")");
     }
     return urls;
 }
 
+void ProjectSettings::slotExportToText()
+{
+    QString savePath = KFileDialog::getSaveFileName(project_folder->url(), "text/plain", this);
+    if (savePath.isEmpty()) return;
+    QString data;
+    data.append(i18n("Project folder: %1",  project_folder->url().path()) + "\n");
+    data.append(i18n("Project profile: %1",  profiles_list->currentText()) + "\n");
+    data.append(i18n("Total clips: %1 (%2 used in timeline).", files_count->text(), used_count->text()) + "\n\n");
+    for (int i = 0; i < files_list->topLevelItemCount(); i++) {
+        if (files_list->topLevelItem(i)->childCount() > 0) {
+            data.append("\n" + files_list->topLevelItem(i)->text(0) + ":\n\n");
+            for (int j = 0; j < files_list->topLevelItem(i)->childCount(); j++) {
+                data.append(files_list->topLevelItem(i)->child(j)->text(0) + "\n");
+            }
+        }
+    }
+    KTemporaryFile tmpfile;
+    if (!tmpfile.open()) {
+        kWarning() << "/////  CANNOT CREATE TMP FILE in: " << tmpfile.fileName();
+        return;
+    }
+    QFile xmlf(tmpfile.fileName());
+    xmlf.open(QIODevice::WriteOnly);
+    xmlf.write(data.toUtf8());
+    if (xmlf.error() != QFile::NoError) {
+        xmlf.close();
+        return;
+    }
+    xmlf.close();
+    KIO::NetAccess::upload(tmpfile.fileName(), savePath, 0);
+}
+
+
+
 #include "projectsettings.moc"
 
 
index ff29e0bdf20380d3932c0ae7b691fc66c19b4b02..cc64a3880f29d1bd06f747138ca4e291f9801907 100644 (file)
@@ -50,6 +50,8 @@ private slots:
     void slotUpdateFiles(bool cacheOnly = false);
     void slotClearCache();
     void slotDeleteUnused();
+    /** @brief Export project data to text file. */
+    void slotExportToText();
 
 private:
     QPushButton *m_buttonOk;
index 6f5c4e681966912cf54d620b9fac4d1e6db5aff2..76858d352ed4183ca416002c6795602c0378d8a0 100644 (file)
@@ -6,15 +6,15 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>295</width>
+    <width>291</width>
     <height>320</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Project Settings</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout_5">
-   <item row="0" column="0">
+  <layout class="QGridLayout" name="gridLayout_3">
+   <item row="0" column="0" colspan="2">
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
       <number>0</number>
          </property>
         </widget>
        </item>
-       <item row="0" column="2">
+       <item row="0" column="3">
         <widget class="QLabel" name="used_size">
          <property name="text">
           <string/>
          </property>
         </widget>
        </item>
-       <item row="1" column="2">
+       <item row="1" column="3">
         <widget class="QLabel" name="unused_size">
          <property name="text">
           <string/>
          </property>
         </widget>
        </item>
-       <item row="1" column="3">
+       <item row="1" column="4">
         <widget class="KPushButton" name="delete_unused">
          <property name="text">
           <string>Delete files</string>
          </property>
         </widget>
        </item>
-       <item row="2" column="2">
+       <item row="2" column="3">
         <widget class="QLabel" name="thumbs_size">
          <property name="text">
           <string/>
          </property>
         </widget>
        </item>
-       <item row="2" column="3">
+       <item row="2" column="4">
         <widget class="KPushButton" name="clear_cache">
          <property name="text">
           <string>Clear cache</string>
          </property>
         </widget>
        </item>
-       <item row="3" column="2" colspan="2">
-        <widget class="KListWidgetSearchLine" name="list_search">
-         <property name="clickMessage">
-          <string>Search</string>
+       <item row="5" column="0" colspan="5">
+        <widget class="QLabel" name="label_fonts">
+         <property name="text">
+          <string>Fonts</string>
          </property>
         </widget>
        </item>
-       <item row="4" column="0" colspan="4">
-        <widget class="QListWidget" name="files_list">
+       <item row="6" column="0" colspan="5">
+        <widget class="QListWidget" name="fonts_list">
          <property name="alternatingRowColors">
           <bool>true</bool>
          </property>
         </widget>
        </item>
-       <item row="5" column="0">
-        <widget class="QLabel" name="label_14">
-         <property name="text">
-          <string>Fonts</string>
+       <item row="4" column="0" colspan="5">
+        <widget class="QTreeWidget" name="files_list">
+         <property name="alternatingRowColors">
+          <bool>true</bool>
          </property>
-        </widget>
-       </item>
-       <item row="6" column="0" colspan="4">
-        <widget class="QListWidget" name="fonts_list">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
+         <property name="rootIsDecorated">
+          <bool>false</bool>
          </property>
-         <property name="alternatingRowColors">
+         <property name="itemsExpandable">
+          <bool>false</bool>
+         </property>
+         <property name="headerHidden">
           <bool>true</bool>
          </property>
+         <property name="expandsOnDoubleClick">
+          <bool>false</bool>
+         </property>
+         <column>
+          <property name="text">
+           <string notr="true">1</string>
+          </property>
+         </column>
+        </widget>
+       </item>
+       <item row="3" column="2" colspan="3">
+        <widget class="KTreeWidgetSearchLine" name="list_search"/>
+       </item>
+       <item row="7" column="0">
+        <widget class="QPushButton" name="button_export">
+         <property name="text">
+          <string>Plain text export</string>
+         </property>
         </widget>
        </item>
       </layout>
      </widget>
     </widget>
    </item>
-   <item row="1" column="0">
+   <item row="1" column="1">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
    <extends>QFrame</extends>
    <header>kurlrequester.h</header>
   </customwidget>
+  <customwidget>
+   <class>KTreeWidgetSearchLine</class>
+   <extends>KLineEdit</extends>
+   <header>ktreewidgetsearchline.h</header>
+  </customwidget>
   <customwidget>
    <class>KPushButton</class>
    <extends>QPushButton</extends>
    <extends>QComboBox</extends>
    <header>kcombobox.h</header>
   </customwidget>
-  <customwidget>
-   <class>KListWidgetSearchLine</class>
-   <extends>KLineEdit</extends>
-   <header>klistwidgetsearchline.h</header>
-  </customwidget>
  </customwidgets>
  <resources/>
  <connections>