author | alwin <alwin> | 2005-04-10 22:18:50 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-04-10 22:18:50 (UTC) |
commit | 840e44417402bbc6048ca5e8ff3dd6be966e753f (patch) (unidiff) | |
tree | 61ca099945cff3c995ddf348149cd2690ee17c97 /noncore/multimedia/opieplayer3/playlist.cpp | |
parent | ad2f1bd57cbfb0fdaf4d348ee3a70d3ea370d5d1 (diff) | |
download | opie-840e44417402bbc6048ca5e8ff3dd6be966e753f.zip opie-840e44417402bbc6048ca5e8ff3dd6be966e753f.tar.gz opie-840e44417402bbc6048ca5e8ff3dd6be966e753f.tar.bz2 |
added opieplayer3
this moment not just more than another container around xine like opieplayer2
(and uses a lot of code direct from there)
difference: first it was a testcontainer to find the bugs in player2
now it is a player looks more like kino2 (eg, no stylesheets) so it
has a real resizeable video-display. early stage (saving playlists and so on
doesn't work) - but it can display videos on my C860 in bigger box than this
small stamp like player2 ;)
Diffstat (limited to 'noncore/multimedia/opieplayer3/playlist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer3/playlist.cpp | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp new file mode 100644 index 0000000..272a71e --- a/dev/null +++ b/noncore/multimedia/opieplayer3/playlist.cpp | |||
@@ -0,0 +1,210 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
33 | #include "playlist.h" | ||
34 | #include "../opieplayer2/lib.h" | ||
35 | |||
36 | #include <opie2/odebug.h> | ||
37 | #include <opie2/oresource.h> | ||
38 | |||
39 | #include <qpe/resource.h> | ||
40 | |||
41 | #include <qfileinfo.h> | ||
42 | |||
43 | PlaylistItem::PlaylistItem(const DocLnk& aLink,PlaylistView*parent) | ||
44 | :QListViewItem(parent),m_Content(aLink),m_video(false) | ||
45 | { | ||
46 | } | ||
47 | |||
48 | PlaylistItem::PlaylistItem(const DocLnk&aLink,PlaylistView*parent,PlaylistItem*after) | ||
49 | :QListViewItem(parent,after),m_Content(aLink),m_video(false) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | void PlaylistItem::Video(bool y) | ||
54 | { | ||
55 | m_video=y; | ||
56 | if (m_video) { | ||
57 | setPixmap(0,Opie::Core::OResource::loadPixmap("opieplayer2/videofile")); | ||
58 | } else { | ||
59 | setPixmap(0,Opie::Core::OResource::loadPixmap("opieplayer2/musicfile")); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | PlaylistItem::~PlaylistItem() | ||
64 | { | ||
65 | } | ||
66 | |||
67 | /* PlaylistView Methods */ | ||
68 | PlaylistView::PlaylistView(QWidget *parent, const char *name) | ||
69 | : QListView(parent,name) | ||
70 | { | ||
71 | // columnLabels << tr("FullName"); | ||
72 | columnLabels << tr(""); // icon | ||
73 | columnLabels << tr("File"); | ||
74 | columnLabels << tr("Playtime"); | ||
75 | columnLabels << tr("Artist"); | ||
76 | columnLabels << tr("Album"); | ||
77 | columnLabels << tr("Title"); | ||
78 | columnLabels << tr("Type"); | ||
79 | columnLabels << tr("Size"); | ||
80 | for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) { | ||
81 | addColumn(*it); | ||
82 | } | ||
83 | m_Infolib=0; | ||
84 | setAllColumnsShowFocus(true); | ||
85 | setSelectionMode(Single); | ||
86 | setSorting(-1); | ||
87 | m_lastItem = 0; | ||
88 | } | ||
89 | |||
90 | PlaylistView::~PlaylistView() | ||
91 | { | ||
92 | if (m_Infolib) delete m_Infolib; | ||
93 | } | ||
94 | |||
95 | void PlaylistView::checkLib() | ||
96 | { | ||
97 | if (!m_Infolib) { | ||
98 | m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately); | ||
99 | m_Infolib->ensureInitialized(); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | void PlaylistView::slotAddFile(const DocLnk&aLink) | ||
104 | { | ||
105 | QFileInfo fileInfo(aLink.file()); | ||
106 | if (!fileInfo.exists()) return; | ||
107 | checkLib(); | ||
108 | |||
109 | m_Infolib->stop(); | ||
110 | |||
111 | if (m_lastItem) { | ||
112 | m_lastItem = new PlaylistItem(aLink,this,m_lastItem); | ||
113 | } else { | ||
114 | m_lastItem = new PlaylistItem(aLink,this); | ||
115 | } | ||
116 | m_lastItem->setExpandable(false); | ||
117 | m_lastItem->setText(1,aLink.name()); | ||
118 | int i = m_Infolib->setfile(aLink.file()); | ||
119 | odebug << "File set: " << i << oendl; | ||
120 | if (i<1) { | ||
121 | return; | ||
122 | } | ||
123 | |||
124 | QString codec = m_Infolib->metaInfo(6); | ||
125 | if (codec.isEmpty()) { | ||
126 | codec = m_Infolib->metaInfo(7); | ||
127 | } | ||
128 | // codec | ||
129 | m_lastItem->setText(COL_TYPE,codec); | ||
130 | // title | ||
131 | m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0)); | ||
132 | // artist | ||
133 | m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2)); | ||
134 | // album | ||
135 | m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4)); | ||
136 | int l = m_Infolib->length(); | ||
137 | int h = l/3600; | ||
138 | l-=h*3600; | ||
139 | int m = l/60; | ||
140 | l-=m*60; | ||
141 | codec = ""; | ||
142 | if (h>0) { | ||
143 | codec+=QString("%1 h").arg(h); | ||
144 | } | ||
145 | if (m>0) { | ||
146 | if (!codec.isEmpty()) codec+=" "; | ||
147 | codec+=QString("%1 m").arg(m); | ||
148 | } | ||
149 | if (l>0) { | ||
150 | if (!codec.isEmpty()) codec+=" "; | ||
151 | codec+=QString("%1 s").arg(l); | ||
152 | } | ||
153 | // time | ||
154 | m_lastItem->setText(COL_TIME,codec); | ||
155 | m_lastItem->Video(m_Infolib->hasVideo()); | ||
156 | m_items.append(m_lastItem); | ||
157 | } | ||
158 | |||
159 | void PlaylistView::removeFromList(PlaylistItem*Item) | ||
160 | { | ||
161 | if (!Item)return; | ||
162 | t_itemlist::Iterator iter; | ||
163 | iter = m_items.find(Item); | ||
164 | if (iter!=m_items.end()) { | ||
165 | m_items.remove(iter); | ||
166 | } | ||
167 | delete Item; | ||
168 | } | ||
169 | |||
170 | XINE::Lib*PlaylistView::getXine() | ||
171 | { | ||
172 | checkLib(); | ||
173 | return m_Infolib; | ||
174 | } | ||
175 | |||
176 | void PlaylistView::setCurrentItem(PlaylistItem*aItem) | ||
177 | { | ||
178 | setSelected(aItem,true); | ||
179 | } | ||
180 | |||
181 | PlaylistItem* PlaylistView::currentItem()const | ||
182 | { | ||
183 | QListViewItem*it = selectedItem(); | ||
184 | if (!it) return 0; | ||
185 | return (PlaylistItem*)it; | ||
186 | } | ||
187 | |||
188 | PlaylistItem* PlaylistView::nextItem(PlaylistItem*parent)const | ||
189 | { | ||
190 | if (m_items.count()==0) return 0; | ||
191 | if (!parent) return m_items[0]; | ||
192 | for (unsigned j=0; j<m_items.count()-1;++j) { | ||
193 | if (m_items[j]==parent) { | ||
194 | return m_items[j+1]; | ||
195 | } | ||
196 | } | ||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | PlaylistItem* PlaylistView::prevItem(PlaylistItem*parent)const | ||
201 | { | ||
202 | if (m_items.count()==0) return 0; | ||
203 | if (!parent) return m_items[m_items.count()-1]; | ||
204 | for (unsigned j=m_items.count()-1; j>0;--j) { | ||
205 | if (m_items[j]==parent) { | ||
206 | return m_items[j-1]; | ||
207 | } | ||
208 | } | ||
209 | return 0; | ||
210 | } | ||