source: smplayer/trunk/src/findsubtitles/subchooserdialog.cpp@ 142

Last change on this file since 142 was 142, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to 0.8.5

  • Property svn:eol-style set to LF
File size: 3.0 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
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
20#include "subchooserdialog.h"
21
22static Qt::CheckState CurItemCheckState = Qt::Unchecked;
23
24SubChooserDialog::SubChooserDialog(QWidget * parent, Qt::WindowFlags f)
25 : QDialog(parent, f )
26{
27 setupUi(this);
28
29 listWidget->setSelectionMode(QAbstractItemView::NoSelection);
30
31 connect(selectAll, SIGNAL(clicked(bool)), this, SLOT(selectAllClicked(bool)));
32 connect(selectNone, SIGNAL(clicked(bool)), this, SLOT(selectNoneClicked(bool)));
33 connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(listItemClicked(QListWidgetItem*)));
34 connect(listWidget, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(listItemPressed(QListWidgetItem*)));
35}
36
37SubChooserDialog::~SubChooserDialog()
38{
39
40}
41
42void SubChooserDialog::selectAllClicked(bool) {
43 for (int k = 0; k < listWidget->count(); k++)
44 listWidget->item(k)->setCheckState(Qt::Checked);
45
46 listWidget->setFocus();
47}
48
49void SubChooserDialog::selectNoneClicked(bool) {
50 for (int k = 0; k < listWidget->count(); k++)
51 listWidget->item(k)->setCheckState(Qt::Unchecked);
52
53 listWidget->setFocus();
54}
55
56void SubChooserDialog::listItemClicked(QListWidgetItem* item) {
57 if (item->checkState() == CurItemCheckState)
58 {
59 //Clicked on the list item (not checkbox)
60 if (item->checkState() == Qt::Checked)
61 {
62 item->setCheckState(Qt::Unchecked);
63 }
64 else
65 item->setCheckState(Qt::Checked);
66 }
67
68 //else - clicked on the checkbox itself, do nothing
69}
70
71void SubChooserDialog::listItemPressed(QListWidgetItem* item) {
72 CurItemCheckState = item->checkState();
73}
74
75void SubChooserDialog::addFile(QString filename) {
76 QListWidgetItem* item = new QListWidgetItem(listWidget);
77 item->setText(filename);
78 item->setCheckState(Qt::Unchecked);
79}
80
81QStringList SubChooserDialog::selectedFiles() {
82 QStringList files;
83
84 for (int n = 0; n < listWidget->count(); n++) {
85 QListWidgetItem * i = listWidget->item(n);
86 if (i && i->checkState() == Qt::Checked) {
87 files.append(i->text());
88 }
89 }
90
91 return files;
92}
93
94void SubChooserDialog::retranslateStrings() {
95 retranslateUi(this);
96}
97
98// Language change stuff
99void SubChooserDialog::changeEvent(QEvent *e) {
100 if (e->type() == QEvent::LanguageChange) {
101 retranslateStrings();
102 } else {
103 QDialog::changeEvent(e);
104 }
105}
106
107#include "moc_subchooserdialog.cpp"
108
Note: See TracBrowser for help on using the repository browser.