]> Some of my projects - aniplayer-old.git/commitdiff
- Add ability to limit automark file to specific paths.
authorAPTX <APTX@.(none)>
Sun, 30 Aug 2009 11:15:08 +0000 (13:15 +0200)
committerAPTX <APTX@.(none)>
Sun, 30 Aug 2009 11:15:08 +0000 (13:15 +0200)
src/anidbconfigdialog.cpp
src/anidbconfigdialog.h
src/anidbconfigdialog.ui
src/videowindow.cpp
src/videowindow.h

index 5a6050bf1c98bf5cac3771332acc2b48b9b04d08..7a2027affbbd5f3da7e95a4cd5c5bac19b11af2c 100644 (file)
@@ -1,6 +1,8 @@
 #include "anidbconfigdialog.h"
 #include "ui_anidbconfigdialog.h"
 
+#include <QDir>
+
 AniDBConfigDialog::AniDBConfigDialog(QWidget *parent) :
     QDialog(parent),
     m_ui(new Ui::AniDBConfigDialog)
@@ -67,6 +69,16 @@ void AniDBConfigDialog::setAutomark(int percent)
        m_ui->automark->setValue(percent);
 }
 
+QStringList AniDBConfigDialog::paths() const
+{
+       return QDir::fromNativeSeparators(m_ui->paths->text()).split(';');
+}
+
+void AniDBConfigDialog::setPaths(const QStringList &paths)
+{
+       m_ui->paths->setText(QDir::toNativeSeparators(paths.join(";")));
+}
+
 AniDBConfigDialog::~AniDBConfigDialog()
 {
     delete m_ui;
index b94504d2cceb6eb149597713bb95bc3b1e71c2bc..078e6b9a7bf0b237ea2cae066a5c5451f5c46ea6 100644 (file)
@@ -32,6 +32,9 @@ public:
        int automark() const;
        void setAutomark(int percent);
 
+       QStringList paths() const;
+       void setPaths(const QStringList &paths);
+
 protected:
     virtual void changeEvent(QEvent *e);
 
index 9ad4cc24f271d10ee9bb3d700f9bf031a1972c51..fecdc235950bdd3fa757bd74e6824de2f244a87c 100644 (file)
@@ -25,6 +25,9 @@
         <property name="text">
          <string>Host:</string>
         </property>
+        <property name="buddy">
+         <cstring>host</cstring>
+        </property>
        </widget>
       </item>
       <item row="0" column="1">
@@ -35,6 +38,9 @@
         <property name="text">
          <string>Port:</string>
         </property>
+        <property name="buddy">
+         <cstring>hostPort</cstring>
+        </property>
        </widget>
       </item>
       <item row="1" column="1">
@@ -55,6 +61,9 @@
         <property name="text">
          <string>Local Port:</string>
         </property>
+        <property name="buddy">
+         <cstring>localPort</cstring>
+        </property>
        </widget>
       </item>
       <item row="2" column="1">
@@ -75,6 +84,9 @@
         <property name="text">
          <string>User:</string>
         </property>
+        <property name="buddy">
+         <cstring>user</cstring>
+        </property>
        </widget>
       </item>
       <item row="3" column="1">
@@ -85,6 +97,9 @@
         <property name="text">
          <string>Password:</string>
         </property>
+        <property name="buddy">
+         <cstring>pass</cstring>
+        </property>
        </widget>
       </item>
       <item row="4" column="1">
         <property name="text">
          <string>Automark on:</string>
         </property>
+        <property name="buddy">
+         <cstring>automark</cstring>
+        </property>
        </widget>
       </item>
       <item row="5" column="1">
         </property>
        </widget>
       </item>
+      <item row="6" column="1">
+       <widget class="QLineEdit" name="paths"/>
+      </item>
+      <item row="6" column="0">
+       <widget class="QLabel" name="lPaths">
+        <property name="text">
+         <string>Paths:</string>
+        </property>
+        <property name="buddy">
+         <cstring>paths</cstring>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
+     <x>257</x>
+     <y>290</y>
     </hint>
     <hint type="destinationlabel">
      <x>157</x>
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
+     <x>325</x>
+     <y>290</y>
     </hint>
     <hint type="destinationlabel">
      <x>286</x>
index 64bf8f45c5736643c62de7c0f557d40c4d53c2b6..8e0cbdbeba5b941cf73e1a18f419e79c66a2c78d 100644 (file)
@@ -248,10 +248,6 @@ void VideoWindow::open(const QString &file, bool closeOnStop)
                return;
        }
 
