Debian Codegraph @

HercStudio/MainPanel.cpp

raw symbols SCIP
1 /*
2 * File: MainPanel.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 7, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25 #include "HerculesStudio.h"
26 #include "MainPanel.h"
27 #include "MainPanelClassic.h"
28 #include "Preferences.h"
29 #include "Environment.h"
30 #include "ConfigurationEditor.h"
31
32 #include <QResizeEvent>
33 #include <QColor>
34 #include <iostream>
35
36 MainPanel::MainPanel(QWidget *parent)
37 :QWidget(parent),
38 mMipsHWM(0)
39 {
40 QString iconsPath = Environment::getIconsPath().c_str();
41 mYellowLow = new QPixmap(iconsPath + "/yellow.png");
42 mYellowHigh = new QPixmap(iconsPath + "/yellowhigh.png");
43 }
44
45 MainPanel::~MainPanel()
46 {
47 }
48
49 void MainPanel::doConnect()
50 {
51 connect(powerOnButton(), SIGNAL(clicked()), this , SLOT(powerOnClickedSlot()));
52 connect(powerOffButton(), SIGNAL(clicked()), this , SLOT(powerOffClickedSlot()));
53 connect(interruptButton(), SIGNAL(clicked()), this , SLOT(interruptClickedSlot()));
54 connect(loadButton(), SIGNAL(clicked()), this , SLOT(loadClickedSlot()));
55 connect(stopButton(), SIGNAL(clicked()), this , SLOT(stopClickedSlot()));
56
57 checkedConnect(mRestartButton,restartClickedSlot());
58 checkedConnect(mStoreButton,storeClickedSlot());
59 checkedConnect(mStartButton,startClickedSlot());
60 }
61
62 void MainPanel::powerOnClickedSlot()
63 {
64 emit powerOnClicked();
65 }
66 void MainPanel::powerOffClickedSlot()
67 {
68 emit powerOffClicked();
69 }
70
71 void MainPanel::loadClickedSlot()
72 {
73 emit loadClicked();
74 }
75
76 void MainPanel::restartClickedSlot()
77 {
78 emit restartClicked();
79 }
80
81 void MainPanel::storeClickedSlot()
82 {
83 emit storeClicked();
84 }
85
86 void MainPanel::startClickedSlot()
87 {
88 mStopped=false;
89 emit startClicked();
90 }
91
92 void MainPanel::stopClickedSlot()
93 {
94 mStopped=true;
95 emit stopClicked();
96 }
97
98 void MainPanel::interruptClickedSlot()
99 {
100 emit interruptClicked();
101 }
102
103
104
105 ClickLabel::ClickLabel(MainPanel * parent, QObject * lcd)
106 : QLabel(parent), mPanel(parent), mLcd(lcd)
107 {
108 }
109
110 void ClickLabel::mousePressEvent(QMouseEvent * event)
111 {
112 mPanel->updateLcd((QLCDNumber*)(mLcd), event->x() > 30 ? 1 : -1);
113 Preferences::getInstance().setIplDevice( std::string(QByteArray::number(mPanel->getLoadAddress(),16).data()) );
114 }
115
116 int MainPanel::getLoadAddress()
117 {
118 return mLcd0->intValue() + 16*mLcd1->intValue() +
119 (16*16)*mLcd2->intValue() + (16*16*16)*mLcd3->intValue();
120 }
121
122 void MainPanel::setLoadAddress(const char *devNo)
123 {
124 int addr = ConfigurationEditor::parseNum(devNo,16);
125 QLCDNumber *nums[4] = {mLcd0, mLcd1, mLcd2, mLcd3};
126 for (int i=0; i< 4; i++)
127 {
128 int dig = addr%16;
129 addr /= 16;
130 nums[i]->display(dig);
131 }
132 Preferences::getInstance().setIplDevice( std::string(QByteArray::number(getLoadAddress(),16).data()) );
133 }
134