1 /*
2 * Cantata
3 *
4 * Copyright (c) 2011-2020 Craig Drummond <craig.p.drummond@gmail.com>
5 *
6 * ----
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24 #include "tagspinbox.h"
25 #include <QPainter>
26 #include <QLineEdit>
27
28 static QString variousText;
29
variousStr()30 QString TagSpinBox::variousStr() { return variousText; }
31
TagSpinBox(QWidget * parent)32 TagSpinBox::TagSpinBox(QWidget *parent)
33 : EmptySpinBox(parent)
34 , isVarious(false)
35 {
36 if (variousText.isEmpty()) {
37 variousText=tr("(Various)");
38 }
39 }
40
sizeHint() const41 QSize TagSpinBox::sizeHint() const
42 {
43 TagSpinBox *that=const_cast<TagSpinBox *>(this);
44 that->setSpecialValueText(variousText);
45 QSize sz=EmptySpinBox::sizeHint();
46 that->setSpecialValueText(QString());
47 return sz;
48 }
49
setVarious(bool v)50 void TagSpinBox::setVarious(bool v)
51 {
52 if (v==isVarious) {
53 return;
54 }
55 isVarious=v;
56 lineEdit()->setPlaceholderText(isVarious ? variousText : QString());
57 }
58
59 #include "moc_tagspinbox.cpp"
60