Ticket #6128: mythmusic-qt4-v2.patch

File mythmusic-qt4-v2.patch, 171.2 KB (added by danielk, 12 years ago)

partial port

  • mythplugins/mythmusic/mythmusic/playbackbox.cpp

     
    66using namespace std;
    77
    88// Qt includes
    9 #include <qapplication.h>
    10 #include <qregexp.h>
    11 //Added by qt3to4:
     9#include <QApplication>
    1210#include <QLabel>
    1311#include <QPixmap>
     12
     13#include <Q3Frame>
    1414#include <Q3ValueList>
    15 #include <QKeyEvent>
    16 #include <Q3Frame>
    17 #include <Q3PtrList>
    1815
    1916// MythTV plugin includes
    2017#include <mythtv/mythcontext.h>
     
    3330#include "databasebox.h"
    3431#include "mainvisual.h"
    3532#include "smartplaylist.h"
     33#include "playlistcontainer.h"
    3634#include "search.h"
    3735
    3836#ifndef USING_MINGW
     
    108106    {
    109107        volume_control = true;
    110108    }
    111     volume_display_timer->start(2000, true);
     109    volume_display_timer->setSingleShot(true);
     110    volume_display_timer->start(2000);
    112111    connect(volume_display_timer, SIGNAL(timeout()),
    113112            this, SLOT(hideVolume()));
    114113
     
    160159    waiting_for_playlists_timer = new QTimer(this);
    161160    connect(waiting_for_playlists_timer, SIGNAL(timeout()), this,
    162161            SLOT(checkForPlaylists()));
    163     waiting_for_playlists_timer->start(50, TRUE);
     162    waiting_for_playlists_timer->setSingleShot(true);
     163    waiting_for_playlists_timer->start(50);
    164164
    165165    // Warm up the visualizer
    166166
     
    175175
    176176    fullscreen_blank = false;
    177177
    178     visual_modes = QStringList::split(';', gContext->GetSetting("VisualMode"));
     178    visual_modes = gContext->GetSetting("VisualMode")
     179        .split(';', QString::SkipEmptyParts);
     180
    179181    if (!visual_modes.count())
    180182        visual_modes.push_front("Blank");
    181183
     
    491493                    resetScrollCount();
    492494
    493495                speed_scroll_timer->stop();
    494                 speed_scroll_timer->start(300, true);
     496                speed_scroll_timer->setSingleShot(true);
     497                speed_scroll_timer->start(300);
    495498
    496499            }
    497500            else if (action == "DOWN")
     
    512515                    resetScrollCount();
    513516
    514517                speed_scroll_timer->stop();
    515                 speed_scroll_timer->start(300, true);
     518                speed_scroll_timer->setSingleShot(true);
     519                speed_scroll_timer->start(300);
    516520            }
    517521            else if (action == "LEFT")
    518522                music_tree_list->popUp();
     
    956960
    957961void PlaybackBoxMusic::occasionallyCheckCD()
    958962{
    959     if (cd_reader_thread->getLock()->locked())
     963    if (!cd_reader_thread->getLock()->tryLock())
    960964        return;
     965    cd_reader_thread->getLock()->unlock();
    961966
    962967    if (!scan_for_cd)
    963968    {
     
    11601165        }
    11611166    }
    11621167
    1163     waiting_for_playlists_timer->start(100, TRUE); // Restart Timer
     1168    waiting_for_playlists_timer->setSingleShot(true);
     1169    waiting_for_playlists_timer->start(100); // Restart Timer
    11641170}
    11651171
    11661172void PlaybackBoxMusic::changeVolume(bool up_or_down)
     
    12231229                volume_status->SetUsed(gPlayer->getOutput()->GetCurrentVolume());
    12241230                volume_status->SetOrder(0);
    12251231                volume_status->refresh();
    1226                 volume_display_timer->start(2000, true);
     1232                volume_display_timer->setSingleShot(true);
     1233                volume_display_timer->start(2000);
    12271234                if (class LCD *lcd = LCD::Get())
    12281235                    lcd->switchToVolume("Music");
    12291236
     
    12661273            speed_status->SetText(speed_text);
    12671274            speed_status->SetOrder(0);
    12681275            speed_status->refresh();
    1269             volume_display_timer->start(2000, true);
     1276            volume_display_timer->setSingleShot(true);
     1277            volume_display_timer->start(2000);
    12701278        }
    12711279    }
    12721280
     
    12861294void PlaybackBoxMusic::resetTimer()
    12871295{
    12881296    if (visual_mode_delay > 0)
    1289         visual_mode_timer->changeInterval(visual_mode_delay * 1000);
     1297        visual_mode_timer->start(visual_mode_delay * 1000);
    12901298}
    12911299
    12921300void PlaybackBoxMusic::play()
     
    15261534        gPlayer->getOutput()->Reset();
    15271535        gPlayer->getOutput()->SetTimecode(pos*1000);
    15281536
    1529         if (gPlayer->getDecoder() && gPlayer->getDecoder()->running())
     1537        if (gPlayer->getDecoder() && gPlayer->getDecoder()->isRunning())
    15301538        {
    15311539            gPlayer->getDecoder()->lock();
    15321540            gPlayer->getDecoder()->seek(pos);
     
    17401748
    17411749    if (position != "")
    17421750    {
    1743         QStringList list = QStringList::split(",", position);
     1751        QStringList list = position.split(",", QString::SkipEmptyParts);
    17441752
    17451753        for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
    17461754            branches_to_current_node.append((*it).toInt());
     
    18551863    }
    18561864
    18571865    visual_mode_timer->stop();
    1858     DatabaseBox dbbox(gContext->GetMainWindow(), m_CDdevice,
    1859                       "music_select", "music-", "database box");
     1866    DatabaseBox *dbbox = new DatabaseBox(
     1867        gContext->GetMainWindow(), m_CDdevice,
     1868        "music_select", "music-", "database box");
    18601869
    18611870    if (cd_watcher)
    18621871        cd_watcher->stop();
    18631872
    1864     dbbox.exec();
     1873    dbbox->exec();
    18651874    if (visual_mode_delay > 0)
    18661875        visual_mode_timer->start(visual_mode_delay * 1000);
    18671876
     
    18881897
    18891898    if (scan_for_cd && cd_watcher)
    18901899        cd_watcher->start(1000);
     1900
     1901    dbbox->deleteLater();
    18911902}
    18921903
    18931904void PlaybackBoxMusic::customEvent(QEvent *event)
  • mythplugins/mythmusic/mythmusic/mythmusic.pro

     
    33include ( ../../programs-libs.pro )
    44include (config.pro)
    55
     6QT += xml sql opengl qt3support network
     7
    68!exists( config.pro ) {
    79   error(Missing config.pro: please run the configure script)
    810}
     
    3537HEADERS += editmetadata.h smartplaylist.h search.h genres.h
    3638HEADERS += treebuilders.h importmusic.h directoryfinder.h
    3739HEADERS += filescanner.h libvisualplugin.h musicplayer.h miniplayer.h
     40HEADERS += playlistcontainer.h
    3841HEADERS += mythlistview-qt3.h mythlistbox-qt3.h
    3942
    4043SOURCES += cddecoder.cpp cdrip.cpp decoder.cpp
     
    5255SOURCES += avfdecoder.cpp editmetadata.cpp smartplaylist.cpp search.cpp
    5356SOURCES += treebuilders.cpp importmusic.cpp directoryfinder.cpp
    5457SOURCES += filescanner.cpp libvisualplugin.cpp musicplayer.cpp miniplayer.cpp
     58SOURCES += playlistcontainer.cpp
    5559SOURCES += mythlistview-qt3.cpp mythlistbox-qt3.cpp
    5660
    5761macx {
     
    6973    LIBS += -logg
    7074}
    7175
    72 
    73 #The following line was inserted by qt3to4
    74 QT += xml  sql opengl qt3support
    75 
    7676include ( ../../libs-targetfix.pro )
  • mythplugins/mythmusic/mythmusic/search.cpp

     
    257257
    258258    while (index < (int) sText.length())
    259259    {
    260         start = sText.find('[', index);
    261         end = sText.find(']', start);
     260        start = sText.indexOf('[', index);
     261        end = sText.indexOf(']', start);
    262262
    263263        if (start != -1 && end != -1)
    264264        {
  • mythplugins/mythmusic/mythmusic/playlist.h

     
    11#ifndef PLAYLIST_H_
    22#define PLAYLIST_H_
    33
    4 #include <q3valuelist.h>
    5 #include <q3listview.h>
    6 #include <q3ptrlist.h>
    7 #include <qthread.h>
     4#include <vector>
     5#include <list>
     6using namespace std;
    87
     8#include <QList>
     9
    910#include "metadata.h"
    1011#include "treecheckitem.h"
    1112#include <mythtv/uitypes.h>
    1213#include <mythtv/uilistbtntype.h>
    1314
    14 class PlaylistsContainer;
     15class PlaylistContainer;
    1516
    1617
    1718enum InsertPLOption
     
    3031    PL_CURRENT
    3132};
    3233
     34typedef enum TrackTypes
     35{
     36    kTrackCD,
     37    kTrackPlaylist,
     38    kTrackSong,
     39    kTrackUnknown,
     40} TrackType;
     41
    3342class Track
    3443{
    3544    //  Why isn't this class just Metadata?
     
    4049  public:
    4150    Track(int x, AllMusic *all_music_ptr);
    4251
    43     void postLoad(PlaylistsContainer *grandparent);
     52    void postLoad(PlaylistContainer *grandparent);
    4453
    4554    void setParent(Playlist *parent_ptr);
    4655    void setValue(int x){index_value = x;}
     
    5867    void setCDFlag(bool yes_or_no) { cd_flag = yes_or_no; }
    5968    bool getCDFlag(void) { return cd_flag; }
    6069
     70    TrackType GetTrackType(void) const;
     71
    6172  private:   
    6273    int           index_value;
    6374    PlaylistTrack *my_widget;
     
    7485    Playlist(AllMusic *all_music_ptr);
    7586    ~Playlist();
    7687
    77     Playlist& operator=(const Playlist& rhs);
     88    //Playlist& operator=(const Playlist& rhs);
    7889
    79     void setParent(PlaylistsContainer *myparent) { parent = myparent; }
     90    void setParent(PlaylistContainer *myparent) { parent = myparent; }
    8091
    8192    void postLoad(void);
    8293
     
    89100
    90101    int writeTree(GenericTree *tree_to_write_to, int a_counter);
    91102
    92     void describeYourself(void); //  debugging
     103    void describeYourself(void) const; //  debugging
    93104
    94105    void fillSongsFromCD();
    95106    void fillSongsFromSonglist(bool filter);
     
    107118
    108119    void moveTrackUpDown(bool flag, Track *the_track);
    109120
    110     bool checkTrack(int a_track_id, bool cd_flag);
     121    bool checkTrack(int a_track_id, bool cd_flag) const;
    111122
    112123    void addTrack(int the_track_id, bool update_display, bool cd_flag);
    113124
     
    115126    void removeAllTracks(void);
    116127    void removeAllWidgets(void);
    117128   
    118     void copyTracks(Playlist *to_ptr, bool update_display);
     129    void copyTracks(Playlist *to_ptr, bool update_display) const;
    119130
    120131    bool hasChanged(void) { return changed; }
    121132    void Changed(void) { changed = true; }
     
    124135    void    setName(QString a_name) { name = a_name; }
    125136
    126137    int     getID(void) { return playlistid; }
    127     int     getFirstTrackID(void);
     138    int     getFirstTrackID(void) const;
    128139    void    setID(int x) { playlistid = x; }
    129140
    130141    bool    containsReference(int to_check, int depth);
     
    139150    int                 playlistid;
    140151    QString             name;
    141152    QString             raw_songlist;
    142     Q3PtrList<Track>     songs;
    143     AllMusic            *all_available_music;
    144     PlaylistsContainer  *parent;
     153    typedef QList<Track*> SongList;
     154    SongList            songs;
     155    AllMusic           *all_available_music;
     156    PlaylistContainer  *parent;
    145157    bool                changed;
    146158};
    147159
    148 class PlaylistLoadingThread : public QThread
    149 {
    150   public:
    151     PlaylistLoadingThread(PlaylistsContainer *parent_ptr,
    152                           AllMusic *all_music_ptr);
    153     virtual void run();
    154    
    155   private: 
    156     PlaylistsContainer* parent;
    157     AllMusic*           all_music;
    158 };
    159 
    160 class PlaylistsContainer
    161 {
    162   public:
    163     PlaylistsContainer(AllMusic *all_music, QString host_name);
    164    ~PlaylistsContainer();
    165 
    166     void            load();
    167     void            describeYourself();    // debugging
    168 
    169     Playlist*       getActive(void) { return active_playlist; }
    170     Playlist*       getPlaylist(int id);
    171 
    172     void            setActiveWidget(PlaylistTitle *widget);
    173     PlaylistTitle*  getActiveWidget(void) { return active_widget; }
    174 
    175     GenericTree*    writeTree(GenericTree *tree_to_write_to);
    176     void            clearCDList();
    177     void            addCDTrack(int x);
    178     void            removeCDTrack(int x);
    179     bool            checkCDTrack(int x);
    180     void            save();
    181 
    182     void            createNewPlaylist(QString name);
    183     void            copyNewPlaylist(QString name);
    184     void            copyToActive(int index);
    185 
    186     void            showRelevantPlaylists(TreeCheckItem *alllist);
    187     void            refreshRelevantPlaylists(TreeCheckItem *alllist);
    188 
    189     QString         getPlaylistName(int index, bool &reference);
    190 
    191     void            postLoad();
    192 
    193     void            deletePlaylist(int index);
    194     void            renamePlaylist(int index, QString new_name);
    195 
    196     void            popBackPlaylist();
    197     bool            pendingWriteback();
    198     void            setPending(int x){pending_writeback_index = x;}
    199     int             getPending(){return pending_writeback_index;}
    200 
    201     bool            nameIsUnique(QString a_name, int which_id);
    202 
    203     void            clearActive();
    204 
    205     bool            doneLoading(){return done_loading;}
    206 
    207     bool            cleanOutThreads();
    208 
    209     void            FillIntelliWeights(int &rating, int &playcount,
    210                                        int &lastplay, int &random);
    211   private: 
    212     Playlist            *active_playlist;
    213     Playlist            *backup_playlist;
    214     Q3ValueList<int>     cd_playlist;
    215     Q3PtrList<Playlist>  *all_other_playlists;
    216     AllMusic            *all_available_music;
    217     PlaylistTitle       *active_widget;
    218     int                 pending_writeback_index;
    219    
    220     PlaylistLoadingThread  *playlists_loader;
    221     bool                    done_loading;
    222     QString                 my_host;
    223 
    224     int RatingWeight;
    225     int PlayCountWeight;
    226     int LastPlayWeight;
    227     int RandomWeight;
    228 };
    229 
    230160#endif
  • mythplugins/mythmusic/mythmusic/miniplayer.cpp

     
    1 #include <iostream>
    2 //Added by qt3to4:
     1// qt
    32#include <QKeyEvent>
    4 #include <Q3PtrList>
    5 #include <Q3Frame>
    6 using namespace std;
     3#include <QPixmap>
     4#include <QImage>
    75
    8 // qt
    9 #include <qpixmap.h>
    10 #include <qimage.h>
    11 #include <qapplication.h>
    12 
    136// mythtv
    147#include <mythtv/mythcontext.h>
    158#include <mythtv/mythdialogs.h>
     
    2720                    bool setsize)
    2821            : MythThemedDialog(parent, name, setsize)
    2922{
    30     setFrameStyle(Q3Frame::NoFrame | Q3Frame::Plain);
     23    setFrameStyle(QFrame::Panel);
    3124    setLineWidth(1);
    3225    m_parentPlayer = parentPlayer;
    3326
     
    6659{
    6760    gPlayer->setListener(NULL);
    6861
    69     m_displayTimer->deleteLater();
     62    // Timers are deleted by Qt
     63    m_displayTimer->disconnect();
    7064    m_displayTimer = NULL;
    7165
    72     m_infoTimer->deleteLater();
     66    m_displayTimer->disconnect();
    7367    m_infoTimer = NULL;
    7468
    7569    if (class LCD *lcd = LCD::Get())
     
    255249                        else
    256250                            m_infoText->SetText(tr("Mute: Off"));
    257251
    258                         m_infoTimer->start(5000, true);
     252                        m_infoTimer->setSingleShot(true);
     253                        m_infoTimer->start(5000);
    259254                    }
    260255
    261256                    if (m_volText)
     
    507502        gPlayer->getOutput()->Reset();
    508503        gPlayer->getOutput()->SetTimecode(pos*1000);
    509504
    510         if (gPlayer->getDecoder() && gPlayer->getDecoder()->running())
     505        if (gPlayer->getDecoder() && gPlayer->getDecoder()->isRunning())
    511506        {
    512507            gPlayer->getDecoder()->lock();
    513508            gPlayer->getDecoder()->seek(pos);
  • mythplugins/mythmusic/mythmusic/decoder.h

     
    55#include <qstring.h>
    66#include <qevent.h>
    77#include <qthread.h>
    8 #include <q3ptrlist.h>
    98#include <qwaitcondition.h>
    109#include <qmutex.h>
    1110
     
    7271    virtual void lock(void) { return mtx.lock(); }
    7372    virtual void unlock(void) { return mtx.unlock(); }
    7473    virtual bool tryLock(void) { return mtx.tryLock(); }
    75     virtual bool locked(void) { return mtx.locked(); }
     74    //virtual bool locked(void) { return mtx.locked(); }
    7675
    7776    QWaitCondition *cond() { return &cnd; }
    7877
  • mythplugins/mythmusic/mythmusic/streaminput.cpp

     
    66
    77#include "streaminput.h"
    88
    9 #include "mythtv/mythcontext.h"
     9#include "mythverbose.h"
    1010
    11 #include <qapplication.h>
    12 #include <q3socket.h>
     11#include <QApplication>
    1312
     13#define LOC      QString("StreamInput: ")
     14#define LOC_WARN QString("StreamInput, Warning: ")
     15#define LOC_ERR  QString("StreamInput, Error: ")
    1416
    15 StreamInput::StreamInput(const Q3Url &source)
    16     : request(0), url(source), sock(0), stage(0)
     17StreamInput::StreamInput(const QUrl &source) :
     18    request(QString::null), url(source), sock(NULL), stage(0)
    1719{
    1820}
    1921
    20 
    21 void StreamInput::setup()
     22void StreamInput::Setup(void)
    2223{
    23     if (! url.isValid())
     24    if (!url.isValid())
    2425        return;
    2526
    26     QString protocol = url.protocol();
     27    QString protocol = url.scheme();
    2728    QString host = url.host();
    2829    QString path = url.path();
    2930    int port = url.port();
     
    3132    if (protocol != "mqp" || host.isNull())
    3233        return;
    3334
    34     if (port == -1)
    35         port = 42666;
     35    port = (port < 0) ? 42666 : port;
    3636
    37     request = ".song " + QString(path.toUtf8()) + "\r\n";
     37    request = path;
     38    request.detach();
    3839
     40    sock = new QTcpSocket();
     41    connect(sock, SIGNAL(Error(QAbstractSocket::SocketError)),
     42            this, SLOT(  Error(QAbstractSocket::SocketError)));
     43    connect(sock, SIGNAL(hostFound()), this, SLOT(HostFound()));
     44    connect(sock, SIGNAL(connected()), this, SLOT(Connected()));
     45    connect(sock, SIGNAL(readyRead()), this, SLOT(Readyread()));
    3946
    40     sock = new Q3Socket;
    41     connect(sock, SIGNAL(error(int)), this, SLOT(error(int)));
    42     connect(sock, SIGNAL(hostFound()), this, SLOT(hostfound()));
    43     connect(sock, SIGNAL(connected()), this, SLOT(connected()));
    44     connect(sock, SIGNAL(readyRead()), this, SLOT(readyread()));
     47    sock->connectToHost(host, port, QIODevice::ReadWrite);
    4548
    46     sock->connectToHost(host, port);
    47 
    4849    while (stage != -1 && stage < 4)
    4950    {
    50         qDebug("processing one event: stage %d %d %ld",
    51                stage, sock->canReadLine(), (long int)sock->bytesAvailable());
    52         qApp->processOneEvent();
     51        VERBOSE(VB_GENERAL, LOC +
     52                QString("Processing one event: stage %1 %2 %3")
     53                .arg(stage).arg(sock->canReadLine())
     54                .arg(sock->bytesAvailable()));
     55
     56        qApp->processEvents();
    5357    }
    5458
    55     qDebug("disconnecting from socket");
    56     disconnect(sock, SIGNAL(error(int)), this, SLOT(error(int)));
    57     disconnect(sock, SIGNAL(hostFound()), this, SLOT(hostfound()));
    58     disconnect(sock, SIGNAL(connected()), this, SLOT(connected()));
    59     disconnect(sock, SIGNAL(readyRead()), this, SLOT(readyread()));
     59    VERBOSE(VB_GENERAL, LOC + "Disconnecting from socket");
     60    disconnect(sock, SIGNAL(Error(QAbstractSocket::SocketError)),
     61               this, SLOT(  Error(QAbstractSocket::SocketError)));
     62    disconnect(sock, SIGNAL(hostFound()), this, SLOT(HostFound()));
     63    disconnect(sock, SIGNAL(connected()), this, SLOT(Connected()));
     64    disconnect(sock, SIGNAL(readyRead()), this, SLOT(ReadyRead()));
    6065
    6166    if (stage == -1)
    6267    {
    6368        // some sort of error
    6469        delete sock;
    65         sock = 0;
     70        sock = NULL;
    6671    }
    6772}
    6873
    6974
    70 void StreamInput::hostfound()
     75void StreamInput::HostFound(void)
    7176{
    72     qDebug("host found");
     77    VERBOSE(VB_GENERAL, LOC + "Host found");
    7378    stage = 1;
    7479}
    7580
    7681
    77 void StreamInput::connected()
     82void StreamInput::Connected(void)
    7883{
    79     qDebug("connected... sending request '%s' %d", request.data(), request.length());
     84    QString tmp = QString(".song %1\r\n").arg(QString(request.toUtf8()));
     85    QByteArray ba = tmp.toAscii();
    8086
    81     sock->writeBlock(request.data(), request.length());
     87    VERBOSE(VB_GENERAL, LOC +
     88            QString("Connected... sending request '%1' %2")
     89            .arg(ba.constData()).arg(ba.length()));
     90
     91    sock->write(ba.constData(), ba.length());
    8292    sock->flush();
    8393
    8494    stage = 2;
    8595}
    8696
    8797
    88 void StreamInput::readyread()
     98void StreamInput::ReadyRead(void)
    8999{
    90100    if (stage == 2)
    91101    {
    92         qDebug("readyread... checking response");
     102        VERBOSE(VB_GENERAL, LOC + "ReadyRead... checking response");
    93103       
    94104        if (! sock->canReadLine())
    95105        {
    96106            stage = -1;
    97             qDebug("can't read line");
     107            VERBOSE(VB_IMPORTANT, LOC_ERR + "ReadyRead... can't read line");
    98108            return;
    99109        }
    100110       
     
    102112        if (line.isEmpty())
    103113        {
    104114            stage = -1;
    105             qDebug("line is empty");
     115            VERBOSE(VB_IMPORTANT, LOC_ERR + "ReadyRead... line is empty");
    106116            return;
    107117        }
    108118
    109119        if (line.left(5) != "*GOOD")
    110120        {
    111             VERBOSE(VB_IMPORTANT, QString("server error response: %1")
    112                     .arg(line));
     121            VERBOSE(VB_IMPORTANT, LOC_ERR +
     122                    QString("Server error response: %1").arg(line));
    113123            stage = -1;
    114124            return;
    115125        }
     
    122132    }
    123133}
    124134
    125 
    126 void StreamInput::error(int err)
     135void StreamInput::Error(QAbstractSocket::SocketError)
    127136{
    128     qDebug("socket error: %d", err);
     137    VERBOSE(VB_IMPORTANT, LOC_ERR +
     138            QString("Socket error: %1").arg(sock->errorString()));
    129139
    130140    stage = -1;
    131141}
  • mythplugins/mythmusic/mythmusic/visualize.cpp

     
    1818#include <qpixmap.h>
    1919#include <qimage.h>
    2020#include <qdir.h>
    21 #include <q3url.h>
    2221
    2322// mythtv
    2423#include <mythtv/mythdbcon.h>
     
    108107    scale.setMax(192, size.width() / analyzerBarWidth);
    109108
    110109    rects.resize( scale.range() );
    111     int i = 0, w = 0;
    112     for (; (unsigned) i < rects.count(); i++, w += analyzerBarWidth)
     110    unsigned int i = 0;
     111    int w = 0;
     112    for (; i < rects.size(); i++, w += analyzerBarWidth)
    113113    {
    114114        rects[i].setRect(w, size.height() / 2, analyzerBarWidth - 1, 1);
    115115    }
    116116
    117     int os = magnitudes.size();
     117    unsigned int os = magnitudes.size();
    118118    magnitudes.resize( scale.range() * 2 );
    119     for (; (unsigned) os < magnitudes.size(); os++)
     119    for (; os < magnitudes.size(); os++)
    120120    {
    121121        magnitudes[os] = 0.0;
    122122    }
     
    161161#endif
    162162
    163163    index = 1;
    164     for (i = 0; i < rects.count(); i++, w += analyzerBarWidth)
     164    for (i = 0; i < rects.size(); i++, w += analyzerBarWidth)
    165165    {       
    166166#ifdef FFTW3_SUPPORT
    167167        magL = (log(sq(real(lout[index])) + sq(real(lout[FFTW_N - index]))) - 22.0) *
     
    252252    double r, g, b, per;
    253253
    254254    p->fillRect(0, 0, size.width(), size.height(), back);
    255     for (uint i = 0; i < rects.count(); i++)
     255    for (uint i = 0; i < rects.size(); i++)
    256256    {
    257257        per = double( rectsp[i].height() - 2 ) / double( size.height() );
    258258
     
    324324{
    325325    // if a front cover image is available show that first
    326326    AlbumArtImages albumArt(m_pParent->metadata());
    327     if (albumArt.isImageAvailable(IT_FRONTCOVER))
     327    if (albumArt.getImage(IT_FRONTCOVER))
    328328        m_currImageType = IT_FRONTCOVER;
    329329    else
    330330    {
    331331        // not available so just show the first image available
    332332        if (albumArt.getImageCount() > 0)
    333             m_currImageType = albumArt.getImageAt(0).imageType;
     333            m_currImageType = albumArt.getImageAt(0)->imageType;
    334334        else
    335335            m_currImageType = IT_UNKNOWN;
    336336    }
     
    362362        {
    363363            newType++;
    364364
    365             while(!albumArt.isImageAvailable((ImageType) newType))
     365            while (!albumArt.getImage((ImageType) newType))
    366366            {
    367367                newType++;
    368368                if (newType == IT_LAST)
     
    568568
    569569#if defined(FFTW3_SUPPORT) || defined(FFTW2_SUPPORT)
    570570    QRect *rectsp = rects.data();
    571     for (uint i = 0; i < rects.count(); i++)
     571    for (uint i = 0; i < rects.size(); i++)
    572572        drawRect(p, &(rectsp[i]), i, center, w, h);
    573573
    574574#else
     
    732732static GLfloat view_rotx=20.0, view_rotz=0.0;
    733733static GLint gear1, gear2, gear3;
    734734
    735 Gears::Gears(QWidget *parent, const char *name)
    736      : QGLWidget(parent, name)
     735Gears::Gears(QWidget *parent, const char *name) :
     736    QGLWidget(parent)
    737737{
     738    setObjectName(name);
    738739    falloff = 4.0;
    739740    analyzerBarWidth = 10;
    740741    fps = 60;
     
    807808
    808809    rects.resize( scale.range() );
    809810    int i = 0, w = 0;
    810     for (; (unsigned) i < rects.count(); i++, w += analyzerBarWidth)
     811    for (; (unsigned) i < rects.size(); i++, w += analyzerBarWidth)
    811812    {
    812813        rects[i].setRect(w, size.height() / 2, analyzerBarWidth - 1, 1);
    813814    }
     
    858859    rfftw_one(plan, rin, rout);
    859860#endif
    860861    index = 1;
    861     for (i = 0; i < rects.count(); i++, w += analyzerBarWidth)
     862    for (i = 0; i < rects.size(); i++, w += analyzerBarWidth)
    862863    {
    863864#ifdef FFTW3_SUPPORT
    864865        magL = (log(sq(real(lout[index])) + sq(real(lout[FFTW_N - index]))) - 22.0) *
  • mythplugins/mythmusic/mythmusic/metaioflacvorbiscomment.cpp

     
    11#include <iostream>
    22#include <sys/stat.h>
    3 //Added by qt3to4:
    4 #include <Q3CString>
    53using namespace std;
    64
    75#include "metaioflacvorbiscomment.h"
     
    298296
    299297        // we need to make sure the '=' comes immediately after
    300298        // the desired label
    301         if ((loc = entrytext.find("=")) &&
     299        if ((loc = entrytext.indexOf("=")) &&
    302300            (loc == (int)qlabel.length()) &&
    303             entrytext.lower().left(qlabel.length()) == qlabel.lower())
     301            entrytext.toLower().left(qlabel.length()) == qlabel.toLower())
    304302        {
    305303            return QString::fromUtf8(entrytext.right(entrytext.length() - loc - 1));
    306304        }
     
    328326
    329327    QString test = getComment(pBlock, pLabel);
    330328
    331     QString thenewentry = QString(pLabel).upper() + "=" + rData;
     329    QString thenewentry = QString(pLabel).toUpper() + "=" + rData;
    332330    QByteArray utf8str = thenewentry.toUtf8();
    333331
    334332    FLAC__StreamMetadata_VorbisComment_Entry entry;
  • mythplugins/mythmusic/mythmusic/mainvisual.h

     
    77#ifndef __mainvisual_h
    88#define __mainvisual_h
    99
     10#include <vector>
     11using namespace std;
     12
    1013#include <mythtv/visual.h>
    1114#include "polygon.h"
    1215#include "constants.h"
    1316
    1417#include <qwidget.h>
    1518#include <qdialog.h>
    16 #include <q3memarray.h>
    1719#include <qpixmap.h>
    1820#include <qimage.h>
    19 #include <q3ptrlist.h>
    2021#include <qstringlist.h>
    2122#include <qtimer.h>
    2223#include <QPaintEvent>
     
    136137    VisualBase *vis;
    137138    Metadata *meta;
    138139    QPixmap pixmap;
    139     Q3PtrList<VisualNode> nodes;
     140    QList<VisualNode*> nodes;
    140141    bool playing;
    141142    int fps;
    142143    QTimer *timer;
     
    176177
    177178protected:
    178179    QColor startColor, targetColor;
    179     Q3MemArray<double> magnitudes;
     180    vector<double> magnitudes;
    180181    QSize size;
    181182    bool rubberband;
    182183    double falloff;
  • mythplugins/mythmusic/mythmusic/metadata.cpp

     
    1 #include <iostream>
    2 
    31// qt
    4 #include <qapplication.h>
    5 #include <qregexp.h>
    6 #include <qdatetime.h>
    7 #include <qdir.h>
    8 //Added by qt3to4:
    9 #include <Q3ValueList>
     2#include <QApplication>
     3#include <QRegExp>
     4#include <QDateTime>
     5#include <QDir>
    106
    11 using namespace std;
    12 
    137// mythtv
    148#include <mythtv/mythcontext.h>
    159#include <mythtv/mythwidgets.h>
     
    4135    return false;
    4236}
    4337
     38static bool meta_less_than(const Metadata *item1, const Metadata *item2)
     39{
     40    return item1->compare(item2) < 0;
     41}
     42
     43static bool music_less_than(const MusicNode *itemA, const MusicNode *itemB)
     44{
     45    QString title1 = itemA->getTitle().toLower();
     46    QString title2 = itemB->getTitle().toLower();
     47   
     48    // Cut "the " off the front of titles
     49    if (title1.left(4) == thePrefix)
     50        title1 = title1.mid(4);
     51    if (title2.left(4) == thePrefix)
     52        title2 = title2.mid(4);
     53
     54    return title1.localeAwareCompare(title2) < 0;
     55}
     56
     57/**************************************************************************/
     58
    4459Metadata& Metadata::operator=(Metadata *rhs)
    4560{
    4661    m_artist = rhs->m_artist;
     
    86101        MythDB::DBError("music persist", query);
    87102}
    88103
    89 int Metadata::compare(Metadata *other)
     104int Metadata::compare(const Metadata *other) const
    90105{
    91106    if (m_format == "cast")
    92107    {
    93         int artist_cmp = Artist().lower().localeAwareCompare(other->Artist().lower());
     108        int artist_cmp = Artist().toLower().localeAwareCompare(
     109            other->Artist().toLower());
    94110
    95111        if (artist_cmp == 0)
    96             return Title().lower().localeAwareCompare(other->Title().lower());
     112            return Title().toLower().localeAwareCompare(
     113                other->Title().toLower());
    97114
    98115        return artist_cmp;
    99116    }
     
    102119        int track_cmp = Track() - other->Track();
    103120
    104121        if (track_cmp == 0)
    105             return Title().lower().localeAwareCompare(other->Title().lower());
     122            return Title().toLower().localeAwareCompare(
     123                other->Title().toLower());
    106124
    107125        return track_cmp;
    108126    }
     
    398416
    399417    if (! m_albumart.empty())
    400418    {
    401         Q3ValueList<struct AlbumArtImage>::iterator it;
     419        QList<struct AlbumArtImage>::iterator it;
    402420        for ( it = m_albumart.begin(); it != m_albumart.end(); ++it )
    403421        {
    404422            query.prepare("SELECT albumart_id FROM music_albumart WHERE "
     
    681699    m_changed = true;
    682700}
    683701
    684 void Metadata::setEmbeddedAlbumArt(Q3ValueList<struct AlbumArtImage> albumart)
     702void Metadata::setEmbeddedAlbumArt(const QList<struct AlbumArtImage> &albumart)
    685703{
    686704    m_albumart = albumart;
    687705}
     
    735753    QImage image;
    736754    ImageType type;
    737755
    738     if (albumArt.isImageAvailable(IT_FRONTCOVER))
     756    AlbumArtImage *albumart_image = NULL;
     757
     758    if ((albumart_image = albumArt.getImage(IT_FRONTCOVER)))
    739759        type = IT_FRONTCOVER;
    740     else if (albumArt.isImageAvailable(IT_UNKNOWN))
     760    else if ((albumart_image = albumArt.getImage(IT_UNKNOWN)))
    741761        type = IT_UNKNOWN;
    742     else if (albumArt.isImageAvailable(IT_BACKCOVER))
     762    else if ((albumart_image = albumArt.getImage(IT_BACKCOVER)))
    743763        type = IT_BACKCOVER;
    744     else if (albumArt.isImageAvailable(IT_INLAY))
     764    else if ((albumart_image = albumArt.getImage(IT_INLAY)))
    745765        type = IT_INLAY;
    746     else if (albumArt.isImageAvailable(IT_CD))
     766    else if ((albumart_image = albumArt.getImage(IT_CD)))
    747767        type = IT_CD;
    748     else
    749         return image;
    750768
    751     AlbumArtImage albumart_image = albumArt.getImage(type);
     769    if (albumart_image)
     770    {
     771        if (albumart_image->embedded)
     772            image = QImage(MetaIOTagLib::getAlbumArt(m_filename, type));
     773        else
     774            image = QImage(albumart_image->filename);
     775    }
    752776
    753     if (albumart_image.embedded)
    754         image = QImage(MetaIOTagLib::getAlbumArt(m_filename, type));
    755     else
    756         image = QImage(albumart_image.filename);
    757 
    758777    return image;
    759778}
    760779
     
    764783
    765784    QImage image;
    766785
    767     if (albumArt.isImageAvailable(type))
     786    AlbumArtImage *albumart_image = albumArt.getImage(type);
     787    if (albumart_image)
    768788    {
    769         AlbumArtImage albumart_image = albumArt.getImage(type);
    770 
    771         if (albumart_image.embedded)
     789        if (albumart_image->embedded)
    772790            image = QImage(MetaIOTagLib::getAlbumArt(m_filename, type));
    773791        else
    774             image = QImage(albumart_image.filename);
     792            image = QImage(albumart_image->filename);
    775793    }
    776794
    777795    return image;
     
    884902    m_metadata_loader = NULL;
    885903    startLoading();
    886904
    887     m_all_music.setAutoDelete(true);
    888 
    889905    m_last_listed = -1;
    890906}
    891907
    892908AllMusic::~AllMusic()
    893909{
    894     m_all_music.clear();
     910    while (!m_all_music.empty())
     911    {
     912        delete m_all_music.back();
     913        m_all_music.pop_back();
     914    }
    895915
    896916    delete m_root_node;
    897917
     
    10391059
    10401060    //  To find this data quickly, build a map
    10411061    //  (a map to pointers!)
    1042 
    1043     Q3PtrListIterator<Metadata> an_iterator( m_all_music );
    1044     Metadata *map_add;
    1045 
    10461062    music_map.clear();
    1047     while ( (map_add = an_iterator.current()) != 0 )
    1048     {
    1049         music_map[map_add->ID()] = map_add;
    1050         ++an_iterator;
    1051     }
     1063    MetadataPtrList::iterator it = m_all_music.begin();
     1064    for (; it != m_all_music.end(); ++it)
     1065        music_map[(*it)->ID()] = *it;
    10521066
    10531067    //  Build a tree to reflect current state of
    10541068    //  the metadata. Once built, sort it.
     
    10851099    //  Select Music screen
    10861100    //
    10871101
    1088     Q3PtrListIterator<Metadata> an_iterator( m_all_music );
    1089     Metadata *inserter;
    10901102    MetadataPtrList list;
    10911103
    1092     while ( (inserter = an_iterator.current()) != 0 )
     1104    MetadataPtrList::iterator it = m_all_music.begin();
     1105    for (; it != m_all_music.end(); ++it)
    10931106    {
    1094         if (inserter->isVisible())
    1095             list.append(inserter);
    1096         ++an_iterator;
    1097 
     1107        if ((*it)->isVisible())
     1108            list.append(*it);
    10981109        m_numLoaded++;
    10991110    }
    11001111
    1101     MusicTreeBuilder *builder = MusicTreeBuilder::createBuilder (m_paths);
    1102     builder->makeTree (m_root_node, list);
     1112    MusicTreeBuilder *builder = MusicTreeBuilder::createBuilder(m_paths);
     1113    builder->makeTree(m_root_node, list);
    11031114    delete builder;
    11041115}
    11051116
     
    12221233    return false;
    12231234}
    12241235
    1225 void AllMusic::save()
     1236/// \brief Check each Metadata entry and save those that have changed (ratings, etc.)
     1237void AllMusic::save(void)
    12261238{
    1227     //  Check each Metadata entry and save those that
    1228     //  have changed (ratings, etc.)
    1229    
    1230    
    1231     Q3PtrListIterator<Metadata> an_iterator( m_all_music );
    1232     Metadata *searcher;
    1233     while ( (searcher = an_iterator.current()) != 0 )
     1239    MetadataPtrList::iterator it = m_all_music.begin();
     1240    for (; it != m_all_music.end(); ++it)
    12341241    {
    1235         if(searcher->hasChanged())
    1236         {
    1237             searcher->persist();
    1238         }
    1239         ++an_iterator;
     1242        if ((*it)->hasChanged())
     1243            (*it)->persist();
    12401244    }
    12411245}
    12421246
     
    12881292        return;
    12891293
    12901294    //  Error checking
    1291     QStringList tree_levels = QStringList::split(" ", m_paths);
     1295    QStringList tree_levels = m_paths.split(" ");
    12921296    QStringList::const_iterator it = tree_levels.begin();
    12931297    for (; it != tree_levels.end(); ++it)
    12941298    {
     
    13071311
    13081312void AllMusic::setAllVisible(bool visible)
    13091313{
    1310     Q3PtrListIterator<Metadata> an_iterator( m_all_music );
    1311     Metadata *md;
    1312     while ( (md = an_iterator.current()) != 0 )
    1313     {
    1314         md->setVisible(visible);
    1315         ++an_iterator;
    1316     }
     1314    MetadataPtrList::iterator it = m_all_music.begin();
     1315    for (; it != m_all_music.end(); ++it)
     1316        (*it)->setVisible(visible);
    13171317}
    13181318
    13191319MusicNode::MusicNode(const QString &a_title, const QString &tree_level)
    13201320{
    13211321    my_title = a_title;
    13221322    my_level = tree_level;
    1323     my_subnodes.setAutoDelete(true);
    13241323    setPlayCountMin(0);
    13251324    setPlayCountMax(0);
    13261325    setLastPlayMin(0);
     
    13291328
    13301329MusicNode::~MusicNode()
    13311330{
    1332     my_subnodes.clear();
     1331    while (!my_subnodes.empty())
     1332    {
     1333        delete my_subnodes.back();
     1334        my_subnodes.pop_back();
     1335    }
    13331336}
    13341337
    13351338// static member vars
     
    13671370    }
    13681371
    13691372
    1370     Q3PtrListIterator<Metadata>  anit(my_tracks);
    1371     Metadata *a_track;
    1372     while ((a_track = anit.current() ) != 0)
     1373    MetadataPtrList::iterator it = my_tracks.begin();
     1374    for (; it != my_tracks.end(); ++it)
    13731375    {
    13741376        QString title_temp = QString(QObject::tr("%1 - %2"))
    1375                                   .arg(a_track->Track()).arg(a_track->Title());
     1377            .arg((*it)->Track()).arg((*it)->Title());
    13761378        QString level_temp = QObject::tr("title");
    1377         TreeCheckItem *new_item = new TreeCheckItem(current_parent, title_temp,
    1378                                                     level_temp, a_track->ID());
    1379         ++anit;
     1379        TreeCheckItem *new_item = new TreeCheckItem(
     1380            current_parent, title_temp, level_temp, (*it)->ID());
    13801381        new_item->setCheck(false); //  Avoiding -Wall     
    13811382    } 
    13821383
     1384    MusicNodePtrList::iterator mit = my_subnodes.begin();
     1385    for (; mit != my_subnodes.end(); ++mit)
     1386        (*mit)->putYourselfOnTheListView(current_parent, true);
    13831387   
    1384     Q3PtrListIterator<MusicNode> iter(my_subnodes);
    1385     MusicNode *sub_traverse;
    1386     while ((sub_traverse = iter.current() ) != 0)
    1387     {
    1388         sub_traverse->putYourselfOnTheListView(current_parent, true);
    1389         ++iter;
    1390     }
    1391    
    13921388}
    13931389
    13941390void MusicNode::writeTree(GenericTree *tree_to_write_to, int a_counter)
     
    14021398    sub_node->setAttribute(4, a_counter);
    14031399    sub_node->setAttribute(5, a_counter);
    14041400
    1405     Q3PtrListIterator<Metadata>  anit(my_tracks);
    1406     Metadata *a_track;
    14071401    int track_counter = 0;
    1408     anit.toFirst();
    1409     while( (a_track = anit.current() ) != 0)
     1402
     1403    MetadataPtrList::iterator it = my_tracks.begin();
     1404    for (; it != my_tracks.end(); ++it)
    14101405    {
    1411         QString title_temp = QString(QObject::tr("%1 - %2")).arg(a_track->Track()).arg(a_track->Title());
    1412         GenericTree *subsub_node = sub_node->addNode(title_temp, a_track->ID(), true);
     1406        QString title_temp = QObject::tr("%1 - %2")
     1407            .arg((*it)->Track()).arg((*it)->Title());
     1408        GenericTree *subsub_node = sub_node->addNode(title_temp, (*it)->ID(), true);
    14131409        subsub_node->setAttribute(0, 1);
    14141410        subsub_node->setAttribute(1, track_counter);    // regular order
    14151411        subsub_node->setAttribute(2, rand());           // random order
     
    14171413        //
    14181414        //  "Intelligent" ordering
    14191415        //
    1420         int rating = a_track->Rating();
    1421         int playcount = a_track->PlayCount();
    1422         double lastplaydbl = a_track->LastPlay();
     1416        int rating = (*it)->Rating();
     1417        int playcount = (*it)->PlayCount();
     1418        double lastplaydbl = (*it)->LastPlay();
    14231419        double ratingValue = (double)(rating) / 10;
    14241420        double playcountValue, lastplayValue;
    14251421
    1426         if (m_playcountMax == m_playcountMin)
    1427             playcountValue = 0;
    1428         else
    1429             playcountValue = ((m_playcountMin - (double)playcount) / (m_playcountMax - m_playcountMin) + 1);
    1430         if (m_lastplayMax == m_lastplayMin)
     1422        if (m_playcountMax == m_playcountMin)
     1423        {
     1424            playcountValue = 0;
     1425        }
     1426        else
     1427        {
     1428            playcountValue = ((m_playcountMin - (double)playcount) /
     1429                              (m_playcountMax - m_playcountMin) + 1);
     1430        }
     1431
     1432        if (m_lastplayMax == m_lastplayMin)
     1433        {
    14311434            lastplayValue = 0;
    1432         else
    1433             lastplayValue = ((m_lastplayMin - lastplaydbl) / (m_lastplayMax - m_lastplayMin) + 1);
     1435        }
     1436        else
     1437        {
     1438            lastplayValue = ((m_lastplayMin - lastplaydbl) /
     1439                             (m_lastplayMax - m_lastplayMin) + 1);
     1440        }
    14341441
    1435         double rating_value =  (m_RatingWeight * ratingValue + m_PlayCountWeight * playcountValue +
    1436                                 m_LastPlayWeight * lastplayValue + m_RandomWeight * (double)rand() /
    1437                                 (RAND_MAX + 1.0));
     1442        double rating_value =
     1443            m_RatingWeight * ratingValue +
     1444            m_PlayCountWeight * playcountValue +
     1445            m_LastPlayWeight * lastplayValue +
     1446            m_RandomWeight * (double)rand() / (RAND_MAX + 1.0);
     1447
    14381448        int integer_rating = (int) (4000001 - rating_value * 10000);
    14391449        subsub_node->setAttribute(3, integer_rating);   //  "intelligent" order
    14401450        ++track_counter;
    1441         ++anit;
    14421451    } 
    14431452
    1444    
    1445     Q3PtrListIterator<MusicNode> iter(my_subnodes);
    1446     MusicNode *sub_traverse;
    1447     int another_counter = 0;
    1448     iter.toFirst();
    1449     while( (sub_traverse = iter.current() ) != 0)
     1453    MusicNodePtrList::const_iterator sit = my_subnodes.begin();
     1454    for (int another_counter = 0; sit != my_subnodes.end(); ++sit)
    14501455    {
    1451         sub_traverse->setPlayCountMin(m_playcountMin);
    1452         sub_traverse->setPlayCountMax(m_playcountMax);
    1453         sub_traverse->setLastPlayMin(m_lastplayMin);
    1454         sub_traverse->setLastPlayMax(m_lastplayMax);
    1455         sub_traverse->writeTree(sub_node, another_counter);
     1456        (*sit)->setPlayCountMin(m_playcountMin);
     1457        (*sit)->setPlayCountMax(m_playcountMax);
     1458        (*sit)->setLastPlayMin(m_lastplayMin);
     1459        (*sit)->setLastPlayMax(m_lastplayMax);
     1460        (*sit)->writeTree(sub_node, another_counter);
    14561461        ++another_counter;
    1457         ++iter;
    14581462    }
    14591463}
    14601464
     
    14621466void MusicNode::sort()
    14631467{
    14641468    //  Sort any tracks
    1465     my_tracks.sort();
     1469    qStableSort(my_tracks.begin(), my_tracks.end(), meta_less_than);
    14661470
    14671471    //  Sort any subnodes
    1468     my_subnodes.sort();
     1472    qStableSort(my_subnodes.begin(), my_subnodes.end(), music_less_than);
    14691473   
    14701474    //  Tell any subnodes to sort themselves
    1471     Q3PtrListIterator<MusicNode> iter(my_subnodes);
    1472     MusicNode *crawler;
    1473     while ( (crawler = iter.current()) != 0 )
    1474     {
    1475         crawler->sort();
    1476         ++iter;
    1477     }
     1475    MusicNodePtrList::const_iterator sit = my_subnodes.begin();
     1476    for (; sit != my_subnodes.end(); ++sit)
     1477        (*sit)->sort();
    14781478}
    14791479
    14801480
    1481 void MusicNode::printYourself(int indent_level)
     1481void MusicNode::printYourself(int indent_level) const
    14821482{
     1483    QString tmp = "";
     1484    for (int i = 0; i < indent_level; ++i)
     1485        tmp += "    ";
     1486    tmp += my_title;
     1487    VERBOSE(VB_GENERAL, tmp);
    14831488
    1484     for(int i = 0; i < (indent_level) * 4; ++i)
     1489    MetadataPtrList::const_iterator it = my_tracks.begin();
     1490    for (; it != my_tracks.end(); ++it)
    14851491    {
    1486         cout << " " ;
     1492        QString tmp = "";
     1493        for (int i = 0; i < indent_level + 1; ++i)
     1494            tmp += "    ";
     1495        tmp += (*it)->Title();
     1496        VERBOSE(VB_GENERAL, tmp);
    14871497    }
    1488     cout << my_title.toLocal8Bit().constData() << endl;
    14891498
    1490     Q3PtrListIterator<Metadata>  anit(my_tracks);
    1491     Metadata *a_track;
    1492     while( (a_track = anit.current() ) != 0)
    1493     {
    1494         for(int j = 0; j < (indent_level + 1) * 4; j++)
    1495         {
    1496             cout << " " ;
    1497         }
    1498         cout << a_track->Title().toLocal8Bit().constData() << endl ;
    1499         ++anit;
    1500     }       
    1501    
    1502     Q3PtrListIterator<MusicNode> iter(my_subnodes);
    1503     MusicNode *print;
    1504     while( (print = iter.current() ) != 0)
    1505     {
    1506         print->printYourself(indent_level + 1);
    1507         ++iter;
    1508     }
     1499    MusicNodePtrList::const_iterator sit = my_subnodes.begin();
     1500    for (; sit != my_subnodes.end(); ++sit)
     1501        (*sit)->printYourself(indent_level + 1);
    15091502}
    15101503
    15111504/**************************************************************************/
    15121505
    1513 int MetadataPtrList::compareItems(Q3PtrCollection::Item item1,
    1514                                   Q3PtrCollection::Item item2)
    1515 {
    1516     return ((Metadata*)item1)->compare((Metadata*)item2);
    1517 }
    1518 
    1519 int MusicNodePtrList::compareItems (Q3PtrCollection::Item item1,
    1520                                     Q3PtrCollection::Item item2)
    1521 {
    1522     MusicNode *itemA = (MusicNode*)item1;
    1523     MusicNode *itemB = (MusicNode*)item2;
    1524 
    1525     QString title1 = itemA->getTitle().lower();
    1526     QString title2 = itemB->getTitle().lower();
    1527    
    1528     // Cut "the " off the front of titles
    1529     if (title1.left(4) == thePrefix)
    1530         title1 = title1.mid(4);
    1531     if (title2.left(4) == thePrefix)
    1532         title2 = title2.mid(4);
    1533 
    1534     return title1.localeAwareCompare(title2);
    1535 }
    1536 
    1537 /**************************************************************************/
    1538 
    15391506AlbumArtImages::AlbumArtImages(Metadata *metadata)
    15401507    : m_parent(metadata)
    15411508{
    1542     m_imageList.setAutoDelete(true);
    1543 
    15441509    findImages();
    15451510}
    15461511
     1512AlbumArtImages::~AlbumArtImages()
     1513{
     1514    while (!m_imageList.empty())
     1515    {
     1516        delete m_imageList.back();
     1517        m_imageList.pop_back();
     1518    }
     1519}
     1520
    15471521void AlbumArtImages::findImages(void)
    15481522{
    1549     m_imageList.clear();
     1523    while (!m_imageList.empty())
     1524    {
     1525        delete m_imageList.back();
     1526        m_imageList.pop_back();
     1527    }
    15501528
    15511529    if (m_parent == NULL)
    15521530        return;
     
    15571535        return;
    15581536
    15591537    QFileInfo fi(m_parent->Filename());
    1560     QString dir = fi.dirPath(true);
     1538    QString dir = fi.absolutePath();
    15611539    dir.remove(0, Metadata::GetStartdir().length());
    15621540
    15631541    MSqlQuery query(MSqlQuery::InitCon());
     
    15861564                image->description = query.value(1).toString();
    15871565                image->embedded = true;
    15881566            }
    1589             else {
     1567            else
     1568            {
    15901569                image->embedded = false;
    15911570            }
    1592             m_imageList.append(image);
     1571            m_imageList.push_back(image);
    15931572        }
    15941573    }
    15951574}
    15961575
    1597 AlbumArtImage AlbumArtImages::getImage(ImageType type)
     1576AlbumArtImage *AlbumArtImages::getImage(ImageType type)
    15981577{
    1599     // try to find a matching image
    1600     AlbumArtImage *image;
    1601 
    1602     for (image = m_imageList.first(); image; image = m_imageList.next())
     1578    ImageList::iterator it = m_imageList.begin();
     1579    for (; it != m_imageList.end(); ++it)
    16031580    {
    1604         if (image->imageType == type)
    1605             return *image;
     1581        if ((*it)->imageType == type)
     1582            return *it;
    16061583    }
    16071584
    1608     return *image;
     1585    return NULL;
    16091586}
    16101587
    1611 QStringList AlbumArtImages::getImageFilenames()
     1588QStringList AlbumArtImages::getImageFilenames(void) const
    16121589{
    16131590    QStringList paths;
    16141591
    1615     AlbumArtImage *image;
     1592    ImageList::const_iterator it = m_imageList.begin();
     1593    for (; it != m_imageList.end(); ++it)
     1594        paths += (*it)->filename;
    16161595
    1617     for (image = m_imageList.first(); image; image = m_imageList.next())
    1618     {
    1619         paths += image->filename;
    1620     }
    1621 
    16221596    return paths;
    16231597}
    16241598
    1625 AlbumArtImage AlbumArtImages::getImageAt(uint index)
     1599AlbumArtImage *AlbumArtImages::getImageAt(uint index)
    16261600{
    1627     return *(m_imageList.at(index));
    1628 }
     1601    if (index < m_imageList.size())
     1602        return m_imageList[index];
    16291603
    1630 bool AlbumArtImages::isImageAvailable(ImageType type)
    1631 {
    1632     // try to find a matching image
    1633     AlbumArtImage *image;
    1634 
    1635     for (image = m_imageList.first(); image; image = m_imageList.next())
    1636     {
    1637         if (image->imageType == type)
    1638             return true;
    1639     }
    1640 
    1641     return false;
     1604    return NULL;
    16421605}
    16431606
    16441607bool AlbumArtImages::saveImageType(const int id, ImageType type)
     
    16621625        QT_TR_NOOP("Inlay")               // IT_INLAY
    16631626    };
    16641627
    1665     return tr(type_strings[type]);
     1628    return QObject::tr(type_strings[type]);
    16661629}
    16671630
    16681631// static method to guess the image type from the filename
     
    16701633{
    16711634    ImageType type = IT_FRONTCOVER;
    16721635
    1673     if (filename.contains(tr("front"), false))
     1636    if (filename.contains(QObject::tr("front"),      Qt::CaseInsensitive))
    16741637        type = IT_FRONTCOVER;
    1675     else if (filename.contains(tr("back"), false))
     1638    else if (filename.contains(QObject::tr("back"),  Qt::CaseInsensitive))
    16761639        type = IT_BACKCOVER;
    1677     else if (filename.contains(tr("inlay"), false))
     1640    else if (filename.contains(QObject::tr("inlay"), Qt::CaseInsensitive))
    16781641        type = IT_INLAY;
    1679     else if (filename.contains(tr("cd"), false))
     1642    else if (filename.contains(QObject::tr("cd"),    Qt::CaseInsensitive))
    16801643        type = IT_CD;
    1681     else if (filename.contains(tr("cover"), false))
     1644    else if (filename.contains(QObject::tr("cover"), Qt::CaseInsensitive))
    16821645        type = IT_FRONTCOVER;
    16831646
    16841647    return type;
  • mythplugins/mythmusic/mythmusic/dbcheck.cpp

     
    4343    {
    4444        query.exec(thequery);
    4545
    46         if (query.lastError().type() != QSqlError::None)
     46        if (query.lastError().type() != QSqlError::NoError)
    4747        {
    4848            QString msg =
    4949                QString("DB Error (Performing database upgrade): \n"
     
    111111    if (dbver == "1000")
    112112    {
    113113        QString startdir = gContext->GetSetting("MusicLocation");
    114         startdir = QDir::cleanDirPath(startdir);
     114        startdir = QDir::cleanPath(startdir);
    115115        if (!startdir.endsWith("/"))
    116116            startdir += "/";
    117117
     
    581581
    582582        // update the VisualMode setting to the new format
    583583        QString setting = gContext->GetSetting("VisualMode");
    584         setting = setting.simplifyWhiteSpace();
     584        setting = setting.simplified();
    585585        setting = setting.replace(' ', ";");
    586586        gContext->SaveSetting("VisualMode", setting);
    587587
  • mythplugins/mythmusic/mythmusic/directoryfinder.cpp

     
    5656                if (m_directoryList[index] == "..")
    5757                {
    5858                    // move up on directory
    59                     int pos = m_curDirectory.findRev('/');
     59                    int pos = m_curDirectory.lastIndexOf('/');
    6060                    if (pos > 0)
    6161                        m_curDirectory = m_curDirectory.left(pos);
    6262                    else
     
    195195void DirectoryFinder::backPressed()
    196196{
    197197    // move up one directory
    198     int pos = m_curDirectory.findRev('/');
     198    int pos = m_curDirectory.lastIndexOf('/');
    199199    if (pos > 0)
    200200        m_curDirectory = m_curDirectory.left(pos);
    201201    else
  • mythplugins/mythmusic/mythmusic/treebuilders.h

     
    11#ifndef TREEBUILDERS_H_
    22#define TREEBUILDERS_H_
    33
    4 #include <qstring.h>
    5 #include <qstringlist.h>
    6 #include <q3ptrdict.h>
    7 #include <q3dict.h>
     4#include <QStringList>
    85
    96#include "metadata.h"
    107
  • mythplugins/mythmusic/mythmusic/cdrip.cpp

     
    1212#include "config.h"
    1313#ifdef HAVE_CDAUDIO
    1414#include <cdaudio.h>
    15 //Added by qt3to4:
    16 #include <QKeyEvent>
    17 #include <Q3PtrList>
    18 #include <QEvent>
    1915extern "C" {
    2016#include <cdda_interface.h>
    2117#include <cdda_paranoia.h>
     
    2824using namespace std;
    2925
    3026// Qt includes
    31 #include <qapplication.h>
    32 #include <qdir.h>
    33 #include <qregexp.h>
     27#include <QApplication>
     28#include <QDir>
     29#include <QRegExp>
     30#include <QKeyEvent>
     31#include <QEvent>
    3432
    3533// MythTV plugin includes
    3634#include <mythtv/mythcontext.h>
     
    940938
    941939            // delete file
    942940            QString musicdir = gContext->GetSetting("MusicLocation");
    943             musicdir = QDir::cleanDirPath(musicdir);
     941            musicdir = QDir::cleanPath(musicdir);
    944942            if (!musicdir.endsWith("/"))
    945943                musicdir += "/";
    946944            QFile::remove(musicdir + filename);
     
    961959QString Ripper::filenameFromMetadata(Metadata *track, bool createDir)
    962960{
    963961    QString musicdir = gContext->GetSetting("MusicLocation");
    964     musicdir = QDir::cleanDirPath(musicdir);
     962    musicdir = QDir::cleanPath(musicdir);
    965963    if (!musicdir.endsWith("/"))
    966964        musicdir += "/";
    967965
     
    976974    int old_i = 0;
    977975    while (i >= 0)
    978976    {
    979         i = rx.search(fntempl, i);
     977        i = rx.indexIn(fntempl, i);
    980978        if (i >= 0)
    981979        {
    982980            if (i > 0)
     
    10241022
    10251023    filename = QString(filename.toLocal8Bit().constData());
    10261024
    1027     QStringList directoryList = QStringList::split("/", filename);
     1025    QStringList directoryList = filename.split("/");
    10281026    for (int i = 0; i < (directoryList.size() - 1); i++)
    10291027    {
    10301028        musicdir += "/" + directoryList[i];
    10311029        if (createDir)
    10321030        {
    10331031            umask(022);
    1034             directoryQD.mkdir(musicdir, true);
     1032            directoryQD.mkdir(musicdir);
    10351033            directoryQD.cd(musicdir);
    10361034        }
    10371035    }
    10381036
    1039     filename = QDir::cleanDirPath(musicdir) + "/" + directoryList.last();
     1037    filename = QDir::cleanPath(musicdir) + "/" + directoryList.last();
    10401038
    10411039    return filename;
    10421040}
     
    14531451    }
    14541452
    14551453    searchDialog->deleteLater();
    1456     setActiveWindow();
     1454    activateWindow();
    14571455
    14581456    return res;
    14591457}
     
    15711569
    15721570        if (action == "ESCAPE")
    15731571        {
    1574             if (m_ripperThread && m_ripperThread->running())
     1572            if (m_ripperThread && m_ripperThread->isRunning())
    15751573            {
    15761574                if (MythPopupBox::showOkCancelPopup(gContext->GetMainWindow(),
    15771575                    "Stop Rip?",
  • mythplugins/mythmusic/mythmusic/playlist.cpp

     
    11#include <unistd.h>
    22#include <inttypes.h>
    33#include <cstdlib>
    4 #include <iostream>
    5 #include <map>
    64
     5#include <map>
     6#include <algorithm>
    77using namespace std;
    8 #include "playlist.h"
    9 #include "qdatetime.h"
    10 //Added by qt3to4:
    11 #include <Q3PtrList>
    12 #include <Q3TextStream>
    138
    14 #include <mythtv/mythcontext.h>
     9#include <QApplication>
     10#include <QTextStream>
     11#include <QFileInfo>
     12#include <q3process.h>
     13
     14#include "playlist.h"
     15#include "playlistcontainer.h"
    1516#include "smartplaylist.h"
    16 #include <mythtv/mythdb.h>
    17 #include <mythtv/compat.h>
    1817
    19 #include <qfileinfo.h>
    20 #include <q3process.h>
    21 #include <qapplication.h>
     18#include <mythcontext.h>
     19#include <mythdb.h>
     20#include <compat.h>
    2221
    2322const char *kID0err = "Song with ID of 0 in playlist, this shouldn't happen.";
    2423
     24#define LOC      QString("Track: ")
     25#define LOC_WARN QString("Track, Warning: ")
     26#define LOC_ERR  QString("Track, Error: ")
     27
    2528Track::Track(int x, AllMusic *all_music_ptr)
    2629{
    2730    index_value = x;
     
    3336    cd_flag = false;
    3437}
    3538
    36 void Track::postLoad(PlaylistsContainer *grandparent)
     39void Track::postLoad(PlaylistContainer *grandparent)
    3740{
    3841    if (cd_flag)
    3942    {
     
    4851                                             bad_reference);
    4952    else
    5053    {
    51         VERBOSE(VB_IMPORTANT, "playlist.o: Not sure how I got 0 as a track "
    52                 "number, but it ain't good");
     54        VERBOSE(VB_IMPORTANT, LOC_WARN + "Track Number of 0 is invalid!");
    5355    }
    5456}
    5557
     
    5961    parent = parent_ptr;
    6062}
    6163
     64void Track::deleteYourself()
     65{
     66    parent->removeTrack(index_value, cd_flag);
     67}
     68
     69void Track::deleteYourWidget()
     70{
     71    if (my_widget)
     72    {
     73        my_widget->RemoveFromParent();
     74        //delete my_widget;  Deleted by the parent..
     75        my_widget = NULL;
     76    }
     77}
     78
     79void Track::moveUpDown(bool flag)
     80{
     81    parent->moveTrackUpDown(flag, this);
     82}
     83
     84TrackType Track::GetTrackType(void) const
     85{
     86    if (my_widget)
     87    {
     88        if (dynamic_cast<PlaylistCD*>(my_widget))
     89            return kTrackCD;
     90
     91        if (dynamic_cast<PlaylistPlaylist*>(my_widget))
     92            return kTrackPlaylist;
     93
     94        if (dynamic_cast<PlaylistTrack*>(my_widget))
     95            return kTrackSong;
     96
     97        return kTrackUnknown;
     98    }
     99
     100    if (cd_flag)
     101        return kTrackCD;
     102
     103    if (index_value < 0)
     104        return kTrackPlaylist;
     105
     106    if (index_value > 0)
     107        return kTrackSong;
     108
     109    return kTrackUnknown;
     110}
     111
     112void Track::putYourselfOnTheListView(UIListGenericTree *a_listviewitem)
     113{
     114    if (my_widget)
     115    {
     116        VERBOSE(VB_IMPORTANT, LOC_ERR +
     117                "putYourselfOnTheListView() called when my_widget already exists.");
     118        return;
     119    }
     120
     121    TrackType type = GetTrackType();
     122    switch (type)
     123    {
     124        case kTrackCD:
     125            my_widget = new PlaylistCD(a_listviewitem, label);       break;
     126        case kTrackSong:
     127            my_widget = new PlaylistTrack(a_listviewitem, label);    break;
     128        case kTrackPlaylist:
     129            my_widget = new PlaylistPlaylist(a_listviewitem, label); break;
     130        default: break;
     131    }
     132
     133    if (my_widget)
     134    {
     135        my_widget->setOwner(this);
     136    }
     137    else
     138    {
     139        VERBOSE(VB_IMPORTANT, LOC_ERR +
     140                "putYourselfOnTheListView() failed to create a widget");
     141    }
     142}
     143
     144#undef LOC
     145#undef LOC_WARN
     146#undef LOC_ERR
     147
     148#define LOC      QString("Playlist: ")
     149#define LOC_WARN QString("Playlist, Warning: ")
     150#define LOC_ERR  QString("Playlist, Error: ")
     151
    62152void Playlist::postLoad()
    63153{
    64     Track *it;
    65     for (it = songs.first(); it; it = songs.current())
     154    SongList::iterator it = songs.begin();
     155    while (it != songs.end())
    66156    {
    67         it->postLoad(parent);
    68         if (it->badReference())
     157        (*it)->postLoad(parent);
     158        if ((*it)->badReference())
    69159        {
    70             songs.remove(it);
     160            delete *it;
     161            it = songs.erase(it);
    71162            Changed();
    72163        }
    73164        else
    74             it = songs.next();
     165        {
     166            ++it;
     167        }
    75168    }
    76169}
    77170
    78 bool Playlist::checkTrack(int a_track_id, bool cd_flag)
     171bool Playlist::checkTrack(int a_track_id, bool cd_flag) const
    79172{
    80173    // XXX SPEED THIS UP
    81174    // Should be a straight lookup against cached index
    82     Track *it;
    83175
    84     for (it = songs.first(); it; it = songs.next())
     176    SongList::const_iterator it = songs.begin();
     177    for (; it != songs.end(); ++it)
    85178    {
    86         if (it->getValue() == a_track_id && it->getCDFlag() == cd_flag)
    87         {
     179        if ((*it)->getValue() == a_track_id && (*it)->getCDFlag() == cd_flag)
    88180            return true;
    89         }
    90181    }
    91182
    92183    return false;
    93184}
    94185
    95 void Playlist::copyTracks(Playlist *to_ptr, bool update_display)
     186void Playlist::copyTracks(Playlist *to_ptr, bool update_display) const
    96187{
    97     Track *it;
    98     for (it = songs.first(); it; it = songs.next())
     188    SongList::const_iterator it = songs.begin();
     189    for (; it != songs.end(); ++it)
    99190    {
    100         if (!it->getCDFlag())
    101             to_ptr->addTrack((*it).getValue(), update_display, false);
     191        if (!(*it)->getCDFlag())
     192            to_ptr->addTrack((*it)->getValue(), update_display, false);
    102193    }
    103194
    104195    to_ptr->fillSonglistFromSongs();
     
    114205    a_track->setCDFlag(cd);
    115206    a_track->postLoad(parent);
    116207    a_track->setParent(this);
    117     songs.append(a_track);
     208    songs.push_back(a_track);
    118209    changed = true;
    119210
    120211    // If I'm part of a GUI, display the existence of this new track
     
    128219        a_track->putYourselfOnTheListView(which_widget);
    129220}
    130221
    131 void Track::deleteYourself()
     222void Playlist::removeAllTracks(void)
    132223{
    133     parent->removeTrack(index_value, cd_flag);
    134 }
    135 
    136 void Track::deleteYourWidget()
    137 {
    138     if (my_widget)
     224    while (!songs.empty())
    139225    {
    140        my_widget->RemoveFromParent();
    141     //    delete my_widget;  Deleted by the parent..
    142         my_widget = NULL;
     226        songs.back()->deleteYourWidget();
     227        delete songs.back();
     228        songs.pop_back();
    143229    }
    144 }
    145230
    146 void Playlist::removeAllTracks()
    147 {
    148     Track *it;
    149     for (it = songs.first(); it; it = songs.current())
    150     {
    151         it->deleteYourWidget();
    152         songs.remove(it);
    153     }
    154 
    155231    changed = true;
    156232}
    157233
    158 void Playlist::removeAllWidgets()
     234void Playlist::removeAllWidgets(void)
    159235{
    160     Track *it;
    161     for (it = songs.first(); it; it = songs.next())
    162     {
    163         it->deleteYourWidget();
    164     }
     236    SongList::iterator it = songs.begin();
     237    for (; it != songs.end(); ++it)
     238        (*it)->deleteYourWidget();
    165239}
    166240
    167241void Playlist::ripOutAllCDTracksNow()
    168242{
    169     Track *it;
    170     for (it = songs.first(); it; it = songs.current())
     243    SongList::iterator it = songs.begin();
     244    while (it != songs.end())
    171245    {
    172         if (it->getCDFlag())
     246        if ((*it)->getCDFlag())
    173247        {
    174             it->deleteYourWidget();
    175             songs.remove(it);
     248            (*it)->deleteYourWidget();
     249            delete *it;
     250            it = songs.erase(it);
     251            changed = true;
    176252        }
    177253        else
    178             it = songs.next();
     254        {
     255            ++it;
     256        }
    179257    }
    180     changed = true;
    181258}
    182259
    183260void Playlist::removeTrack(int the_track, bool cd_flag)
    184261{
    185262    // Should be a straight lookup against cached index
    186     Track *it;
    187     for (it = songs.first(); it; it = songs.current())
     263
     264    SongList::iterator it = songs.begin();
     265    while (it != songs.end())
    188266    {
    189         if (it->getValue() == the_track && cd_flag == it->getCDFlag())
     267        if ((*it)->getValue() == the_track && cd_flag == (*it)->getCDFlag())
    190268        {
    191             it->deleteYourWidget();
    192             songs.remove(it);
    193             //it = songs.last();
     269            (*it)->deleteYourWidget();
     270            delete *it;
     271            it = songs.erase(it);
     272            changed = true;
    194273        }
    195274        else
    196             it = songs.next();
     275        {
     276            ++it;
     277        }
    197278    }
    198     changed = true;
    199279}
    200280
    201281void Playlist::moveTrackUpDown(bool flag, Track *the_track)
    202282{
    203     // Slightly complicated, as the PtrList owns the pointers
    204     // Need to turn off auto delete
    205 
    206     songs.setAutoDelete(false);
    207 
    208283    uint insertion_point = 0;
    209     int where_its_at = songs.findRef(the_track);
     284    int where_its_at = songs.indexOf(the_track);
    210285    if (where_its_at < 0)
    211         VERBOSE(VB_IMPORTANT, "playlist.o: A playlist was asked to move a "
     286    {
     287        VERBOSE(VB_IMPORTANT, LOC_ERR + "A playlist was asked to move a "
    212288                "track, but can'd find it");
     289        return;
     290    }
     291
     292    if (flag)
     293        insertion_point = ((uint)where_its_at) - 1;
    213294    else
    214     {
    215         if (flag)
    216             insertion_point = ((uint)where_its_at) - 1;
    217         else
    218             insertion_point = ((uint)where_its_at) + 1;
     295        insertion_point = ((uint)where_its_at) + 1;
    219296
    220         songs.remove(the_track);
    221         songs.insert(insertion_point, the_track);
    222     }
     297    songs.removeAt(where_its_at);
     298    songs.insert(insertion_point, the_track);
    223299
    224     songs.setAutoDelete(true);
    225300    changed = true; //  This playlist is now different than Database
    226301}
    227302
    228 void Track::moveUpDown(bool flag)
    229 {
    230     parent->moveTrackUpDown(flag, this);
    231 }
    232 
    233 PlaylistLoadingThread::PlaylistLoadingThread(PlaylistsContainer *parent_ptr,
    234                                              AllMusic *all_music_ptr)
    235 {
    236     parent = parent_ptr;
    237     all_music = all_music_ptr;
    238 }
    239 
    240 void PlaylistLoadingThread::run()
    241 {
    242     while(!all_music->doneLoading())
    243     {
    244         sleep(1);
    245     }
    246     parent->load();
    247 }
    248 
    249 void PlaylistsContainer::clearCDList()
    250 {
    251     cd_playlist.clear();
    252 }
    253 
    254 void PlaylistsContainer::addCDTrack(int track)
    255 {
    256     cd_playlist.append(track);
    257 }
    258 
    259 void PlaylistsContainer::removeCDTrack(int track)
    260 {
    261     cd_playlist.remove(track);
    262 }
    263 
    264 bool PlaylistsContainer::checkCDTrack(int track)
    265 {
    266     for (int i = 0; i < (int)cd_playlist.count(); i++)
    267     {
    268         if (cd_playlist[i] == track)
    269             return true;
    270     }
    271     return false;
    272 }
    273 
    274 PlaylistsContainer::PlaylistsContainer(AllMusic *all_music, QString host_name)
    275 {
    276     active_widget = NULL;
    277     my_host = host_name;
    278 
    279     active_playlist = NULL;
    280     backup_playlist = NULL;
    281     all_other_playlists = NULL;
    282 
    283     all_available_music = all_music;
    284 
    285     done_loading = false;
    286 
    287     RatingWeight = gContext->GetNumSetting("IntelliRatingWeight", 2);
    288     PlayCountWeight = gContext->GetNumSetting("IntelliPlayCountWeight", 2);
    289     LastPlayWeight = gContext->GetNumSetting("IntelliLastPlayWeight", 2);
    290     RandomWeight = gContext->GetNumSetting("IntelliRandomWeight", 2);
    291 
    292     playlists_loader = new PlaylistLoadingThread(this, all_music);
    293     playlists_loader->start();
    294 }
    295 
    296 PlaylistsContainer::~PlaylistsContainer()
    297 {
    298     if (active_playlist)
    299         delete active_playlist;
    300     if (backup_playlist)
    301         delete backup_playlist;
    302     if (all_other_playlists)
    303         delete all_other_playlists;
    304 
    305     playlists_loader->wait();
    306     delete playlists_loader;
    307 }
    308 
    309 void PlaylistsContainer::FillIntelliWeights(int &rating, int &playcount,
    310                                             int &lastplay, int &random)
    311 {
    312     rating = RatingWeight;
    313     playcount = PlayCountWeight;
    314     lastplay = LastPlayWeight;
    315     random = RandomWeight;
    316 }
    317 
    318 void PlaylistsContainer::load()
    319 {
    320     done_loading = false;
    321     active_playlist = new Playlist(all_available_music);
    322     active_playlist->setParent(this);
    323 
    324     backup_playlist = new Playlist(all_available_music);
    325     backup_playlist->setParent(this);
    326 
    327     all_other_playlists = new Q3PtrList<Playlist>;
    328     all_other_playlists->setAutoDelete(true);
    329 
    330     cd_playlist.clear();
    331 
    332     active_playlist->loadPlaylist("default_playlist_storage", my_host);
    333     active_playlist->fillSongsFromSonglist(false);
    334 
    335     backup_playlist->loadPlaylist("backup_playlist_storage", my_host);
    336     backup_playlist->fillSongsFromSonglist(false);
    337 
    338     all_other_playlists->clear();
    339 
    340     MSqlQuery query(MSqlQuery::InitCon());
    341     query.prepare("SELECT playlist_id FROM music_playlists "
    342                   "WHERE playlist_name != :DEFAULT"
    343                   " AND playlist_name != :BACKUP "
    344                   " AND (hostname = '' OR hostname = :HOST) "
    345                   "ORDER BY playlist_id;");
    346     query.bindValue(":DEFAULT", "default_playlist_storage");
    347     query.bindValue(":BACKUP", "backup_playlist_storage");
    348     query.bindValue(":HOST", my_host);
    349 
    350     if (query.exec() && query.isActive() && query.size() > 0)
    351     {
    352         while (query.next())
    353         {
    354             Playlist *temp_playlist = new Playlist(all_available_music);
    355             //  No, we don't destruct this ...
    356             temp_playlist->setParent(this);
    357             temp_playlist->loadPlaylistByID(query.value(0).toInt(), my_host);
    358             temp_playlist->fillSongsFromSonglist(false);
    359             all_other_playlists->append(temp_playlist);
    360             //  ... cause it's sitting on this PtrList
    361         }
    362     }
    363     postLoad();
    364 
    365     pending_writeback_index = 0;
    366 
    367     int x = gContext->GetNumSetting("LastMusicPlaylistPush");
    368     setPending(x);
    369     done_loading = true;
    370 }
    371 
    372 void PlaylistsContainer::describeYourself()
    373 {
    374     //    Debugging
    375 
    376     active_playlist->describeYourself();
    377     Playlist *a_list;
    378     for (a_list = all_other_playlists->first(); a_list;
    379          a_list = all_other_playlists->next())
    380     {
    381         a_list->describeYourself();
    382     }
    383 }
    384 
    385303Playlist::Playlist(AllMusic *all_music_ptr)
    386304{
    387305    //  fallback values
    388306    playlistid = 0;
    389307    name = QObject::tr("oops");
    390308    raw_songlist = "";
    391     songs.setAutoDelete(true);  //  mine!
    392309    all_available_music = all_music_ptr;
    393310    changed = false;
    394311}
    395312
    396 void Track::putYourselfOnTheListView(UIListGenericTree *a_listviewitem)
    397 {
    398     if (cd_flag)
    399     {
    400         my_widget = new PlaylistCD(a_listviewitem, label);
    401         my_widget->setOwner(this);
    402     }
    403     else
    404     {
    405         if (index_value > 0)
    406         {
    407             my_widget = new PlaylistTrack(a_listviewitem, label);
    408             my_widget->setOwner(this);
    409         }
    410         else if (index_value < 0)
    411         {
    412             my_widget = new PlaylistPlaylist(a_listviewitem, label);
    413             my_widget->setOwner(this);
    414         }
    415     }
    416 }
    417 
    418313void Playlist::putYourselfOnTheListView(UIListGenericTree *a_listviewitem)
    419314{
    420     Track *it;
    421     for (it = songs.first(); it; it = songs.next())
    422         it->putYourselfOnTheListView(a_listviewitem);
     315    SongList::iterator it = songs.begin();
     316    for (; it != songs.end(); ++it)
     317        (*it)->putYourselfOnTheListView(a_listviewitem);
    423318}
    424319
    425 int Playlist::getFirstTrackID()
     320int Playlist::getFirstTrackID(void) const
    426321{
    427     Track *it = songs.first();
    428     if (it)
    429     {
    430         return it->getValue();
    431     }
     322    SongList::const_iterator it = songs.begin();
     323    if (it != songs.end())
     324        return (*it)->getValue();
    432325    return 0;
    433326}
    434327
    435328Playlist::~Playlist()
    436329{
    437     songs.setAutoDelete(true);
    438     songs.clear();
     330    while (!songs.empty())
     331    {
     332        delete songs.front();
     333        songs.pop_front();
     334    }
    439335}
    440336
     337/*
    441338Playlist& Playlist::operator=(const Playlist& rhs)
    442339{
    443340    if (this == &rhs)
     
    448345    playlistid = rhs.playlistid;
    449346    name = rhs.name;
    450347    raw_songlist = rhs.raw_songlist;
    451     songs = rhs.songs;
     348
     349    while (!songs.empty())
     350    {
     351        delete songs.front();
     352        songs.pop_front();
     353    }
     354#error Can not safely copy Playlist.. Track does not have a deep copy constructor
     355
    452356    return *this;
    453357}
     358*/
    454359
    455 void Playlist::describeYourself()
     360void Playlist::describeYourself(void) const
    456361{
    457362    //  This is for debugging
    458363/*
     
    461366    cout << "     songlist(raw) is \"" << raw_songlist << "\"" << endl;
    462367    cout << "     songlist list is ";
    463368*/
    464     QString msg;
    465     Track *it;
    466     for(it = songs.first(); it; it = songs.next())
    467     {
    468         msg += it->getValue() + "," ;
    469     }
     369    QString msg = "";
     370    SongList::const_iterator it = songs.begin();
     371    for (; it != songs.end(); ++it)
     372        msg += (*it)->getValue() + ",";
    470373
    471     VERBOSE(VB_IMPORTANT, msg);
     374    VERBOSE(VB_IMPORTANT, LOC + msg);
    472375}
    473376
    474377
    475378void Playlist::loadPlaylist(QString a_name, QString a_host)
    476379{
    477380    QString thequery;
    478     if (a_host.length() < 1)
     381    if (a_host.isEmpty())
    479382    {
    480         VERBOSE(VB_IMPORTANT, "loadPlaylist() - We need a valid hostname");
     383        VERBOSE(VB_IMPORTANT, LOC_ERR + "loadPlaylist() - We need a valid hostname");
    481384        return;
    482385    }
    483386
     
    564467    if (filter)
    565468        all_available_music->setAllVisible(false);
    566469
    567     QStringList list = QStringList::split(",", raw_songlist);
     470    QStringList list = raw_songlist.split(",", QString::SkipEmptyParts);
    568471    QStringList::iterator it = list.begin();
    569472    for (; it != list.end(); it++)
    570473    {
     
    581484            {
    582485                Track *a_track = new Track(an_int, all_available_music);
    583486                a_track->setParent(this);
    584                 songs.append(a_track);
     487                songs.push_back(a_track);
    585488            }
    586489        }
    587490        else
    588491        {
    589492            changed = true;
    590             VERBOSE(VB_IMPORTANT, "Taking a 0 (zero) off a "
    591                     "playlist. If this happens on repeated invocations of "
     493
     494            VERBOSE(VB_IMPORTANT, LOC_ERR +
     495                    "Taking a 0 (zero) off a playlist. \n\t\t\t"
     496                    "If this happens on repeated invocations of "
    592497                    "mythmusic, then something is really wrong");
    593498        }
    594499    }
     
    601506    }
    602507}
    603508
    604 void Playlist::fillSonglistFromSongs()
     509void Playlist::fillSonglistFromSongs(void)
    605510{
    606511    QString a_list = "";
    607     Track *it;
    608     for (it = songs.first(); it; it = songs.next())
     512    SongList::const_iterator it = songs.begin();
     513    for (; it != songs.end(); ++it)
    609514    {
    610         if (!it->getCDFlag())
    611         {
    612             a_list += QString(",%1").arg(it->getValue());
    613         }
     515        if (!(*it)->getCDFlag())
     516            a_list += QString(",%1").arg((*it)->getValue());
    614517    }
    615518
    616519    raw_songlist = "";
    617     if (a_list.length() > 1)
     520    if (!a_list.isEmpty())
    618521        raw_songlist = a_list.remove(0, 1);
    619522}
    620523
     
    681584
    682585        case PL_INSERTAFTERCURRENT:
    683586        {
    684             QStringList list = QStringList::split(",", raw_songlist);
     587            QStringList list = raw_songlist.split(",", QString::SkipEmptyParts);
    685588            QStringList::iterator it = list.begin();
    686589            raw_songlist = "";
    687590            bool bFound = false;
     
    745648    int categoryID = SmartPlaylistEditor::lookupCategoryID(category);
    746649    if (categoryID == -1)
    747650    {
    748         VERBOSE(VB_GENERAL, "Cannot find Smartplaylist Category: " + category);
     651        VERBOSE(VB_GENERAL, LOC_WARN +
     652                QString("Cannot find Smartplaylist Category: %1")
     653                .arg(category));
    749654        return;
    750655    }
    751656
     
    773678        }
    774679        else
    775680        {
    776             VERBOSE(VB_GENERAL, "Cannot find smartplaylist: " + name);
     681            VERBOSE(VB_GENERAL, LOC_WARN +
     682                    QString("Cannot find smartplaylist: %1").arg(name));
    777683            return;
    778684        }
    779685    }
     
    825731
    826732void Playlist::savePlaylist(QString a_name, QString a_host)
    827733{
    828     name = a_name.simplifyWhiteSpace();
     734    name = a_name.simplified();
    829735    if (name.length() < 1)
    830736    {
    831         VERBOSE(VB_GENERAL, "Not going to save a playlist with no name");
     737        VERBOSE(VB_GENERAL, LOC_WARN +
     738                "Not saving unnamed playlist");
    832739        return;
    833740    }
    834741
    835742    if (a_host.length() < 1)
    836743    {
    837         VERBOSE(VB_GENERAL, "Not going to save a playlist with no hostname");
     744        VERBOSE(VB_GENERAL, LOC_WARN +
     745                "Not saving playlist without a host name");
    838746        return;
    839747    }
    840748    if (name.length() < 1)
     
    844752    MSqlQuery query(MSqlQuery::InitCon());
    845753
    846754    int length = 0, songcount = 0, playtime = 0, an_int;
    847     QStringList list = QStringList::split(",", raw_songlist);
     755    QStringList list = raw_songlist.split(",", QString::SkipEmptyParts);
    848756    QStringList::iterator it = list.begin();
    849757    for (; it != list.end(); it++)
    850758    {
     
    927835{
    928836    raw_songlist.remove(' ');
    929837
    930     QStringList curList = QStringList::split(",", raw_songlist);
    931     QStringList newList = QStringList::split(",", new_songlist);
     838    QStringList curList = raw_songlist.split(",", QString::SkipEmptyParts);
     839    QStringList newList = new_songlist.split(",", QString::SkipEmptyParts);
    932840    QStringList::iterator it = newList.begin();
    933841    QString songlist = "";
    934842
     
    943851
    944852int Playlist::writeTree(GenericTree *tree_to_write_to, int a_counter)
    945853{
    946     Track *it;
    947 
    948854    // compute max/min playcount,lastplay for this playlist
    949855    int playcountMin = 0;
    950856    int playcountMax = 0;
     
    961867    ArtistMap::iterator            Iartist;
    962868    QString                        artist;
    963869
    964     for (it = songs.first(); it; it = songs.next())
     870    uint idx = 0;
     871    SongList::const_iterator it = songs.begin();
     872    for (; it != songs.end(); ++it, ++idx)
    965873    {
    966         if (!it->getCDFlag())
     874        if (!(*it)->getCDFlag())
    967875        {
    968             if (it->getValue() == 0)
     876            if ((*it)->getValue() == 0)
    969877            {
    970                 VERBOSE(VB_IMPORTANT, kID0err);
     878                VERBOSE(VB_IMPORTANT, LOC_ERR + kID0err);
    971879            }
    972             if (it->getValue() > 0)
     880            if ((*it)->getValue() > 0)
    973881            {
    974882                // Normal track
    975                 Metadata *tmpdata
    976                     = all_available_music->getMetadata(it->getValue());
     883                Metadata *tmpdata =
     884                    all_available_music->getMetadata((*it)->getValue());
    977885                if (tmpdata)
    978886                {
    979887                    if (tmpdata->isVisible())
    980888                    {
    981                         if (songs.at() == 0)
     889                        if (0 == idx)
    982890                        { // first song
    983891                            playcountMin = playcountMax = tmpdata->PlayCount();
    984892                            lastplayMin = lastplayMax = tmpdata->LastPlay();
     
    1034942    parent->FillIntelliWeights(RatingWeight, PlayCountWeight, LastPlayWeight,
    1035943                               RandomWeight);
    1036944
    1037     for (it = songs.first(); it; it = songs.next())
     945    for (it = songs.begin(); it != songs.end(); ++it)
    1038946    {
    1039         if (!it->getCDFlag())
     947        if (!(*it)->getCDFlag())
    1040948        {
    1041             if (it->getValue() == 0)
     949            if ((*it)->getValue() == 0)
    1042950            {
    1043                 VERBOSE(VB_IMPORTANT, kID0err);
     951                VERBOSE(VB_IMPORTANT, LOC_ERR + kID0err);
    1044952            }
    1045             if (it->getValue() > 0)
     953            if ((*it)->getValue() > 0)
    1046954            {
    1047955                // Normal track
    1048                 Metadata *tmpdata
    1049                     = all_available_music->getMetadata(it->getValue());
     956                Metadata *tmpdata =
     957                    all_available_music->getMetadata((*it)->getValue());
    1050958                if (tmpdata && tmpdata->isVisible())
    1051959                {
    1052960                    QString a_string = QString("%1 ~ %2")
    1053961                                       .arg(tmpdata->FormatArtist())
    1054962                                       .arg(tmpdata->FormatTitle());
    1055963                    GenericTree *added_node = tree_to_write_to->addNode(
    1056                         a_string, it->getValue(), true);
     964                        a_string, (*it)->getValue(), true);
    1057965                    ++a_counter;
    1058966                    added_node->setAttribute(0, 1);
    1059967                    added_node->setAttribute(1, a_counter); //  regular order
     
    11281036                    added_node->setAttribute(5, integer_order);
    11291037                }
    11301038            }
    1131             if (it->getValue() < 0)
     1039            if ((*it)->getValue() < 0)
    11321040            {
    11331041                // it's a playlist, recurse (mildly)
    11341042                Playlist *level_down
    1135                     = parent->getPlaylist((it->getValue()) * -1);
     1043                    = parent->getPlaylist(((*it)->getValue()) * -1);
    11361044                if (level_down)
    11371045                {
    11381046                    a_counter = level_down->writeTree(tree_to_write_to,
     
    11421050        }
    11431051        else
    11441052        {
    1145             Metadata *tmpdata
    1146                 = all_available_music->getMetadata(it->getValue());
     1053            Metadata *tmpdata =
     1054                all_available_music->getMetadata((*it)->getValue());
    11471055            if (tmpdata)
    11481056            {
    11491057                QString a_string = QString("(CD) %1 ~ %2")
     
    11541062                {
    11551063                    a_string = QString("(CD) Track %1").arg(tmpdata->Track());
    11561064                }
    1157                 GenericTree *added_node
    1158                     = tree_to_write_to->addNode(a_string, it->getValue(), true);
     1065                GenericTree *added_node =
     1066                    tree_to_write_to->addNode(a_string, (*it)->getValue(), true);
    11591067                ++a_counter;
    11601068                added_node->setAttribute(0, 1);
    11611069                added_node->setAttribute(1, a_counter); //  regular order
     
    11671075    return a_counter;
    11681076}
    11691077
    1170 GenericTree* PlaylistsContainer::writeTree(GenericTree *tree_to_write_to)
    1171 {
    1172     all_available_music->writeTree(tree_to_write_to);
    1173 
    1174     GenericTree *sub_node
    1175         = tree_to_write_to->addNode(QObject::tr("All My Playlists"), 1);
    1176     sub_node->setAttribute(0, 1);
    1177     sub_node->setAttribute(1, 1);
    1178     sub_node->setAttribute(2, 1);
    1179     sub_node->setAttribute(3, 1);
    1180 
    1181     GenericTree *subsub_node
    1182         = sub_node->addNode(QObject::tr("Active Play Queue"), 0);
    1183     subsub_node->setAttribute(0, 0);
    1184     subsub_node->setAttribute(1, 0);
    1185     subsub_node->setAttribute(2, rand());
    1186     subsub_node->setAttribute(3, rand());
    1187 
    1188     active_playlist->writeTree(subsub_node, 0);
    1189 
    1190     int a_counter = 0;
    1191 
    1192     //
    1193     //  Write the CD playlist (if there's anything in it)
    1194     //
    1195 
    1196 /*
    1197     if (cd_playlist.count() > 0)
    1198     {
    1199         ++a_counter;
    1200         QString a_string = QObject::tr("CD: ");
    1201         a_string += all_available_music->getCDTitle();
    1202         GenericTree *cd_node = sub_node->addNode(a_string, 0);
    1203         cd_node->setAttribute(0, 0);
    1204         cd_node->setAttribute(1, a_counter);
    1205         cd_node->setAttribute(2, rand());
    1206         cd_node->setAttribute(3, rand());
    1207     }
    1208 */
    1209 
    1210     //
    1211     //  Write the other playlists
    1212     //
    1213 
    1214     Q3PtrListIterator<Playlist> iterator( *all_other_playlists );
    1215     Playlist *a_list;
    1216     while( ( a_list = iterator.current() ) != 0)
    1217     {
    1218         ++a_counter;
    1219         GenericTree *new_node = sub_node->addNode(a_list->getName(),
    1220                                                   a_list->getID());
    1221         new_node->setAttribute(0, 0);
    1222         new_node->setAttribute(1, a_counter);
    1223         new_node->setAttribute(2, rand());
    1224         new_node->setAttribute(3, rand());
    1225         a_list->writeTree(new_node, 0);
    1226         ++iterator;
    1227     }
    1228 
    1229     GenericTree* active_playlist_node = subsub_node->findLeaf();
    1230     if (!active_playlist_node) active_playlist_node = subsub_node;
    1231     return active_playlist_node;
    1232 }
    1233 
    1234 void PlaylistsContainer::save()
    1235 {
    1236     Playlist *a_list;
    1237 
    1238     for(a_list = all_other_playlists->first();
    1239         a_list; a_list = all_other_playlists->next())
    1240     {
    1241         if (a_list->hasChanged())
    1242         {
    1243             a_list->fillSonglistFromSongs();
    1244             a_list->savePlaylist(a_list->getName(), my_host);
    1245         }
    1246     }
    1247 
    1248     active_playlist->savePlaylist("default_playlist_storage", my_host);
    1249     backup_playlist->savePlaylist("backup_playlist_storage", my_host);
    1250 }
    1251 
    1252 void PlaylistsContainer::createNewPlaylist(QString name)
    1253 {
    1254     Playlist *new_list = new Playlist(all_available_music);
    1255     new_list->setParent(this);
    1256 
    1257     //  Need to touch the database to get persistent ID
    1258     new_list->savePlaylist(name, my_host);
    1259     new_list->Changed();
    1260     all_other_playlists->append(new_list);
    1261     //if (my_widget)
    1262     //{
    1263     //    new_list->putYourselfOnTheListView(my_widget);
    1264     //}
    1265 }
    1266 
    1267 void PlaylistsContainer::copyNewPlaylist(QString name)
    1268 {
    1269     Playlist *new_list = new Playlist(all_available_music);
    1270     new_list->setParent(this);
    1271 
    1272     //  Need to touch the database to get persistent ID
    1273     new_list->savePlaylist(name, my_host);
    1274     new_list->Changed();
    1275     all_other_playlists->append(new_list);
    1276     active_playlist->copyTracks(new_list, false);
    1277     pending_writeback_index = 0;
    1278     active_widget->setText(QObject::tr("Active Play Queue"));
    1279     active_playlist->removeAllTracks();
    1280     active_playlist->addTrack(new_list->getID() * -1, true, false);
    1281 }
    1282 
    1283 void PlaylistsContainer::setActiveWidget(PlaylistTitle *widget)
    1284 {
    1285     active_widget = widget;
    1286     if (active_widget && pending_writeback_index > 0)
    1287     {
    1288         bool bad = false;
    1289         QString newlabel = QString(QObject::tr("Active Play Queue (%1)"))
    1290                            .arg(getPlaylistName(pending_writeback_index, bad));
    1291         active_widget->setText(newlabel);
    1292     }
    1293 }
    1294 
    1295 void PlaylistsContainer::popBackPlaylist()
    1296 {
    1297     Playlist *destination = getPlaylist(pending_writeback_index);
    1298     if (!destination)
    1299     {
    1300         VERBOSE(VB_IMPORTANT, QString("Unknown playlist: %1")
    1301                 .arg(pending_writeback_index));
    1302         return;
    1303     }
    1304     destination->removeAllTracks();
    1305     destination->Changed();
    1306     active_playlist->copyTracks(destination, false);
    1307     active_playlist->removeAllTracks();
    1308     backup_playlist->copyTracks(active_playlist, true);
    1309     pending_writeback_index = 0;
    1310     active_widget->setText(QObject::tr("Active Play Queue"));
    1311 
    1312     active_playlist->Changed();
    1313     backup_playlist->Changed();
    1314 }
    1315 
    1316 void PlaylistsContainer::copyToActive(int index)
    1317 {
    1318     backup_playlist->removeAllTracks();
    1319     active_playlist->copyTracks(backup_playlist, false);
    1320 
    1321     pending_writeback_index = index;
    1322     if (active_widget)
    1323     {
    1324         bool bad = false;
    1325         QString newlabel = QString(QObject::tr("Active Play Queue (%1)"))
    1326             .arg(getPlaylistName(index, bad));
    1327         active_widget->setText(newlabel);
    1328     }
    1329     active_playlist->removeAllTracks();
    1330     Playlist *copy_from = getPlaylist(index);
    1331     if (!copy_from)
    1332     {
    1333         VERBOSE(VB_IMPORTANT, QString("Unknown playlist: %1").arg(index));
    1334         return;
    1335     }
    1336     copy_from->copyTracks(active_playlist, true);
    1337 
    1338     active_playlist->Changed();
    1339     backup_playlist->Changed();
    1340 }
    1341 
    1342 
    1343 void PlaylistsContainer::renamePlaylist(int index, QString new_name)
    1344 {
    1345     Playlist *list_to_rename = getPlaylist(index);
    1346     if (list_to_rename)
    1347     {
    1348         list_to_rename->setName(new_name);
    1349         list_to_rename->Changed();
    1350         if (list_to_rename->getID() == pending_writeback_index)
    1351         {
    1352             QString newlabel = QString(QObject::tr("Active Play Queue (%1)"))
    1353                 .arg(new_name);
    1354             active_widget->setText(newlabel);
    1355         }
    1356     }
    1357 }
    1358 
    1359 void PlaylistsContainer::deletePlaylist(int kill_me)
    1360 {
    1361     Playlist *list_to_kill = getPlaylist(kill_me);
    1362     if (!list_to_kill)
    1363     {
    1364         VERBOSE(VB_IMPORTANT, QString("Unknown playlist: %1").arg(kill_me));
    1365         return;
    1366     }
    1367     //  First, we need to take out any **track** on any other
    1368     //  playlist that is actually a reference to this
    1369     //  playlist
    1370 
    1371     if (kill_me == pending_writeback_index)
    1372         popBackPlaylist();
    1373 
    1374     active_playlist->removeTrack(kill_me * -1, false);
    1375 
    1376     Q3PtrListIterator<Playlist> iterator( *all_other_playlists );
    1377     Playlist *a_list;
    1378     while( ( a_list = iterator.current() ) != 0)
    1379     {
    1380         ++iterator;
    1381         if (a_list != list_to_kill)
    1382         {
    1383             a_list->removeTrack(kill_me * -1, false);
    1384         }
    1385     }
    1386 
    1387     MSqlQuery query(MSqlQuery::InitCon());
    1388     query.prepare("DELETE FROM music_playlists WHERE playlist_id = :ID ;");
    1389     query.bindValue(":ID", kill_me);
    1390 
    1391     if (!query.exec() || query.numRowsAffected() < 1)
    1392     {
    1393         MythDB::DBError("playlist delete", query);
    1394     }
    1395     list_to_kill->removeAllTracks();
    1396     all_other_playlists->remove(list_to_kill);
    1397 }
    1398 
    1399 
    1400 QString PlaylistsContainer::getPlaylistName(int index, bool &reference)
    1401 {
    1402     if (active_playlist)
    1403     {
    1404         if (active_playlist->getID() == index)
    1405         {
    1406             return active_playlist->getName();
    1407         }
    1408 
    1409         Playlist *a_list;
    1410         for(a_list = all_other_playlists->last();
    1411             a_list; a_list = all_other_playlists->prev())
    1412         {
    1413             if (a_list->getID() == index)
    1414             {
    1415                 return a_list->getName();
    1416             }
    1417         }
    1418     }
    1419     VERBOSE(VB_IMPORTANT, "getPlaylistName() called with unknown index number");
    1420     reference = true;
    1421     return QObject::tr("Something is Wrong");
    1422 }
    1423 
    14241078bool Playlist::containsReference(int to_check, int depth)
    14251079{
    14261080    if (depth > 10)
    14271081    {
    1428         VERBOSE(VB_IMPORTANT, "Recursively checking playlists, and have "
    1429                               "reached a search depth over 10 ");
     1082        VERBOSE(VB_IMPORTANT,
     1083                LOC_ERR + "Recursively checking playlists, and have "
     1084                "reached a search depth over 10 ");
    14301085    }
    14311086    bool ref_exists = false;
    14321087
     
    14341089    //  Attempt to avoid infinite recursion
    14351090    //  in playlists (within playlists) =P
    14361091
    1437     Track *it;
    1438     for(it = songs.first(); it; it = songs.next())
     1092    SongList::const_iterator it = songs.begin();
     1093    for (; it != songs.end(); ++it)
    14391094    {
    1440         check = it->getValue();
    1441         if (check < 0 && !it->getCDFlag())
     1095        check = (*it)->getValue();
     1096        if (check < 0 && !(*it)->getCDFlag())
    14421097        {
    14431098            if (check * -1 == to_check)
    14441099            {
     
    14591114    return ref_exists;
    14601115}
    14611116
    1462 Playlist *PlaylistsContainer::getPlaylist(int id)
    1463 {
    1464     //  return a pointer to a playlist
    1465     //  by id;
    1466 
    1467     if (active_playlist->getID() == id)
    1468     {
    1469         return active_playlist;
    1470     }
    1471 
    1472     //  Very Suprisingly, we need to use an iterator on this,
    1473     //  because if we just traverse the list, other functions (that
    1474     //  called this) that are also traversing the same list get
    1475     //  reset. That took a **long** time to figure out
    1476 
    1477     Q3PtrListIterator<Playlist> iterator( *all_other_playlists );
    1478     Playlist *a_list;
    1479     while( ( a_list = iterator.current() ) != 0)
    1480     {
    1481         ++iterator;
    1482         if (a_list->getID() == id)
    1483         {
    1484             return a_list;
    1485         }
    1486     }
    1487     VERBOSE(VB_IMPORTANT, "getPlaylistName() called with unknown index number");
    1488     return NULL;
    1489 }
    1490 
    1491 void PlaylistsContainer::showRelevantPlaylists(TreeCheckItem *alllists)
    1492 {
    1493     QString templevel, temptitle;
    1494     int id;
    1495     //  Deleting anything that's there
    1496     while (alllists->childCount() > 0)
    1497     {
    1498         UIListGenericTree *first_child;
    1499         first_child = (UIListGenericTree *)(alllists->getChildAt(0));
    1500         {
    1501             first_child->RemoveFromParent();
    1502             //delete first_child;  Deleted by GenericTree.
    1503         }
    1504     }
    1505 
    1506     //  Add everything but the current playlist
    1507     Playlist *some_list;
    1508     for (some_list = all_other_playlists->first(); some_list;
    1509          some_list = all_other_playlists->next())
    1510     {
    1511         id = some_list->getID() * -1 ;
    1512         temptitle = some_list->getName();
    1513         templevel = "playlist";
    1514 
    1515         TreeCheckItem *some_item = new TreeCheckItem(alllists, temptitle,
    1516                                                      templevel, id);
    1517 
    1518         some_item->setCheckable(true);
    1519         some_item->setActive(true);
    1520 
    1521         if (some_list->containsReference(pending_writeback_index, 0) ||
    1522             (id * -1) == pending_writeback_index)
    1523         {
    1524             some_item->setCheckable(false);
    1525             some_item->setActive(false);
    1526         }
    1527 
    1528         some_list->putYourselfOnTheListView(some_item);
    1529     }
    1530 
    1531     if (alllists->childCount() == 0)
    1532         alllists->setCheckable(false);
    1533     else
    1534         alllists->setCheckable(true);
    1535 }
    1536 
    1537 void PlaylistsContainer::refreshRelevantPlaylists(TreeCheckItem *alllists)
    1538 {
    1539     if (alllists->childCount() == 0)
    1540     {
    1541         alllists->setCheckable(false);
    1542         return;
    1543     }
    1544 
    1545     UIListGenericTree *walker = (UIListGenericTree *)(alllists->getChildAt(0));
    1546     while (walker)
    1547     {
    1548         if (TreeCheckItem *check_item = dynamic_cast<TreeCheckItem*>(walker))
    1549         {
    1550             int id = check_item->getID() * -1;
    1551             Playlist *check_playlist = getPlaylist(id);
    1552             if ((check_playlist &&
    1553                 check_playlist->containsReference(pending_writeback_index, 0))
    1554                || id == pending_writeback_index)
    1555             {
    1556                 check_item->setCheckable(false);
    1557                 check_item->setActive(false);
    1558             }
    1559             else
    1560             {
    1561                 check_item->setCheckable(true);
    1562                 check_item->setActive(true);
    1563             }
    1564         }
    1565         walker = (UIListGenericTree *)(walker->nextSibling(1));
    1566     }
    1567 
    1568     alllists->setCheckable(true);
    1569 }
    1570 
    1571 void PlaylistsContainer::postLoad()
    1572 {
    1573     //  Now that everything is loaded, we need to recheck all
    1574     //  tracks and update those that refer to a playlist
    1575 
    1576     active_playlist->postLoad();
    1577     backup_playlist->postLoad();
    1578     Q3PtrListIterator<Playlist> iterator( *all_other_playlists );
    1579     Playlist *a_list;
    1580     while( ( a_list = iterator.current() ) != 0)
    1581     {
    1582         ++iterator;
    1583         a_list->postLoad();
    1584     }
    1585 }
    1586 
    1587 bool PlaylistsContainer::pendingWriteback()
    1588 {
    1589     if (pending_writeback_index > 0)
    1590     {
    1591         return true;
    1592     }
    1593     return false;
    1594 }
    1595 
    1596 bool PlaylistsContainer::nameIsUnique(QString a_name, int which_id)
    1597 {
    1598     if (a_name == "default_playlist_storage")
    1599     {
    1600         return false;
    1601     }
    1602 
    1603     if (a_name == "backup_playlist_storage")
    1604     {
    1605         return false;
    1606     }
    1607 
    1608     Q3PtrListIterator<Playlist> iterator( *all_other_playlists );
    1609     Playlist *a_list;
    1610     while( ( a_list = iterator.current() ) != 0)
    1611     {
    1612         ++iterator;
    1613         if (a_list->getName() == a_name &&
    1614            a_list->getID() != which_id)
    1615         {
    1616             return false;
    1617         }
    1618     }
    1619     return true ;
    1620 }
    1621 
    1622 bool PlaylistsContainer::cleanOutThreads()
    1623 {
    1624     if (playlists_loader->isFinished())
    1625     {
    1626         return true;
    1627     }
    1628     playlists_loader->wait();
    1629     return false;
    1630 }
    1631 
    1632 void PlaylistsContainer::clearActive()
    1633 {
    1634     backup_playlist->removeAllTracks();
    1635     active_playlist->removeAllTracks();
    1636     backup_playlist->Changed();
    1637     active_playlist->Changed();
    1638     pending_writeback_index = 0;
    1639     active_widget->setText(QObject::tr("Active Play Queue"));
    1640 }
    1641 
    16421117// Here begins CD Writing things. ComputeSize, CreateCDMP3 & CreateCDAudio
    16431118
    16441119void Playlist::computeSize(double &size_in_MB, double &size_in_sec)
    16451120{
    1646     Track *it;
    16471121    double child_MB;
    16481122    double child_sec;
    16491123
     
    16511125    size_in_MB = 0.0;
    16521126    size_in_sec = 0.0;
    16531127
    1654     for (it = songs.first(); it; it = songs.next())
     1128    SongList::const_iterator it = songs.begin();
     1129    for (; it != songs.end(); ++it)
    16551130    {
    1656         if (it->getCDFlag())
     1131        if ((*it)->getCDFlag())
    16571132            continue;
    16581133
    1659         if (it->getValue() == 0)
     1134        if ((*it)->getValue() == 0)
    16601135        {
    16611136            VERBOSE(VB_IMPORTANT, kID0err);
    16621137        }
    1663         else if (it->getValue() > 0)
     1138        else if ((*it)->getValue() > 0)
    16641139        {
    16651140            // Normal track
    1666             Metadata *tmpdata
    1667                 = all_available_music->getMetadata(it->getValue());
     1141            Metadata *tmpdata =
     1142                all_available_music->getMetadata((*it)->getValue());
    16681143            if (tmpdata)
    16691144            {
    16701145                if (tmpdata->Length() > 0)
     
    16791154                size_in_MB += finfo.size() / 1000000;
    16801155            }
    16811156        }
    1682         if (it->getValue() < 0)
     1157        if ((*it)->getValue() < 0)
    16831158        {
    16841159            // it's a playlist, recurse (mildly)
    16851160
    16861161            // Comment: I can't make this thing work.
    16871162            // Nothing is computed with playlists
    1688             Playlist *level_down = parent->getPlaylist((it->getValue()) * -1);
     1163            Playlist *level_down = parent->getPlaylist(((*it)->getValue()) * -1);
    16891164            if (level_down)
    16901165            {
    16911166                level_down->computeSize(child_MB, child_sec);
     
    17201195
    17211196    QStringList reclist;
    17221197
    1723     Track *it;
    1724     for (it = songs.first(); it; it = songs.next())
     1198    SongList::const_iterator it = songs.begin();
     1199    for (; it != songs.end(); ++it)
    17251200    {
    1726         if (it->getCDFlag())
     1201        if ((*it)->getCDFlag())
    17271202            continue;
    17281203
    1729         if (it->getValue() == 0)
     1204        if ((*it)->getValue() == 0)
    17301205        {
    17311206            VERBOSE(VB_IMPORTANT, kID0err);
    17321207        }
    1733         else if (it->getValue() > 0)
     1208        else if ((*it)->getValue() > 0)
    17341209        {
    17351210            // Normal track
    1736             Metadata *tmpdata
    1737                 = all_available_music->getMetadata(it->getValue());
     1211            Metadata *tmpdata =
     1212                all_available_music->getMetadata((*it)->getValue());
    17381213            if (tmpdata)
    17391214            {
    17401215                // check filename..
     
    17571232                reclist += outline;
    17581233            }
    17591234        }
    1760         else if (it->getValue() < 0)
     1235        else if ((*it)->getValue() < 0)
    17611236        {
    17621237            // FIXME: handle playlists
    17631238        }
     
    18001275        return 1;
    18011276    }
    18021277
    1803     Q3TextStream recstream(&reclistfile);
     1278    QTextStream recstream(&reclistfile);
    18041279
    18051280    QStringList::Iterator iter;
    18061281
     
    18411316                if (buf[6] == '%')
    18421317                {
    18431318                    buf = buf.mid(0, 3);
    1844                     progress->setProgress(buf.stripWhiteSpace().toInt());
     1319                    progress->setProgress(buf.trimmed().toInt());
    18451320                }
    18461321            }
    18471322            if (isofs.isRunning())
     
    19121387                QString line = burn.readLineStdout();
    19131388                if (line.mid(15, 2) == "of")
    19141389                {
    1915                     int mbdone = line.mid(10, 5).stripWhiteSpace().toInt();
    1916                     int mbtotal = line.mid(17, 5).stripWhiteSpace().toInt();
     1390                    int mbdone = line.mid(10, 5).trimmed().toInt();
     1391                    int mbtotal = line.mid(17, 5).trimmed().toInt();
    19171392
    19181393                    if (mbtotal > 0)
    19191394                    {
     
    19571432{
    19581433    return -1;
    19591434}
    1960 
  • mythplugins/mythmusic/mythmusic/vorbisencoder.cpp

     
    11#include <qstring.h>
    2 #include <q3cstring.h>
    32#include <qapplication.h>
    4 #include <q3progressbar.h>
    53
    64#include "metadata.h"
    75#include "encoder.h"
  • mythplugins/mythmusic/mythmusic/decoder.cpp

     
    1313
    1414#include <qapplication.h>
    1515#include <qobject.h>
    16 #include <q3ptrlist.h>
    1716#include <qdir.h>
    1817#include <qstringlist.h>
    1918#include <qregexp.h>
     
    171170void Decoder::SetLocationFormatUseTags(void)
    172171{
    173172    QString startdir = gContext->GetSetting("MusicLocation");
    174     startdir = QDir::cleanDirPath(startdir);
     173    startdir = QDir::cleanPath(startdir);
    175174    if (!startdir.endsWith("/"))
    176175        startdir += "/";
    177176
     
    180179    ignore_id3 = gContext->GetNumSetting("Ignore_ID3", 0);
    181180}
    182181
    183 static Q3PtrList<DecoderFactory> *factories = 0;
     182static QList<DecoderFactory*> *factories = NULL;
    184183
    185184static void checkFactories()
    186185{
    187186    if (!factories)
    188187    {
    189         factories = new Q3PtrList<DecoderFactory>;
     188        factories = new QList<DecoderFactory*>;
    190189
    191190#ifndef USING_MINGW
    192191        Decoder::registerFactory(new CdDecoderFactory);
     
    203202    checkFactories();
    204203
    205204    QStringList l;
    206     DecoderFactory *fact = factories->first();
    207     while (fact)
    208     {
    209         l << fact->description();
    210         fact = factories->next();
    211     }
    212205
     206    QList<DecoderFactory*>::iterator it = factories->begin();
     207    for (; it != factories->end(); ++it)
     208        l += (*it)->description();
     209
    213210    return l;
    214211}
    215212
     
    217214{
    218215    checkFactories();
    219216
    220     DecoderFactory *fact = factories->first();
    221     while (fact)
     217    QList<DecoderFactory*>::iterator it = factories->begin();
     218    for (; it != factories->end(); ++it)
    222219    {
    223         if (fact->supports(source))
    224             return TRUE;
    225 
    226         fact = factories->next();
     220        if ((*it)->supports(source))
     221            return true;
    227222    }
    228223
    229     return FALSE;
     224    return false;
    230225}
    231226
    232227void Decoder::registerFactory(DecoderFactory *fact)
    233228{
    234     factories->append(fact);
     229    factories->push_back(fact);
    235230}
    236231
    237232Decoder *Decoder::create(const QString &source, QIODevice *input,
     
    239234{
    240235    checkFactories();
    241236
    242     Decoder *decoder = 0;
    243 
    244     DecoderFactory *fact = factories->first();
    245     while (fact)
     237    QList<DecoderFactory*>::iterator it = factories->begin();
     238    for (; it != factories->end(); ++it)
    246239    {
    247         if (fact->supports(source))
    248         {
    249             decoder = fact->create(source, input, output, deletable);
    250             break;
    251         }
    252 
    253         fact = factories->next();
     240        if ((*it)->supports(source))
     241            return (*it)->create(source, input, output, deletable);
    254242    }
    255243
    256     return decoder;
     244    return NULL;
    257245}
    258246
    259247
  • mythplugins/mythmusic/mythmusic/smartplaylist.cpp

     
    975975
    976976    // criteria Rows
    977977    SmartPLCriteriaRow *row;
    978     criteriaRows.setAutoDelete(true);
    979978
    980979    hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult));
    981980    row = new SmartPLCriteriaRow(this, hbox);
    982981    connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void)));
    983     criteriaRows.append(row);
     982    criteriaRows.push_back(row);
    984983
    985984    hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult));
    986985    row = new SmartPLCriteriaRow(this, hbox);
    987986    connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void)));
    988     criteriaRows.append(row);
     987    criteriaRows.push_back(row);
    989988
    990989    hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult));
    991990    row = new SmartPLCriteriaRow(this, hbox);
    992991    connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void)));
    993     criteriaRows.append(row);
     992    criteriaRows.push_back(row);
    994993
    995994    hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult));
    996995    row = new SmartPLCriteriaRow(this, hbox);
    997996    connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void)));
    998     criteriaRows.append(row);
     997    criteriaRows.push_back(row);
    999998
    1000999    hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult));
    10011000    message = tr("Order By:");
     
    11081107SmartPlaylistEditor::~SmartPlaylistEditor(void)
    11091108{
    11101109    gContext->removeListener(this);
     1110    while (!criteriaRows.empty())
     1111    {
     1112        delete criteriaRows.back();
     1113        criteriaRows.pop_back();
     1114    }
    11111115}
    11121116
    11131117void SmartPlaylistEditor::titleChanged(void)
     
    11171121
    11181122void SmartPlaylistEditor::updateMatches(void)
    11191123{
    1120     QString sql = "select count(*) from music_songs "
    1121                   "LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
    1122                   "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
    1123                   "LEFT JOIN music_artists AS music_comp_artists ON "
    1124                   "music_albums.artist_id=music_comp_artists.artist_id "
    1125                   "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id ";
     1124    QString sql =
     1125        "SELECT count(*) "
     1126        "FROM music_songs "
     1127        "LEFT JOIN music_artists ON "
     1128        "    music_songs.artist_id=music_artists.artist_id "
     1129        "LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
     1130        "LEFT JOIN music_artists AS music_comp_artists ON "
     1131        "    music_albums.artist_id=music_comp_artists.artist_id "
     1132        "LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id ";
    11261133
    11271134    sql += getWhereClause();
    11281135
     1136    matchesCount = 0;
     1137
    11291138    MSqlQuery query(MSqlQuery::InitCon());
    1130     if (query.exec(sql))
    1131     {
    1132         if (query.size() > 0)
    1133         {
    1134             query.first();
    1135             matchesCount = query.value(0).toInt();
    1136         }
    1137         else
    1138             matchesCount = 0;
    1139     }
    1140     else
    1141     {
    1142         matchesCount = 0;
    1143     }
     1139    if (!query.exec(sql))
     1140        MythDB::DBError("SmartPlaylistEditor::updateMatches", query);
     1141    else if (query.next())
     1142        matchesCount = query.value(0).toInt();
    11441143
    1145     matchesLabel->setText(QString().setNum(matchesCount));
     1144    matchesLabel->setText(QString::number(matchesCount));
    11461145
    11471146    bPlaylistIsValid = (matchesCount > 0);
    11481147    showResultsButton->setEnabled(matchesCount > 0);
     
    12101209    }
    12111210
    12121211    // save smartplaylist items
    1213     SmartPLCriteriaRow *row;
    1214     for (row = criteriaRows.first(); row; row = criteriaRows.next())
    1215     {
    1216         row->saveToDatabase(ID);
    1217     }
     1212    vector<SmartPLCriteriaRow*>::iterator it = criteriaRows.begin();
     1213    for (; it != criteriaRows.end(); ++it)
     1214        (*it)->saveToDatabase(ID);
    12181215
    12191216    reject();
    12201217}
     
    12911288    if (query.isActive() && query.size() > 0)
    12921289    {
    12931290        rowCount = query.size();
    1294         if (rowCount > criteriaRows.count())
     1291        if (rowCount > criteriaRows.size())
    12951292        {
    1296             rowCount = criteriaRows.count();
     1293            rowCount = criteriaRows.size();
    12971294            VERBOSE(VB_IMPORTANT, QString("Warning:"
    12981295                    " got too many smartplaylistitems: %1").arg(rowCount));
    12991296        }
     
    13011298        query.first();
    13021299        for (uint x = 0; x < rowCount; x++)
    13031300        {
    1304             row = criteriaRows.at(x);
     1301            row = criteriaRows[x];
    13051302            QString Field = query.value(0).toString();
    13061303            QString Operator = query.value(1).toString();
    13071304            QString Value1 = query.value(2).toString();
     
    14741471
    14751472QString SmartPlaylistEditor::getWhereClause(void)
    14761473{
    1477     SmartPLCriteriaRow *row;
    1478     QString sql, criteria, matchType;
    1479 
    14801474    bool bFirst = true;
     1475    QString sql = "WHERE ";
    14811476
    1482     sql = "WHERE ";
    1483     for (row = criteriaRows.first(); row; row = criteriaRows.next())
     1477    vector<SmartPLCriteriaRow*>::iterator it = criteriaRows.begin();
     1478    for (; it != criteriaRows.end(); ++it)
    14841479    {
    1485         criteria = row->getSQL();
     1480        QString criteria = (*it)->getSQL();
    14861481        if (criteria.isEmpty())
    14871482            continue;
    14881483
  • mythplugins/mythmusic/mythmusic/lameencoder.cpp

     
    2424*/
    2525
    2626#include <qstring.h>
    27 #include <q3cstring.h>
    2827#include <qapplication.h>
    29 #include <q3progressbar.h>
    3028
    3129#include "metadata.h"
    3230#include "lameencoder.h"
  • mythplugins/mythmusic/mythmusic/treecheckitem.h

     
    66#include <QPixmap>
    77
    88class QPixmap;
    9 class PlaylistsContainer;
     9class PlaylistContainer;
    1010class Playlist;
    1111class Track;
    1212
  • mythplugins/mythmusic/mythmusic/databasebox.h

     
    11#ifndef DATABASEBOX_H_
    22#define DATABASEBOX_H_
    33
    4 #include <qwidget.h>
    5 #include <qdialog.h>
    6 #include <qstringlist.h>
    7 #include <qthread.h>
    8 #include <qtimer.h>
    9 #include <q3ptrlist.h>
    10 //Added by qt3to4:
     4#include <vector>
     5using namespace std;
     6
     7#include <QStringList>
     8#include <QThread>
    119#include <QPixmap>
    12 #include <QKeyEvent>
    1310
    1411#include "metadata.h"
    1512#include "playlist.h"
     
    1815#include <mythtv/uilistbtntype.h>
    1916
    2017class TreeCheckItem;
     18class QTimer;
     19class QKeyEvent;
    2120
    2221class ReadCDThread : public QThread
    2322{
     
    115114
    116115    QStringList         treelevels;
    117116
    118     Q3PtrList<UITextType> m_lines;
     117    vector<UITextType*> m_lines;
    119118};
    120119
    121120#endif
  • mythplugins/mythmusic/mythmusic/metadata.h

     
    11#ifndef METADATA_H_
    22#define METADATA_H_
    33
     4// C++
     5#include <vector>
     6using namespace std;
     7
    48// qt
    5 #include <qstring.h>
    6 #include <qstringlist.h>
    7 #include <q3ptrlist.h>
    8 #include <q3valuelist.h>
    9 #include <qmap.h>
    10 #include <qthread.h>
     9#include <QStringList>
     10#include <QMap>
     11#include <QThread>
    1112
    1213// mythtv
    1314#include <mythtv/uitypes.h>
     
    1819
    1920class AllMusic;
    2021class CoverArt;
    21 class PlaylistsContainer;
     22class PlaylistContainer;
    2223
    2324enum ImageType
    2425{
     
    170171    }
    171172    bool determineIfCompilation(bool cd = false);
    172173
    173     void setEmbeddedAlbumArt(Q3ValueList<struct AlbumArtImage> art);
     174    void setEmbeddedAlbumArt(const QList<struct AlbumArtImage> &art);
    174175
    175176    bool isInDatabase(void);
    176177    void dumpToDatabase(void);
     
    178179    void getField(const QString& field, QString *data);
    179180    void persist();
    180181    bool hasChanged() {return m_changed;}
    181     int compare (Metadata *other);
     182    int compare(const Metadata *other) const;
    182183    static void setArtistAndTrackFormats();
    183184
    184185    static void SetStartdir(const QString &dir);
     
    217218    QString m_lastplay;
    218219    int m_playcount;
    219220    bool m_compilation;
    220     Q3ValueList<struct AlbumArtImage> m_albumart;
     221    QList<struct AlbumArtImage> m_albumart;
    221222
    222223    unsigned int m_id;
    223224    QString m_filename;
     
    242243bool operator==(const Metadata& a, const Metadata& b);
    243244bool operator!=(const Metadata& a, const Metadata& b);
    244245
    245 class MetadataPtrList : public Q3PtrList<Metadata>
    246 {
    247   public:
    248     MetadataPtrList() {}
    249     ~MetadataPtrList() {}
    250 
    251   protected:
    252     int compareItems(Q3PtrCollection::Item item1,
    253                      Q3PtrCollection::Item item2);
    254 };
    255 
     246typedef QList<Metadata*> MetadataPtrList;
    256247class MusicNode;
    257 class MusicNodePtrList : public Q3PtrList<MusicNode>
    258 {
    259   public:
    260     MusicNodePtrList() {}
    261     ~MusicNodePtrList() {}
     248typedef QList<MusicNode*> MusicNodePtrList;
    262249
    263   protected:
    264     int compareItems(Q3PtrCollection::Item item1,
    265                      Q3PtrCollection::Item item2);
    266 };
    267 
    268250class MusicNode
    269251{   
    270252  public:
     
    272254    MusicNode(const QString &a_title, const QString &tree_level);
    273255   ~MusicNode();
    274256
    275     QString     getTitle(){return my_title;}
    276     void        printYourself(int indent_amount);   // debugging
     257    QString     getTitle(void) const { return my_title; }
     258    void        printYourself(int indent_amount) const;   // debugging
    277259    void        putYourselfOnTheListView(TreeCheckItem *parent, bool show_node);
    278260    void        writeTree(GenericTree *tree_to_write_to, int a_counter);
    279261    void        sort();
     
    384366    typedef QMap<int, Metadata*> MusicMap;
    385367    MusicMap music_map;
    386368   
    387     typedef Q3ValueList<Metadata>  ValueMetadata;
     369    typedef QList<Metadata>       ValueMetadata;
    388370    ValueMetadata                 m_cd_data; //  More than one cd player?
    389371    QString                       m_cd_title;
    390372
     
    414396
    415397    QString             paths;
    416398    QString             startdir;
    417     PlaylistsContainer *all_playlists;
     399    PlaylistContainer *all_playlists;
    418400    AllMusic           *all_music;
    419401    bool                runPost;
    420402};
     
    424406
    425407//----------------------------------------------------------------------------
    426408
    427 class AlbumArtImages: public QObject
     409class AlbumArtImages
    428410{
    429   Q_OBJECT
    430 
    431411  public:
    432412    AlbumArtImages(Metadata *metadata);
     413    ~AlbumArtImages();
    433414
    434     uint                     getImageCount() { return m_imageList.count(); }
    435     AlbumArtImage            getImage(ImageType type);
     415    typedef vector<AlbumArtImage*> ImageList;
     416
     417    uint                     getImageCount() { return m_imageList.size(); }
     418    AlbumArtImage           *getImage(ImageType type);
    436419    QString                  getTypeName(ImageType type);
    437     QStringList              getImageFilenames();
    438     Q3PtrList<AlbumArtImage> *getImageList() { return &m_imageList; }
    439     AlbumArtImage            getImageAt(uint index);
     420    QStringList              getImageFilenames(void) const;
     421    ImageList               *getImageList(void) { return &m_imageList; }
     422    AlbumArtImage           *getImageAt(uint index);
    440423
    441     bool isImageAvailable(ImageType type);
    442 
    443424    bool saveImageType(const int id, ImageType type);
    444425
    445426    static ImageType guessImageType(const QString &filename);
     
    447428  private:
    448429    void findImages(void);
    449430
    450     Metadata                *m_parent;
    451     Q3PtrList<AlbumArtImage>  m_imageList;
     431    Metadata  *m_parent;
     432    ImageList  m_imageList;
    452433};
    453434
    454435#endif
  • mythplugins/mythmusic/mythmusic/editmetadata.cpp

     
    1 #include <mythtv/mythcontext.h>
    2 #include <mythtv/mythdbcon.h>
    3 #include <mythtv/libmythui/mythuihelper.h>
    4 #include <qdir.h>
    5 //Added by qt3to4:
     1#include <QDir>
    62#include <QKeyEvent>
    73#include <QLabel>
    8 #include <Q3PtrList>
    94#include <QPixmap>
     5
    106#include "editmetadata.h"
    117#include "decoder.h"
    128#include "genres.h"
    139#include "metadata.h"
    1410
     11#include <mythcontext.h>
     12#include <mythdbcon.h>
     13#include <libmythui/mythuihelper.h>
     14
    1515EditMetadataDialog::EditMetadataDialog(Metadata       *source_metadata,
    1616                                       MythMainWindow *parent,
    1717                                       const QString  &window_name,
     
    148148
    149149void EditMetadataDialog::updateImageGrid()
    150150{
    151     Q3PtrList<AlbumArtImage> *albumArtList = albumArt->getImageList();
     151    vector<AlbumArtImage*> *albumArtList = albumArt->getImageList();
    152152
    153153    QSize size = coverart_grid->getImageItemSize();
    154154
    155     for (uint x = 0; x < albumArtList->count(); x++)
     155    for (uint x = 0; x < albumArtList->size(); x++)
    156156    {
    157157        if (albumArtList->at(x)->embedded)
    158158            continue;
     
    166166        coverart_grid->appendItem(item);
    167167    }
    168168
    169     coverart_grid->setItemCount(albumArtList->count());
     169    coverart_grid->setItemCount(albumArtList->size());
    170170    coverart_grid->recalculateLayout();
    171171
    172     if (albumArtList->count() > 0)
     172    if (!albumArtList->empty())
    173173        gridItemChanged(coverart_grid->getItemAt(0));
    174174
    175175    coverart_grid->refresh();
     
    536536    }
    537537
    538538    searchDialog->deleteLater();
    539     setActiveWindow();
     539    activateWindow();
    540540
    541541    return res;
    542542}
     
    653653    {
    654654        popup->deleteLater();
    655655        popup = NULL;
    656         setActiveWindow();
     656        activateWindow();
    657657    }
    658658}
    659659
  • mythplugins/mythmusic/mythmusic/treebuilders.cpp

     
    102102    typedef QMap<QString, Branch*> BranchMap;
    103103    BranchMap branches;
    104104   
    105     Metadata *meta;
    106     Q3PtrListIterator<Metadata> iter(metas);
    107     while ((meta = iter.current()) != 0)
     105    MetadataPtrList::const_iterator it = metas.begin();
     106    for (; it != metas.end(); ++it)
    108107    {
     108        Metadata *meta = *it;
    109109        if (isLeafDone(meta))
    110110        {
    111111            root->addLeaf(meta);
     
    113113        else
    114114        {
    115115            QString field = getField(meta);
    116             QString field_key = field.lower();
     116            QString field_key = field.toLower();
    117117
    118118            if (field_key.left(4) == thePrefix)
    119119                field_key = field_key.mid(4);
     
    127127            }
    128128            branch->list.append(meta);
    129129        }
    130 
    131         ++iter;
    132130    }
    133131
    134132    for(BranchMap::iterator it = branches.begin(); it != branches.end(); it++)
    135133    {
    136         Branch *branch = it.data();
     134        Branch *branch = *it;
    137135        MusicNode *sub_node = createNode(branch->field);
    138136        root->addChild(sub_node);
    139137        makeTree(sub_node, branch->list);
     
    148146  public:
    149147    MusicFieldTreeBuilder(const QString &paths)
    150148    {
    151         m_paths = QStringList::split(' ', paths);
     149        m_paths = paths.split(' ', QString::SkipEmptyParts);
    152150    }
    153151
    154152    ~MusicFieldTreeBuilder()
     
    198196
    199197    QString getSplitField(Metadata *meta, const QString &field)
    200198    {
    201         QString firstchar_str = meta->FormatArtist().stripWhiteSpace();
     199        QString firstchar_str = meta->FormatArtist().trimmed();
    202200
    203         if (firstchar_str.left(4).lower() == thePrefix)
    204             firstchar_str = firstchar_str.mid(4,1).upper();
     201        if (firstchar_str.left(4).toLower() == thePrefix)
     202            firstchar_str = firstchar_str.mid(4,1).toUpper();
    205203        else
    206             firstchar_str = firstchar_str.left(1).upper();
     204            firstchar_str = firstchar_str.left(1).toUpper();
    207205       
    208206        QChar firstchar = firstchar_str[0];
    209207        QString split = m_split_map[firstchar];
     
    291289    ~MusicDirectoryTreeBuilder()
    292290    {
    293291        for(MetaMap::iterator it = m_map.begin(); it != m_map.end(); it++)
    294             delete it.data();
     292            delete *it;
    295293    }
    296294
    297295protected:
     
    321319            return paths;
    322320
    323321        QString filename = meta->Filename().remove(0, getStartdir().length());
    324         paths = new QStringList(QStringList::split('/', filename));
     322        paths = new QStringList(filename.split('/'));
    325323        m_map[meta] = paths;
    326324       
    327325        return paths;
  • mythplugins/mythmusic/mythmusic/musicplayer.h

     
    11#ifndef MUSICPLAYER_H_
    22#define MUSICPLAYER_H_
    33
    4 #include <iostream>
    5 
    64#include <mythtv/mythdialogs.h>
    75#include <mythtv/audiooutput.h>
    86
     
    1412
    1513class MusicPlayer : public QObject
    1614{
    17   //Q_OBJECT
    18 
    1915  public:
    20 
    2116     MusicPlayer(QObject *parent, const QString &dev);
    22     ~MusicPlayer(void);
    2317
    2418    void playFile(const QString &filename);
    2519    void playFile(const Metadata &meta);
     
    111105    ResumeMode  getResumeMode(void) { return m_resumeMode; }
    112106
    113107  protected:
     108    ~MusicPlayer(void);
    114109    void customEvent(QEvent *event);
    115110
    116111  private:
  • mythplugins/mythmusic/mythmusic/avfdecoder.cpp

     
    124124    seekTime = -1.0;
    125125    totalTime = 0.0;
    126126
    127     filename = ((QFile *)input())->name();
     127    filename = ((QFile *)input())->fileName();
    128128
    129129    if (!output_buf)
    130130        output_buf = new char[globalBufferSize];
     
    137137
    138138    // open the media file
    139139    // this should populate the input context
    140     int error;
    141     error = av_open_input_file(&m_inputContext, filename, m_inputFormat, 0,
    142                                m_ap);
     140    int error = av_open_input_file(
     141        &m_inputContext, filename.toLocal8Bit().constData(),
     142        m_inputFormat, 0, m_ap);
     143
    143144    if (error < 0)
    144145    {
    145146        VERBOSE(VB_GENERAL, QString("Could open file with the AV decoder. "
     
    427428
    428429bool avfDecoderFactory::supports(const QString &source) const
    429430{
    430      QStringList list = QStringList::split("|", extension());
    431      for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
    432      {
    433          if (*it == source.right((*it).length()).lower())
    434              return true;
    435      }
     431    QStringList list = extension().split("|", QString::SkipEmptyParts);
     432    for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
     433    {
     434        if (*it == source.right((*it).length()).toLower())
     435            return true;
     436    }
    436437
    437      return false;
     438    return false;
    438439}
    439440
    440441const QString &avfDecoderFactory::extension() const
  • mythplugins/mythmusic/mythmusic/playlistcontainer.cpp

     
     1#include <mythcontext.h>
     2#include <mythdb.h>
     3#include <compat.h>
     4
     5#include "playlistcontainer.h"
     6
     7PlaylistLoadingThread::PlaylistLoadingThread(PlaylistContainer *parent_ptr,
     8                                             AllMusic *all_music_ptr)
     9{
     10    parent = parent_ptr;
     11    all_music = all_music_ptr;
     12}
     13
     14void PlaylistLoadingThread::run()
     15{
     16    while(!all_music->doneLoading())
     17    {
     18        sleep(1);
     19    }
     20    parent->load();
     21}
     22
     23#define LOC      QString("PlaylistContainer: ")
     24#define LOC_WARN QString("PlaylistContainer, Warning: ")
     25#define LOC_ERR  QString("PlaylistContainer, Error: ")
     26
     27void PlaylistContainer::clearCDList()
     28{
     29    cd_playlist.clear();
     30}
     31
     32void PlaylistContainer::addCDTrack(int track)
     33{
     34    cd_playlist.push_back(track);
     35}
     36
     37void PlaylistContainer::removeCDTrack(int track)
     38{
     39    cd_playlist.remove(track);
     40}
     41
     42bool PlaylistContainer::checkCDTrack(int track)
     43{
     44    list<int>::const_iterator it =
     45        find(cd_playlist.begin(), cd_playlist.end(), track);
     46    return it != cd_playlist.end();
     47}
     48
     49PlaylistContainer::PlaylistContainer(AllMusic *all_music, const QString &host_name) :
     50    active_playlist(NULL),      backup_playlist(NULL),
     51    all_other_playlists(NULL),  all_available_music(all_music),
     52    active_widget(NULL),
     53
     54    playlists_loader(new PlaylistLoadingThread(this, all_music)),
     55    done_loading(false),        my_host(host_name),
     56
     57    RatingWeight(   gContext->GetNumSetting("IntelliRatingWeight",    2)),
     58    PlayCountWeight(gContext->GetNumSetting("IntelliPlayCountWeight", 2)),
     59    LastPlayWeight( gContext->GetNumSetting("IntelliLastPlayWeight",  2)),
     60    RandomWeight(   gContext->GetNumSetting("IntelliRandomWeight",    2))
     61{
     62    playlists_loader->start();
     63}
     64
     65PlaylistContainer::~PlaylistContainer()
     66{
     67    playlists_loader->wait();
     68    playlists_loader->deleteLater();
     69
     70    if (active_playlist)
     71        delete active_playlist;
     72    if (backup_playlist)
     73        delete backup_playlist;
     74    if (all_other_playlists)
     75    {
     76        while (!all_other_playlists->empty())
     77        {
     78            delete all_other_playlists->front();
     79            all_other_playlists->pop_front();
     80        }
     81        delete all_other_playlists;
     82    }
     83}
     84
     85void PlaylistContainer::FillIntelliWeights(int &rating, int &playcount,
     86                                            int &lastplay, int &random)
     87{
     88    rating = RatingWeight;
     89    playcount = PlayCountWeight;
     90    lastplay = LastPlayWeight;
     91    random = RandomWeight;
     92}
     93
     94void PlaylistContainer::load()
     95{
     96    done_loading = false;
     97    active_playlist = new Playlist(all_available_music);
     98    active_playlist->setParent(this);
     99
     100    backup_playlist = new Playlist(all_available_music);
     101    backup_playlist->setParent(this);
     102
     103    all_other_playlists = new list<Playlist*>;
     104
     105    cd_playlist.clear();
     106
     107    active_playlist->loadPlaylist("default_playlist_storage", my_host);
     108    active_playlist->fillSongsFromSonglist(false);
     109
     110    backup_playlist->loadPlaylist("backup_playlist_storage", my_host);
     111    backup_playlist->fillSongsFromSonglist(false);
     112
     113    MSqlQuery query(MSqlQuery::InitCon());
     114    query.prepare("SELECT playlist_id FROM music_playlists "
     115                  "WHERE playlist_name != :DEFAULT"
     116                  " AND playlist_name != :BACKUP "
     117                  " AND (hostname = '' OR hostname = :HOST) "
     118                  "ORDER BY playlist_id;");
     119    query.bindValue(":DEFAULT", "default_playlist_storage");
     120    query.bindValue(":BACKUP", "backup_playlist_storage");
     121    query.bindValue(":HOST", my_host);
     122
     123    if (!query.exec())
     124    {
     125        MythDB::DBError("Querying playlists", query);
     126    }
     127    else
     128    {
     129        while (query.next())
     130        {
     131            Playlist *temp_playlist = new Playlist(all_available_music);
     132            //  No, we don't destruct this ...
     133            temp_playlist->setParent(this);
     134            temp_playlist->loadPlaylistByID(query.value(0).toInt(), my_host);
     135            temp_playlist->fillSongsFromSonglist(false);
     136            all_other_playlists->push_back(temp_playlist);
     137            //  ... cause it's sitting on this PtrList
     138        }
     139    }
     140    postLoad();
     141
     142    pending_writeback_index = 0;
     143
     144    int x = gContext->GetNumSetting("LastMusicPlaylistPush");
     145    setPending(x);
     146    done_loading = true;
     147}
     148
     149void PlaylistContainer::describeYourself(void) const
     150{
     151    //    Debugging
     152    active_playlist->describeYourself();
     153    list<Playlist*>::const_iterator it = all_other_playlists->begin();
     154    for (; it != all_other_playlists->end(); ++it)
     155        (*it)->describeYourself();
     156}
     157
     158Playlist *PlaylistContainer::getPlaylist(int id)
     159{
     160    //  return a pointer to a playlist
     161    //  by id;
     162
     163    if (active_playlist->getID() == id)
     164    {
     165        return active_playlist;
     166    }
     167
     168    list<Playlist*>::iterator it = all_other_playlists->begin();
     169    for (; it != all_other_playlists->end(); ++it)
     170    {
     171        if ((*it)->getID() == id)
     172            return *it;
     173    }
     174
     175    VERBOSE(VB_IMPORTANT, "getPlaylistName() called with unknown index number");
     176    return NULL;
     177}
     178
     179GenericTree* PlaylistContainer::writeTree(GenericTree *tree_to_write_to)
     180{
     181    all_available_music->writeTree(tree_to_write_to);
     182
     183    GenericTree *sub_node
     184        = tree_to_write_to->addNode(QObject::tr("All My Playlists"), 1);
     185    sub_node->setAttribute(0, 1);
     186    sub_node->setAttribute(1, 1);
     187    sub_node->setAttribute(2, 1);
     188    sub_node->setAttribute(3, 1);
     189
     190    GenericTree *subsub_node
     191        = sub_node->addNode(QObject::tr("Active Play Queue"), 0);
     192    subsub_node->setAttribute(0, 0);
     193    subsub_node->setAttribute(1, 0);
     194    subsub_node->setAttribute(2, rand());
     195    subsub_node->setAttribute(3, rand());
     196
     197    active_playlist->writeTree(subsub_node, 0);
     198
     199    int a_counter = 0;
     200
     201    //
     202    //  Write the CD playlist (if there's anything in it)
     203    //
     204
     205/*
     206    if (cd_playlist.count() > 0)
     207    {
     208        ++a_counter;
     209        QString a_string = QObject::tr("CD: ");
     210        a_string += all_available_music->getCDTitle();
     211        GenericTree *cd_node = sub_node->addNode(a_string, 0);
     212        cd_node->setAttribute(0, 0);
     213        cd_node->setAttribute(1, a_counter);
     214        cd_node->setAttribute(2, rand());
     215        cd_node->setAttribute(3, rand());
     216    }
     217*/
     218
     219    //
     220    //  Write the other playlists
     221    //
     222
     223    list<Playlist*>::const_iterator it = all_other_playlists->begin();
     224    for (; it != all_other_playlists->end(); ++it)
     225    {
     226        ++a_counter;
     227        GenericTree *new_node = sub_node->addNode((*it)->getName(), (*it)->getID());
     228        new_node->setAttribute(0, 0);
     229        new_node->setAttribute(1, a_counter);
     230        new_node->setAttribute(2, rand());
     231        new_node->setAttribute(3, rand());
     232        (*it)->writeTree(new_node, 0);
     233    }
     234
     235    GenericTree* active_playlist_node = subsub_node->findLeaf();
     236    if (!active_playlist_node) active_playlist_node = subsub_node;
     237    return active_playlist_node;
     238}
     239
     240void PlaylistContainer::save(void)
     241{
     242    list<Playlist*>::const_iterator it = all_other_playlists->begin();
     243    for (; it != all_other_playlists->end(); ++it)
     244    {
     245        if ((*it)->hasChanged())
     246        {
     247            (*it)->fillSonglistFromSongs();
     248            (*it)->savePlaylist((*it)->getName(), my_host);
     249        }
     250    }
     251
     252    active_playlist->savePlaylist("default_playlist_storage", my_host);
     253    backup_playlist->savePlaylist("backup_playlist_storage", my_host);
     254}
     255
     256void PlaylistContainer::createNewPlaylist(QString name)
     257{
     258    Playlist *new_list = new Playlist(all_available_music);
     259    new_list->setParent(this);
     260
     261    //  Need to touch the database to get persistent ID
     262    new_list->savePlaylist(name, my_host);
     263    new_list->Changed();
     264    all_other_playlists->push_back(new_list);
     265    //if (my_widget)
     266    //{
     267    //    new_list->putYourselfOnTheListView(my_widget);
     268    //}
     269}
     270
     271void PlaylistContainer::copyNewPlaylist(QString name)
     272{
     273    Playlist *new_list = new Playlist(all_available_music);
     274    new_list->setParent(this);
     275
     276    //  Need to touch the database to get persistent ID
     277    new_list->savePlaylist(name, my_host);
     278    new_list->Changed();
     279    all_other_playlists->push_back(new_list);
     280    active_playlist->copyTracks(new_list, false);
     281    pending_writeback_index = 0;
     282    active_widget->setText(QObject::tr("Active Play Queue"));
     283    active_playlist->removeAllTracks();
     284    active_playlist->addTrack(new_list->getID() * -1, true, false);
     285}
     286
     287void PlaylistContainer::setActiveWidget(PlaylistTitle *widget)
     288{
     289    active_widget = widget;
     290    if (active_widget && pending_writeback_index > 0)
     291    {
     292        bool bad = false;
     293        QString newlabel = QString(QObject::tr("Active Play Queue (%1)"))
     294                           .arg(getPlaylistName(pending_writeback_index, bad));
     295        active_widget->setText(newlabel);
     296    }
     297}
     298
     299void PlaylistContainer::popBackPlaylist()
     300{
     301    Playlist *destination = getPlaylist(pending_writeback_index);
     302    if (!destination)
     303    {
     304        VERBOSE(VB_IMPORTANT, LOC_WARN + "popBackPlaylist() " +
     305                QString("Unknown playlist: %1")
     306                .arg(pending_writeback_index));
     307        return;
     308    }
     309    destination->removeAllTracks();
     310    destination->Changed();
     311    active_playlist->copyTracks(destination, false);
     312    active_playlist->removeAllTracks();
     313    backup_playlist->copyTracks(active_playlist, true);
     314    pending_writeback_index = 0;
     315    active_widget->setText(QObject::tr("Active Play Queue"));
     316
     317    active_playlist->Changed();
     318    backup_playlist->Changed();
     319}
     320
     321void PlaylistContainer::copyToActive(int index)
     322{
     323    backup_playlist->removeAllTracks();
     324    active_playlist->copyTracks(backup_playlist, false);
     325
     326    pending_writeback_index = index;
     327    if (active_widget)
     328    {
     329        bool bad = false;
     330        QString newlabel = QString(QObject::tr("Active Play Queue (%1)"))
     331            .arg(getPlaylistName(index, bad));
     332        active_widget->setText(newlabel);
     333    }
     334    active_playlist->removeAllTracks();
     335    Playlist *copy_from = getPlaylist(index);
     336    if (!copy_from)
     337    {
     338        VERBOSE(VB_IMPORTANT, LOC_ERR + "copyToActive() " +
     339                QString("Unknown playlist: %1").arg(index));
     340        return;
     341    }
     342    copy_from->copyTracks(active_playlist, true);
     343
     344    active_playlist->Changed();
     345    backup_playlist->Changed();
     346}
     347
     348
     349void PlaylistContainer::renamePlaylist(int index, QString new_name)
     350{
     351    Playlist *list_to_rename = getPlaylist(index);
     352    if (list_to_rename)
     353    {
     354        list_to_rename->setName(new_name);
     355        list_to_rename->Changed();
     356        if (list_to_rename->getID() == pending_writeback_index)
     357        {
     358            QString newlabel = QString(QObject::tr("Active Play Queue (%1)"))
     359                .arg(new_name);
     360            active_widget->setText(newlabel);
     361        }
     362    }
     363}
     364
     365void PlaylistContainer::deletePlaylist(int kill_me)
     366{
     367    Playlist *list_to_kill = getPlaylist(kill_me);
     368    if (!list_to_kill)
     369    {
     370        VERBOSE(VB_IMPORTANT, LOC_ERR + "deletePlaylist() " +
     371                QString("Unknown playlist: %1").arg(kill_me));
     372        return;
     373    }
     374    //  First, we need to take out any **track** on any other
     375    //  playlist that is actually a reference to this
     376    //  playlist
     377
     378    if (kill_me == pending_writeback_index)
     379        popBackPlaylist();
     380
     381    active_playlist->removeTrack(kill_me * -1, false);
     382
     383    list<Playlist*>::iterator it = all_other_playlists->begin();
     384    for (; it != all_other_playlists->end(); ++it)
     385    {
     386        if ((*it) != list_to_kill)
     387            (*it)->removeTrack(kill_me * -1, false);
     388    }
     389
     390    MSqlQuery query(MSqlQuery::InitCon());
     391    query.prepare("DELETE FROM music_playlists WHERE playlist_id = :ID ;");
     392    query.bindValue(":ID", kill_me);
     393
     394    if (!query.exec() || query.numRowsAffected() < 1)
     395    {
     396        MythDB::DBError("playlist delete", query);
     397    }
     398    list_to_kill->removeAllTracks();
     399    all_other_playlists->remove(list_to_kill);
     400}
     401
     402
     403QString PlaylistContainer::getPlaylistName(int index, bool &reference)
     404{
     405    if (active_playlist)
     406    {
     407        if (active_playlist->getID() == index)
     408        {
     409            return active_playlist->getName();
     410        }
     411
     412        list<Playlist*>::const_reverse_iterator it = all_other_playlists->rbegin();
     413        for (; it != all_other_playlists->rend(); it++)
     414        {
     415            if ((*it)->getID() == index)
     416                return (*it)->getName();
     417        }
     418    }
     419
     420    VERBOSE(VB_IMPORTANT, LOC_ERR +
     421            "getPlaylistName() called with unknown index number");
     422
     423    reference = true;
     424    return QObject::tr("Something is Wrong");
     425}
     426
     427void PlaylistContainer::showRelevantPlaylists(TreeCheckItem *alllists)
     428{
     429    QString templevel, temptitle;
     430    int id;
     431    //  Deleting anything that's there
     432    while (alllists->childCount() > 0)
     433    {
     434        UIListGenericTree *first_child;
     435        first_child = (UIListGenericTree *)(alllists->getChildAt(0));
     436        {
     437            first_child->RemoveFromParent();
     438            //delete first_child;  Deleted by GenericTree.
     439        }
     440    }
     441
     442    //  Add everything but the current playlist
     443    list<Playlist*>::iterator it = all_other_playlists->begin();
     444    for (; it != all_other_playlists->end(); ++it)
     445    {
     446        id = (*it)->getID() * -1 ;
     447        temptitle = (*it)->getName();
     448        templevel = "playlist";
     449
     450        TreeCheckItem *some_item = new TreeCheckItem(alllists, temptitle,
     451                                                     templevel, id);
     452
     453        some_item->setCheckable(true);
     454        some_item->setActive(true);
     455
     456        if ((*it)->containsReference(pending_writeback_index, 0) ||
     457            (id * -1) == pending_writeback_index)
     458        {
     459            some_item->setCheckable(false);
     460            some_item->setActive(false);
     461        }
     462
     463        (*it)->putYourselfOnTheListView(some_item);
     464    }
     465
     466    if (alllists->childCount() == 0)
     467        alllists->setCheckable(false);
     468    else
     469        alllists->setCheckable(true);
     470}
     471
     472void PlaylistContainer::refreshRelevantPlaylists(TreeCheckItem *alllists)
     473{
     474    if (alllists->childCount() == 0)
     475    {
     476        alllists->setCheckable(false);
     477        return;
     478    }
     479
     480    UIListGenericTree *walker = (UIListGenericTree *)(alllists->getChildAt(0));
     481    while (walker)
     482    {
     483        if (TreeCheckItem *check_item = dynamic_cast<TreeCheckItem*>(walker))
     484        {
     485            int id = check_item->getID() * -1;
     486            Playlist *check_playlist = getPlaylist(id);
     487            if ((check_playlist &&
     488                check_playlist->containsReference(pending_writeback_index, 0))
     489               || id == pending_writeback_index)
     490            {
     491                check_item->setCheckable(false);
     492                check_item->setActive(false);
     493            }
     494            else
     495            {
     496                check_item->setCheckable(true);
     497                check_item->setActive(true);
     498            }
     499        }
     500        walker = (UIListGenericTree *)(walker->nextSibling(1));
     501    }
     502
     503    alllists->setCheckable(true);
     504}
     505
     506void PlaylistContainer::postLoad()
     507{
     508    //  Now that everything is loaded, we need to recheck all
     509    //  tracks and update those that refer to a playlist
     510
     511    active_playlist->postLoad();
     512    backup_playlist->postLoad();
     513
     514    list<Playlist*>::iterator it = all_other_playlists->begin();
     515    for (; it != all_other_playlists->end(); ++it)
     516        (*it)->postLoad();
     517}
     518
     519bool PlaylistContainer::pendingWriteback()
     520{
     521    if (pending_writeback_index > 0)
     522    {
     523        return true;
     524    }
     525    return false;
     526}
     527
     528bool PlaylistContainer::nameIsUnique(QString a_name, int which_id)
     529{
     530    if (a_name == "default_playlist_storage")
     531        return false;
     532
     533    if (a_name == "backup_playlist_storage")
     534        return false;
     535
     536    list<Playlist*>::iterator it = all_other_playlists->begin();
     537    for (; it != all_other_playlists->end(); ++it)
     538    {
     539        if ((*it)->getName() == a_name && (*it)->getID() != which_id)
     540            return false;
     541    }
     542
     543    return true;
     544}
     545
     546bool PlaylistContainer::cleanOutThreads()
     547{
     548    if (playlists_loader->isFinished())
     549    {
     550        return true;
     551    }
     552    playlists_loader->wait();
     553    return false;
     554}
     555
     556void PlaylistContainer::clearActive()
     557{
     558    backup_playlist->removeAllTracks();
     559    active_playlist->removeAllTracks();
     560    backup_playlist->Changed();
     561    active_playlist->Changed();
     562    pending_writeback_index = 0;
     563    active_widget->setText(QObject::tr("Active Play Queue"));
     564}
     565
  • mythplugins/mythmusic/mythmusic/metaiotaglib.h

     
    11#ifndef METAIOTAGLIB_H_
    22#define METAIOTAGLIB_H_
    33
    4 #include "metaio.h"
    5 #include "metadata.h"
    64#include <id3v2tag.h>
    75#include <textidentificationframe.h>
    86#include <attachedpictureframe.h>
    97#include <mpegfile.h>
    108#include <mpegproperties.h>
    11 //Added by qt3to4:
    12 #include <Q3ValueList>
    139
     10#include <QList>
     11
     12#include "metaio.h"
     13#include "metadata.h"
     14
    1415using TagLib::MPEG::File;
    1516using TagLib::Tag;
    1617using TagLib::ID3v2::UserTextIdentificationFrame;
     
    1920using TagLib::String;
    2021using TagLib::MPEG::Properties;
    2122
    22 typedef Q3ValueList<struct AlbumArtImage> AlbumArtList;
     23typedef QList<struct AlbumArtImage> AlbumArtList;
    2324
    2425class MetaIOTagLib : public MetaIO
    2526{
  • mythplugins/mythmusic/mythmusic/smartplaylist.h

     
    11#ifndef SMARTPLAYLIST_H_
    22#define SMARTPLAYLIST_H_
    33
    4 #include <qdatetime.h>
    5 #include <qlayout.h>
    6 #include <q3hbox.h>
    7 #include <qvariant.h>
     4#include <vector>
     5using namespace std;
     6
     7#include <QDateTime>
     8#include <QVariant>
     9#include <QKeyEvent>
    810//Added by qt3to4:
     11#include <QLayout>
     12#include <QLabel>
     13#include <Q3HBox>
    914#include <Q3HBoxLayout>
    10 #include <QLabel>
    11 #include <Q3PtrList>
    12 #include <QKeyEvent>
    1315#include <Q3VBoxLayout>
    1416
    1517#include <mythtv/mythwidgets.h>
     
    155157    QAbstractButton            *renameCategoryButton;
    156158    QAbstractButton            *deleteCategoryButton;
    157159   
    158     Q3PtrList<SmartPLCriteriaRow> criteriaRows;
     160    vector<SmartPLCriteriaRow*> criteriaRows;
    159161    int matchesCount;
    160162    bool bNewPlaylist;
    161163    bool bPlaylistIsValid;
  • mythplugins/mythmusic/mythmusic/databasebox.cpp

     
     1// C
    12#include <cstdlib>
     3
     4// C++
    25#include <iostream>
    3 //Added by qt3to4:
    4 #include <QKeyEvent>
    5 #include <Q3PtrList>
    66using namespace std;
    77
    88// qt
    9 #include <qapplication.h>
    10 #include <qstringlist.h>
    11 #include <qpixmap.h>
    12 #include <qregexp.h>
    13 #include <q3frame.h>
    14 #include <qlayout.h>
    15 #include <qevent.h>
     9#include <QApplication>
     10#include <QKeyEvent>
     11#include <QRegExp>
     12#include <QLayout>
     13#include <QEvent>
    1614
    1715// mythtv
    1816#include <mythtv/dialogbox.h>
     
    2624#include "databasebox.h"
    2725#include "treecheckitem.h"
    2826#include "cddecoder.h"
    29 #include "playlist.h"
     27#include "playlistcontainer.h"
    3028#include "musicplayer.h"
    3129#ifndef USING_MINGW
    3230#include "cddecoder.h"
     
    5250    cd_checking_flag = gContext->GetNumSetting("AutoLookupCD");
    5351
    5452    QString treelev = gContext->GetSetting("TreeLevels", "artist album title");
    55     QStringList treelevels = QStringList::split(" ", treelev.lower());
     53    QStringList treelevels = treelev.toLower().split(" ");
    5654
    5755    active_popup = NULL;
    5856    active_pl_edit = NULL;
     
    8886    {
    8987        QString linename = QString("line%1").arg(i);
    9088        if ((line = getUITextType(linename)))
    91             m_lines.append(line);
     89            m_lines.push_back(line);
    9290    }
    9391
    94     if (m_lines.count() < 3)
     92    if (m_lines.size() < 3)
    9593    {
    9694        DialogBox *dlg = new DialogBox(
    9795            gContext->GetMainWindow(),
     
    234232
    235233void DatabaseBox::occasionallyCheckCD()
    236234{
    237     if (cd_reader_thread->getLock()->locked())
     235    if (!cd_reader_thread->getLock()->tryLock())
    238236        return;
     237    cd_reader_thread->getLock()->unlock();
    239238
    240239    if (cd_reader_thread->statusChanged())
    241240    {
     
    245244            fillCD();
    246245        }
    247246    }
    248     if (!cd_reader_thread->running())
     247    if (!cd_reader_thread->isRunning())
    249248        cd_reader_thread->start();
    250249}
    251250
     
    700699        }
    701700
    702701        // Pre increment as not incremented from previous use.
    703         while (++line < m_lines.count())
     702        while (++line < (unsigned) m_lines.size())
    704703          m_lines.at(line)->SetText("");
    705704
    706705        // Don't forget to delete the mdata storage if we allocated it.
     
    749748        dispat++;
    750749    }
    751750
    752     for (unsigned int i = dispat; i < m_lines.count(); i++)
     751    for (unsigned int i = dispat; i < (unsigned) m_lines.size(); i++)
    753752        m_lines.at(i)->SetText("");
    754753}
    755754
  • mythplugins/mythmusic/mythmusic/vcedit.c

     
    100100/* Next two functions pulled straight from libvorbis, apart from one change
    101101 * - we don't want to overwrite the vendor string.
    102102 */
    103 static void _v_writestring(oggpack_buffer *o,char *s, int len)
     103static void _v_writestring(oggpack_buffer *o,const char *s, int len)
    104104{
    105105        while(len--)
    106106        {
  • mythplugins/mythmusic/mythmusic/main.cpp

     
    2525#include "metadata.h"
    2626#include "databasebox.h"
    2727#include "playbackbox.h"
    28 #include "playlist.h"
     28#include "playlistcontainer.h"
    2929#include "globalsettings.h"
    3030#include "dbcheck.h"
    3131#include "filescanner.h"
     
    218218{
    219219    (void) data;
    220220
    221     QString sel = selection.lower();
     221    QString sel = selection.toLower();
    222222    if (sel == "music_create_playlist")
    223223        startDatabaseTree();
    224224    else if (sel == "music_play")
     
    443443
    444444    //  Load all available info about songs (once!)
    445445    QString startdir = gContext->GetSetting("MusicLocation");
    446     startdir = QDir::cleanDirPath(startdir);
     446    startdir = QDir::cleanPath(startdir);
    447447    if (!startdir.endsWith("/"))
    448448        startdir += "/";
    449449
     
    468468    AllMusic *all_music = new AllMusic(paths, startdir);
    469469
    470470    //  Load all playlists into RAM (once!)
    471     PlaylistsContainer *all_playlists = new PlaylistsContainer(all_music, gContext->GetHostName());
     471    PlaylistContainer *all_playlists = new PlaylistContainer(
     472        all_music, gContext->GetHostName());
    472473
    473474    gMusicData->paths = paths;
    474475    gMusicData->startdir = startdir;
     
    512513    gMusicData->runPost = false;
    513514    gMusicData->paths = gContext->GetSetting("TreeLevels");
    514515    gMusicData->startdir = gContext->GetSetting("MusicLocation");
    515     gMusicData->startdir = QDir::cleanDirPath(gMusicData->startdir);
     516    gMusicData->startdir = QDir::cleanPath(gMusicData->startdir);
    516517
    517518    if (!gMusicData->startdir.endsWith("/"))
    518519        gMusicData->startdir += "/";
     
    528529
    529530void mythplugin_destroy(void)
    530531{
    531     delete gPlayer;
     532    gPlayer->deleteLater();
    532533    delete gMusicData;
    533534}
    534535
  • mythplugins/mythmusic/mythmusic/musicplayer.cpp

     
    11// ANSI C includes
    22#include <cstdlib>
    33
    4 // C++ includes
    5 #include <iostream>
    6 #include <Q3ValueList>
    7 
    8 using namespace std;
    9 
    104// qt
    11 #include <qapplication.h>
    12 #include <q3url.h>
    13 #include <qwidget.h>
     5#include <QApplication>
     6#include <QWidget>
    147#include <QFile>
     8#include <QList>
    159
    1610// mythtv
    1711#include <mythtv/mythcontext.h>
     
    2519#include "constants.h"
    2620#include "mainvisual.h"
    2721#include "miniplayer.h"
    28 #include "playlist.h"
     22#include "playlistcontainer.h"
    2923
    3024// how long to wait before updating the lastplay and playcount fields
    3125#define LASTPLAY_DELAY 15
     
    5852    m_playSpeed = 1.0;
    5953
    6054    QString playmode = gContext->GetSetting("PlayMode", "none");
    61     if (playmode.lower() == "random")
     55    if (playmode.toLower() == "random")
    6256        setShuffleMode(SHUFFLE_RANDOM);
    63     else if (playmode.lower() == "intelligent")
     57    else if (playmode.toLower() == "intelligent")
    6458        setShuffleMode(SHUFFLE_INTELLIGENT);
    65     else if (playmode.lower() == "album")
     59    else if (playmode.toLower() == "album")
    6660        setShuffleMode(SHUFFLE_ALBUM);
    67     else if (playmode.lower() == "artist")
     61    else if (playmode.toLower() == "artist")
    6862        setShuffleMode(SHUFFLE_ARTIST);
    6963    else
    7064        setShuffleMode(SHUFFLE_OFF);
    7165
    7266    QString repeatmode = gContext->GetSetting("RepeatMode", "all");
    73     if (repeatmode.lower() == "track")
     67    if (repeatmode.toLower() == "track")
    7468        setRepeatMode(REPEAT_TRACK);
    75     else if (repeatmode.lower() == "all")
     69    else if (repeatmode.toLower() == "all")
    7670        setRepeatMode(REPEAT_ALL);
    7771    else
    7872        setRepeatMode(REPEAT_OFF);
    7973
    8074    QString resumestring = gContext->GetSetting("ResumeMode", "off");
    81     if (resumestring.lower() == "off")
     75    if (resumestring.toLower() == "off")
    8276        m_resumeMode = RESUME_OFF;
    83     else if (resumestring.lower() == "track")
     77    else if (resumestring.toLower() == "track")
    8478        m_resumeMode = RESUME_TRACK;
    8579    else
    8680        m_resumeMode = RESUME_EXACT;
     
    326320
    327321void MusicPlayer::stopDecoder(void)
    328322{
    329     if (m_decoder && m_decoder->running())
     323    if (m_decoder && m_decoder->isRunning())
    330324    {
    331325        m_decoder->lock();
    332326        m_decoder->stop();
     
    666660
    667661void MusicPlayer::restorePosition(const QString &position)
    668662{
    669     Q3ValueList <int> branches_to_current_node;
     663    QList<int> branches_to_current_node;
    670664
    671665    if (position != "")
    672666    {
    673         QStringList list = QStringList::split(",", position);
     667        QStringList list = position.split(",", QString::SkipEmptyParts);
    674668
    675669        for (QStringList::Iterator it = list.begin(); it != list.end(); ++it)
    676670            branches_to_current_node.append((*it).toInt());
     
    707701        m_output->Reset();
    708702        m_output->SetTimecode(pos*1000);
    709703
    710         if (m_decoder && m_decoder->running())
     704        if (m_decoder && m_decoder->isRunning())
    711705        {
    712706            m_decoder->lock();
    713707            m_decoder->seek(pos);
  • mythplugins/mythmusic/mythmusic/metaiotaglib.cpp

     
    1 #include <math.h>
     1#include <cmath>
    22
    33#include "metaiotaglib.h"
    44#include "metadata.h"
    55
    6 #include <mythtv/mythcontext.h>
    7 //Added by qt3to4:
    8 #include <Q3ValueList>
     6#include <mythverbose.h>
    97
     8#undef QStringToTString
     9#define QStringToTString(s) TagLib::String(s.toUtf8().data(), TagLib::String::UTF8)
     10#undef TStringToQString
     11#define TStringToQString(s) QString::fromUtf8(s.toCString(true))
     12
     13
    1014MetaIOTagLib::MetaIOTagLib(void)
    1115    : MetaIO(".mp3")
    1216{
     
    129133            genre = "";
    130134    int year = 0, tracknum = 0, length = 0, playcount = 0, rating = 0, id = 0;
    131135    bool compilation = false;
    132     Q3ValueList<struct AlbumArtImage> albumart;
     136    QList<struct AlbumArtImage> albumart;
    133137
    134138    QString extension = filename.section( '.', -1 ) ;
    135139
     
    148152    // Basic Tags
    149153    if (! tag->isEmpty())
    150154    {
    151         title = TStringToQString(tag->title()).stripWhiteSpace();
    152         artist = TStringToQString(tag->artist()).stripWhiteSpace();
    153         album = TStringToQString(tag->album()).stripWhiteSpace();
     155        title = TStringToQString(tag->title()).trimmed();
     156        artist = TStringToQString(tag->artist()).trimmed();
     157        album = TStringToQString(tag->album()).trimmed();
    154158        tracknum = tag->track();
    155159        year = tag->year();
    156         genre = TStringToQString(tag->genre()).stripWhiteSpace();
     160        genre = TStringToQString(tag->genre()).trimmed();
    157161    }
    158162
    159163    // ID3V2 Only Tags
     
    164168        {
    165169            compilation_artist = TStringToQString(
    166170            taglib->ID3v2Tag()->frameListMap()["TPE4"].front()->toString())
    167             .stripWhiteSpace();
     171                .trimmed();
    168172        }
    169173
    170174        // Look for MusicBrainz Album+Artist ID in TXXX Frame
     
    323327 */
    324328AlbumArtList MetaIOTagLib::readAlbumArt(TagLib::ID3v2::Tag *tag)
    325329{
     330    QList<struct AlbumArtImage> artlist;
    326331
    327     Q3ValueList<struct AlbumArtImage> artlist;
    328 
    329332    if (!tag->frameListMap()["APIC"].isEmpty())
    330333    {
    331334        TagLib::ID3v2::FrameList apicframes = tag->frameListMap()["APIC"];
  • mythplugins/mythmusic/mythmusic/playbackbox.h

     
    22#define PLAYBACKBOX_H_
    33
    44// qt
    5 #include <qtimer.h>
    6 #include <qmutex.h>
    7 #include <q3valuevector.h>
    85#include <QKeyEvent>
     6#include <q3valuevector.h>
    97
    108// mythtv
    119#include <mythtv/mythwidgets.h>
     
    2220
    2321class Output;
    2422class Decoder;
     23class QTimer;
    2524
    2625class PlaybackBoxMusic : public MythThemedDialog
    2726{
  • mythplugins/mythmusic/mythmusic/mainvisual.cpp

     
    7474    int y = size.height() / 2 - height / 2;
    7575
    7676    for (int offset = 0; offset < height; offset += fm.height()) {
    77         QString l = warning.left(warning.find("\n"));
     77        QString l = warning.left(warning.indexOf("\n"));
    7878        p->drawText(x, y + offset, width, height, Qt::AlignCenter, l);
    7979        warning.remove(0, l.length () + 1);
    8080    }
    8181}
    8282
    8383MainVisual::MainVisual(QWidget *parent, const char *name)
    84     : QWidget(parent, name), vis(0), meta(0), playing(FALSE), fps(20),
     84    : QWidget(parent), vis(0), meta(0), playing(FALSE), fps(20),
    8585      timer (0), bannerTimer(0), info_widget(0)
    8686{
     87    setObjectName(name);
    8788    int screenwidth = 0, screenheight = 0;
    8889    float wmult = 0, hmult = 0;
    8990
     
    121122    delete bannerTimer;
    122123    bannerTimer = 0;
    123124
    124     nodes.setAutoDelete(TRUE);
    125     nodes.clear();
     125    while (!nodes.empty())
     126    {
     127        delete nodes.back();
     128        nodes.pop_back();
     129    }
    126130}
    127131
    128132void MainVisual::setVisual(const QString &name)
     
    167171
    168172void MainVisual::prepare()
    169173{
    170     nodes.setAutoDelete(TRUE);
    171     nodes.clear();
    172     nodes.setAutoDelete(FALSE);
     174    while (!nodes.empty())
     175    {
     176        delete nodes.back();
     177        nodes.pop_back();
     178    }
    173179}
    174180
    175181void MainVisual::add(uchar *b, unsigned long b_len, unsigned long w, int c, int p)
     
    219225        return;
    220226    }
    221227
    222     VisualNode *node = 0;
    223 
     228    VisualNode *node = NULL;
    224229    if (playing && output())
    225230    {
    226231        long synctime = output()->GetAudiotime();
    227232        mutex()->lock();
    228         VisualNode *prev = 0;
    229         while ((node = nodes.first()))
     233        VisualNode *prev = NULL;
     234        while (!nodes.empty())
    230235        {
     236            node = nodes.front();
    231237            if (node->offset > synctime)
    232238                break;
    233             delete prev;
    234             nodes.removeFirst();
     239            nodes.pop_front();
     240
     241            if (prev)
     242                delete prev;
    235243            prev = node;
    236244        }
    237245        mutex()->unlock();
     
    443451        QString info_copy = info;
    444452        for (int offset = 0; offset < textHeight; offset += fm.height())
    445453        {
    446             QString l = info_copy.left(info_copy.find("\n"));
     454            QString l = info_copy.left(info_copy.indexOf("\n"));
    447455            p.setPen(Qt::black);
    448456            p.drawText(x + 2, y + offset + 2, textWidth, textHeight, Qt::AlignLeft, l);
    449457            p.setPen(Qt::white);
     
    489497    QString info_copy = info;
    490498    for (int offset = 0; offset < textHeight; offset += fm.height())
    491499    {
    492         QString l = info_copy.left(info_copy.find("\n"));
     500        QString l = info_copy.left(info_copy.indexOf("\n"));
    493501        p.setPen(Qt::black);
    494502        p.drawText(x + 2, y + offset + 2, textWidth, textHeight, Qt::AlignLeft, l);
    495503        p.setPen(Qt::white);
     
    527535    uint os = magnitudes.size();
    528536    magnitudes.resize( size.width() * 2 );
    529537    for ( ; os < magnitudes.size(); os++ )
    530     magnitudes[os] = 0.0;
     538        magnitudes[os] = 0.0;
    531539}
    532540
    533541bool StereoScope::process( VisualNode *node )
  • mythplugins/mythmusic/mythmusic/playlistcontainer.h

     
     1#ifndef _PLAYLIST_CONTAINER_H_
     2#define _PLAYLIST_CONTAINER_H_
     3
     4#include <QThread>
     5
     6#include "playlist.h"
     7
     8class PlaylistLoadingThread : public QThread
     9{
     10  public:
     11    PlaylistLoadingThread(PlaylistContainer *parent_ptr,
     12                          AllMusic *all_music_ptr);
     13    virtual void run();
     14   
     15  private: 
     16    PlaylistContainer *parent;
     17    AllMusic          *all_music;
     18};
     19
     20class PlaylistContainer
     21{
     22  public:
     23    PlaylistContainer(AllMusic *all_music, const QString &host_name);
     24   ~PlaylistContainer();
     25
     26    void            load();
     27    void            describeYourself(void) const;    // debugging
     28
     29    Playlist*       getActive(void) { return active_playlist; }
     30    Playlist*       getPlaylist(int id);
     31
     32    void            setActiveWidget(PlaylistTitle *widget);
     33    PlaylistTitle*  getActiveWidget(void) { return active_widget; }
     34
     35    GenericTree*    writeTree(GenericTree *tree_to_write_to);
     36    void            clearCDList();
     37    void            addCDTrack(int x);
     38    void            removeCDTrack(int x);
     39    bool            checkCDTrack(int x);
     40    void            save();
     41
     42    void            createNewPlaylist(QString name);
     43    void            copyNewPlaylist(QString name);
     44    void            copyToActive(int index);
     45
     46    void            showRelevantPlaylists(TreeCheckItem *alllist);
     47    void            refreshRelevantPlaylists(TreeCheckItem *alllist);
     48
     49    QString         getPlaylistName(int index, bool &reference);
     50
     51    void            postLoad();
     52
     53    void            deletePlaylist(int index);
     54    void            renamePlaylist(int index, QString new_name);
     55
     56    void            popBackPlaylist();
     57    bool            pendingWriteback();
     58    void            setPending(int x){pending_writeback_index = x;}
     59    int             getPending(){return pending_writeback_index;}
     60
     61    bool            nameIsUnique(QString a_name, int which_id);
     62
     63    void            clearActive();
     64
     65    bool            doneLoading(){return done_loading;}
     66
     67    bool            cleanOutThreads();
     68
     69    void            FillIntelliWeights(int &rating, int &playcount,
     70                                       int &lastplay, int &random);
     71  private: 
     72    Playlist            *active_playlist;
     73    Playlist            *backup_playlist;
     74    list<int>            cd_playlist;
     75    list<Playlist*>     *all_other_playlists;
     76    AllMusic            *all_available_music;
     77    PlaylistTitle       *active_widget;
     78    int                 pending_writeback_index;
     79   
     80    PlaylistLoadingThread  *playlists_loader;
     81    bool                    done_loading;
     82    QString                 my_host;
     83
     84    int RatingWeight;
     85    int PlayCountWeight;
     86    int LastPlayWeight;
     87    int RandomWeight;
     88};
     89
     90#endif // _PLAYLIST_CONTAINER_H_
  • mythplugins/mythmusic/mythmusic/importmusic.cpp

     
    555555        ++it;
    556556        if (fi->fileName() == "." || fi->fileName() == "..")
    557557            continue;
    558         QString filename = fi->absFilePath();
     558        QString filename = fi->absoluteFilePath();
    559559        if (fi->isDir())
    560560            scanDirectory(filename, tracks);
    561561        else
     
    10871087    QFileInfo fi(filename);
    10881088    filename = fi.fileName();
    10891089
    1090     if (filename.contains("front", false) > 0)
     1090    if (filename.contains("front", Qt::CaseInsensitive) > 0)
    10911091        m_type_selector->setToItem(tr("Front Cover"));
    1092     else if (filename.contains("back", false) > 0)
     1092    else if (filename.contains("back", Qt::CaseInsensitive) > 0)
    10931093        m_type_selector->setToItem(tr("Back Cover"));
    1094     else if (filename.contains("inlay", false) > 0)
     1094    else if (filename.contains("inlay", Qt::CaseInsensitive) > 0)
    10951095        m_type_selector->setToItem(tr("Inlay"));
    1096     else if (filename.contains("cd", false) > 0)
     1096    else if (filename.contains("cd", Qt::CaseInsensitive) > 0)
    10971097        m_type_selector->setToItem(tr("CD"));
    10981098    else
    10991099        m_type_selector->setToItem(tr("<Unknown>"));
  • mythplugins/mythmusic/mythmusic/cddecoder.cpp

     
    258258void CdDecoder::setCDSpeed(int speed)
    259259{
    260260    QMutexLocker lock(getMutex());
    261     MediaMonitor::SetCDSpeed(devicename, speed);
     261    MediaMonitor::SetCDSpeed(devicename.toLocal8Bit().constData(), speed);
    262262}
    263263
    264264int CdDecoder::getNumTracks(void)
     
    408408
    409409    compilation_artist = M_QSTRING_UNICODE(discdata.data_artist);
    410410
    411     if (compilation_artist.lower().left(7) == "various")
     411    if (compilation_artist.toLower().left(7) == "various")
    412412    {
    413413        compilation_artist = QObject::tr("Various Artists");
    414414    }
     
    419419
    420420    if (!genre.isEmpty())
    421421    {
    422         QString flet = genre.upper().left(1);
    423         QString rt = genre.right(genre.length()-1).lower();
     422        QString flet = genre.toUpper().left(1);
     423        QString rt = genre.right(genre.length()-1).toLower();
    424424        genre = flet + rt;
    425425    }
    426426
     
    547547
    548548bool CdDecoderFactory::supports(const QString &source) const
    549549{
    550     return (source.right(extension().length()).lower() == extension());
     550    return (source.right(extension().length()).toLower() == extension());
    551551}
    552552
    553553const QString &CdDecoderFactory::extension() const
  • mythplugins/mythmusic/mythmusic/metaio.cpp

     
    1313MetaIO::MetaIO(QString fileExtension)
    1414    : mFileExtension(fileExtension)
    1515{
    16     mFilenameFormat = gContext->GetSetting("NonID3FileNameFormat").upper();
     16    mFilenameFormat = gContext->GetSetting("NonID3FileNameFormat").toUpper();
    1717}
    1818
    1919
     
    4444    static QString regext = mFileExtension + "$";
    4545    int part_num = 0;
    4646    filename.replace(QRegExp(QString("_")), QString(" "));
    47     filename.replace(QRegExp(regext, FALSE), QString(""));
    48     QStringList fmt_list = QStringList::split("/", mFilenameFormat);
     47    filename.replace(QRegExp(regext, Qt::CaseInsensitive), QString(""));
     48    QStringList fmt_list = mFilenameFormat.split("/");
    4949    QStringList::iterator fmt_it = fmt_list.begin();
    5050
    5151    // go through loop once to get minimum part number
     
    6767            title = part_str;
    6868        else if ( *fmt_it == "TRACK_TITLE" )
    6969        {
    70             QStringList tracktitle_list = QStringList::split("-", part_str);
     70            QStringList tracktitle_list = part_str.split("-");
    7171            if (tracktitle_list.size() > 1)
    7272            {
    7373                tracknum = tracktitle_list[0].toInt();
    74                 title = tracktitle_list[1].simplifyWhiteSpace();
     74                title = tracktitle_list[1].simplified();
    7575            }
    7676            else
    7777                title = part_str;
    7878        }
    7979        else if ( *fmt_it == "ARTIST_TITLE" )
    8080        {
    81             QStringList artisttitle_list = QStringList::split("-", part_str);
     81            QStringList artisttitle_list = part_str.split("-");
    8282            if (artisttitle_list.size() > 1)
    8383            {
    84                 artist = artisttitle_list[0].simplifyWhiteSpace();
    85                 title = artisttitle_list[1].simplifyWhiteSpace();
     84                artist = artisttitle_list[0].simplified();
     85                title = artisttitle_list[1].simplified();
    8686            }
    8787            else
    8888            {
  • mythplugins/mythmusic/mythmusic/goom/graphic.h

     
    1818extern const Color ORANGE;
    1919extern const Color VIOLET;
    2020
    21 inline void setPixelRGB (Uint * buffer, Uint x, Uint y, Color c);
    22 inline void getPixelRGB (Uint * buffer, Uint x, Uint y, Color * c);
     21//inline void setPixelRGB (Uint * buffer, Uint x, Uint y, Color c);
     22//inline void getPixelRGB (Uint * buffer, Uint x, Uint y, Color * c);
    2323
    2424#endif /* GRAPHIC_H */
  • mythplugins/mythmusic/mythmusic/streaminput.h

     
    1 //Added by qt3to4:
    2 #include <Q3CString>
    31// Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
    42//
    53// Use, modification and distribution is allowed without limitation,
     
    119
    1210class StreamInput;
    1311
    14 #include <q3url.h>
    15 #include <q3socket.h>
     12#include <QUrl>
     13#include <QTcpSocket>
    1614
    17 
    1815class StreamInput : public QObject
    1916{
    2017    Q_OBJECT
    21 public:
    22     StreamInput(const Q3Url &);
    2318
    24     QIODevice *socket() { return sock; }
     19  public:
     20    StreamInput(const QUrl&);
    2521
    26     void setup();
     22    QIODevice *GetSocket(void) { return sock; }
    2723
     24    void Setup(void);
    2825
    29 private slots:
    30     void hostfound();
    31     void connected();
    32     void readyread();
    33     void error(int);
     26  private slots:
     27    void HostFound(void);
     28    void Connected(void);
     29    void ReadyRead(void);
     30    void Error(QAbstractSocket::SocketError);
    3431
    35 
    36 private:
    37     Q3CString request;
    38     Q3Url url;
    39     Q3Socket *sock;
    40     int stage;
     32  private:
     33    QString     request;
     34    QUrl        url;
     35    QTcpSocket *sock;
     36    int         stage;
    4137};
    4238
    4339
  • mythplugins/mythmusic/mythmusic/visualize.h

     
    1212#ifndef VISUALIZE_H
    1313#define VISUALIZE_H
    1414
     15#include <vector>
     16using namespace std;
     17
    1518#include <mythtv/visual.h>
    1619#include "mainvisual.h"
    1720#include "metadata.h"
     
    1922#include "config.h"
    2023
    2124#include <complex>
    22 //Added by qt3to4:
    23 #include <Q3MemArray>
    2425extern "C" {
    2526#ifdef FFTW3_SUPPORT
    2627#include <fftw3.h>
     
    6364    inline double clamp(double cur, double max, double min);
    6465
    6566    QColor startColor, targetColor;
    66     Q3MemArray<QRect> rects;
    67     Q3MemArray<double> magnitudes;
     67    vector<QRect> rects;
     68    vector<double> magnitudes;
    6869    QSize size;
    6970    LogScale scale;
    7071    double scaleFactor, falloff;
     
    159160               
    160161  private:
    161162    QColor startColor, targetColor;
    162     Q3MemArray<QRect> rects;
    163     Q3MemArray<double> magnitudes;
     163    vector<QRect> rects;
     164    vector<double> magnitudes;
    164165    QSize size;
    165166    LogScale scale;
    166167    double scaleFactor, falloff;
  • mythplugins/mythmusic/mythmusic/metaiooggvorbiscomment.cpp

     
    7070        {
    7171            // find the tagname
    7272            tmp = pComment->user_comments[i];
    73             int tag = tmp.find('=');
     73            int tag = tmp.indexOf('=');
    7474            if (tag)
    7575            {
    76                 tmp = tmp.left(tag).upper();
     76                tmp = tmp.left(tag).toUpper();
    7777                if (MYTH_VORBISCOMMENT_ARTIST != tmp
    7878                    && MYTH_VORBISCOMMENT_COMPILATIONARTIST != tmp
    7979                    && MYTH_VORBISCOMMENT_TITLE != tmp
     
    209209    QString newfilename = createTempFile(
    210210        QString(l8bit.constData()) + ".XXXXXX");
    211211
    212     FILE *p_output = fopen(newfilename, "wb");
     212    FILE *p_output = fopen(newfilename.toLocal8Bit().constData(), "wb");
    213213
    214214    if (!p_output)
    215215    {
  • mythplugins/mythmusic/mythmusic/filescanner.cpp

     
    104104        ++it;
    105105        if (fi->fileName() == "." || fi->fileName() == "..")
    106106            continue;
    107         QString filename = fi->absFilePath();
     107        QString filename = fi->absoluteFilePath();
    108108        if (fi->isDir())
    109109        {
    110110
    111111            QString dir(filename);
    112112            dir.remove(0, m_startdir.length());
    113113
    114             newparentid = m_directoryid[QString(dir.toUtf8()).lower()];
     114            newparentid = m_directoryid[QString(dir.toUtf8()).toLower()];
    115115
    116116            if (newparentid == 0)
    117117            {
    118118                int id = GetDirectoryId(dir, parentid);
    119                 m_directoryid[QString(dir.toUtf8()).lower()] = id;
     119                m_directoryid[QString(dir.toUtf8()).toLower()] = id;
    120120
    121121                if (id > 0)
    122122                {
     
    249249                                              "*.png;*.jpg;*.jpeg;*.gif;*.bmp");
    250250
    251251    // If this file is an image, insert the details into the music_albumart table
    252     if (nameFilter.find(extension.lower()) > -1)
     252    if (nameFilter.indexOf(extension.toLower()) > -1)
    253253    {
    254254        QString name = filename.section( '/', -1);
    255255
     
    258258                      "directory_id = :DIRID, imagetype = :TYPE;");
    259259        query.bindValue(":FILE", name);
    260260        query.bindValue(":DIRID", m_directoryid[
    261                             QString(directory.toUtf8()).lower()]);
     261                            QString(directory.toUtf8()).toLower()]);
    262262        query.bindValue(":TYPE", AlbumArtImages::guessImageType(name));
    263263
    264264        if (!query.exec() || query.numRowsAffected() <= 0)
     
    279279            QString album_cache_string;
    280280
    281281            // Set values from cache
    282             int did = m_directoryid[QString(directory.toUtf8()).lower()];
     282            int did = m_directoryid[QString(directory.toUtf8()).toLower()];
    283283            if (did > 0)
    284284                data->setDirectoryId(did);
    285285
    286             int aid = m_artistid[QString(data->Artist().toUtf8()).lower()];
     286            int aid = m_artistid[QString(data->Artist().toUtf8()).toLower()];
    287287            if (aid > 0)
    288288            {
    289289                data->setArtistId(aid);
    290290
    291291                // The album cache depends on the artist id
    292292                album_cache_string = data->getArtistId() + "#"
    293                     + QString(data->Album().toUtf8()).lower();
     293                    + QString(data->Album().toUtf8()).toLower();
    294294
    295295                if (m_albumid[album_cache_string] > 0)
    296296                    data->setAlbumId(m_albumid[album_cache_string]);
    297297            }
    298298
    299             int gid = m_genreid[QString(data->Genre().toUtf8()).lower()];
     299            int gid = m_genreid[QString(data->Genre().toUtf8()).toLower()];
    300300            if (gid > 0)
    301301                data->setGenreId(gid);
    302302
     
    304304            data->dumpToDatabase();
    305305
    306306            // Update the cache
    307             m_artistid[QString(data->Artist().toUtf8()).lower()] =
     307            m_artistid[QString(data->Artist().toUtf8()).toLower()] =
    308308                data->getArtistId();
    309309
    310             m_genreid[QString(data->Genre().toUtf8()).lower()] =
     310            m_genreid[QString(data->Genre().toUtf8()).toLower()] =
    311311                data->getGenreId();
    312312
    313313            album_cache_string = data->getArtistId() + "#"
    314                 + QString(data->Album().toUtf8()).lower();
     314                + QString(data->Album().toUtf8()).toLower();
    315315            m_albumid[album_cache_string] = data->getAlbumId();
    316316            delete data;
    317317        }
     
    430430    QString nameFilter = gContext->GetSetting("AlbumArtFilter",
    431431                                              "*.png;*.jpg;*.jpeg;*.gif;*.bmp");
    432432
    433     if (nameFilter.find(extension) > -1)
     433    if (nameFilter.indexOf(extension) > -1)
    434434    {
    435435        MSqlQuery query(MSqlQuery::InitCon());
    436436        query.prepare("DELETE FROM music_albumart WHERE filename= :FILE AND "
    437437                      "directory_id= :DIRID;");
    438438        query.bindValue(":FILE", sqlfilename);
    439439        query.bindValue(":DIRID", m_directoryid[
    440                             QString(directory.toUtf8()).lower()]);
     440                            QString(directory.toUtf8()).toLower()]);
    441441
    442442        if (!query.exec() || query.numRowsAffected() <= 0)
    443443        {
     
    480480            QString album_cache_string;
    481481
    482482            // Set values from cache
    483             int did = m_directoryid[QString(directory.toUtf8()).lower()];
     483            int did = m_directoryid[QString(directory.toUtf8()).toLower()];
    484484            if (did > 0)
    485485                disk_meta->setDirectoryId(did);
    486486
    487             int aid = m_artistid[QString(disk_meta->Artist().toUtf8()).lower()];
     487            int aid = m_artistid[QString(disk_meta->Artist().toUtf8()).toLower()];
    488488            if (aid > 0)
    489489            {
    490490                disk_meta->setArtistId(aid);
    491491
    492492                // The album cache depends on the artist id
    493493                album_cache_string = disk_meta->getArtistId() + "#" +
    494                     QString(disk_meta->Album().toUtf8()).lower();
     494                    QString(disk_meta->Album().toUtf8()).toLower();
    495495
    496496                if (m_albumid[album_cache_string] > 0)
    497497                    disk_meta->setAlbumId(m_albumid[album_cache_string]);
    498498            }
    499499
    500             int gid = m_genreid[QString(disk_meta->Genre().toUtf8()).lower()];
     500            int gid = m_genreid[QString(disk_meta->Genre().toUtf8()).toLower()];
    501501            if (gid > 0)
    502502                disk_meta->setGenreId(gid);
    503503
     
    505505            disk_meta->dumpToDatabase();
    506506
    507507            // Update the cache
    508             m_artistid[QString(disk_meta->Artist().toUtf8()).lower()]
     508            m_artistid[QString(disk_meta->Artist().toUtf8()).toLower()]
    509509                = disk_meta->getArtistId();
    510             m_genreid[QString(disk_meta->Genre().toUtf8()).lower()]
     510            m_genreid[QString(disk_meta->Genre().toUtf8()).toLower()]
    511511                = disk_meta->getGenreId();
    512512            album_cache_string = disk_meta->getArtistId() + "#" +
    513                 QString(disk_meta->Album().toUtf8()).lower();
     513                QString(disk_meta->Album().toUtf8()).toLower();
    514514            m_albumid[album_cache_string] = disk_meta->getAlbumId();
    515515        }
    516516
     
    667667                    else if (HasFileChanged(name, query.value(1).toString()))
    668668                        music_files[name] = kNeedUpdate;
    669669                    else
    670                         music_files.remove(iter);
     670                        music_files.erase(iter);
    671671                }
    672672                else
    673673                {
     
    737737                        continue;
    738738                    }
    739739                    else
    740                         music_files.remove(iter);
     740                        music_files.erase(iter);
    741741                }
    742742                else
    743743                {
  • mythtv/libs/libmyth/uilistbtntype.h

     
    4444    int getCheck(void) { return m_check; }
    4545    virtual void setCheck(int flag);
    4646
    47     void setItem(UIListBtnTypeItem *item) { m_physitem = item; }
    48     UIListBtnTypeItem *getItem(void) { return m_physitem; }
     47    void SetItem(UIListBtnTypeItem *item);
     48    UIListBtnTypeItem *GetItem(void) { return m_physitem; }
    4949
    5050    void setText(const QString &text);
    5151    void setPixmap(QPixmap *pixmap);
     
    335335     
    336336    void setData(void *data);
    337337    void *getData();
    338    
     338
     339    void SetTree(UIListGenericTree*);
     340
    339341    void setOverrideInactive(bool flag);
    340342    bool getOverrideInactive(void);
    341343
     
    365367
    366368    bool           m_overrideInactive;
    367369    int            m_justify;
     370    UIListGenericTree *m_tree;
    368371
    369372    friend class UIListBtnType;
    370373};
  • mythtv/libs/libmyth/uilistbtntype.cpp

     
    6262    }
    6363}
    6464
     65void UIListGenericTree::SetItem(UIListBtnTypeItem *item)
     66{
     67    m_physitem = item;
     68    if (m_physitem)
     69        m_physitem->SetTree(this);
     70}
     71
    6572UIListGenericTree::~UIListGenericTree()
    6673{
     74    if (m_physitem)
     75    {
     76        m_physitem->SetTree(NULL);
     77        m_physitem = NULL;
     78    }
     79    m_image = NULL;
    6780}
    6881
    6982void UIListGenericTree::RemoveFromParent(void)
     
    400413    while (clear)
    401414    {
    402415        UIListGenericTree *gt = (UIListGenericTree *)clear->getData();
    403         gt->setItem(NULL);
     416        gt->SetItem(NULL);
    404417        clear = list->GetItemNext(clear);
    405418    }
    406419
     
    449462                                        (uichild->childCount() > 0));
    450463        newitem->setData(uichild);
    451464
    452         uichild->setItem(newitem);
     465        uichild->SetItem(newitem);
    453466
    454467        if (!uichild->getActive())
    455468            newitem->setOverrideInactive(true);
     
    10511064
    10521065    m_itemCount--;
    10531066
    1054     if (m_topItem != m_itemList.first())
     1067    if (!m_itemList.empty() && m_topItem != m_itemList.first())
    10551068        m_showUpArrow = true;
    10561069    else
    10571070        m_showUpArrow = false;
     
    19331946
    19341947void UIListBtnTypeItem::CalcDimensions(void)
    19351948{
     1949    if (!m_parent)
     1950        return;
     1951
    19361952    if (!m_parent->m_initialized)
    19371953        m_parent->Init();
    19381954
     
    19461962    QPixmap& checkPix = m_parent->m_checkNonePix;
    19471963    QPixmap& arrowPix = m_parent->m_arrowPix;
    19481964
     1965    if (checkPix.isNull() || arrowPix.isNull())
     1966        return;
     1967
    19491968    int cw = checkPix.width();
    19501969    int ch = checkPix.height();
    19511970    int aw = arrowPix.width();
     
    19862005{
    19872006    if (m_parent)
    19882007        m_parent->RemoveItem(this);
     2008
     2009    if (m_tree)
     2010    {
     2011        m_tree->SetItem(NULL);
     2012        m_tree = NULL;
     2013    }
    19892014}
    19902015
     2016void UIListBtnTypeItem::SetTree(UIListGenericTree *tree)
     2017{
     2018    m_tree = tree;
     2019}
     2020
    19912021QString UIListBtnTypeItem::text() const
    19922022{
    19932023    return m_text;
     
    20412071void UIListBtnTypeItem::setDrawArrow(bool flag)
    20422072{
    20432073    m_showArrow = flag;
    2044     CalcDimensions();
     2074    if (m_parent && m_parent->m_initialized)
     2075        CalcDimensions();
    20452076}
    20462077
    20472078void UIListBtnTypeItem::setData(void *data)