-       AniDBUdpClient::Hash *h = new AniDBUdpClient::Hash(this);
-       h->hashFile(fileInfo);
-
-
        playlist->setDirectory(fileInfo.absoluteDir());
        playlist->setCurrent(playlist->indexOfFile(file));
 
@@ -260,6 +256,10 @@ void VideoWindow::open(const QString &file, bool closeOnStop)
        Phonon::MediaSource mediaSource(file);
        videoPlayer->open(mediaSource);
 
+#ifndef NO_ANIDBUDPCLIENT
+       updateAutomarkable();
+#endif
+
        m_closeOnStop = closeOnStop;
 }
 
@@ -407,7 +407,7 @@ void VideoWindow::tick(qint64 time)
        menu->tick(time);
 
 #ifndef NO_ANIDBUDPCLIENT
-       if (!m_automark || m_marked)
+       if (!m_automarkable || !m_automark || m_marked)
                return;
 
        int percentPlayed = int(double(time) / double(videoPlayer->totalTime()) * double(100));
@@ -571,6 +571,7 @@ void VideoWindow::anidbSettings()
        dialog.setUser(anidb->user());
        dialog.setPass(anidb->pass());
        dialog.setAutomark(m_automark);
+       dialog.setPaths(m_automarkPaths);
 
        if (!dialog.exec())
        {
@@ -585,6 +586,32 @@ void VideoWindow::anidbSettings()
        anidb->setUser(dialog.user());
        anidb->setPass(dialog.pass());
        m_automark = dialog.automark();
+       m_automarkPaths = dialog.paths();
+
+       updateAutomarkable();
+}
+
+void VideoWindow::updateAutomarkable()
+{
+       if (m_automarkPaths.isEmpty())
+       {
+               m_automarkable = true;
+       }
+       else
+       {
+               m_automarkable = false;
+               QString absoluteFilePath = QFileInfo(videoPlayer->currentFile()).absoluteFilePath();
+qDebug() << "FULL" << absoluteFilePath;
+               foreach (const QString &p, m_automarkPaths)
+               {
+qDebug() << "PART" << p;
+                       if (absoluteFilePath.startsWith(p, Qt::CaseSensitive))
+                       {
+                               m_automarkable = true;
+                               break;
+                       }
+               }
+       }
 }
 #endif
 
@@ -653,6 +680,7 @@ void VideoWindow::saveSettings()
                settings.setValue("user", anidb->user());
                settings.setValue("pass", anidb->pass());
                settings.setValue("automark", m_automark);
+               settings.setValue("paths", m_automarkPaths);
        settings.endGroup();
 #  endif
 #endif
@@ -686,6 +714,7 @@ void VideoWindow::loadSettings()
                anidb->setUser(settings.value("user").toString());
                anidb->setPass(settings.value("pass").toString());
                m_automark = settings.value("automark", 0).toInt();
+               m_automarkPaths = settings.value("paths", QStringList()).toStringList();
        settings.endGroup();
 #  endif
 #endif
index 95482fe4a7c2d011f58e6a0bc72b52e334f575c0..754ae4e717c61928f312a953f3ee32d7ff4b3e14 100644 (file)
@@ -102,6 +102,8 @@ private slots:
        void showMarkResult(bool success);
 
        void anidbSettings();
+       void updateAutomarkable();
+
 #endif
 private:
        void addAction(const QString &name, const QString &text, const QKeySequence &shortcut = QKeySequence(), bool checkable = false);
@@ -145,7 +147,9 @@ private:
 
 #ifndef NO_ANIDBUDPCLIENT
        int m_automark;
+       QStringList m_automarkPaths;
        bool m_marked;
+       bool m_automarkable;
        AniDBUdpClient::Client *anidb;
        AniDBUdpClient::MylistAddCommand *addCommand;
 #endif