Ticket #6128: mythmusic-qt4-v2.patch
File mythmusic-qt4-v2.patch, 171.2 KB (added by , 17 years ago) |
---|
-
mythplugins/mythmusic/mythmusic/playbackbox.cpp
6 6 using namespace std; 7 7 8 8 // Qt includes 9 #include <qapplication.h> 10 #include <qregexp.h> 11 //Added by qt3to4: 9 #include <QApplication> 12 10 #include <QLabel> 13 11 #include <QPixmap> 12 13 #include <Q3Frame> 14 14 #include <Q3ValueList> 15 #include <QKeyEvent>16 #include <Q3Frame>17 #include <Q3PtrList>18 15 19 16 // MythTV plugin includes 20 17 #include <mythtv/mythcontext.h> … … 33 30 #include "databasebox.h" 34 31 #include "mainvisual.h" 35 32 #include "smartplaylist.h" 33 #include "playlistcontainer.h" 36 34 #include "search.h" 37 35 38 36 #ifndef USING_MINGW … … 108 106 { 109 107 volume_control = true; 110 108 } 111 volume_display_timer->start(2000, true); 109 volume_display_timer->setSingleShot(true); 110 volume_display_timer->start(2000); 112 111 connect(volume_display_timer, SIGNAL(timeout()), 113 112 this, SLOT(hideVolume())); 114 113 … … 160 159 waiting_for_playlists_timer = new QTimer(this); 161 160 connect(waiting_for_playlists_timer, SIGNAL(timeout()), this, 162 161 SLOT(checkForPlaylists())); 163 waiting_for_playlists_timer->start(50, TRUE); 162 waiting_for_playlists_timer->setSingleShot(true); 163 waiting_for_playlists_timer->start(50); 164 164 165 165 // Warm up the visualizer 166 166 … … 175 175 176 176 fullscreen_blank = false; 177 177 178 visual_modes = QStringList::split(';', gContext->GetSetting("VisualMode")); 178 visual_modes = gContext->GetSetting("VisualMode") 179 .split(';', QString::SkipEmptyParts); 180 179 181 if (!visual_modes.count()) 180 182 visual_modes.push_front("Blank"); 181 183 … … 491 493 resetScrollCount(); 492 494 493 495 speed_scroll_timer->stop(); 494 speed_scroll_timer->start(300, true); 496 speed_scroll_timer->setSingleShot(true); 497 speed_scroll_timer->start(300); 495 498 496 499 } 497 500 else if (action == "DOWN") … … 512 515 resetScrollCount(); 513 516 514 517 speed_scroll_timer->stop(); 515 speed_scroll_timer->start(300, true); 518 speed_scroll_timer->setSingleShot(true); 519 speed_scroll_timer->start(300); 516 520 } 517 521 else if (action == "LEFT") 518 522 music_tree_list->popUp(); … … 956 960 957 961 void PlaybackBoxMusic::occasionallyCheckCD() 958 962 { 959 if ( cd_reader_thread->getLock()->locked())963 if (!cd_reader_thread->getLock()->tryLock()) 960 964 return; 965 cd_reader_thread->getLock()->unlock(); 961 966 962 967 if (!scan_for_cd) 963 968 { … … 1160 1165 } 1161 1166 } 1162 1167 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 1164 1170 } 1165 1171 1166 1172 void PlaybackBoxMusic::changeVolume(bool up_or_down) … … 1223 1229 volume_status->SetUsed(gPlayer->getOutput()->GetCurrentVolume()); 1224 1230 volume_status->SetOrder(0); 1225 1231 volume_status->refresh(); 1226 volume_display_timer->start(2000, true); 1232 volume_display_timer->setSingleShot(true); 1233 volume_display_timer->start(2000); 1227 1234 if (class LCD *lcd = LCD::Get()) 1228 1235 lcd->switchToVolume("Music"); 1229 1236 … … 1266 1273 speed_status->SetText(speed_text); 1267 1274 speed_status->SetOrder(0); 1268 1275 speed_status->refresh(); 1269 volume_display_timer->start(2000, true); 1276 volume_display_timer->setSingleShot(true); 1277 volume_display_timer->start(2000); 1270 1278 } 1271 1279 } 1272 1280 … … 1286 1294 void PlaybackBoxMusic::resetTimer() 1287 1295 { 1288 1296 if (visual_mode_delay > 0) 1289 visual_mode_timer-> changeInterval(visual_mode_delay * 1000);1297 visual_mode_timer->start(visual_mode_delay * 1000); 1290 1298 } 1291 1299 1292 1300 void PlaybackBoxMusic::play() … … 1526 1534 gPlayer->getOutput()->Reset(); 1527 1535 gPlayer->getOutput()->SetTimecode(pos*1000); 1528 1536 1529 if (gPlayer->getDecoder() && gPlayer->getDecoder()-> running())1537 if (gPlayer->getDecoder() && gPlayer->getDecoder()->isRunning()) 1530 1538 { 1531 1539 gPlayer->getDecoder()->lock(); 1532 1540 gPlayer->getDecoder()->seek(pos); … … 1740 1748 1741 1749 if (position != "") 1742 1750 { 1743 QStringList list = QStringList::split(",", position);1751 QStringList list = position.split(",", QString::SkipEmptyParts); 1744 1752 1745 1753 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) 1746 1754 branches_to_current_node.append((*it).toInt()); … … 1855 1863 } 1856 1864 1857 1865 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"); 1860 1869 1861 1870 if (cd_watcher) 1862 1871 cd_watcher->stop(); 1863 1872 1864 dbbox .exec();1873 dbbox->exec(); 1865 1874 if (visual_mode_delay > 0) 1866 1875 visual_mode_timer->start(visual_mode_delay * 1000); 1867 1876 … … 1888 1897 1889 1898 if (scan_for_cd && cd_watcher) 1890 1899 cd_watcher->start(1000); 1900 1901 dbbox->deleteLater(); 1891 1902 } 1892 1903 1893 1904 void PlaybackBoxMusic::customEvent(QEvent *event) -
mythplugins/mythmusic/mythmusic/mythmusic.pro
3 3 include ( ../../programs-libs.pro ) 4 4 include (config.pro) 5 5 6 QT += xml sql opengl qt3support network 7 6 8 !exists( config.pro ) { 7 9 error(Missing config.pro: please run the configure script) 8 10 } … … 35 37 HEADERS += editmetadata.h smartplaylist.h search.h genres.h 36 38 HEADERS += treebuilders.h importmusic.h directoryfinder.h 37 39 HEADERS += filescanner.h libvisualplugin.h musicplayer.h miniplayer.h 40 HEADERS += playlistcontainer.h 38 41 HEADERS += mythlistview-qt3.h mythlistbox-qt3.h 39 42 40 43 SOURCES += cddecoder.cpp cdrip.cpp decoder.cpp … … 52 55 SOURCES += avfdecoder.cpp editmetadata.cpp smartplaylist.cpp search.cpp 53 56 SOURCES += treebuilders.cpp importmusic.cpp directoryfinder.cpp 54 57 SOURCES += filescanner.cpp libvisualplugin.cpp musicplayer.cpp miniplayer.cpp 58 SOURCES += playlistcontainer.cpp 55 59 SOURCES += mythlistview-qt3.cpp mythlistbox-qt3.cpp 56 60 57 61 macx { … … 69 73 LIBS += -logg 70 74 } 71 75 72 73 #The following line was inserted by qt3to474 QT += xml sql opengl qt3support75 76 76 include ( ../../libs-targetfix.pro ) -
mythplugins/mythmusic/mythmusic/search.cpp
257 257 258 258 while (index < (int) sText.length()) 259 259 { 260 start = sText. find('[', index);261 end = sText. find(']', start);260 start = sText.indexOf('[', index); 261 end = sText.indexOf(']', start); 262 262 263 263 if (start != -1 && end != -1) 264 264 { -
mythplugins/mythmusic/mythmusic/playlist.h
1 1 #ifndef PLAYLIST_H_ 2 2 #define PLAYLIST_H_ 3 3 4 #include <q3valuelist.h> 5 #include <q3listview.h> 6 #include <q3ptrlist.h> 7 #include <qthread.h> 4 #include <vector> 5 #include <list> 6 using namespace std; 8 7 8 #include <QList> 9 9 10 #include "metadata.h" 10 11 #include "treecheckitem.h" 11 12 #include <mythtv/uitypes.h> 12 13 #include <mythtv/uilistbtntype.h> 13 14 14 class Playlist sContainer;15 class PlaylistContainer; 15 16 16 17 17 18 enum InsertPLOption … … 30 31 PL_CURRENT 31 32 }; 32 33 34 typedef enum TrackTypes 35 { 36 kTrackCD, 37 kTrackPlaylist, 38 kTrackSong, 39 kTrackUnknown, 40 } TrackType; 41 33 42 class Track 34 43 { 35 44 // Why isn't this class just Metadata? … … 40 49 public: 41 50 Track(int x, AllMusic *all_music_ptr); 42 51 43 void postLoad(Playlist sContainer *grandparent);52 void postLoad(PlaylistContainer *grandparent); 44 53 45 54 void setParent(Playlist *parent_ptr); 46 55 void setValue(int x){index_value = x;} … … 58 67 void setCDFlag(bool yes_or_no) { cd_flag = yes_or_no; } 59 68 bool getCDFlag(void) { return cd_flag; } 60 69 70 TrackType GetTrackType(void) const; 71 61 72 private: 62 73 int index_value; 63 74 PlaylistTrack *my_widget; … … 74 85 Playlist(AllMusic *all_music_ptr); 75 86 ~Playlist(); 76 87 77 Playlist& operator=(const Playlist& rhs);88 //Playlist& operator=(const Playlist& rhs); 78 89 79 void setParent(Playlist sContainer *myparent) { parent = myparent; }90 void setParent(PlaylistContainer *myparent) { parent = myparent; } 80 91 81 92 void postLoad(void); 82 93 … … 89 100 90 101 int writeTree(GenericTree *tree_to_write_to, int a_counter); 91 102 92 void describeYourself(void) ; // debugging103 void describeYourself(void) const; // debugging 93 104 94 105 void fillSongsFromCD(); 95 106 void fillSongsFromSonglist(bool filter); … … 107 118 108 119 void moveTrackUpDown(bool flag, Track *the_track); 109 120 110 bool checkTrack(int a_track_id, bool cd_flag) ;121 bool checkTrack(int a_track_id, bool cd_flag) const; 111 122 112 123 void addTrack(int the_track_id, bool update_display, bool cd_flag); 113 124 … … 115 126 void removeAllTracks(void); 116 127 void removeAllWidgets(void); 117 128 118 void copyTracks(Playlist *to_ptr, bool update_display) ;129 void copyTracks(Playlist *to_ptr, bool update_display) const; 119 130 120 131 bool hasChanged(void) { return changed; } 121 132 void Changed(void) { changed = true; } … … 124 135 void setName(QString a_name) { name = a_name; } 125 136 126 137 int getID(void) { return playlistid; } 127 int getFirstTrackID(void) ;138 int getFirstTrackID(void) const; 128 139 void setID(int x) { playlistid = x; } 129 140 130 141 bool containsReference(int to_check, int depth); … … 139 150 int playlistid; 140 151 QString name; 141 152 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; 145 157 bool changed; 146 158 }; 147 159 148 class PlaylistLoadingThread : public QThread149 {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 PlaylistsContainer161 {162 public:163 PlaylistsContainer(AllMusic *all_music, QString host_name);164 ~PlaylistsContainer();165 166 void load();167 void describeYourself(); // debugging168 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 230 160 #endif -
mythplugins/mythmusic/mythmusic/miniplayer.cpp
1 #include <iostream> 2 //Added by qt3to4: 1 // qt 3 2 #include <QKeyEvent> 4 #include <Q3PtrList> 5 #include <Q3Frame> 6 using namespace std; 3 #include <QPixmap> 4 #include <QImage> 7 5 8 // qt9 #include <qpixmap.h>10 #include <qimage.h>11 #include <qapplication.h>12 13 6 // mythtv 14 7 #include <mythtv/mythcontext.h> 15 8 #include <mythtv/mythdialogs.h> … … 27 20 bool setsize) 28 21 : MythThemedDialog(parent, name, setsize) 29 22 { 30 setFrameStyle(Q 3Frame::NoFrame | Q3Frame::Plain);23 setFrameStyle(QFrame::Panel); 31 24 setLineWidth(1); 32 25 m_parentPlayer = parentPlayer; 33 26 … … 66 59 { 67 60 gPlayer->setListener(NULL); 68 61 69 m_displayTimer->deleteLater(); 62 // Timers are deleted by Qt 63 m_displayTimer->disconnect(); 70 64 m_displayTimer = NULL; 71 65 72 m_ infoTimer->deleteLater();66 m_displayTimer->disconnect(); 73 67 m_infoTimer = NULL; 74 68 75 69 if (class LCD *lcd = LCD::Get()) … … 255 249 else 256 250 m_infoText->SetText(tr("Mute: Off")); 257 251 258 m_infoTimer->start(5000, true); 252 m_infoTimer->setSingleShot(true); 253 m_infoTimer->start(5000); 259 254 } 260 255 261 256 if (m_volText) … … 507 502 gPlayer->getOutput()->Reset(); 508 503 gPlayer->getOutput()->SetTimecode(pos*1000); 509 504 510 if (gPlayer->getDecoder() && gPlayer->getDecoder()-> running())505 if (gPlayer->getDecoder() && gPlayer->getDecoder()->isRunning()) 511 506 { 512 507 gPlayer->getDecoder()->lock(); 513 508 gPlayer->getDecoder()->seek(pos); -
mythplugins/mythmusic/mythmusic/decoder.h
5 5 #include <qstring.h> 6 6 #include <qevent.h> 7 7 #include <qthread.h> 8 #include <q3ptrlist.h>9 8 #include <qwaitcondition.h> 10 9 #include <qmutex.h> 11 10 … … 72 71 virtual void lock(void) { return mtx.lock(); } 73 72 virtual void unlock(void) { return mtx.unlock(); } 74 73 virtual bool tryLock(void) { return mtx.tryLock(); } 75 virtual bool locked(void) { return mtx.locked(); }74 //virtual bool locked(void) { return mtx.locked(); } 76 75 77 76 QWaitCondition *cond() { return &cnd; } 78 77 -
mythplugins/mythmusic/mythmusic/streaminput.cpp
6 6 7 7 #include "streaminput.h" 8 8 9 #include "myth tv/mythcontext.h"9 #include "mythverbose.h" 10 10 11 #include <qapplication.h> 12 #include <q3socket.h> 11 #include <QApplication> 13 12 13 #define LOC QString("StreamInput: ") 14 #define LOC_WARN QString("StreamInput, Warning: ") 15 #define LOC_ERR QString("StreamInput, Error: ") 14 16 15 StreamInput::StreamInput(const Q 3Url &source)16 : request(0), url(source), sock(0), stage(0)17 StreamInput::StreamInput(const QUrl &source) : 18 request(QString::null), url(source), sock(NULL), stage(0) 17 19 { 18 20 } 19 21 20 21 void StreamInput::setup() 22 void StreamInput::Setup(void) 22 23 { 23 if (! 24 if (!url.isValid()) 24 25 return; 25 26 26 QString protocol = url. protocol();27 QString protocol = url.scheme(); 27 28 QString host = url.host(); 28 29 QString path = url.path(); 29 30 int port = url.port(); … … 31 32 if (protocol != "mqp" || host.isNull()) 32 33 return; 33 34 34 if (port == -1) 35 port = 42666; 35 port = (port < 0) ? 42666 : port; 36 36 37 request = ".song " + QString(path.toUtf8()) + "\r\n"; 37 request = path; 38 request.detach(); 38 39 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())); 39 46 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); 45 48 46 sock->connectToHost(host, port);47 48 49 while (stage != -1 && stage < 4) 49 50 { 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(); 53 57 } 54 58 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())); 60 65 61 66 if (stage == -1) 62 67 { 63 68 // some sort of error 64 69 delete sock; 65 sock = 0;70 sock = NULL; 66 71 } 67 72 } 68 73 69 74 70 void StreamInput:: hostfound()75 void StreamInput::HostFound(void) 71 76 { 72 qDebug("host found");77 VERBOSE(VB_GENERAL, LOC + "Host found"); 73 78 stage = 1; 74 79 } 75 80 76 81 77 void StreamInput:: connected()82 void StreamInput::Connected(void) 78 83 { 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(); 80 86 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()); 82 92 sock->flush(); 83 93 84 94 stage = 2; 85 95 } 86 96 87 97 88 void StreamInput:: readyread()98 void StreamInput::ReadyRead(void) 89 99 { 90 100 if (stage == 2) 91 101 { 92 qDebug("readyread... checking response");102 VERBOSE(VB_GENERAL, LOC + "ReadyRead... checking response"); 93 103 94 104 if (! sock->canReadLine()) 95 105 { 96 106 stage = -1; 97 qDebug("can't read line");107 VERBOSE(VB_IMPORTANT, LOC_ERR + "ReadyRead... can't read line"); 98 108 return; 99 109 } 100 110 … … 102 112 if (line.isEmpty()) 103 113 { 104 114 stage = -1; 105 qDebug("line is empty");115 VERBOSE(VB_IMPORTANT, LOC_ERR + "ReadyRead... line is empty"); 106 116 return; 107 117 } 108 118 109 119 if (line.left(5) != "*GOOD") 110 120 { 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)); 113 123 stage = -1; 114 124 return; 115 125 } … … 122 132 } 123 133 } 124 134 125 126 void StreamInput::error(int err) 135 void StreamInput::Error(QAbstractSocket::SocketError) 127 136 { 128 qDebug("socket error: %d", err); 137 VERBOSE(VB_IMPORTANT, LOC_ERR + 138 QString("Socket error: %1").arg(sock->errorString())); 129 139 130 140 stage = -1; 131 141 } -
mythplugins/mythmusic/mythmusic/visualize.cpp
18 18 #include <qpixmap.h> 19 19 #include <qimage.h> 20 20 #include <qdir.h> 21 #include <q3url.h>22 21 23 22 // mythtv 24 23 #include <mythtv/mythdbcon.h> … … 108 107 scale.setMax(192, size.width() / analyzerBarWidth); 109 108 110 109 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) 113 113 { 114 114 rects[i].setRect(w, size.height() / 2, analyzerBarWidth - 1, 1); 115 115 } 116 116 117 int os = magnitudes.size();117 unsigned int os = magnitudes.size(); 118 118 magnitudes.resize( scale.range() * 2 ); 119 for (; (unsigned)os < magnitudes.size(); os++)119 for (; os < magnitudes.size(); os++) 120 120 { 121 121 magnitudes[os] = 0.0; 122 122 } … … 161 161 #endif 162 162 163 163 index = 1; 164 for (i = 0; i < rects. count(); i++, w += analyzerBarWidth)164 for (i = 0; i < rects.size(); i++, w += analyzerBarWidth) 165 165 { 166 166 #ifdef FFTW3_SUPPORT 167 167 magL = (log(sq(real(lout[index])) + sq(real(lout[FFTW_N - index]))) - 22.0) * … … 252 252 double r, g, b, per; 253 253 254 254 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++) 256 256 { 257 257 per = double( rectsp[i].height() - 2 ) / double( size.height() ); 258 258 … … 324 324 { 325 325 // if a front cover image is available show that first 326 326 AlbumArtImages albumArt(m_pParent->metadata()); 327 if (albumArt. isImageAvailable(IT_FRONTCOVER))327 if (albumArt.getImage(IT_FRONTCOVER)) 328 328 m_currImageType = IT_FRONTCOVER; 329 329 else 330 330 { 331 331 // not available so just show the first image available 332 332 if (albumArt.getImageCount() > 0) 333 m_currImageType = albumArt.getImageAt(0) .imageType;333 m_currImageType = albumArt.getImageAt(0)->imageType; 334 334 else 335 335 m_currImageType = IT_UNKNOWN; 336 336 } … … 362 362 { 363 363 newType++; 364 364 365 while (!albumArt.isImageAvailable((ImageType) newType))365 while (!albumArt.getImage((ImageType) newType)) 366 366 { 367 367 newType++; 368 368 if (newType == IT_LAST) … … 568 568 569 569 #if defined(FFTW3_SUPPORT) || defined(FFTW2_SUPPORT) 570 570 QRect *rectsp = rects.data(); 571 for (uint i = 0; i < rects. count(); i++)571 for (uint i = 0; i < rects.size(); i++) 572 572 drawRect(p, &(rectsp[i]), i, center, w, h); 573 573 574 574 #else … … 732 732 static GLfloat view_rotx=20.0, view_rotz=0.0; 733 733 static GLint gear1, gear2, gear3; 734 734 735 Gears::Gears(QWidget *parent, const char *name) 736 : QGLWidget(parent, name)735 Gears::Gears(QWidget *parent, const char *name) : 736 QGLWidget(parent) 737 737 { 738 setObjectName(name); 738 739 falloff = 4.0; 739 740 analyzerBarWidth = 10; 740 741 fps = 60; … … 807 808 808 809 rects.resize( scale.range() ); 809 810 int i = 0, w = 0; 810 for (; (unsigned) i < rects. count(); i++, w += analyzerBarWidth)811 for (; (unsigned) i < rects.size(); i++, w += analyzerBarWidth) 811 812 { 812 813 rects[i].setRect(w, size.height() / 2, analyzerBarWidth - 1, 1); 813 814 } … … 858 859 rfftw_one(plan, rin, rout); 859 860 #endif 860 861 index = 1; 861 for (i = 0; i < rects. count(); i++, w += analyzerBarWidth)862 for (i = 0; i < rects.size(); i++, w += analyzerBarWidth) 862 863 { 863 864 #ifdef FFTW3_SUPPORT 864 865 magL = (log(sq(real(lout[index])) + sq(real(lout[FFTW_N - index]))) - 22.0) * -
mythplugins/mythmusic/mythmusic/metaioflacvorbiscomment.cpp
1 1 #include <iostream> 2 2 #include <sys/stat.h> 3 //Added by qt3to4:4 #include <Q3CString>5 3 using namespace std; 6 4 7 5 #include "metaioflacvorbiscomment.h" … … 298 296 299 297 // we need to make sure the '=' comes immediately after 300 298 // the desired label 301 if ((loc = entrytext. find("=")) &&299 if ((loc = entrytext.indexOf("=")) && 302 300 (loc == (int)qlabel.length()) && 303 entrytext. lower().left(qlabel.length()) == qlabel.lower())301 entrytext.toLower().left(qlabel.length()) == qlabel.toLower()) 304 302 { 305 303 return QString::fromUtf8(entrytext.right(entrytext.length() - loc - 1)); 306 304 } … … 328 326 329 327 QString test = getComment(pBlock, pLabel); 330 328 331 QString thenewentry = QString(pLabel). upper() + "=" + rData;329 QString thenewentry = QString(pLabel).toUpper() + "=" + rData; 332 330 QByteArray utf8str = thenewentry.toUtf8(); 333 331 334 332 FLAC__StreamMetadata_VorbisComment_Entry entry; -
mythplugins/mythmusic/mythmusic/mainvisual.h
7 7 #ifndef __mainvisual_h 8 8 #define __mainvisual_h 9 9 10 #include <vector> 11 using namespace std; 12 10 13 #include <mythtv/visual.h> 11 14 #include "polygon.h" 12 15 #include "constants.h" 13 16 14 17 #include <qwidget.h> 15 18 #include <qdialog.h> 16 #include <q3memarray.h>17 19 #include <qpixmap.h> 18 20 #include <qimage.h> 19 #include <q3ptrlist.h>20 21 #include <qstringlist.h> 21 22 #include <qtimer.h> 22 23 #include <QPaintEvent> … … 136 137 VisualBase *vis; 137 138 Metadata *meta; 138 139 QPixmap pixmap; 139 Q 3PtrList<VisualNode> nodes;140 QList<VisualNode*> nodes; 140 141 bool playing; 141 142 int fps; 142 143 QTimer *timer; … … 176 177 177 178 protected: 178 179 QColor startColor, targetColor; 179 Q3MemArray<double> magnitudes;180 vector<double> magnitudes; 180 181 QSize size; 181 182 bool rubberband; 182 183 double falloff; -
mythplugins/mythmusic/mythmusic/metadata.cpp
1 #include <iostream>2 3 1 // 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> 10 6 11 using namespace std;12 13 7 // mythtv 14 8 #include <mythtv/mythcontext.h> 15 9 #include <mythtv/mythwidgets.h> … … 41 35 return false; 42 36 } 43 37 38 static bool meta_less_than(const Metadata *item1, const Metadata *item2) 39 { 40 return item1->compare(item2) < 0; 41 } 42 43 static 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 44 59 Metadata& Metadata::operator=(Metadata *rhs) 45 60 { 46 61 m_artist = rhs->m_artist; … … 86 101 MythDB::DBError("music persist", query); 87 102 } 88 103 89 int Metadata::compare( Metadata *other)104 int Metadata::compare(const Metadata *other) const 90 105 { 91 106 if (m_format == "cast") 92 107 { 93 int artist_cmp = Artist().lower().localeAwareCompare(other->Artist().lower()); 108 int artist_cmp = Artist().toLower().localeAwareCompare( 109 other->Artist().toLower()); 94 110 95 111 if (artist_cmp == 0) 96 return Title().lower().localeAwareCompare(other->Title().lower()); 112 return Title().toLower().localeAwareCompare( 113 other->Title().toLower()); 97 114 98 115 return artist_cmp; 99 116 } … … 102 119 int track_cmp = Track() - other->Track(); 103 120 104 121 if (track_cmp == 0) 105 return Title().lower().localeAwareCompare(other->Title().lower()); 122 return Title().toLower().localeAwareCompare( 123 other->Title().toLower()); 106 124 107 125 return track_cmp; 108 126 } … … 398 416 399 417 if (! m_albumart.empty()) 400 418 { 401 Q 3ValueList<struct AlbumArtImage>::iterator it;419 QList<struct AlbumArtImage>::iterator it; 402 420 for ( it = m_albumart.begin(); it != m_albumart.end(); ++it ) 403 421 { 404 422 query.prepare("SELECT albumart_id FROM music_albumart WHERE " … … 681 699 m_changed = true; 682 700 } 683 701 684 void Metadata::setEmbeddedAlbumArt( Q3ValueList<struct AlbumArtImage>albumart)702 void Metadata::setEmbeddedAlbumArt(const QList<struct AlbumArtImage> &albumart) 685 703 { 686 704 m_albumart = albumart; 687 705 } … … 735 753 QImage image; 736 754 ImageType type; 737 755 738 if (albumArt.isImageAvailable(IT_FRONTCOVER)) 756 AlbumArtImage *albumart_image = NULL; 757 758 if ((albumart_image = albumArt.getImage(IT_FRONTCOVER))) 739 759 type = IT_FRONTCOVER; 740 else if ( albumArt.isImageAvailable(IT_UNKNOWN))760 else if ((albumart_image = albumArt.getImage(IT_UNKNOWN))) 741 761 type = IT_UNKNOWN; 742 else if ( albumArt.isImageAvailable(IT_BACKCOVER))762 else if ((albumart_image = albumArt.getImage(IT_BACKCOVER))) 743 763 type = IT_BACKCOVER; 744 else if ( albumArt.isImageAvailable(IT_INLAY))764 else if ((albumart_image = albumArt.getImage(IT_INLAY))) 745 765 type = IT_INLAY; 746 else if ( albumArt.isImageAvailable(IT_CD))766 else if ((albumart_image = albumArt.getImage(IT_CD))) 747 767 type = IT_CD; 748 else749 return image;750 768 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 } 752 776 753 if (albumart_image.embedded)754 image = QImage(MetaIOTagLib::getAlbumArt(m_filename, type));755 else756 image = QImage(albumart_image.filename);757 758 777 return image; 759 778 } 760 779 … … 764 783 765 784 QImage image; 766 785 767 if (albumArt.isImageAvailable(type)) 786 AlbumArtImage *albumart_image = albumArt.getImage(type); 787 if (albumart_image) 768 788 { 769 AlbumArtImage albumart_image = albumArt.getImage(type); 770 771 if (albumart_image.embedded) 789 if (albumart_image->embedded) 772 790 image = QImage(MetaIOTagLib::getAlbumArt(m_filename, type)); 773 791 else 774 image = QImage(albumart_image .filename);792 image = QImage(albumart_image->filename); 775 793 } 776 794 777 795 return image; … … 884 902 m_metadata_loader = NULL; 885 903 startLoading(); 886 904 887 m_all_music.setAutoDelete(true);888 889 905 m_last_listed = -1; 890 906 } 891 907 892 908 AllMusic::~AllMusic() 893 909 { 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 } 895 915 896 916 delete m_root_node; 897 917 … … 1039 1059 1040 1060 // To find this data quickly, build a map 1041 1061 // (a map to pointers!) 1042 1043 Q3PtrListIterator<Metadata> an_iterator( m_all_music );1044 Metadata *map_add;1045 1046 1062 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; 1052 1066 1053 1067 // Build a tree to reflect current state of 1054 1068 // the metadata. Once built, sort it. … … 1085 1099 // Select Music screen 1086 1100 // 1087 1101 1088 Q3PtrListIterator<Metadata> an_iterator( m_all_music );1089 Metadata *inserter;1090 1102 MetadataPtrList list; 1091 1103 1092 while ( (inserter = an_iterator.current()) != 0 ) 1104 MetadataPtrList::iterator it = m_all_music.begin(); 1105 for (; it != m_all_music.end(); ++it) 1093 1106 { 1094 if (inserter->isVisible()) 1095 list.append(inserter); 1096 ++an_iterator; 1097 1107 if ((*it)->isVisible()) 1108 list.append(*it); 1098 1109 m_numLoaded++; 1099 1110 } 1100 1111 1101 MusicTreeBuilder *builder = MusicTreeBuilder::createBuilder 1102 builder->makeTree 1112 MusicTreeBuilder *builder = MusicTreeBuilder::createBuilder(m_paths); 1113 builder->makeTree(m_root_node, list); 1103 1114 delete builder; 1104 1115 } 1105 1116 … … 1222 1233 return false; 1223 1234 } 1224 1235 1225 void AllMusic::save() 1236 /// \brief Check each Metadata entry and save those that have changed (ratings, etc.) 1237 void AllMusic::save(void) 1226 1238 { 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) 1234 1241 { 1235 if(searcher->hasChanged()) 1236 { 1237 searcher->persist(); 1238 } 1239 ++an_iterator; 1242 if ((*it)->hasChanged()) 1243 (*it)->persist(); 1240 1244 } 1241 1245 } 1242 1246 … … 1288 1292 return; 1289 1293 1290 1294 // Error checking 1291 QStringList tree_levels = QStringList::split(" ", m_paths);1295 QStringList tree_levels = m_paths.split(" "); 1292 1296 QStringList::const_iterator it = tree_levels.begin(); 1293 1297 for (; it != tree_levels.end(); ++it) 1294 1298 { … … 1307 1311 1308 1312 void AllMusic::setAllVisible(bool visible) 1309 1313 { 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); 1317 1317 } 1318 1318 1319 1319 MusicNode::MusicNode(const QString &a_title, const QString &tree_level) 1320 1320 { 1321 1321 my_title = a_title; 1322 1322 my_level = tree_level; 1323 my_subnodes.setAutoDelete(true);1324 1323 setPlayCountMin(0); 1325 1324 setPlayCountMax(0); 1326 1325 setLastPlayMin(0); … … 1329 1328 1330 1329 MusicNode::~MusicNode() 1331 1330 { 1332 my_subnodes.clear(); 1331 while (!my_subnodes.empty()) 1332 { 1333 delete my_subnodes.back(); 1334 my_subnodes.pop_back(); 1335 } 1333 1336 } 1334 1337 1335 1338 // static member vars … … 1367 1370 } 1368 1371 1369 1372 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) 1373 1375 { 1374 1376 QString title_temp = QString(QObject::tr("%1 - %2")) 1375 .arg(a_track->Track()).arg(a_track->Title());1377 .arg((*it)->Track()).arg((*it)->Title()); 1376 1378 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()); 1380 1381 new_item->setCheck(false); // Avoiding -Wall 1381 1382 } 1382 1383 1384 MusicNodePtrList::iterator mit = my_subnodes.begin(); 1385 for (; mit != my_subnodes.end(); ++mit) 1386 (*mit)->putYourselfOnTheListView(current_parent, true); 1383 1387 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 1392 1388 } 1393 1389 1394 1390 void MusicNode::writeTree(GenericTree *tree_to_write_to, int a_counter) … … 1402 1398 sub_node->setAttribute(4, a_counter); 1403 1399 sub_node->setAttribute(5, a_counter); 1404 1400 1405 Q3PtrListIterator<Metadata> anit(my_tracks);1406 Metadata *a_track;1407 1401 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) 1410 1405 { 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); 1413 1409 subsub_node->setAttribute(0, 1); 1414 1410 subsub_node->setAttribute(1, track_counter); // regular order 1415 1411 subsub_node->setAttribute(2, rand()); // random order … … 1417 1413 // 1418 1414 // "Intelligent" ordering 1419 1415 // 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(); 1423 1419 double ratingValue = (double)(rating) / 10; 1424 1420 double playcountValue, lastplayValue; 1425 1421 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 { 1431 1434 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 } 1434 1441 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 1438 1448 int integer_rating = (int) (4000001 - rating_value * 10000); 1439 1449 subsub_node->setAttribute(3, integer_rating); // "intelligent" order 1440 1450 ++track_counter; 1441 ++anit;1442 1451 } 1443 1452 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) 1450 1455 { 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); 1456 1461 ++another_counter; 1457 ++iter;1458 1462 } 1459 1463 } 1460 1464 … … 1462 1466 void MusicNode::sort() 1463 1467 { 1464 1468 // Sort any tracks 1465 my_tracks.sort();1469 qStableSort(my_tracks.begin(), my_tracks.end(), meta_less_than); 1466 1470 1467 1471 // Sort any subnodes 1468 my_subnodes.sort();1472 qStableSort(my_subnodes.begin(), my_subnodes.end(), music_less_than); 1469 1473 1470 1474 // 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(); 1478 1478 } 1479 1479 1480 1480 1481 void MusicNode::printYourself(int indent_level) 1481 void MusicNode::printYourself(int indent_level) const 1482 1482 { 1483 QString tmp = ""; 1484 for (int i = 0; i < indent_level; ++i) 1485 tmp += " "; 1486 tmp += my_title; 1487 VERBOSE(VB_GENERAL, tmp); 1483 1488 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) 1485 1491 { 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); 1487 1497 } 1488 cout << my_title.toLocal8Bit().constData() << endl;1489 1498 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); 1509 1502 } 1510 1503 1511 1504 /**************************************************************************/ 1512 1505 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 titles1529 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 1539 1506 AlbumArtImages::AlbumArtImages(Metadata *metadata) 1540 1507 : m_parent(metadata) 1541 1508 { 1542 m_imageList.setAutoDelete(true);1543 1544 1509 findImages(); 1545 1510 } 1546 1511 1512 AlbumArtImages::~AlbumArtImages() 1513 { 1514 while (!m_imageList.empty()) 1515 { 1516 delete m_imageList.back(); 1517 m_imageList.pop_back(); 1518 } 1519 } 1520 1547 1521 void AlbumArtImages::findImages(void) 1548 1522 { 1549 m_imageList.clear(); 1523 while (!m_imageList.empty()) 1524 { 1525 delete m_imageList.back(); 1526 m_imageList.pop_back(); 1527 } 1550 1528 1551 1529 if (m_parent == NULL) 1552 1530 return; … … 1557 1535 return; 1558 1536 1559 1537 QFileInfo fi(m_parent->Filename()); 1560 QString dir = fi. dirPath(true);1538 QString dir = fi.absolutePath(); 1561 1539 dir.remove(0, Metadata::GetStartdir().length()); 1562 1540 1563 1541 MSqlQuery query(MSqlQuery::InitCon()); … … 1586 1564 image->description = query.value(1).toString(); 1587 1565 image->embedded = true; 1588 1566 } 1589 else { 1567 else 1568 { 1590 1569 image->embedded = false; 1591 1570 } 1592 m_imageList. append(image);1571 m_imageList.push_back(image); 1593 1572 } 1594 1573 } 1595 1574 } 1596 1575 1597 AlbumArtImage AlbumArtImages::getImage(ImageType type)1576 AlbumArtImage *AlbumArtImages::getImage(ImageType type) 1598 1577 { 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) 1603 1580 { 1604 if ( image->imageType == type)1605 return *i mage;1581 if ((*it)->imageType == type) 1582 return *it; 1606 1583 } 1607 1584 1608 return *image;1585 return NULL; 1609 1586 } 1610 1587 1611 QStringList AlbumArtImages::getImageFilenames( )1588 QStringList AlbumArtImages::getImageFilenames(void) const 1612 1589 { 1613 1590 QStringList paths; 1614 1591 1615 AlbumArtImage *image; 1592 ImageList::const_iterator it = m_imageList.begin(); 1593 for (; it != m_imageList.end(); ++it) 1594 paths += (*it)->filename; 1616 1595 1617 for (image = m_imageList.first(); image; image = m_imageList.next())1618 {1619 paths += image->filename;1620 }1621 1622 1596 return paths; 1623 1597 } 1624 1598 1625 AlbumArtImage AlbumArtImages::getImageAt(uint index)1599 AlbumArtImage *AlbumArtImages::getImageAt(uint index) 1626 1600 { 1627 return *(m_imageList.at(index));1628 } 1601 if (index < m_imageList.size()) 1602 return m_imageList[index]; 1629 1603 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; 1642 1605 } 1643 1606 1644 1607 bool AlbumArtImages::saveImageType(const int id, ImageType type) … … 1662 1625 QT_TR_NOOP("Inlay") // IT_INLAY 1663 1626 }; 1664 1627 1665 return tr(type_strings[type]);1628 return QObject::tr(type_strings[type]); 1666 1629 } 1667 1630 1668 1631 // static method to guess the image type from the filename … … 1670 1633 { 1671 1634 ImageType type = IT_FRONTCOVER; 1672 1635 1673 if (filename.contains( tr("front"), false))1636 if (filename.contains(QObject::tr("front"), Qt::CaseInsensitive)) 1674 1637 type = IT_FRONTCOVER; 1675 else if (filename.contains( tr("back"), false))1638 else if (filename.contains(QObject::tr("back"), Qt::CaseInsensitive)) 1676 1639 type = IT_BACKCOVER; 1677 else if (filename.contains( tr("inlay"), false))1640 else if (filename.contains(QObject::tr("inlay"), Qt::CaseInsensitive)) 1678 1641 type = IT_INLAY; 1679 else if (filename.contains( tr("cd"), false))1642 else if (filename.contains(QObject::tr("cd"), Qt::CaseInsensitive)) 1680 1643 type = IT_CD; 1681 else if (filename.contains( tr("cover"), false))1644 else if (filename.contains(QObject::tr("cover"), Qt::CaseInsensitive)) 1682 1645 type = IT_FRONTCOVER; 1683 1646 1684 1647 return type; -
mythplugins/mythmusic/mythmusic/dbcheck.cpp
43 43 { 44 44 query.exec(thequery); 45 45 46 if (query.lastError().type() != QSqlError::No ne)46 if (query.lastError().type() != QSqlError::NoError) 47 47 { 48 48 QString msg = 49 49 QString("DB Error (Performing database upgrade): \n" … … 111 111 if (dbver == "1000") 112 112 { 113 113 QString startdir = gContext->GetSetting("MusicLocation"); 114 startdir = QDir::clean DirPath(startdir);114 startdir = QDir::cleanPath(startdir); 115 115 if (!startdir.endsWith("/")) 116 116 startdir += "/"; 117 117 … … 581 581 582 582 // update the VisualMode setting to the new format 583 583 QString setting = gContext->GetSetting("VisualMode"); 584 setting = setting.simplif yWhiteSpace();584 setting = setting.simplified(); 585 585 setting = setting.replace(' ', ";"); 586 586 gContext->SaveSetting("VisualMode", setting); 587 587 -
mythplugins/mythmusic/mythmusic/directoryfinder.cpp
56 56 if (m_directoryList[index] == "..") 57 57 { 58 58 // move up on directory 59 int pos = m_curDirectory. findRev('/');59 int pos = m_curDirectory.lastIndexOf('/'); 60 60 if (pos > 0) 61 61 m_curDirectory = m_curDirectory.left(pos); 62 62 else … … 195 195 void DirectoryFinder::backPressed() 196 196 { 197 197 // move up one directory 198 int pos = m_curDirectory. findRev('/');198 int pos = m_curDirectory.lastIndexOf('/'); 199 199 if (pos > 0) 200 200 m_curDirectory = m_curDirectory.left(pos); 201 201 else -
mythplugins/mythmusic/mythmusic/treebuilders.h
1 1 #ifndef TREEBUILDERS_H_ 2 2 #define TREEBUILDERS_H_ 3 3 4 #include <qstring.h> 5 #include <qstringlist.h> 6 #include <q3ptrdict.h> 7 #include <q3dict.h> 4 #include <QStringList> 8 5 9 6 #include "metadata.h" 10 7 -
mythplugins/mythmusic/mythmusic/cdrip.cpp
12 12 #include "config.h" 13 13 #ifdef HAVE_CDAUDIO 14 14 #include <cdaudio.h> 15 //Added by qt3to4:16 #include <QKeyEvent>17 #include <Q3PtrList>18 #include <QEvent>19 15 extern "C" { 20 16 #include <cdda_interface.h> 21 17 #include <cdda_paranoia.h> … … 28 24 using namespace std; 29 25 30 26 // 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> 34 32 35 33 // MythTV plugin includes 36 34 #include <mythtv/mythcontext.h> … … 940 938 941 939 // delete file 942 940 QString musicdir = gContext->GetSetting("MusicLocation"); 943 musicdir = QDir::clean DirPath(musicdir);941 musicdir = QDir::cleanPath(musicdir); 944 942 if (!musicdir.endsWith("/")) 945 943 musicdir += "/"; 946 944 QFile::remove(musicdir + filename); … … 961 959 QString Ripper::filenameFromMetadata(Metadata *track, bool createDir) 962 960 { 963 961 QString musicdir = gContext->GetSetting("MusicLocation"); 964 musicdir = QDir::clean DirPath(musicdir);962 musicdir = QDir::cleanPath(musicdir); 965 963 if (!musicdir.endsWith("/")) 966 964 musicdir += "/"; 967 965 … … 976 974 int old_i = 0; 977 975 while (i >= 0) 978 976 { 979 i = rx. search(fntempl, i);977 i = rx.indexIn(fntempl, i); 980 978 if (i >= 0) 981 979 { 982 980 if (i > 0) … … 1024 1022 1025 1023 filename = QString(filename.toLocal8Bit().constData()); 1026 1024 1027 QStringList directoryList = QStringList::split("/", filename);1025 QStringList directoryList = filename.split("/"); 1028 1026 for (int i = 0; i < (directoryList.size() - 1); i++) 1029 1027 { 1030 1028 musicdir += "/" + directoryList[i]; 1031 1029 if (createDir) 1032 1030 { 1033 1031 umask(022); 1034 directoryQD.mkdir(musicdir , true);1032 directoryQD.mkdir(musicdir); 1035 1033 directoryQD.cd(musicdir); 1036 1034 } 1037 1035 } 1038 1036 1039 filename = QDir::clean DirPath(musicdir) + "/" + directoryList.last();1037 filename = QDir::cleanPath(musicdir) + "/" + directoryList.last(); 1040 1038 1041 1039 return filename; 1042 1040 } … … 1453 1451 } 1454 1452 1455 1453 searchDialog->deleteLater(); 1456 setActiveWindow();1454 activateWindow(); 1457 1455 1458 1456 return res; 1459 1457 } … … 1571 1569 1572 1570 if (action == "ESCAPE") 1573 1571 { 1574 if (m_ripperThread && m_ripperThread-> running())1572 if (m_ripperThread && m_ripperThread->isRunning()) 1575 1573 { 1576 1574 if (MythPopupBox::showOkCancelPopup(gContext->GetMainWindow(), 1577 1575 "Stop Rip?", -
mythplugins/mythmusic/mythmusic/playlist.cpp
1 1 #include <unistd.h> 2 2 #include <inttypes.h> 3 3 #include <cstdlib> 4 #include <iostream>5 #include <map>6 4 5 #include <map> 6 #include <algorithm> 7 7 using namespace std; 8 #include "playlist.h"9 #include "qdatetime.h"10 //Added by qt3to4:11 #include <Q3PtrList>12 #include <Q3TextStream>13 8 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" 15 16 #include "smartplaylist.h" 16 #include <mythtv/mythdb.h>17 #include <mythtv/compat.h>18 17 19 #include < qfileinfo.h>20 #include < q3process.h>21 #include < qapplication.h>18 #include <mythcontext.h> 19 #include <mythdb.h> 20 #include <compat.h> 22 21 23 22 const char *kID0err = "Song with ID of 0 in playlist, this shouldn't happen."; 24 23 24 #define LOC QString("Track: ") 25 #define LOC_WARN QString("Track, Warning: ") 26 #define LOC_ERR QString("Track, Error: ") 27 25 28 Track::Track(int x, AllMusic *all_music_ptr) 26 29 { 27 30 index_value = x; … … 33 36 cd_flag = false; 34 37 } 35 38 36 void Track::postLoad(Playlist sContainer *grandparent)39 void Track::postLoad(PlaylistContainer *grandparent) 37 40 { 38 41 if (cd_flag) 39 42 { … … 48 51 bad_reference); 49 52 else 50 53 { 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!"); 53 55 } 54 56 } 55 57 … … 59 61 parent = parent_ptr; 60 62 } 61 63 64 void Track::deleteYourself() 65 { 66 parent->removeTrack(index_value, cd_flag); 67 } 68 69 void 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 79 void Track::moveUpDown(bool flag) 80 { 81 parent->moveTrackUpDown(flag, this); 82 } 83 84 TrackType 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 112 void 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 62 152 void Playlist::postLoad() 63 153 { 64 Track *it;65 for (it = songs.first(); it; it = songs.current())154 SongList::iterator it = songs.begin(); 155 while (it != songs.end()) 66 156 { 67 it->postLoad(parent);68 if ( it->badReference())157 (*it)->postLoad(parent); 158 if ((*it)->badReference()) 69 159 { 70 songs.remove(it); 160 delete *it; 161 it = songs.erase(it); 71 162 Changed(); 72 163 } 73 164 else 74 it = songs.next(); 165 { 166 ++it; 167 } 75 168 } 76 169 } 77 170 78 bool Playlist::checkTrack(int a_track_id, bool cd_flag) 171 bool Playlist::checkTrack(int a_track_id, bool cd_flag) const 79 172 { 80 173 // XXX SPEED THIS UP 81 174 // Should be a straight lookup against cached index 82 Track *it;83 175 84 for (it = songs.first(); it; it = songs.next()) 176 SongList::const_iterator it = songs.begin(); 177 for (; it != songs.end(); ++it) 85 178 { 86 if (it->getValue() == a_track_id && it->getCDFlag() == cd_flag) 87 { 179 if ((*it)->getValue() == a_track_id && (*it)->getCDFlag() == cd_flag) 88 180 return true; 89 }90 181 } 91 182 92 183 return false; 93 184 } 94 185 95 void Playlist::copyTracks(Playlist *to_ptr, bool update_display) 186 void Playlist::copyTracks(Playlist *to_ptr, bool update_display) const 96 187 { 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) 99 190 { 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); 102 193 } 103 194 104 195 to_ptr->fillSonglistFromSongs(); … … 114 205 a_track->setCDFlag(cd); 115 206 a_track->postLoad(parent); 116 207 a_track->setParent(this); 117 songs. append(a_track);208 songs.push_back(a_track); 118 209 changed = true; 119 210 120 211 // If I'm part of a GUI, display the existence of this new track … … 128 219 a_track->putYourselfOnTheListView(which_widget); 129 220 } 130 221 131 void Track::deleteYourself()222 void Playlist::removeAllTracks(void) 132 223 { 133 parent->removeTrack(index_value, cd_flag); 134 } 135 136 void Track::deleteYourWidget() 137 { 138 if (my_widget) 224 while (!songs.empty()) 139 225 { 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(); 143 229 } 144 }145 230 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 155 231 changed = true; 156 232 } 157 233 158 void Playlist::removeAllWidgets( )234 void Playlist::removeAllWidgets(void) 159 235 { 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(); 165 239 } 166 240 167 241 void Playlist::ripOutAllCDTracksNow() 168 242 { 169 Track *it;170 for (it = songs.first(); it; it = songs.current())243 SongList::iterator it = songs.begin(); 244 while (it != songs.end()) 171 245 { 172 if ( it->getCDFlag())246 if ((*it)->getCDFlag()) 173 247 { 174 it->deleteYourWidget(); 175 songs.remove(it); 248 (*it)->deleteYourWidget(); 249 delete *it; 250 it = songs.erase(it); 251 changed = true; 176 252 } 177 253 else 178 it = songs.next(); 254 { 255 ++it; 256 } 179 257 } 180 changed = true;181 258 } 182 259 183 260 void Playlist::removeTrack(int the_track, bool cd_flag) 184 261 { 185 262 // 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()) 188 266 { 189 if ( it->getValue() == the_track && cd_flag == it->getCDFlag())267 if ((*it)->getValue() == the_track && cd_flag == (*it)->getCDFlag()) 190 268 { 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; 194 273 } 195 274 else 196 it = songs.next(); 275 { 276 ++it; 277 } 197 278 } 198 changed = true;199 279 } 200 280 201 281 void Playlist::moveTrackUpDown(bool flag, Track *the_track) 202 282 { 203 // Slightly complicated, as the PtrList owns the pointers204 // Need to turn off auto delete205 206 songs.setAutoDelete(false);207 208 283 uint insertion_point = 0; 209 int where_its_at = songs. findRef(the_track);284 int where_its_at = songs.indexOf(the_track); 210 285 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 " 212 288 "track, but can'd find it"); 289 return; 290 } 291 292 if (flag) 293 insertion_point = ((uint)where_its_at) - 1; 213 294 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; 219 296 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); 223 299 224 songs.setAutoDelete(true);225 300 changed = true; // This playlist is now different than Database 226 301 } 227 302 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 PtrList361 }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 // Debugging375 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 385 303 Playlist::Playlist(AllMusic *all_music_ptr) 386 304 { 387 305 // fallback values 388 306 playlistid = 0; 389 307 name = QObject::tr("oops"); 390 308 raw_songlist = ""; 391 songs.setAutoDelete(true); // mine!392 309 all_available_music = all_music_ptr; 393 310 changed = false; 394 311 } 395 312 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 else404 {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 418 313 void Playlist::putYourselfOnTheListView(UIListGenericTree *a_listviewitem) 419 314 { 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); 423 318 } 424 319 425 int Playlist::getFirstTrackID( )320 int Playlist::getFirstTrackID(void) const 426 321 { 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(); 432 325 return 0; 433 326 } 434 327 435 328 Playlist::~Playlist() 436 329 { 437 songs.setAutoDelete(true); 438 songs.clear(); 330 while (!songs.empty()) 331 { 332 delete songs.front(); 333 songs.pop_front(); 334 } 439 335 } 440 336 337 /* 441 338 Playlist& Playlist::operator=(const Playlist& rhs) 442 339 { 443 340 if (this == &rhs) … … 448 345 playlistid = rhs.playlistid; 449 346 name = rhs.name; 450 347 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 452 356 return *this; 453 357 } 358 */ 454 359 455 void Playlist::describeYourself( )360 void Playlist::describeYourself(void) const 456 361 { 457 362 // This is for debugging 458 363 /* … … 461 366 cout << " songlist(raw) is \"" << raw_songlist << "\"" << endl; 462 367 cout << " songlist list is "; 463 368 */ 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() + ","; 470 373 471 VERBOSE(VB_IMPORTANT, msg);374 VERBOSE(VB_IMPORTANT, LOC + msg); 472 375 } 473 376 474 377 475 378 void Playlist::loadPlaylist(QString a_name, QString a_host) 476 379 { 477 380 QString thequery; 478 if (a_host. length() < 1)381 if (a_host.isEmpty()) 479 382 { 480 VERBOSE(VB_IMPORTANT, "loadPlaylist() - We need a valid hostname");383 VERBOSE(VB_IMPORTANT, LOC_ERR + "loadPlaylist() - We need a valid hostname"); 481 384 return; 482 385 } 483 386 … … 564 467 if (filter) 565 468 all_available_music->setAllVisible(false); 566 469 567 QStringList list = QStringList::split(",", raw_songlist);470 QStringList list = raw_songlist.split(",", QString::SkipEmptyParts); 568 471 QStringList::iterator it = list.begin(); 569 472 for (; it != list.end(); it++) 570 473 { … … 581 484 { 582 485 Track *a_track = new Track(an_int, all_available_music); 583 486 a_track->setParent(this); 584 songs. append(a_track);487 songs.push_back(a_track); 585 488 } 586 489 } 587 490 else 588 491 { 589 492 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 " 592 497 "mythmusic, then something is really wrong"); 593 498 } 594 499 } … … 601 506 } 602 507 } 603 508 604 void Playlist::fillSonglistFromSongs( )509 void Playlist::fillSonglistFromSongs(void) 605 510 { 606 511 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) 609 514 { 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()); 614 517 } 615 518 616 519 raw_songlist = ""; 617 if ( a_list.length() > 1)520 if (!a_list.isEmpty()) 618 521 raw_songlist = a_list.remove(0, 1); 619 522 } 620 523 … … 681 584 682 585 case PL_INSERTAFTERCURRENT: 683 586 { 684 QStringList list = QStringList::split(",", raw_songlist);587 QStringList list = raw_songlist.split(",", QString::SkipEmptyParts); 685 588 QStringList::iterator it = list.begin(); 686 589 raw_songlist = ""; 687 590 bool bFound = false; … … 745 648 int categoryID = SmartPlaylistEditor::lookupCategoryID(category); 746 649 if (categoryID == -1) 747 650 { 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)); 749 654 return; 750 655 } 751 656 … … 773 678 } 774 679 else 775 680 { 776 VERBOSE(VB_GENERAL, "Cannot find smartplaylist: " + name); 681 VERBOSE(VB_GENERAL, LOC_WARN + 682 QString("Cannot find smartplaylist: %1").arg(name)); 777 683 return; 778 684 } 779 685 } … … 825 731 826 732 void Playlist::savePlaylist(QString a_name, QString a_host) 827 733 { 828 name = a_name.simplif yWhiteSpace();734 name = a_name.simplified(); 829 735 if (name.length() < 1) 830 736 { 831 VERBOSE(VB_GENERAL, "Not going to save a playlist with no name"); 737 VERBOSE(VB_GENERAL, LOC_WARN + 738 "Not saving unnamed playlist"); 832 739 return; 833 740 } 834 741 835 742 if (a_host.length() < 1) 836 743 { 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"); 838 746 return; 839 747 } 840 748 if (name.length() < 1) … … 844 752 MSqlQuery query(MSqlQuery::InitCon()); 845 753 846 754 int length = 0, songcount = 0, playtime = 0, an_int; 847 QStringList list = QStringList::split(",", raw_songlist);755 QStringList list = raw_songlist.split(",", QString::SkipEmptyParts); 848 756 QStringList::iterator it = list.begin(); 849 757 for (; it != list.end(); it++) 850 758 { … … 927 835 { 928 836 raw_songlist.remove(' '); 929 837 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); 932 840 QStringList::iterator it = newList.begin(); 933 841 QString songlist = ""; 934 842 … … 943 851 944 852 int Playlist::writeTree(GenericTree *tree_to_write_to, int a_counter) 945 853 { 946 Track *it;947 948 854 // compute max/min playcount,lastplay for this playlist 949 855 int playcountMin = 0; 950 856 int playcountMax = 0; … … 961 867 ArtistMap::iterator Iartist; 962 868 QString artist; 963 869 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) 965 873 { 966 if (! it->getCDFlag())874 if (!(*it)->getCDFlag()) 967 875 { 968 if ( it->getValue() == 0)876 if ((*it)->getValue() == 0) 969 877 { 970 VERBOSE(VB_IMPORTANT, kID0err);878 VERBOSE(VB_IMPORTANT, LOC_ERR + kID0err); 971 879 } 972 if ( it->getValue() > 0)880 if ((*it)->getValue() > 0) 973 881 { 974 882 // Normal track 975 Metadata *tmpdata 976 = all_available_music->getMetadata(it->getValue());883 Metadata *tmpdata = 884 all_available_music->getMetadata((*it)->getValue()); 977 885 if (tmpdata) 978 886 { 979 887 if (tmpdata->isVisible()) 980 888 { 981 if ( songs.at() == 0)889 if (0 == idx) 982 890 { // first song 983 891 playcountMin = playcountMax = tmpdata->PlayCount(); 984 892 lastplayMin = lastplayMax = tmpdata->LastPlay(); … … 1034 942 parent->FillIntelliWeights(RatingWeight, PlayCountWeight, LastPlayWeight, 1035 943 RandomWeight); 1036 944 1037 for (it = songs. first(); it; it = songs.next())945 for (it = songs.begin(); it != songs.end(); ++it) 1038 946 { 1039 if (! it->getCDFlag())947 if (!(*it)->getCDFlag()) 1040 948 { 1041 if ( it->getValue() == 0)949 if ((*it)->getValue() == 0) 1042 950 { 1043 VERBOSE(VB_IMPORTANT, kID0err);951 VERBOSE(VB_IMPORTANT, LOC_ERR + kID0err); 1044 952 } 1045 if ( it->getValue() > 0)953 if ((*it)->getValue() > 0) 1046 954 { 1047 955 // Normal track 1048 Metadata *tmpdata 1049 = all_available_music->getMetadata(it->getValue());956 Metadata *tmpdata = 957 all_available_music->getMetadata((*it)->getValue()); 1050 958 if (tmpdata && tmpdata->isVisible()) 1051 959 { 1052 960 QString a_string = QString("%1 ~ %2") 1053 961 .arg(tmpdata->FormatArtist()) 1054 962 .arg(tmpdata->FormatTitle()); 1055 963 GenericTree *added_node = tree_to_write_to->addNode( 1056 a_string, it->getValue(), true);964 a_string, (*it)->getValue(), true); 1057 965 ++a_counter; 1058 966 added_node->setAttribute(0, 1); 1059 967 added_node->setAttribute(1, a_counter); // regular order … … 1128 1036 added_node->setAttribute(5, integer_order); 1129 1037 } 1130 1038 } 1131 if ( it->getValue() < 0)1039 if ((*it)->getValue() < 0) 1132 1040 { 1133 1041 // it's a playlist, recurse (mildly) 1134 1042 Playlist *level_down 1135 = parent->getPlaylist(( it->getValue()) * -1);1043 = parent->getPlaylist(((*it)->getValue()) * -1); 1136 1044 if (level_down) 1137 1045 { 1138 1046 a_counter = level_down->writeTree(tree_to_write_to, … … 1142 1050 } 1143 1051 else 1144 1052 { 1145 Metadata *tmpdata 1146 = all_available_music->getMetadata(it->getValue());1053 Metadata *tmpdata = 1054 all_available_music->getMetadata((*it)->getValue()); 1147 1055 if (tmpdata) 1148 1056 { 1149 1057 QString a_string = QString("(CD) %1 ~ %2") … … 1154 1062 { 1155 1063 a_string = QString("(CD) Track %1").arg(tmpdata->Track()); 1156 1064 } 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); 1159 1067 ++a_counter; 1160 1068 added_node->setAttribute(0, 1); 1161 1069 added_node->setAttribute(1, a_counter); // regular order … … 1167 1075 return a_counter; 1168 1076 } 1169 1077 1170 GenericTree* PlaylistsContainer::writeTree(GenericTree *tree_to_write_to)1171 {1172 all_available_music->writeTree(tree_to_write_to);1173 1174 GenericTree *sub_node1175 = 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_node1182 = 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 playlists1212 //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 ID1258 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 ID1273 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 other1368 // playlist that is actually a reference to this1369 // playlist1370 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 1424 1078 bool Playlist::containsReference(int to_check, int depth) 1425 1079 { 1426 1080 if (depth > 10) 1427 1081 { 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 "); 1430 1085 } 1431 1086 bool ref_exists = false; 1432 1087 … … 1434 1089 // Attempt to avoid infinite recursion 1435 1090 // in playlists (within playlists) =P 1436 1091 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) 1439 1094 { 1440 check = it->getValue();1441 if (check < 0 && ! it->getCDFlag())1095 check = (*it)->getValue(); 1096 if (check < 0 && !(*it)->getCDFlag()) 1442 1097 { 1443 1098 if (check * -1 == to_check) 1444 1099 { … … 1459 1114 return ref_exists; 1460 1115 } 1461 1116 1462 Playlist *PlaylistsContainer::getPlaylist(int id)1463 {1464 // return a pointer to a playlist1465 // 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 (that1474 // called this) that are also traversing the same list get1475 // reset. That took a **long** time to figure out1476 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 there1496 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 playlist1507 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 else1534 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 else1560 {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 all1574 // tracks and update those that refer to a playlist1575 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 1642 1117 // Here begins CD Writing things. ComputeSize, CreateCDMP3 & CreateCDAudio 1643 1118 1644 1119 void Playlist::computeSize(double &size_in_MB, double &size_in_sec) 1645 1120 { 1646 Track *it;1647 1121 double child_MB; 1648 1122 double child_sec; 1649 1123 … … 1651 1125 size_in_MB = 0.0; 1652 1126 size_in_sec = 0.0; 1653 1127 1654 for (it = songs.first(); it; it = songs.next()) 1128 SongList::const_iterator it = songs.begin(); 1129 for (; it != songs.end(); ++it) 1655 1130 { 1656 if ( it->getCDFlag())1131 if ((*it)->getCDFlag()) 1657 1132 continue; 1658 1133 1659 if ( it->getValue() == 0)1134 if ((*it)->getValue() == 0) 1660 1135 { 1661 1136 VERBOSE(VB_IMPORTANT, kID0err); 1662 1137 } 1663 else if ( it->getValue() > 0)1138 else if ((*it)->getValue() > 0) 1664 1139 { 1665 1140 // Normal track 1666 Metadata *tmpdata 1667 = all_available_music->getMetadata(it->getValue());1141 Metadata *tmpdata = 1142 all_available_music->getMetadata((*it)->getValue()); 1668 1143 if (tmpdata) 1669 1144 { 1670 1145 if (tmpdata->Length() > 0) … … 1679 1154 size_in_MB += finfo.size() / 1000000; 1680 1155 } 1681 1156 } 1682 if ( it->getValue() < 0)1157 if ((*it)->getValue() < 0) 1683 1158 { 1684 1159 // it's a playlist, recurse (mildly) 1685 1160 1686 1161 // Comment: I can't make this thing work. 1687 1162 // Nothing is computed with playlists 1688 Playlist *level_down = parent->getPlaylist(( it->getValue()) * -1);1163 Playlist *level_down = parent->getPlaylist(((*it)->getValue()) * -1); 1689 1164 if (level_down) 1690 1165 { 1691 1166 level_down->computeSize(child_MB, child_sec); … … 1720 1195 1721 1196 QStringList reclist; 1722 1197 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) 1725 1200 { 1726 if ( it->getCDFlag())1201 if ((*it)->getCDFlag()) 1727 1202 continue; 1728 1203 1729 if ( it->getValue() == 0)1204 if ((*it)->getValue() == 0) 1730 1205 { 1731 1206 VERBOSE(VB_IMPORTANT, kID0err); 1732 1207 } 1733 else if ( it->getValue() > 0)1208 else if ((*it)->getValue() > 0) 1734 1209 { 1735 1210 // Normal track 1736 Metadata *tmpdata 1737 = all_available_music->getMetadata(it->getValue());1211 Metadata *tmpdata = 1212 all_available_music->getMetadata((*it)->getValue()); 1738 1213 if (tmpdata) 1739 1214 { 1740 1215 // check filename.. … … 1757 1232 reclist += outline; 1758 1233 } 1759 1234 } 1760 else if ( it->getValue() < 0)1235 else if ((*it)->getValue() < 0) 1761 1236 { 1762 1237 // FIXME: handle playlists 1763 1238 } … … 1800 1275 return 1; 1801 1276 } 1802 1277 1803 Q 3TextStream recstream(&reclistfile);1278 QTextStream recstream(&reclistfile); 1804 1279 1805 1280 QStringList::Iterator iter; 1806 1281 … … 1841 1316 if (buf[6] == '%') 1842 1317 { 1843 1318 buf = buf.mid(0, 3); 1844 progress->setProgress(buf. stripWhiteSpace().toInt());1319 progress->setProgress(buf.trimmed().toInt()); 1845 1320 } 1846 1321 } 1847 1322 if (isofs.isRunning()) … … 1912 1387 QString line = burn.readLineStdout(); 1913 1388 if (line.mid(15, 2) == "of") 1914 1389 { 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(); 1917 1392 1918 1393 if (mbtotal > 0) 1919 1394 { … … 1957 1432 { 1958 1433 return -1; 1959 1434 } 1960 -
mythplugins/mythmusic/mythmusic/vorbisencoder.cpp
1 1 #include <qstring.h> 2 #include <q3cstring.h>3 2 #include <qapplication.h> 4 #include <q3progressbar.h>5 3 6 4 #include "metadata.h" 7 5 #include "encoder.h" -
mythplugins/mythmusic/mythmusic/decoder.cpp
13 13 14 14 #include <qapplication.h> 15 15 #include <qobject.h> 16 #include <q3ptrlist.h>17 16 #include <qdir.h> 18 17 #include <qstringlist.h> 19 18 #include <qregexp.h> … … 171 170 void Decoder::SetLocationFormatUseTags(void) 172 171 { 173 172 QString startdir = gContext->GetSetting("MusicLocation"); 174 startdir = QDir::clean DirPath(startdir);173 startdir = QDir::cleanPath(startdir); 175 174 if (!startdir.endsWith("/")) 176 175 startdir += "/"; 177 176 … … 180 179 ignore_id3 = gContext->GetNumSetting("Ignore_ID3", 0); 181 180 } 182 181 183 static Q 3PtrList<DecoderFactory> *factories = 0;182 static QList<DecoderFactory*> *factories = NULL; 184 183 185 184 static void checkFactories() 186 185 { 187 186 if (!factories) 188 187 { 189 factories = new Q 3PtrList<DecoderFactory>;188 factories = new QList<DecoderFactory*>; 190 189 191 190 #ifndef USING_MINGW 192 191 Decoder::registerFactory(new CdDecoderFactory); … … 203 202 checkFactories(); 204 203 205 204 QStringList l; 206 DecoderFactory *fact = factories->first();207 while (fact)208 {209 l << fact->description();210 fact = factories->next();211 }212 205 206 QList<DecoderFactory*>::iterator it = factories->begin(); 207 for (; it != factories->end(); ++it) 208 l += (*it)->description(); 209 213 210 return l; 214 211 } 215 212 … … 217 214 { 218 215 checkFactories(); 219 216 220 DecoderFactory *fact = factories->first();221 while (fact)217 QList<DecoderFactory*>::iterator it = factories->begin(); 218 for (; it != factories->end(); ++it) 222 219 { 223 if (fact->supports(source)) 224 return TRUE; 225 226 fact = factories->next(); 220 if ((*it)->supports(source)) 221 return true; 227 222 } 228 223 229 return FALSE;224 return false; 230 225 } 231 226 232 227 void Decoder::registerFactory(DecoderFactory *fact) 233 228 { 234 factories-> append(fact);229 factories->push_back(fact); 235 230 } 236 231 237 232 Decoder *Decoder::create(const QString &source, QIODevice *input, … … 239 234 { 240 235 checkFactories(); 241 236 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) 246 239 { 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); 254 242 } 255 243 256 return decoder;244 return NULL; 257 245 } 258 246 259 247 -
mythplugins/mythmusic/mythmusic/smartplaylist.cpp
975 975 976 976 // criteria Rows 977 977 SmartPLCriteriaRow *row; 978 criteriaRows.setAutoDelete(true);979 978 980 979 hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); 981 980 row = new SmartPLCriteriaRow(this, hbox); 982 981 connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void))); 983 criteriaRows. append(row);982 criteriaRows.push_back(row); 984 983 985 984 hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); 986 985 row = new SmartPLCriteriaRow(this, hbox); 987 986 connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void))); 988 criteriaRows. append(row);987 criteriaRows.push_back(row); 989 988 990 989 hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); 991 990 row = new SmartPLCriteriaRow(this, hbox); 992 991 connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void))); 993 criteriaRows. append(row);992 criteriaRows.push_back(row); 994 993 995 994 hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); 996 995 row = new SmartPLCriteriaRow(this, hbox); 997 996 connect(row, SIGNAL(criteriaChanged(void)), this, SLOT(updateMatches(void))); 998 criteriaRows. append(row);997 criteriaRows.push_back(row); 999 998 1000 999 hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); 1001 1000 message = tr("Order By:"); … … 1108 1107 SmartPlaylistEditor::~SmartPlaylistEditor(void) 1109 1108 { 1110 1109 gContext->removeListener(this); 1110 while (!criteriaRows.empty()) 1111 { 1112 delete criteriaRows.back(); 1113 criteriaRows.pop_back(); 1114 } 1111 1115 } 1112 1116 1113 1117 void SmartPlaylistEditor::titleChanged(void) … … 1117 1121 1118 1122 void SmartPlaylistEditor::updateMatches(void) 1119 1123 { 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 "; 1126 1133 1127 1134 sql += getWhereClause(); 1128 1135 1136 matchesCount = 0; 1137 1129 1138 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(); 1144 1143 1145 matchesLabel->setText(QString ().setNum(matchesCount));1144 matchesLabel->setText(QString::number(matchesCount)); 1146 1145 1147 1146 bPlaylistIsValid = (matchesCount > 0); 1148 1147 showResultsButton->setEnabled(matchesCount > 0); … … 1210 1209 } 1211 1210 1212 1211 // 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); 1218 1215 1219 1216 reject(); 1220 1217 } … … 1291 1288 if (query.isActive() && query.size() > 0) 1292 1289 { 1293 1290 rowCount = query.size(); 1294 if (rowCount > criteriaRows. count())1291 if (rowCount > criteriaRows.size()) 1295 1292 { 1296 rowCount = criteriaRows. count();1293 rowCount = criteriaRows.size(); 1297 1294 VERBOSE(VB_IMPORTANT, QString("Warning:" 1298 1295 " got too many smartplaylistitems: %1").arg(rowCount)); 1299 1296 } … … 1301 1298 query.first(); 1302 1299 for (uint x = 0; x < rowCount; x++) 1303 1300 { 1304 row = criteriaRows .at(x);1301 row = criteriaRows[x]; 1305 1302 QString Field = query.value(0).toString(); 1306 1303 QString Operator = query.value(1).toString(); 1307 1304 QString Value1 = query.value(2).toString(); … … 1474 1471 1475 1472 QString SmartPlaylistEditor::getWhereClause(void) 1476 1473 { 1477 SmartPLCriteriaRow *row;1478 QString sql, criteria, matchType;1479 1480 1474 bool bFirst = true; 1475 QString sql = "WHERE "; 1481 1476 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) 1484 1479 { 1485 criteria = row->getSQL();1480 QString criteria = (*it)->getSQL(); 1486 1481 if (criteria.isEmpty()) 1487 1482 continue; 1488 1483 -
mythplugins/mythmusic/mythmusic/lameencoder.cpp
24 24 */ 25 25 26 26 #include <qstring.h> 27 #include <q3cstring.h>28 27 #include <qapplication.h> 29 #include <q3progressbar.h>30 28 31 29 #include "metadata.h" 32 30 #include "lameencoder.h" -
mythplugins/mythmusic/mythmusic/treecheckitem.h
6 6 #include <QPixmap> 7 7 8 8 class QPixmap; 9 class Playlist sContainer;9 class PlaylistContainer; 10 10 class Playlist; 11 11 class Track; 12 12 -
mythplugins/mythmusic/mythmusic/databasebox.h
1 1 #ifndef DATABASEBOX_H_ 2 2 #define DATABASEBOX_H_ 3 3 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> 5 using namespace std; 6 7 #include <QStringList> 8 #include <QThread> 11 9 #include <QPixmap> 12 #include <QKeyEvent>13 10 14 11 #include "metadata.h" 15 12 #include "playlist.h" … … 18 15 #include <mythtv/uilistbtntype.h> 19 16 20 17 class TreeCheckItem; 18 class QTimer; 19 class QKeyEvent; 21 20 22 21 class ReadCDThread : public QThread 23 22 { … … 115 114 116 115 QStringList treelevels; 117 116 118 Q3PtrList<UITextType> m_lines;117 vector<UITextType*> m_lines; 119 118 }; 120 119 121 120 #endif -
mythplugins/mythmusic/mythmusic/metadata.h
1 1 #ifndef METADATA_H_ 2 2 #define METADATA_H_ 3 3 4 // C++ 5 #include <vector> 6 using namespace std; 7 4 8 // 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> 11 12 12 13 // mythtv 13 14 #include <mythtv/uitypes.h> … … 18 19 19 20 class AllMusic; 20 21 class CoverArt; 21 class Playlist sContainer;22 class PlaylistContainer; 22 23 23 24 enum ImageType 24 25 { … … 170 171 } 171 172 bool determineIfCompilation(bool cd = false); 172 173 173 void setEmbeddedAlbumArt( Q3ValueList<struct AlbumArtImage>art);174 void setEmbeddedAlbumArt(const QList<struct AlbumArtImage> &art); 174 175 175 176 bool isInDatabase(void); 176 177 void dumpToDatabase(void); … … 178 179 void getField(const QString& field, QString *data); 179 180 void persist(); 180 181 bool hasChanged() {return m_changed;} 181 int compare (Metadata *other);182 int compare(const Metadata *other) const; 182 183 static void setArtistAndTrackFormats(); 183 184 184 185 static void SetStartdir(const QString &dir); … … 217 218 QString m_lastplay; 218 219 int m_playcount; 219 220 bool m_compilation; 220 Q 3ValueList<struct AlbumArtImage> m_albumart;221 QList<struct AlbumArtImage> m_albumart; 221 222 222 223 unsigned int m_id; 223 224 QString m_filename; … … 242 243 bool operator==(const Metadata& a, const Metadata& b); 243 244 bool operator!=(const Metadata& a, const Metadata& b); 244 245 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 246 typedef QList<Metadata*> MetadataPtrList; 256 247 class MusicNode; 257 class MusicNodePtrList : public Q3PtrList<MusicNode> 258 { 259 public: 260 MusicNodePtrList() {} 261 ~MusicNodePtrList() {} 248 typedef QList<MusicNode*> MusicNodePtrList; 262 249 263 protected:264 int compareItems(Q3PtrCollection::Item item1,265 Q3PtrCollection::Item item2);266 };267 268 250 class MusicNode 269 251 { 270 252 public: … … 272 254 MusicNode(const QString &a_title, const QString &tree_level); 273 255 ~MusicNode(); 274 256 275 QString getTitle( ){return my_title;}276 void printYourself(int indent_amount) ; // debugging257 QString getTitle(void) const { return my_title; } 258 void printYourself(int indent_amount) const; // debugging 277 259 void putYourselfOnTheListView(TreeCheckItem *parent, bool show_node); 278 260 void writeTree(GenericTree *tree_to_write_to, int a_counter); 279 261 void sort(); … … 384 366 typedef QMap<int, Metadata*> MusicMap; 385 367 MusicMap music_map; 386 368 387 typedef Q 3ValueList<Metadata>ValueMetadata;369 typedef QList<Metadata> ValueMetadata; 388 370 ValueMetadata m_cd_data; // More than one cd player? 389 371 QString m_cd_title; 390 372 … … 414 396 415 397 QString paths; 416 398 QString startdir; 417 Playlist sContainer*all_playlists;399 PlaylistContainer *all_playlists; 418 400 AllMusic *all_music; 419 401 bool runPost; 420 402 }; … … 424 406 425 407 //---------------------------------------------------------------------------- 426 408 427 class AlbumArtImages : public QObject409 class AlbumArtImages 428 410 { 429 Q_OBJECT430 431 411 public: 432 412 AlbumArtImages(Metadata *metadata); 413 ~AlbumArtImages(); 433 414 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); 436 419 QString getTypeName(ImageType type); 437 QStringList getImageFilenames( );438 Q3PtrList<AlbumArtImage> *getImageList() { return &m_imageList; }439 AlbumArtImage 420 QStringList getImageFilenames(void) const; 421 ImageList *getImageList(void) { return &m_imageList; } 422 AlbumArtImage *getImageAt(uint index); 440 423 441 bool isImageAvailable(ImageType type);442 443 424 bool saveImageType(const int id, ImageType type); 444 425 445 426 static ImageType guessImageType(const QString &filename); … … 447 428 private: 448 429 void findImages(void); 449 430 450 Metadata 451 Q3PtrList<AlbumArtImage>m_imageList;431 Metadata *m_parent; 432 ImageList m_imageList; 452 433 }; 453 434 454 435 #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> 6 2 #include <QKeyEvent> 7 3 #include <QLabel> 8 #include <Q3PtrList>9 4 #include <QPixmap> 5 10 6 #include "editmetadata.h" 11 7 #include "decoder.h" 12 8 #include "genres.h" 13 9 #include "metadata.h" 14 10 11 #include <mythcontext.h> 12 #include <mythdbcon.h> 13 #include <libmythui/mythuihelper.h> 14 15 15 EditMetadataDialog::EditMetadataDialog(Metadata *source_metadata, 16 16 MythMainWindow *parent, 17 17 const QString &window_name, … … 148 148 149 149 void EditMetadataDialog::updateImageGrid() 150 150 { 151 Q3PtrList<AlbumArtImage> *albumArtList = albumArt->getImageList();151 vector<AlbumArtImage*> *albumArtList = albumArt->getImageList(); 152 152 153 153 QSize size = coverart_grid->getImageItemSize(); 154 154 155 for (uint x = 0; x < albumArtList-> count(); x++)155 for (uint x = 0; x < albumArtList->size(); x++) 156 156 { 157 157 if (albumArtList->at(x)->embedded) 158 158 continue; … … 166 166 coverart_grid->appendItem(item); 167 167 } 168 168 169 coverart_grid->setItemCount(albumArtList-> count());169 coverart_grid->setItemCount(albumArtList->size()); 170 170 coverart_grid->recalculateLayout(); 171 171 172 if ( albumArtList->count() > 0)172 if (!albumArtList->empty()) 173 173 gridItemChanged(coverart_grid->getItemAt(0)); 174 174 175 175 coverart_grid->refresh(); … … 536 536 } 537 537 538 538 searchDialog->deleteLater(); 539 setActiveWindow();539 activateWindow(); 540 540 541 541 return res; 542 542 } … … 653 653 { 654 654 popup->deleteLater(); 655 655 popup = NULL; 656 setActiveWindow();656 activateWindow(); 657 657 } 658 658 } 659 659 -
mythplugins/mythmusic/mythmusic/treebuilders.cpp
102 102 typedef QMap<QString, Branch*> BranchMap; 103 103 BranchMap branches; 104 104 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) 108 107 { 108 Metadata *meta = *it; 109 109 if (isLeafDone(meta)) 110 110 { 111 111 root->addLeaf(meta); … … 113 113 else 114 114 { 115 115 QString field = getField(meta); 116 QString field_key = field. lower();116 QString field_key = field.toLower(); 117 117 118 118 if (field_key.left(4) == thePrefix) 119 119 field_key = field_key.mid(4); … … 127 127 } 128 128 branch->list.append(meta); 129 129 } 130 131 ++iter;132 130 } 133 131 134 132 for(BranchMap::iterator it = branches.begin(); it != branches.end(); it++) 135 133 { 136 Branch *branch = it.data();134 Branch *branch = *it; 137 135 MusicNode *sub_node = createNode(branch->field); 138 136 root->addChild(sub_node); 139 137 makeTree(sub_node, branch->list); … … 148 146 public: 149 147 MusicFieldTreeBuilder(const QString &paths) 150 148 { 151 m_paths = QStringList::split(' ', paths);149 m_paths = paths.split(' ', QString::SkipEmptyParts); 152 150 } 153 151 154 152 ~MusicFieldTreeBuilder() … … 198 196 199 197 QString getSplitField(Metadata *meta, const QString &field) 200 198 { 201 QString firstchar_str = meta->FormatArtist(). stripWhiteSpace();199 QString firstchar_str = meta->FormatArtist().trimmed(); 202 200 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(); 205 203 else 206 firstchar_str = firstchar_str.left(1). upper();204 firstchar_str = firstchar_str.left(1).toUpper(); 207 205 208 206 QChar firstchar = firstchar_str[0]; 209 207 QString split = m_split_map[firstchar]; … … 291 289 ~MusicDirectoryTreeBuilder() 292 290 { 293 291 for(MetaMap::iterator it = m_map.begin(); it != m_map.end(); it++) 294 delete it.data();292 delete *it; 295 293 } 296 294 297 295 protected: … … 321 319 return paths; 322 320 323 321 QString filename = meta->Filename().remove(0, getStartdir().length()); 324 paths = new QStringList( QStringList::split('/', filename));322 paths = new QStringList(filename.split('/')); 325 323 m_map[meta] = paths; 326 324 327 325 return paths; -
mythplugins/mythmusic/mythmusic/musicplayer.h
1 1 #ifndef MUSICPLAYER_H_ 2 2 #define MUSICPLAYER_H_ 3 3 4 #include <iostream>5 6 4 #include <mythtv/mythdialogs.h> 7 5 #include <mythtv/audiooutput.h> 8 6 … … 14 12 15 13 class MusicPlayer : public QObject 16 14 { 17 //Q_OBJECT18 19 15 public: 20 21 16 MusicPlayer(QObject *parent, const QString &dev); 22 ~MusicPlayer(void);23 17 24 18 void playFile(const QString &filename); 25 19 void playFile(const Metadata &meta); … … 111 105 ResumeMode getResumeMode(void) { return m_resumeMode; } 112 106 113 107 protected: 108 ~MusicPlayer(void); 114 109 void customEvent(QEvent *event); 115 110 116 111 private: -
mythplugins/mythmusic/mythmusic/avfdecoder.cpp
124 124 seekTime = -1.0; 125 125 totalTime = 0.0; 126 126 127 filename = ((QFile *)input())-> name();127 filename = ((QFile *)input())->fileName(); 128 128 129 129 if (!output_buf) 130 130 output_buf = new char[globalBufferSize]; … … 137 137 138 138 // open the media file 139 139 // 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 143 144 if (error < 0) 144 145 { 145 146 VERBOSE(VB_GENERAL, QString("Could open file with the AV decoder. " … … 427 428 428 429 bool avfDecoderFactory::supports(const QString &source) const 429 430 { 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 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 } 436 437 437 438 return false; 438 439 } 439 440 440 441 const 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 7 PlaylistLoadingThread::PlaylistLoadingThread(PlaylistContainer *parent_ptr, 8 AllMusic *all_music_ptr) 9 { 10 parent = parent_ptr; 11 all_music = all_music_ptr; 12 } 13 14 void 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 27 void PlaylistContainer::clearCDList() 28 { 29 cd_playlist.clear(); 30 } 31 32 void PlaylistContainer::addCDTrack(int track) 33 { 34 cd_playlist.push_back(track); 35 } 36 37 void PlaylistContainer::removeCDTrack(int track) 38 { 39 cd_playlist.remove(track); 40 } 41 42 bool 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 49 PlaylistContainer::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 65 PlaylistContainer::~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 85 void 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 94 void 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 149 void 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 158 Playlist *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 179 GenericTree* 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 240 void 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 256 void 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 271 void 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 287 void 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 299 void 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 321 void 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 349 void 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 365 void 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 403 QString 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 427 void 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 472 void 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 506 void 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 519 bool PlaylistContainer::pendingWriteback() 520 { 521 if (pending_writeback_index > 0) 522 { 523 return true; 524 } 525 return false; 526 } 527 528 bool 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 546 bool PlaylistContainer::cleanOutThreads() 547 { 548 if (playlists_loader->isFinished()) 549 { 550 return true; 551 } 552 playlists_loader->wait(); 553 return false; 554 } 555 556 void 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
1 1 #ifndef METAIOTAGLIB_H_ 2 2 #define METAIOTAGLIB_H_ 3 3 4 #include "metaio.h"5 #include "metadata.h"6 4 #include <id3v2tag.h> 7 5 #include <textidentificationframe.h> 8 6 #include <attachedpictureframe.h> 9 7 #include <mpegfile.h> 10 8 #include <mpegproperties.h> 11 //Added by qt3to4:12 #include <Q3ValueList>13 9 10 #include <QList> 11 12 #include "metaio.h" 13 #include "metadata.h" 14 14 15 using TagLib::MPEG::File; 15 16 using TagLib::Tag; 16 17 using TagLib::ID3v2::UserTextIdentificationFrame; … … 19 20 using TagLib::String; 20 21 using TagLib::MPEG::Properties; 21 22 22 typedef Q 3ValueList<struct AlbumArtImage> AlbumArtList;23 typedef QList<struct AlbumArtImage> AlbumArtList; 23 24 24 25 class MetaIOTagLib : public MetaIO 25 26 { -
mythplugins/mythmusic/mythmusic/smartplaylist.h
1 1 #ifndef SMARTPLAYLIST_H_ 2 2 #define SMARTPLAYLIST_H_ 3 3 4 #include <qdatetime.h> 5 #include <qlayout.h> 6 #include <q3hbox.h> 7 #include <qvariant.h> 4 #include <vector> 5 using namespace std; 6 7 #include <QDateTime> 8 #include <QVariant> 9 #include <QKeyEvent> 8 10 //Added by qt3to4: 11 #include <QLayout> 12 #include <QLabel> 13 #include <Q3HBox> 9 14 #include <Q3HBoxLayout> 10 #include <QLabel>11 #include <Q3PtrList>12 #include <QKeyEvent>13 15 #include <Q3VBoxLayout> 14 16 15 17 #include <mythtv/mythwidgets.h> … … 155 157 QAbstractButton *renameCategoryButton; 156 158 QAbstractButton *deleteCategoryButton; 157 159 158 Q3PtrList<SmartPLCriteriaRow> criteriaRows;160 vector<SmartPLCriteriaRow*> criteriaRows; 159 161 int matchesCount; 160 162 bool bNewPlaylist; 161 163 bool bPlaylistIsValid; -
mythplugins/mythmusic/mythmusic/databasebox.cpp
1 // C 1 2 #include <cstdlib> 3 4 // C++ 2 5 #include <iostream> 3 //Added by qt3to4:4 #include <QKeyEvent>5 #include <Q3PtrList>6 6 using namespace std; 7 7 8 8 // 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> 16 14 17 15 // mythtv 18 16 #include <mythtv/dialogbox.h> … … 26 24 #include "databasebox.h" 27 25 #include "treecheckitem.h" 28 26 #include "cddecoder.h" 29 #include "playlist .h"27 #include "playlistcontainer.h" 30 28 #include "musicplayer.h" 31 29 #ifndef USING_MINGW 32 30 #include "cddecoder.h" … … 52 50 cd_checking_flag = gContext->GetNumSetting("AutoLookupCD"); 53 51 54 52 QString treelev = gContext->GetSetting("TreeLevels", "artist album title"); 55 QStringList treelevels = QStringList::split(" ", treelev.lower());53 QStringList treelevels = treelev.toLower().split(" "); 56 54 57 55 active_popup = NULL; 58 56 active_pl_edit = NULL; … … 88 86 { 89 87 QString linename = QString("line%1").arg(i); 90 88 if ((line = getUITextType(linename))) 91 m_lines. append(line);89 m_lines.push_back(line); 92 90 } 93 91 94 if (m_lines. count() < 3)92 if (m_lines.size() < 3) 95 93 { 96 94 DialogBox *dlg = new DialogBox( 97 95 gContext->GetMainWindow(), … … 234 232 235 233 void DatabaseBox::occasionallyCheckCD() 236 234 { 237 if ( cd_reader_thread->getLock()->locked())235 if (!cd_reader_thread->getLock()->tryLock()) 238 236 return; 237 cd_reader_thread->getLock()->unlock(); 239 238 240 239 if (cd_reader_thread->statusChanged()) 241 240 { … … 245 244 fillCD(); 246 245 } 247 246 } 248 if (!cd_reader_thread-> running())247 if (!cd_reader_thread->isRunning()) 249 248 cd_reader_thread->start(); 250 249 } 251 250 … … 700 699 } 701 700 702 701 // Pre increment as not incremented from previous use. 703 while (++line < m_lines.count())702 while (++line < (unsigned) m_lines.size()) 704 703 m_lines.at(line)->SetText(""); 705 704 706 705 // Don't forget to delete the mdata storage if we allocated it. … … 749 748 dispat++; 750 749 } 751 750 752 for (unsigned int i = dispat; i < m_lines.count(); i++)751 for (unsigned int i = dispat; i < (unsigned) m_lines.size(); i++) 753 752 m_lines.at(i)->SetText(""); 754 753 } 755 754 -
mythplugins/mythmusic/mythmusic/vcedit.c
100 100 /* Next two functions pulled straight from libvorbis, apart from one change 101 101 * - we don't want to overwrite the vendor string. 102 102 */ 103 static void _v_writestring(oggpack_buffer *o,c har *s, int len)103 static void _v_writestring(oggpack_buffer *o,const char *s, int len) 104 104 { 105 105 while(len--) 106 106 { -
mythplugins/mythmusic/mythmusic/main.cpp
25 25 #include "metadata.h" 26 26 #include "databasebox.h" 27 27 #include "playbackbox.h" 28 #include "playlist .h"28 #include "playlistcontainer.h" 29 29 #include "globalsettings.h" 30 30 #include "dbcheck.h" 31 31 #include "filescanner.h" … … 218 218 { 219 219 (void) data; 220 220 221 QString sel = selection. lower();221 QString sel = selection.toLower(); 222 222 if (sel == "music_create_playlist") 223 223 startDatabaseTree(); 224 224 else if (sel == "music_play") … … 443 443 444 444 // Load all available info about songs (once!) 445 445 QString startdir = gContext->GetSetting("MusicLocation"); 446 startdir = QDir::clean DirPath(startdir);446 startdir = QDir::cleanPath(startdir); 447 447 if (!startdir.endsWith("/")) 448 448 startdir += "/"; 449 449 … … 468 468 AllMusic *all_music = new AllMusic(paths, startdir); 469 469 470 470 // 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()); 472 473 473 474 gMusicData->paths = paths; 474 475 gMusicData->startdir = startdir; … … 512 513 gMusicData->runPost = false; 513 514 gMusicData->paths = gContext->GetSetting("TreeLevels"); 514 515 gMusicData->startdir = gContext->GetSetting("MusicLocation"); 515 gMusicData->startdir = QDir::clean DirPath(gMusicData->startdir);516 gMusicData->startdir = QDir::cleanPath(gMusicData->startdir); 516 517 517 518 if (!gMusicData->startdir.endsWith("/")) 518 519 gMusicData->startdir += "/"; … … 528 529 529 530 void mythplugin_destroy(void) 530 531 { 531 delete gPlayer;532 gPlayer->deleteLater(); 532 533 delete gMusicData; 533 534 } 534 535 -
mythplugins/mythmusic/mythmusic/musicplayer.cpp
1 1 // ANSI C includes 2 2 #include <cstdlib> 3 3 4 // C++ includes5 #include <iostream>6 #include <Q3ValueList>7 8 using namespace std;9 10 4 // qt 11 #include <qapplication.h> 12 #include <q3url.h> 13 #include <qwidget.h> 5 #include <QApplication> 6 #include <QWidget> 14 7 #include <QFile> 8 #include <QList> 15 9 16 10 // mythtv 17 11 #include <mythtv/mythcontext.h> … … 25 19 #include "constants.h" 26 20 #include "mainvisual.h" 27 21 #include "miniplayer.h" 28 #include "playlist .h"22 #include "playlistcontainer.h" 29 23 30 24 // how long to wait before updating the lastplay and playcount fields 31 25 #define LASTPLAY_DELAY 15 … … 58 52 m_playSpeed = 1.0; 59 53 60 54 QString playmode = gContext->GetSetting("PlayMode", "none"); 61 if (playmode. lower() == "random")55 if (playmode.toLower() == "random") 62 56 setShuffleMode(SHUFFLE_RANDOM); 63 else if (playmode. lower() == "intelligent")57 else if (playmode.toLower() == "intelligent") 64 58 setShuffleMode(SHUFFLE_INTELLIGENT); 65 else if (playmode. lower() == "album")59 else if (playmode.toLower() == "album") 66 60 setShuffleMode(SHUFFLE_ALBUM); 67 else if (playmode. lower() == "artist")61 else if (playmode.toLower() == "artist") 68 62 setShuffleMode(SHUFFLE_ARTIST); 69 63 else 70 64 setShuffleMode(SHUFFLE_OFF); 71 65 72 66 QString repeatmode = gContext->GetSetting("RepeatMode", "all"); 73 if (repeatmode. lower() == "track")67 if (repeatmode.toLower() == "track") 74 68 setRepeatMode(REPEAT_TRACK); 75 else if (repeatmode. lower() == "all")69 else if (repeatmode.toLower() == "all") 76 70 setRepeatMode(REPEAT_ALL); 77 71 else 78 72 setRepeatMode(REPEAT_OFF); 79 73 80 74 QString resumestring = gContext->GetSetting("ResumeMode", "off"); 81 if (resumestring. lower() == "off")75 if (resumestring.toLower() == "off") 82 76 m_resumeMode = RESUME_OFF; 83 else if (resumestring. lower() == "track")77 else if (resumestring.toLower() == "track") 84 78 m_resumeMode = RESUME_TRACK; 85 79 else 86 80 m_resumeMode = RESUME_EXACT; … … 326 320 327 321 void MusicPlayer::stopDecoder(void) 328 322 { 329 if (m_decoder && m_decoder-> running())323 if (m_decoder && m_decoder->isRunning()) 330 324 { 331 325 m_decoder->lock(); 332 326 m_decoder->stop(); … … 666 660 667 661 void MusicPlayer::restorePosition(const QString &position) 668 662 { 669 Q 3ValueList<int> branches_to_current_node;663 QList<int> branches_to_current_node; 670 664 671 665 if (position != "") 672 666 { 673 QStringList list = QStringList::split(",", position);667 QStringList list = position.split(",", QString::SkipEmptyParts); 674 668 675 669 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) 676 670 branches_to_current_node.append((*it).toInt()); … … 707 701 m_output->Reset(); 708 702 m_output->SetTimecode(pos*1000); 709 703 710 if (m_decoder && m_decoder-> running())704 if (m_decoder && m_decoder->isRunning()) 711 705 { 712 706 m_decoder->lock(); 713 707 m_decoder->seek(pos); -
mythplugins/mythmusic/mythmusic/metaiotaglib.cpp
1 #include < math.h>1 #include <cmath> 2 2 3 3 #include "metaiotaglib.h" 4 4 #include "metadata.h" 5 5 6 #include <mythtv/mythcontext.h> 7 //Added by qt3to4: 8 #include <Q3ValueList> 6 #include <mythverbose.h> 9 7 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 10 14 MetaIOTagLib::MetaIOTagLib(void) 11 15 : MetaIO(".mp3") 12 16 { … … 129 133 genre = ""; 130 134 int year = 0, tracknum = 0, length = 0, playcount = 0, rating = 0, id = 0; 131 135 bool compilation = false; 132 Q 3ValueList<struct AlbumArtImage> albumart;136 QList<struct AlbumArtImage> albumart; 133 137 134 138 QString extension = filename.section( '.', -1 ) ; 135 139 … … 148 152 // Basic Tags 149 153 if (! tag->isEmpty()) 150 154 { 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(); 154 158 tracknum = tag->track(); 155 159 year = tag->year(); 156 genre = TStringToQString(tag->genre()). stripWhiteSpace();160 genre = TStringToQString(tag->genre()).trimmed(); 157 161 } 158 162 159 163 // ID3V2 Only Tags … … 164 168 { 165 169 compilation_artist = TStringToQString( 166 170 taglib->ID3v2Tag()->frameListMap()["TPE4"].front()->toString()) 167 .stripWhiteSpace();171 .trimmed(); 168 172 } 169 173 170 174 // Look for MusicBrainz Album+Artist ID in TXXX Frame … … 323 327 */ 324 328 AlbumArtList MetaIOTagLib::readAlbumArt(TagLib::ID3v2::Tag *tag) 325 329 { 330 QList<struct AlbumArtImage> artlist; 326 331 327 Q3ValueList<struct AlbumArtImage> artlist;328 329 332 if (!tag->frameListMap()["APIC"].isEmpty()) 330 333 { 331 334 TagLib::ID3v2::FrameList apicframes = tag->frameListMap()["APIC"]; -
mythplugins/mythmusic/mythmusic/playbackbox.h
2 2 #define PLAYBACKBOX_H_ 3 3 4 4 // qt 5 #include <qtimer.h>6 #include <qmutex.h>7 #include <q3valuevector.h>8 5 #include <QKeyEvent> 6 #include <q3valuevector.h> 9 7 10 8 // mythtv 11 9 #include <mythtv/mythwidgets.h> … … 22 20 23 21 class Output; 24 22 class Decoder; 23 class QTimer; 25 24 26 25 class PlaybackBoxMusic : public MythThemedDialog 27 26 { -
mythplugins/mythmusic/mythmusic/mainvisual.cpp
74 74 int y = size.height() / 2 - height / 2; 75 75 76 76 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")); 78 78 p->drawText(x, y + offset, width, height, Qt::AlignCenter, l); 79 79 warning.remove(0, l.length () + 1); 80 80 } 81 81 } 82 82 83 83 MainVisual::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), 85 85 timer (0), bannerTimer(0), info_widget(0) 86 86 { 87 setObjectName(name); 87 88 int screenwidth = 0, screenheight = 0; 88 89 float wmult = 0, hmult = 0; 89 90 … … 121 122 delete bannerTimer; 122 123 bannerTimer = 0; 123 124 124 nodes.setAutoDelete(TRUE); 125 nodes.clear(); 125 while (!nodes.empty()) 126 { 127 delete nodes.back(); 128 nodes.pop_back(); 129 } 126 130 } 127 131 128 132 void MainVisual::setVisual(const QString &name) … … 167 171 168 172 void MainVisual::prepare() 169 173 { 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 } 173 179 } 174 180 175 181 void MainVisual::add(uchar *b, unsigned long b_len, unsigned long w, int c, int p) … … 219 225 return; 220 226 } 221 227 222 VisualNode *node = 0; 223 228 VisualNode *node = NULL; 224 229 if (playing && output()) 225 230 { 226 231 long synctime = output()->GetAudiotime(); 227 232 mutex()->lock(); 228 VisualNode *prev = 0;229 while ( (node = nodes.first()))233 VisualNode *prev = NULL; 234 while (!nodes.empty()) 230 235 { 236 node = nodes.front(); 231 237 if (node->offset > synctime) 232 238 break; 233 delete prev; 234 nodes.removeFirst(); 239 nodes.pop_front(); 240 241 if (prev) 242 delete prev; 235 243 prev = node; 236 244 } 237 245 mutex()->unlock(); … … 443 451 QString info_copy = info; 444 452 for (int offset = 0; offset < textHeight; offset += fm.height()) 445 453 { 446 QString l = info_copy.left(info_copy. find("\n"));454 QString l = info_copy.left(info_copy.indexOf("\n")); 447 455 p.setPen(Qt::black); 448 456 p.drawText(x + 2, y + offset + 2, textWidth, textHeight, Qt::AlignLeft, l); 449 457 p.setPen(Qt::white); … … 489 497 QString info_copy = info; 490 498 for (int offset = 0; offset < textHeight; offset += fm.height()) 491 499 { 492 QString l = info_copy.left(info_copy. find("\n"));500 QString l = info_copy.left(info_copy.indexOf("\n")); 493 501 p.setPen(Qt::black); 494 502 p.drawText(x + 2, y + offset + 2, textWidth, textHeight, Qt::AlignLeft, l); 495 503 p.setPen(Qt::white); … … 527 535 uint os = magnitudes.size(); 528 536 magnitudes.resize( size.width() * 2 ); 529 537 for ( ; os < magnitudes.size(); os++ ) 530 magnitudes[os] = 0.0;538 magnitudes[os] = 0.0; 531 539 } 532 540 533 541 bool 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 8 class 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 20 class 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
555 555 ++it; 556 556 if (fi->fileName() == "." || fi->fileName() == "..") 557 557 continue; 558 QString filename = fi->abs FilePath();558 QString filename = fi->absoluteFilePath(); 559 559 if (fi->isDir()) 560 560 scanDirectory(filename, tracks); 561 561 else … … 1087 1087 QFileInfo fi(filename); 1088 1088 filename = fi.fileName(); 1089 1089 1090 if (filename.contains("front", false) > 0)1090 if (filename.contains("front", Qt::CaseInsensitive) > 0) 1091 1091 m_type_selector->setToItem(tr("Front Cover")); 1092 else if (filename.contains("back", false) > 0)1092 else if (filename.contains("back", Qt::CaseInsensitive) > 0) 1093 1093 m_type_selector->setToItem(tr("Back Cover")); 1094 else if (filename.contains("inlay", false) > 0)1094 else if (filename.contains("inlay", Qt::CaseInsensitive) > 0) 1095 1095 m_type_selector->setToItem(tr("Inlay")); 1096 else if (filename.contains("cd", false) > 0)1096 else if (filename.contains("cd", Qt::CaseInsensitive) > 0) 1097 1097 m_type_selector->setToItem(tr("CD")); 1098 1098 else 1099 1099 m_type_selector->setToItem(tr("<Unknown>")); -
mythplugins/mythmusic/mythmusic/cddecoder.cpp
258 258 void CdDecoder::setCDSpeed(int speed) 259 259 { 260 260 QMutexLocker lock(getMutex()); 261 MediaMonitor::SetCDSpeed(devicename , speed);261 MediaMonitor::SetCDSpeed(devicename.toLocal8Bit().constData(), speed); 262 262 } 263 263 264 264 int CdDecoder::getNumTracks(void) … … 408 408 409 409 compilation_artist = M_QSTRING_UNICODE(discdata.data_artist); 410 410 411 if (compilation_artist. lower().left(7) == "various")411 if (compilation_artist.toLower().left(7) == "various") 412 412 { 413 413 compilation_artist = QObject::tr("Various Artists"); 414 414 } … … 419 419 420 420 if (!genre.isEmpty()) 421 421 { 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(); 424 424 genre = flet + rt; 425 425 } 426 426 … … 547 547 548 548 bool CdDecoderFactory::supports(const QString &source) const 549 549 { 550 return (source.right(extension().length()). lower() == extension());550 return (source.right(extension().length()).toLower() == extension()); 551 551 } 552 552 553 553 const QString &CdDecoderFactory::extension() const -
mythplugins/mythmusic/mythmusic/metaio.cpp
13 13 MetaIO::MetaIO(QString fileExtension) 14 14 : mFileExtension(fileExtension) 15 15 { 16 mFilenameFormat = gContext->GetSetting("NonID3FileNameFormat"). upper();16 mFilenameFormat = gContext->GetSetting("NonID3FileNameFormat").toUpper(); 17 17 } 18 18 19 19 … … 44 44 static QString regext = mFileExtension + "$"; 45 45 int part_num = 0; 46 46 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("/"); 49 49 QStringList::iterator fmt_it = fmt_list.begin(); 50 50 51 51 // go through loop once to get minimum part number … … 67 67 title = part_str; 68 68 else if ( *fmt_it == "TRACK_TITLE" ) 69 69 { 70 QStringList tracktitle_list = QStringList::split("-", part_str);70 QStringList tracktitle_list = part_str.split("-"); 71 71 if (tracktitle_list.size() > 1) 72 72 { 73 73 tracknum = tracktitle_list[0].toInt(); 74 title = tracktitle_list[1].simplif yWhiteSpace();74 title = tracktitle_list[1].simplified(); 75 75 } 76 76 else 77 77 title = part_str; 78 78 } 79 79 else if ( *fmt_it == "ARTIST_TITLE" ) 80 80 { 81 QStringList artisttitle_list = QStringList::split("-", part_str);81 QStringList artisttitle_list = part_str.split("-"); 82 82 if (artisttitle_list.size() > 1) 83 83 { 84 artist = artisttitle_list[0].simplif yWhiteSpace();85 title = artisttitle_list[1].simplif yWhiteSpace();84 artist = artisttitle_list[0].simplified(); 85 title = artisttitle_list[1].simplified(); 86 86 } 87 87 else 88 88 { -
mythplugins/mythmusic/mythmusic/goom/graphic.h
18 18 extern const Color ORANGE; 19 19 extern const Color VIOLET; 20 20 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); 23 23 24 24 #endif /* GRAPHIC_H */ -
mythplugins/mythmusic/mythmusic/streaminput.h
1 //Added by qt3to4:2 #include <Q3CString>3 1 // Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com> 4 2 // 5 3 // Use, modification and distribution is allowed without limitation, … … 11 9 12 10 class StreamInput; 13 11 14 #include < q3url.h>15 #include < q3socket.h>12 #include <QUrl> 13 #include <QTcpSocket> 16 14 17 18 15 class StreamInput : public QObject 19 16 { 20 17 Q_OBJECT 21 public:22 StreamInput(const Q3Url &);23 18 24 QIODevice *socket() { return sock; } 19 public: 20 StreamInput(const QUrl&); 25 21 26 void setup();22 QIODevice *GetSocket(void) { return sock; } 27 23 24 void Setup(void); 28 25 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); 34 31 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; 41 37 }; 42 38 43 39 -
mythplugins/mythmusic/mythmusic/visualize.h
12 12 #ifndef VISUALIZE_H 13 13 #define VISUALIZE_H 14 14 15 #include <vector> 16 using namespace std; 17 15 18 #include <mythtv/visual.h> 16 19 #include "mainvisual.h" 17 20 #include "metadata.h" … … 19 22 #include "config.h" 20 23 21 24 #include <complex> 22 //Added by qt3to4:23 #include <Q3MemArray>24 25 extern "C" { 25 26 #ifdef FFTW3_SUPPORT 26 27 #include <fftw3.h> … … 63 64 inline double clamp(double cur, double max, double min); 64 65 65 66 QColor startColor, targetColor; 66 Q3MemArray<QRect> rects;67 Q3MemArray<double> magnitudes;67 vector<QRect> rects; 68 vector<double> magnitudes; 68 69 QSize size; 69 70 LogScale scale; 70 71 double scaleFactor, falloff; … … 159 160 160 161 private: 161 162 QColor startColor, targetColor; 162 Q3MemArray<QRect> rects;163 Q3MemArray<double> magnitudes;163 vector<QRect> rects; 164 vector<double> magnitudes; 164 165 QSize size; 165 166 LogScale scale; 166 167 double scaleFactor, falloff; -
mythplugins/mythmusic/mythmusic/metaiooggvorbiscomment.cpp
70 70 { 71 71 // find the tagname 72 72 tmp = pComment->user_comments[i]; 73 int tag = tmp. find('=');73 int tag = tmp.indexOf('='); 74 74 if (tag) 75 75 { 76 tmp = tmp.left(tag). upper();76 tmp = tmp.left(tag).toUpper(); 77 77 if (MYTH_VORBISCOMMENT_ARTIST != tmp 78 78 && MYTH_VORBISCOMMENT_COMPILATIONARTIST != tmp 79 79 && MYTH_VORBISCOMMENT_TITLE != tmp … … 209 209 QString newfilename = createTempFile( 210 210 QString(l8bit.constData()) + ".XXXXXX"); 211 211 212 FILE *p_output = fopen(newfilename , "wb");212 FILE *p_output = fopen(newfilename.toLocal8Bit().constData(), "wb"); 213 213 214 214 if (!p_output) 215 215 { -
mythplugins/mythmusic/mythmusic/filescanner.cpp
104 104 ++it; 105 105 if (fi->fileName() == "." || fi->fileName() == "..") 106 106 continue; 107 QString filename = fi->abs FilePath();107 QString filename = fi->absoluteFilePath(); 108 108 if (fi->isDir()) 109 109 { 110 110 111 111 QString dir(filename); 112 112 dir.remove(0, m_startdir.length()); 113 113 114 newparentid = m_directoryid[QString(dir.toUtf8()). lower()];114 newparentid = m_directoryid[QString(dir.toUtf8()).toLower()]; 115 115 116 116 if (newparentid == 0) 117 117 { 118 118 int id = GetDirectoryId(dir, parentid); 119 m_directoryid[QString(dir.toUtf8()). lower()] = id;119 m_directoryid[QString(dir.toUtf8()).toLower()] = id; 120 120 121 121 if (id > 0) 122 122 { … … 249 249 "*.png;*.jpg;*.jpeg;*.gif;*.bmp"); 250 250 251 251 // 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) 253 253 { 254 254 QString name = filename.section( '/', -1); 255 255 … … 258 258 "directory_id = :DIRID, imagetype = :TYPE;"); 259 259 query.bindValue(":FILE", name); 260 260 query.bindValue(":DIRID", m_directoryid[ 261 QString(directory.toUtf8()). lower()]);261 QString(directory.toUtf8()).toLower()]); 262 262 query.bindValue(":TYPE", AlbumArtImages::guessImageType(name)); 263 263 264 264 if (!query.exec() || query.numRowsAffected() <= 0) … … 279 279 QString album_cache_string; 280 280 281 281 // Set values from cache 282 int did = m_directoryid[QString(directory.toUtf8()). lower()];282 int did = m_directoryid[QString(directory.toUtf8()).toLower()]; 283 283 if (did > 0) 284 284 data->setDirectoryId(did); 285 285 286 int aid = m_artistid[QString(data->Artist().toUtf8()). lower()];286 int aid = m_artistid[QString(data->Artist().toUtf8()).toLower()]; 287 287 if (aid > 0) 288 288 { 289 289 data->setArtistId(aid); 290 290 291 291 // The album cache depends on the artist id 292 292 album_cache_string = data->getArtistId() + "#" 293 + QString(data->Album().toUtf8()). lower();293 + QString(data->Album().toUtf8()).toLower(); 294 294 295 295 if (m_albumid[album_cache_string] > 0) 296 296 data->setAlbumId(m_albumid[album_cache_string]); 297 297 } 298 298 299 int gid = m_genreid[QString(data->Genre().toUtf8()). lower()];299 int gid = m_genreid[QString(data->Genre().toUtf8()).toLower()]; 300 300 if (gid > 0) 301 301 data->setGenreId(gid); 302 302 … … 304 304 data->dumpToDatabase(); 305 305 306 306 // Update the cache 307 m_artistid[QString(data->Artist().toUtf8()). lower()] =307 m_artistid[QString(data->Artist().toUtf8()).toLower()] = 308 308 data->getArtistId(); 309 309 310 m_genreid[QString(data->Genre().toUtf8()). lower()] =310 m_genreid[QString(data->Genre().toUtf8()).toLower()] = 311 311 data->getGenreId(); 312 312 313 313 album_cache_string = data->getArtistId() + "#" 314 + QString(data->Album().toUtf8()). lower();314 + QString(data->Album().toUtf8()).toLower(); 315 315 m_albumid[album_cache_string] = data->getAlbumId(); 316 316 delete data; 317 317 } … … 430 430 QString nameFilter = gContext->GetSetting("AlbumArtFilter", 431 431 "*.png;*.jpg;*.jpeg;*.gif;*.bmp"); 432 432 433 if (nameFilter. find(extension) > -1)433 if (nameFilter.indexOf(extension) > -1) 434 434 { 435 435 MSqlQuery query(MSqlQuery::InitCon()); 436 436 query.prepare("DELETE FROM music_albumart WHERE filename= :FILE AND " 437 437 "directory_id= :DIRID;"); 438 438 query.bindValue(":FILE", sqlfilename); 439 439 query.bindValue(":DIRID", m_directoryid[ 440 QString(directory.toUtf8()). lower()]);440 QString(directory.toUtf8()).toLower()]); 441 441 442 442 if (!query.exec() || query.numRowsAffected() <= 0) 443 443 { … … 480 480 QString album_cache_string; 481 481 482 482 // Set values from cache 483 int did = m_directoryid[QString(directory.toUtf8()). lower()];483 int did = m_directoryid[QString(directory.toUtf8()).toLower()]; 484 484 if (did > 0) 485 485 disk_meta->setDirectoryId(did); 486 486 487 int aid = m_artistid[QString(disk_meta->Artist().toUtf8()). lower()];487 int aid = m_artistid[QString(disk_meta->Artist().toUtf8()).toLower()]; 488 488 if (aid > 0) 489 489 { 490 490 disk_meta->setArtistId(aid); 491 491 492 492 // The album cache depends on the artist id 493 493 album_cache_string = disk_meta->getArtistId() + "#" + 494 QString(disk_meta->Album().toUtf8()). lower();494 QString(disk_meta->Album().toUtf8()).toLower(); 495 495 496 496 if (m_albumid[album_cache_string] > 0) 497 497 disk_meta->setAlbumId(m_albumid[album_cache_string]); 498 498 } 499 499 500 int gid = m_genreid[QString(disk_meta->Genre().toUtf8()). lower()];500 int gid = m_genreid[QString(disk_meta->Genre().toUtf8()).toLower()]; 501 501 if (gid > 0) 502 502 disk_meta->setGenreId(gid); 503 503 … … 505 505 disk_meta->dumpToDatabase(); 506 506 507 507 // Update the cache 508 m_artistid[QString(disk_meta->Artist().toUtf8()). lower()]508 m_artistid[QString(disk_meta->Artist().toUtf8()).toLower()] 509 509 = disk_meta->getArtistId(); 510 m_genreid[QString(disk_meta->Genre().toUtf8()). lower()]510 m_genreid[QString(disk_meta->Genre().toUtf8()).toLower()] 511 511 = disk_meta->getGenreId(); 512 512 album_cache_string = disk_meta->getArtistId() + "#" + 513 QString(disk_meta->Album().toUtf8()). lower();513 QString(disk_meta->Album().toUtf8()).toLower(); 514 514 m_albumid[album_cache_string] = disk_meta->getAlbumId(); 515 515 } 516 516 … … 667 667 else if (HasFileChanged(name, query.value(1).toString())) 668 668 music_files[name] = kNeedUpdate; 669 669 else 670 music_files. remove(iter);670 music_files.erase(iter); 671 671 } 672 672 else 673 673 { … … 737 737 continue; 738 738 } 739 739 else 740 music_files. remove(iter);740 music_files.erase(iter); 741 741 } 742 742 else 743 743 { -
mythtv/libs/libmyth/uilistbtntype.h
44 44 int getCheck(void) { return m_check; } 45 45 virtual void setCheck(int flag); 46 46 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; } 49 49 50 50 void setText(const QString &text); 51 51 void setPixmap(QPixmap *pixmap); … … 335 335 336 336 void setData(void *data); 337 337 void *getData(); 338 338 339 void SetTree(UIListGenericTree*); 340 339 341 void setOverrideInactive(bool flag); 340 342 bool getOverrideInactive(void); 341 343 … … 365 367 366 368 bool m_overrideInactive; 367 369 int m_justify; 370 UIListGenericTree *m_tree; 368 371 369 372 friend class UIListBtnType; 370 373 }; -
mythtv/libs/libmyth/uilistbtntype.cpp
62 62 } 63 63 } 64 64 65 void UIListGenericTree::SetItem(UIListBtnTypeItem *item) 66 { 67 m_physitem = item; 68 if (m_physitem) 69 m_physitem->SetTree(this); 70 } 71 65 72 UIListGenericTree::~UIListGenericTree() 66 73 { 74 if (m_physitem) 75 { 76 m_physitem->SetTree(NULL); 77 m_physitem = NULL; 78 } 79 m_image = NULL; 67 80 } 68 81 69 82 void UIListGenericTree::RemoveFromParent(void) … … 400 413 while (clear) 401 414 { 402 415 UIListGenericTree *gt = (UIListGenericTree *)clear->getData(); 403 gt-> setItem(NULL);416 gt->SetItem(NULL); 404 417 clear = list->GetItemNext(clear); 405 418 } 406 419 … … 449 462 (uichild->childCount() > 0)); 450 463 newitem->setData(uichild); 451 464 452 uichild-> setItem(newitem);465 uichild->SetItem(newitem); 453 466 454 467 if (!uichild->getActive()) 455 468 newitem->setOverrideInactive(true); … … 1051 1064 1052 1065 m_itemCount--; 1053 1066 1054 if ( m_topItem != m_itemList.first())1067 if (!m_itemList.empty() && m_topItem != m_itemList.first()) 1055 1068 m_showUpArrow = true; 1056 1069 else 1057 1070 m_showUpArrow = false; … … 1933 1946 1934 1947 void UIListBtnTypeItem::CalcDimensions(void) 1935 1948 { 1949 if (!m_parent) 1950 return; 1951 1936 1952 if (!m_parent->m_initialized) 1937 1953 m_parent->Init(); 1938 1954 … … 1946 1962 QPixmap& checkPix = m_parent->m_checkNonePix; 1947 1963 QPixmap& arrowPix = m_parent->m_arrowPix; 1948 1964 1965 if (checkPix.isNull() || arrowPix.isNull()) 1966 return; 1967 1949 1968 int cw = checkPix.width(); 1950 1969 int ch = checkPix.height(); 1951 1970 int aw = arrowPix.width(); … … 1986 2005 { 1987 2006 if (m_parent) 1988 2007 m_parent->RemoveItem(this); 2008 2009 if (m_tree) 2010 { 2011 m_tree->SetItem(NULL); 2012 m_tree = NULL; 2013 } 1989 2014 } 1990 2015 2016 void UIListBtnTypeItem::SetTree(UIListGenericTree *tree) 2017 { 2018 m_tree = tree; 2019 } 2020 1991 2021 QString UIListBtnTypeItem::text() const 1992 2022 { 1993 2023 return m_text; … … 2041 2071 void UIListBtnTypeItem::setDrawArrow(bool flag) 2042 2072 { 2043 2073 m_showArrow = flag; 2044 CalcDimensions(); 2074 if (m_parent && m_parent->m_initialized) 2075 CalcDimensions(); 2045 2076 } 2046 2077 2047 2078 void UIListBtnTypeItem::setData(void *data)