author | alwin <alwin> | 2005-04-14 23:15:05 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-04-14 23:15:05 (UTC) |
commit | 4bf8d42034beee5e28b25182e21cf74f3c2da6a8 (patch) (unidiff) | |
tree | 8b882f872f9ddea939722242c229eea46545274b | |
parent | 5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf (diff) | |
download | opie-4bf8d42034beee5e28b25182e21cf74f3c2da6a8.zip opie-4bf8d42034beee5e28b25182e21cf74f3c2da6a8.tar.gz opie-4bf8d42034beee5e28b25182e21cf74f3c2da6a8.tar.bz2 |
small fix
-rw-r--r-- | noncore/multimedia/opieplayer3/playlist.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp index 6f2e668..fe2dde3 100644 --- a/noncore/multimedia/opieplayer3/playlist.cpp +++ b/noncore/multimedia/opieplayer3/playlist.cpp | |||
@@ -70,193 +70,197 @@ void PlaylistItem::Video(bool y) | |||
70 | PlaylistItem::~PlaylistItem() | 70 | PlaylistItem::~PlaylistItem() |
71 | { | 71 | { |
72 | } | 72 | } |
73 | 73 | ||
74 | /* PlaylistView Methods */ | 74 | /* PlaylistView Methods */ |
75 | PlaylistView::PlaylistView(QWidget *parent, const char *name) | 75 | PlaylistView::PlaylistView(QWidget *parent, const char *name) |
76 | : QListView(parent,name) | 76 | : QListView(parent,name) |
77 | { | 77 | { |
78 | // columnLabels << tr("FullName"); | 78 | // columnLabels << tr("FullName"); |
79 | columnLabels << tr(""); // icon | 79 | columnLabels << tr(""); // icon |
80 | columnLabels << tr("File"); | 80 | columnLabels << tr("File"); |
81 | columnLabels << tr("Playtime"); | 81 | columnLabels << tr("Playtime"); |
82 | columnLabels << tr("Artist"); | 82 | columnLabels << tr("Artist"); |
83 | columnLabels << tr("Album"); | 83 | columnLabels << tr("Album"); |
84 | columnLabels << tr("Title"); | 84 | columnLabels << tr("Title"); |
85 | columnLabels << tr("Type"); | 85 | columnLabels << tr("Type"); |
86 | columnLabels << tr("Size"); | 86 | columnLabels << tr("Size"); |
87 | for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) { | 87 | for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) { |
88 | addColumn(*it); | 88 | addColumn(*it); |
89 | } | 89 | } |
90 | m_Infolib=0; | 90 | m_Infolib=0; |
91 | setAllColumnsShowFocus(true); | 91 | setAllColumnsShowFocus(true); |
92 | setSelectionMode(Single); | 92 | setSelectionMode(Single); |
93 | setSorting(-1); | 93 | setSorting(-1); |
94 | m_lastItem = 0; | 94 | m_lastItem = 0; |
95 | m_lastDir = QDir::homeDirPath(); | 95 | m_lastDir = QDir::homeDirPath(); |
96 | } | 96 | } |
97 | 97 | ||
98 | PlaylistView::~PlaylistView() | 98 | PlaylistView::~PlaylistView() |
99 | { | 99 | { |
100 | if (m_Infolib) delete m_Infolib; | 100 | if (m_Infolib) delete m_Infolib; |
101 | } | 101 | } |
102 | 102 | ||
103 | void PlaylistView::checkLib() | 103 | void PlaylistView::checkLib() |
104 | { | 104 | { |
105 | if (!m_Infolib) { | 105 | if (!m_Infolib) { |
106 | m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately); | 106 | m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately); |
107 | connect(m_Infolib,SIGNAL(stopped()),this,SLOT(slotDummyStop())); | 107 | connect(m_Infolib,SIGNAL(stopped()),this,SLOT(slotDummyStop())); |
108 | m_Infolib->ensureInitialized(); | 108 | m_Infolib->ensureInitialized(); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | 111 | ||
112 | void PlaylistView::slotDummyStop() | 112 | void PlaylistView::slotDummyStop() |
113 | { | 113 | { |
114 | odebug << "void PlaylistView::slotDummyStop()" << oendl; | 114 | odebug << "void PlaylistView::slotDummyStop()" << oendl; |
115 | } | 115 | } |
116 | 116 | ||
117 | void PlaylistView::slotAddFile(const DocLnk&aLink) | 117 | void PlaylistView::slotAddFile(const DocLnk&aLink) |
118 | { | 118 | { |
119 | QFileInfo f(aLink.file()); | 119 | QFileInfo f(aLink.file()); |
120 | if (f.extension(FALSE).lower()=="m3u"||f.extension(FALSE).lower()=="pls") { | 120 | if (f.extension(FALSE).lower()=="m3u"||f.extension(FALSE).lower()=="pls") { |
121 | readPlayList(aLink.file()); | 121 | readPlayList(aLink.file()); |
122 | } else { | 122 | } else { |
123 | addFile(aLink.file(),aLink.name()); | 123 | addFile(aLink.file(),aLink.name()); |
124 | } | 124 | } |
125 | emit contentChanged(childCount()); | 125 | emit contentChanged(childCount()); |
126 | } | 126 | } |
127 | 127 | ||
128 | void PlaylistView::addFile(const QString&aFile,const QString&aName) | 128 | void PlaylistView::addFile(const QString&aFile,const QString&aName) |
129 | { | 129 | { |
130 | QFileInfo fileInfo(aFile); | 130 | QFileInfo fileInfo(aFile); |
131 | if (!fileInfo.exists()) return; | 131 | if (!fileInfo.exists()) return; |
132 | checkLib(); | 132 | checkLib(); |
133 | QString name = aName; | 133 | QString name = aName; |
134 | if (name.isEmpty()) { | 134 | if (name.isEmpty()) { |
135 | name = fileInfo.fileName(); | 135 | name = fileInfo.fileName(); |
136 | } | 136 | } |
137 | int i = m_Infolib->setfile(aFile.utf8().data()); | 137 | int i = m_Infolib->setfile(aFile.utf8().data()); |
138 | /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */ | 138 | /* realy! otherwise we get an "stopped" signal when playing! - I don't know why */ |
139 | m_Infolib->stop(); | 139 | m_Infolib->stop(); |
140 | odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; | 140 | odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl; |
141 | if (i<1) { | 141 | if (i<1) { |
142 | i = m_Infolib->error(); | 142 | i = m_Infolib->error(); |
143 | odebug << "Errorcode: " << i << oendl; | 143 | odebug << "Errorcode: " << i << oendl; |
144 | QString msg; | 144 | QString msg; |
145 | msg = QString(tr("Error open file %1: ")).arg(name); | 145 | msg = QString(tr("Error open file %1: ")).arg(name); |
146 | switch (i) { | 146 | switch (i) { |
147 | case 1: | 147 | case 1: |
148 | msg += tr("No input plugin"); | 148 | msg += tr("No input plugin"); |
149 | break; | 149 | break; |
150 | case 2: | 150 | case 2: |
151 | msg += tr("No demuxer plugin"); | 151 | msg += tr("No demuxer plugin"); |
152 | break; | 152 | break; |
153 | case 3: | 153 | case 3: |
154 | msg += tr("Demuxer failed"); | 154 | msg += tr("Demuxer failed"); |
155 | break; | 155 | break; |
156 | case 4: | 156 | case 4: |
157 | msg+=tr("Malformed mrl"); | 157 | msg+=tr("Malformed mrl"); |
158 | break; | 158 | break; |
159 | default: | 159 | default: |
160 | msg += tr("Unknown error"); | 160 | msg += tr("Unknown error"); |
161 | break; | 161 | break; |
162 | } | 162 | } |
163 | QMessageBox::warning(0,tr("Error reading fileheader"),msg); | 163 | QMessageBox::warning(0,tr("Error reading fileheader"),msg); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | m_lastItem = m_items.last(); | 166 | if (m_items.count()>0) { |
167 | m_lastItem = m_items.last(); | ||
168 | } else { | ||
169 | m_lastItem = 0; | ||
170 | } | ||
167 | PlaylistItem*_it = currentItem(); | 171 | PlaylistItem*_it = currentItem(); |
168 | 172 | ||
169 | if (m_lastItem) { | 173 | if (m_lastItem) { |
170 | m_lastItem = new PlaylistItem(aFile,this,m_lastItem); | 174 | m_lastItem = new PlaylistItem(aFile,this,m_lastItem); |
171 | } else { | 175 | } else { |
172 | m_lastItem = new PlaylistItem(aFile,this); | 176 | m_lastItem = new PlaylistItem(aFile,this); |
173 | } | 177 | } |
174 | m_lastItem->setExpandable(false); | 178 | m_lastItem->setExpandable(false); |
175 | m_lastItem->setText(1,name); | 179 | m_lastItem->setText(1,name); |
176 | 180 | ||
177 | QString codec = m_Infolib->metaInfo(6); | 181 | QString codec = m_Infolib->metaInfo(6); |
178 | if (codec.isEmpty()) { | 182 | if (codec.isEmpty()) { |
179 | codec = m_Infolib->metaInfo(7); | 183 | codec = m_Infolib->metaInfo(7); |
180 | } | 184 | } |
181 | // codec | 185 | // codec |
182 | m_lastItem->setText(COL_TYPE,codec); | 186 | m_lastItem->setText(COL_TYPE,codec); |
183 | // title | 187 | // title |
184 | m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); | 188 | m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); |
185 | // artist | 189 | // artist |
186 | m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); | 190 | m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); |
187 | // album | 191 | // album |
188 | m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); | 192 | m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); |
189 | int l = m_Infolib->length(); | 193 | int l = m_Infolib->length(); |
190 | int h = l/3600; | 194 | int h = l/3600; |
191 | l-=h*3600; | 195 | l-=h*3600; |
192 | int m = l/60; | 196 | int m = l/60; |
193 | l-=m*60; | 197 | l-=m*60; |
194 | codec = ""; | 198 | codec = ""; |
195 | if (h>0) { | 199 | if (h>0) { |
196 | codec.sprintf("%2i:%2i:%2i h",h,m,l); | 200 | codec.sprintf("%2i:%2i:%2i h",h,m,l); |
197 | } else { | 201 | } else { |
198 | codec.sprintf("%02i:%02i m",m,l); | 202 | codec.sprintf("%02i:%02i m",m,l); |
199 | } | 203 | } |
200 | // time | 204 | // time |
201 | m_lastItem->setText(COL_TIME,codec); | 205 | m_lastItem->setText(COL_TIME,codec); |
202 | m_lastItem->Video(m_Infolib->hasVideo()); | 206 | m_lastItem->Video(m_Infolib->hasVideo()); |
203 | m_items.append(m_lastItem); | 207 | m_items.append(m_lastItem); |
204 | if (_it==NULL) { | 208 | if (_it==NULL) { |
205 | setSelected(m_lastItem,true); | 209 | setSelected(m_lastItem,true); |
206 | } | 210 | } |
207 | } | 211 | } |
208 | 212 | ||
209 | void PlaylistView::slotAppendDir() | 213 | void PlaylistView::slotAppendDir() |
210 | { | 214 | { |
211 | QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); | 215 | QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir); |
212 | if (_dir.isEmpty()) return; | 216 | if (_dir.isEmpty()) return; |
213 | m_lastDir = _dir; | 217 | m_lastDir = _dir; |
214 | QDir sDir(_dir); | 218 | QDir sDir(_dir); |
215 | QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); | 219 | QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase); |
216 | for (unsigned i = 0; i < list.count();++i) { | 220 | for (unsigned i = 0; i < list.count();++i) { |
217 | addFile(_dir+QString("/")+list[i]); | 221 | addFile(_dir+QString("/")+list[i]); |
218 | } | 222 | } |
219 | emit contentChanged(childCount()); | 223 | emit contentChanged(childCount()); |
220 | } | 224 | } |
221 | 225 | ||
222 | void PlaylistView::slotOpenM3u() | 226 | void PlaylistView::slotOpenM3u() |
223 | { | 227 | { |
224 | QStringList types; | 228 | QStringList types; |
225 | QMap<QString, QStringList> mimeTypes; | 229 | QMap<QString, QStringList> mimeTypes; |
226 | types << "audio/x-mpegurl"; | 230 | types << "audio/x-mpegurl"; |
227 | mimeTypes.insert("Playlists",types); | 231 | mimeTypes.insert("Playlists",types); |
228 | // mimeTypes.insert("All",types); | 232 | // mimeTypes.insert("All",types); |
229 | QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, | 233 | QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED, |
230 | m_lastDir,"playlist.m3u", mimeTypes); | 234 | m_lastDir,"playlist.m3u", mimeTypes); |
231 | if (fileName.isEmpty()) { | 235 | if (fileName.isEmpty()) { |
232 | return; | 236 | return; |
233 | } | 237 | } |
234 | readPlayList(fileName); | 238 | readPlayList(fileName); |
235 | emit contentChanged(childCount()); | 239 | emit contentChanged(childCount()); |
236 | } | 240 | } |
237 | 241 | ||
238 | void PlaylistView::readPlayList(const QString&fileName) | 242 | void PlaylistView::readPlayList(const QString&fileName) |
239 | { | 243 | { |
240 | QFileInfo f(fileName); | 244 | QFileInfo f(fileName); |
241 | 245 | ||
242 | Om3u _om3u(fileName, IO_ReadOnly); | 246 | Om3u _om3u(fileName, IO_ReadOnly); |
243 | if (f.extension(FALSE).lower()=="m3u") { | 247 | if (f.extension(FALSE).lower()=="m3u") { |
244 | _om3u.readM3u(); | 248 | _om3u.readM3u(); |
245 | } else if (f.extension(FALSE).lower()=="pls") { | 249 | } else if (f.extension(FALSE).lower()=="pls") { |
246 | _om3u.readPls(); | 250 | _om3u.readPls(); |
247 | } | 251 | } |
248 | for (unsigned int j=0; j<_om3u.count();++j) { | 252 | for (unsigned int j=0; j<_om3u.count();++j) { |
249 | addFile(_om3u[j]); | 253 | addFile(_om3u[j]); |
250 | } | 254 | } |
251 | } | 255 | } |
252 | 256 | ||
253 | void PlaylistView::slotSaveAsM3u() | 257 | void PlaylistView::slotSaveAsM3u() |
254 | { | 258 | { |
255 | QStringList types; | 259 | QStringList types; |
256 | QMap<QString, QStringList> mimeTypes; | 260 | QMap<QString, QStringList> mimeTypes; |
257 | types << "audio/x-mpegurl"; | 261 | types << "audio/x-mpegurl"; |
258 | mimeTypes.insert("Playlists",types); | 262 | mimeTypes.insert("Playlists",types); |
259 | QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED, | 263 | QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED, |
260 | m_lastDir,"playlist.m3u", mimeTypes); | 264 | m_lastDir,"playlist.m3u", mimeTypes); |
261 | odebug << "Save as " << fileName << oendl; | 265 | odebug << "Save as " << fileName << oendl; |
262 | if (fileName.isEmpty()) { | 266 | if (fileName.isEmpty()) { |