1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: comboQuant.cpp,v 1.1.1.1 2003/10/27 18:54:52 wschweer Exp $
// (C) Copyright 2001 Werner Schweer (ws@seh.de)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2 of
// the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=========================================================
#include <stdio.h>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QHeaderView>
#include "comboQuant.h"
namespace MusEGui {
static int quantTable[] = {
1, 16, 32, 64, 128, 256, 512, 1024,
1, 24, 48, 96, 192, 384, 768, 1536,
1, 36, 72, 144, 288, 576, 1152, 2304
};
static const char* quantStrings[] = {
QT_TRANSLATE_NOOP("MusEGui::ComboQuant", "Off"), "64T", "32T", "16T", "8T", "4T", "2T", "1T",
QT_TRANSLATE_NOOP("MusEGui::ComboQuant", "Off"), "64", "32", "16", "8", "4", "2", "1",
QT_TRANSLATE_NOOP("MusEGui::ComboQuant", "Off"), "64.", "32.", "16.", "8.", "4.", "2.", "1."
};
//---------------------------------------------------------
// ComboQuant
//---------------------------------------------------------
ComboQuant::ComboQuant(QWidget* parent)
: QComboBox(parent)
{
///Q3ListBox* qlist = new Q3ListBox(this);
///qlist->setMinimumWidth(95);
//setListBox(qlist); ddskrjo
///qlist->setColumnMode(3);
qlist = new QTableWidget(8, 3);
qlist->verticalHeader()->setDefaultSectionSize(22);
qlist->horizontalHeader()->setDefaultSectionSize(32);
qlist->setSelectionMode(QAbstractItemView::SingleSelection);
qlist->verticalHeader()->hide();
qlist->horizontalHeader()->hide();
qlist->setMinimumWidth(96);
setView(qlist);
///for (int i = 0; i < 24; i++)
/// qlist->insertItem(tr(quantStrings[i]), i);
for (int j = 0; j < 3; j++)
for (int i = 0; i < 8; i++)
qlist->setItem(i, j, new QTableWidgetItem(tr(quantStrings[i + j * 8])));
connect(this, SIGNAL(activated(int)), SLOT(activated(int)));
}
//---------------------------------------------------------
// activated
//---------------------------------------------------------
void ComboQuant::activated(int /*index*/)
{
///emit valueChanged(quantTable[index]);
emit valueChanged(quantTable[qlist->currentRow() + qlist->currentColumn() * 8]);
}
//---------------------------------------------------------
// setQuant
//---------------------------------------------------------
void ComboQuant::setValue(int val)
{
for (int i = 0; i < 24; i++) {
if (val == quantTable[i]) {
setCurrentIndex(i);
return;
}
}
for (unsigned i = 0; i < sizeof(quantTable)/sizeof(*quantTable); i++) {
if (val == quantTable[i]) {
setCurrentIndex(i);
return;
}
}
printf("ComboQuant::setValue(%d) not defined\n", val);
setCurrentIndex(0);
}
} // namespace MusEGui
|