1 /* dvbcut
2 Copyright (c) 2005 Sven Over <svenover@svenover.de>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 /* $Id$ */
20
21 #include <qlabel.h>
22 #include <QCoreApplication>
23 #include <QHBoxLayout>
24 #include "eventlistitem.h"
25 #include "settings.h"
26
EventListItem(QListWidget * listbox,const QPixmap & pixmap,eventtype type,int picture,int picturetype,pts_t _pts)27 EventListItem::EventListItem( QListWidget *listbox, const QPixmap &pixmap,
28 eventtype type, int picture, int picturetype, pts_t _pts ) :
29 QListWidgetItem("", listbox), evtype(type), pic(picture), pictype(picturetype), pts(_pts)
30 {
31 QWidget *w = new QWidget();
32
33 QLabel *label_pic = new QLabel(w);
34 label_pic->setPixmap(pixmap.scaledToHeight(80, Qt::SmoothTransformation));
35
36 label_text = new QLabel(getstring(), w);
37
38 QHBoxLayout *hbox = new QHBoxLayout();
39 hbox->addWidget(label_pic);
40 hbox->addWidget(label_text);
41 w->setLayout(hbox);
42
43 listbox->setItemWidget(this, w);
44
45 setSizeHint(label_pic->size());
46 }
47
~EventListItem()48 EventListItem::~EventListItem()
49 {}
50
getstring() const51 QString EventListItem::getstring() const
52 {
53 QString label;
54 if (evtype==start)
55 label = QString("<font size=\"+1\" color=\"darkgreen\"><b>%1</b></font>")
56 //: Text shown on start markers in the main window marker list
57 .arg(QCoreApplication::translate("eventlist", "START"));
58 else if (evtype==stop)
59 label = QString("<font size=\"+1\" color=\"darkred\"><b>%1</b></font>")
60 //: Text shown on stop markers in the main window marker list
61 .arg(QCoreApplication::translate("eventlist", "STOP"));
62 else if (evtype==chapter)
63 label = QString("<font color=\"darkgoldenrod\">%1</font>")
64 //: Text shown on chapter markers in the main window marker list
65 .arg(QCoreApplication::translate("eventlist", "CHAPTER"));
66 else if (evtype==bookmark)
67 label = QString("<font color=\"darkblue\">%1</font>")
68 //: Text shown on bookmark markers in the main window marker list
69 .arg(QCoreApplication::translate("eventlist", "BOOKMARK"));
70
71 return label + QString().sprintf("<br>%02d:%02d:%02d.%03d<br>%d (%c)",
72 int(pts/(3600*90000)),
73 int(pts/(60*90000))%60,
74 int(pts/90000)%60,
75 int(pts/90)%1000,
76 pic,
77 ((const char *)".IPB....")[pictype&7]);
78 }
79
operator <(const QListWidgetItem & other) const80 /*virtual*/ bool EventListItem::operator<(const QListWidgetItem &other) const
81 {
82 const EventListItem *item = dynamic_cast<const EventListItem *>(&other);
83 if (!item)
84 return false;
85
86 if (pic != item->pic)
87 return pic < item->pic;
88 else
89 return evtype < item->evtype;
90 }
91