1 /**************************************************************************
3 channelview.cpp - The ChannelView dialog
4 Copyright (C) 1998 Antonio Larrosa Jimenez
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 Send comments and bug fixes to larrosa@kde.org
21 or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
23 ***************************************************************************/
25 #include <kapplication.h>
28 #include "channelview.h"
29 #include "channel3d.h"
30 #include "channel4d.h"
33 #include <QResizeEvent>
34 #include <QCloseEvent>
37 ChannelView::ChannelView(void) : KXmlGuiWindow(0)
39 setObjectName("ChannelView");
40 setCaption(i18n("Channel View"));
41 for (int i
=0;i
<16;i
++)
44 Channel
[i
]=new KMidChannel3D(i
+1,this);
46 Channel
[i
]=new KMidChannel4D(i
+1,this);
47 connect(Channel
[i
],SIGNAL(signalToKMidClient(int *)),this,SLOT(slottokmidclient(int *)));
48 Channel
[i
]->setGeometry(5,5+i
*CHANNELHEIGHT
,width()-20,CHANNELHEIGHT
);
51 scrollbar
= new QScrollBar(Qt::Vertical
, this);
52 scrollbar
->setMinimum(1);
53 scrollbar
->setMaximum(16);
54 scrollbar
->setSingleStep(1);
55 scrollbar
->setPageStep(1);
56 scrollbar
->setValue(1);
57 scrollbar
->setObjectName("Channelscrollbar");
58 connect(scrollbar
,SIGNAL(valueChanged(int)),this,SLOT(ScrollChn(int)));
62 ChannelView::~ChannelView()
67 void ChannelView::closeEvent(QCloseEvent
*e
)
73 void ChannelView::resizeEvent(QResizeEvent
*)
75 scrollbar
->setGeometry(width()-16,0,16,height());
76 for (int i
=0;i
<16;i
++)
78 Channel
[i
]->setGeometry(5,5+(i
-(scrollbar
->value()-1))*CHANNELHEIGHT
,width()-20,CHANNELHEIGHT
);
84 void ChannelView::setScrollBarRange(void)
86 nvisiblechannels
=height()/CHANNELHEIGHT
;
87 if (nvisiblechannels
<16)
88 scrollbar
->setRange(1,16-nvisiblechannels
+1);
90 scrollbar
->setRange(1,1);
93 void ChannelView::ScrollChn(int v
)
95 for (int i
=0;i
<16;i
++)
97 Channel
[i
]->move(5,5+(i
-(v
-1))*CHANNELHEIGHT
);
101 void ChannelView::noteOn(int chn
,int note
)
103 Channel
[chn
]->noteOn(note
);
106 void ChannelView::noteOff(int chn
,int note
)
108 Channel
[chn
]->noteOff(note
);
111 void ChannelView::changeInstrument(int chn
,int pgm
)
113 Channel
[chn
]->changeInstrument(pgm
);
116 void ChannelView::changeForceState(int chn
,bool i
)
118 Channel
[chn
]->changeForceState(i
);
122 void ChannelView::reset(int level
)
124 for (int i
=0;i
<16;i
++)
126 Channel
[i
]->reset(level
);
130 int ChannelView::lookmode
=0;
132 int ChannelView::lookMode(void)
134 KConfig
*kcfg
=(KApplication::kApplication())->sessionConfig();
136 KConfigGroup kmidGroup
= kcfg
->group("KMid");
137 lookmode
= kmidGroup
.readEntry("ChannelViewLookMode", 0);
142 void ChannelView::lookMode(int i
)
144 KConfig
*kcfg
=(KApplication::kApplication())->sessionConfig();
148 KConfigGroup kmidGroup
= kcfg
->group("KMid");
149 kmidGroup
.writeEntry("ChannelViewLookMode", lookmode
);
153 for (int i
=0;i
<16;i
++)
155 Channel
[i
]->saveState(tmp
,&pgm
);
159 Channel
[i
]=new KMidChannel3D(i
+1,this);
161 Channel
[i
]=new KMidChannel4D(i
+1,this);
163 connect(Channel
[i
],SIGNAL(signalToKMidClient(int *)),this,SLOT(slottokmidclient(int *)));
164 Channel
[i
]->setGeometry(5,5+(i
-(scrollbar
->value()-1))*CHANNELHEIGHT
,width()-20,CHANNELHEIGHT
);
165 Channel
[i
]->loadState(tmp
,&pgm
);
171 void ChannelView::slottokmidclient(int *data
)
173 emit
signalToKMidClient(data
);
175 #include "channelview.moc"