Ticket #808: mythvideo-ignore.patch

File mythvideo-ignore.patch, 5.4 KB (added by mythtv@…, 18 years ago)

proposed patch (should be somewhat faster too)

  • mythvideo/mythvideo/videolist.h

     
    33
    44#include <qapplication.h>
    55#include <qdialog.h>
     6#include <qmap.h>
    67
    78#include <mythtv/mythwidgets.h>
    89#include <mythtv/uitypes.h>
     
    3738        void buildFsysList(bool flatlist, int parental_level);
    3839        void buildDbList(bool flatlist, int parental_level);
    3940        void buildFileList(const QString& directory);
    40         bool ignoreExtension(const QString& extension);
     41        bool ignoreExtension(const QString& extension) const;
     42
    4143        void removeUpnodes(GenericTree *parent);
    4244        void addUpnodes(GenericTree *parent);
    4345        GenericTree *addDirNode(GenericTree *where_to_add,
     
    4749
    4850        bool m_ListUnknown;
    4951        bool m_LoadMetaData;
    50         QStringList m_IgnoreList;
     52        QMap<QString,bool> m_IgnoreList;
    5153
    5254        QSqlDatabase *db;
    5355        int nitems;      // Number of real items in the tree
  • mythvideo/mythvideo/videoscan.h

     
    22#define  VIDEO_SCANNER_H
    33#include <qobject.h>
    44#include <qmap.h>
     5#include <qmap.h>
    56
    67enum VideoFileLocation
    78{
     
    2526        bool m_RemoveAll;
    2627        bool m_KeepAll;
    2728        VideoLoadedMap m_VideoFiles;
    28         QStringList m_IgnoreList;
    2929
     30        QMap<QString,bool> m_IgnoreList;
     31
    3032        void promptForRemoval(const QString& filename);
    3133        bool ignoreExtension(const QString& extension) const;
    3234        void verifyFiles();
  • mythvideo/mythvideo/videolist.cpp

     
    1717    m_LoadMetaData = gContext->GetNumSetting("VideoTreeLoadMetaData", 0);
    1818
    1919    MSqlQuery query(MSqlQuery::InitCon());
    20     QString thequery("SELECT extension FROM videotypes WHERE f_ignore = 1 ;");
     20    QString thequery("SELECT extension,f_ignore FROM videotypes;");
    2121    query.exec(thequery);
    2222
    2323    if (query.isActive() && query.size() > 0)
    2424    {
    2525        while (query.next())
    2626        {
    27             m_IgnoreList.append(query.value(0).toString());
     27            QString ext = query.value(0).toString().lower();
     28            bool ignore = query.value(1).toBool();
     29            m_IgnoreList.insert(ext, ignore);
    2830        }
    2931    }
    3032
     
    6163    }
    6264}
    6365
     66bool VideoList::ignoreExtension(const QString &extension) const
     67{
     68    QString ext = extension.lower();
     69    QMap<QString,bool>::const_iterator it = m_IgnoreList.find(ext);
     70    if (it == m_IgnoreList.end())
     71        return !m_ListUnknown;
     72    return it.data();
     73}
    6474
     75
    6576//
    6677// Build a generic tree containing the video files. You can control the
    6778// contents and the shape of the tree in de following ways:
     
    468479            continue;
    469480        }
    470481       
    471         if(!fi->isDir())
    472         {
    473             QRegExp r;
    474 
    475             r.setPattern("^" + fi->extension(false) + "$");
    476             r.setCaseSensitive(false);
    477             QStringList result = m_IgnoreList.grep(r);
    478             if ((!result.isEmpty() && (!m_ListUnknown))) {
     482        if(!fi->isDir() && ignoreExtension(fi->extension(false)))
    479483                continue;
    480             }
    481 
    482         }
    483484       
    484485        QString filename = fi->absFilePath();
    485486        if (fi->isDir())
  • mythvideo/mythvideo/videoscan.cpp

     
    1616    m_ListUnknown = gContext->GetNumSetting("VideoListUnknownFileTypes", 1);
    1717
    1818    MSqlQuery query(MSqlQuery::InitCon());
    19     QString thequery("SELECT extension FROM videotypes WHERE f_ignore = 1 ;");
     19    QString thequery("SELECT extension,f_ignore FROM videotypes;");
    2020    query.exec(thequery);
    2121
    2222    if (query.isActive() && query.size() > 0)
    2323    {
    2424        while (query.next())
    2525        {
    26             m_IgnoreList.append(query.value(0).toString());
     26            QString ext = query.value(0).toString().lower();
     27            bool ignore = query.value(1).toBool();
     28            m_IgnoreList.insert(ext, ignore);
    2729        }
    2830    }
    2931
    30 
    3132}
    3233
    3334void VideoScanner::doScan(const QString& videoDirs)
     
    163164    progressDlg.Close();
    164165}
    165166 
     167bool VideoScanner::ignoreExtension(const QString &extension) const
     168{
     169    QString ext = extension.lower();
     170    QMap<QString,bool>::const_iterator it = m_IgnoreList.find(ext);
     171    if (it == m_IgnoreList.end())
     172        return !m_ListUnknown;
     173    return it.data();
     174}
    166175
    167 
    168176void VideoScanner::buildFileList(const QString &directory,
    169177                                 const QStringList &imageExtensions)
    170178{
     
    193201        {
    194202            continue;
    195203        }
    196        
    197         if(!fi->isDir())
    198         {
    199             r.setPattern("^" + fi->extension(false) + "$");
    200             r.setCaseSensitive(false);
    201             QStringList result = m_IgnoreList.grep(r);
    202             if ((!result.isEmpty() && (!m_ListUnknown))) {
     204
     205        if(!fi->isDir() && ignoreExtension(fi->extension(false)))
    203206                continue;
    204             }
    205         }
    206207       
    207208        QString filename = fi->absFilePath();
    208209        if (fi->isDir())