Debian Codegraph @

HercConfiguration/DevicesWidget.cpp

raw symbols SCIP
1 /*
2 * File: DevicesWidget.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 "DevicesWidget.h"cxx . . $ `<file>/HercConfiguration/DevicesWidget.h`/
26 #include "Configuration.h"cxx . . $ `<file>/HercConfiguration/Configuration.h`/
27 #include "DeviceConfigLine.h"cxx . . $ `<file>/HercConfiguration/DeviceConfigLine.h`/
28 #include "GenericDeviceProperties.h"cxx . . $ `<file>/HercConfiguration/GenericDeviceProperties.h`/
29 #include "Environment.h"cxx . . $ `<file>/HercStudio/Environment.h`/
30
31 #include <QMouseEvent>
32 #include <QMessageBox>
33 #include <QHeaderView>
34
35 #include <iostream>
36 #include <sstream>
37
38 DevicesWidgetcxx . . $ DevicesWidget#::DevicesWidgetcxx . . $ DevicesWidget#DevicesWidget(5aa5159e220541f7).(ConfigFilecxx . . $ ConfigFile# * configFile, QWidgetcxx . . $ QWidget# * parent) :
39 DeviceMenuProcessorcxx . . $ DeviceMenuProcessor#(parent) , mConfigFilecxx . . $ DevicesWidget#mConfigFile.(configFile), mConfigViewcxx . . $ DevicesWidget#mConfigView.()
40 {
41 mConfigViewcxx . . $ DevicesWidget#mConfigView. = new DeviceConfigViewcxx . . $ DeviceConfigView#(this);
42 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setAutoScrollcxx . . $ QAbstractItemView#setAutoScroll(b45ddcbc8423892c).(false);
43 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setGeometrycxx . . $ QWidget#setGeometry(748afa4755bc9595).(0,0, 680,420);
44 mConfigViewcxx . . $ DevicesWidget#mConfigView.->horizontalHeadercxx . . $ QTableView#horizontalHeader(f0c0fe1a435d30ff).()->setDefaultAlignmentcxx . . $ QHeaderView#setDefaultAlignment(9d0000d583057bbf).(Qtcxx . . $ QFlags#QFlags(9b289cee16747614).::AlignLeftcxx . . $ Qt/AlignLeft.);
45
46 QStringcxx . . $ QString# iconPathcxx . . $ QString#QString(e1217c004a86c950). = Environmentcxx . . $ QString#QString(85c52e162fed56f9).::getIconsPathcxx . . $ Environment#getIconsPath(75da78375bc7a3dd).().c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).();
47 mCardIconcxx . . $ DevicesWidget#mCardIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/card.jpg");
48 mConsoleIconcxx . . $ DevicesWidget#mConsoleIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/card.jpg");
49 mDasdIconcxx . . $ DevicesWidget#mDasdIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/dasd.jpg");
50 mNetIconcxx . . $ DevicesWidget#mNetIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/net.jpg");
51 mPrinterIconcxx . . $ DevicesWidget#mPrinterIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/printer.jpg");
52 mTapeIconcxx . . $ DevicesWidget#mTapeIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/tape.jpg");
53 mTerminalIconcxx . . $ DevicesWidget#mTerminalIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/terminal.jpg");
54 mUnknownIconcxx . . $ DevicesWidget#mUnknownIcon. = new QIconcxx . . $ QIcon#QIcon(3520e46b33348bf6).(iconPath +cxx . . $ operator+(3d22f08efddf8107). "/unknown.jpg");
55
56 initializecxx . . $ DevicesWidget#initialize(49f6e7a06ebc5aa8).();
57 QPushButtoncxx . . $ QPushButton# * okButton = new QPushButtoncxx . . $ QPushButton#(this);
58 okButton->setTextcxx . . $ QAbstractButton#setText(3520e46b33348bf6).("OK"cxx . . $ QString#QString(85c52e162fed56f9).);
59 okButton->movecxx . . $ QWidget#move(3e454b8ccf442868).(10,630);
60
61 QPushButtoncxx . . $ QPushButton# * cancelButton = new QPushButtoncxx . . $ QPushButton#(this);
62 cancelButton->setTextcxx . . $ QAbstractButton#setText(3520e46b33348bf6).("Cancel"cxx . . $ QString#QString(85c52e162fed56f9).);
63 cancelButton->movecxx . . $ QWidget#move(3e454b8ccf442868).(710,630);
64
65 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setVisiblecxx . . $ QWidget#setVisible(b45ddcbc8423892c).(true);
66 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mConfigViewcxx . . $ DevicesWidget#mConfigView., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(pressed(QModelIndex)),this,SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(mousePressed(QModelIndex)));
67 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mConfigViewcxx . . $ DevicesWidget#mConfigView., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(deviceClick(QMouseEvent *)),this,SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(devicesClick(QMouseEvent *)));
68 }
69
70 DevicesWidgetcxx . . $ DevicesWidget#::~cxx . . $ DevicesWidget#`~DevicesWidget`(49f6e7a06ebc5aa8).DevicesWidgetcxx . . $ DevicesWidget#()
71 {
72 }
73
74 void DevicesWidgetcxx . . $ DevicesWidget#::updatecxx . . $ DevicesWidget#update(5afcb95a9687fc35).(ConfigFilecxx . . $ ConfigFile# *configFile)
75 {
76 mConfigFilecxx . . $ DevicesWidget#mConfigFile. = configFile;
77 initializecxx . . $ DevicesWidget#initialize(49f6e7a06ebc5aa8).();
78 }
79
80 void DevicesWidgetcxx . . $ DevicesWidget#::mousePressedcxx . . $ DevicesWidget#mousePressed(58b98458fece0954).(const QModelIndexcxx . . $ QModelIndex# index)
81 {
82 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(3, "widget mouse pressed " << index.row())
83 mClickRowcxx . . $ DeviceMenuProcessor#mClickRow. = index.rowcxx . . $ QModelIndex#row(455f465bc33b4cdf).();
84 }
85
86 bool DevicesWidgetcxx . . $ DevicesWidget#::realDevicecxx . . $ DevicesWidget#realDevice(c9857a73d68e59ba).()
87 {
88 return (mClickRowcxx . . $ DeviceMenuProcessor#mClickRow. >=0 && isRealDevcxx . . $ DevicesWidget#isRealDev(83c267b20bac841a).(mClickRowcxx . . $ DeviceMenuProcessor#mClickRow.));
89 }
90
91 bool DevicesWidgetcxx . . $ DevicesWidget#::canAddSYSGcxx . . $ DevicesWidget#canAddSYSG(c9857a73d68e59ba).()
92 {
93 return (mConfigFilecxx . . $ DevicesWidget#mConfigFile.->findFirstDeviceByTypecxx . . $ ConfigFile#findFirstDeviceByType(a405516eca06dda3).("SYSG") == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
94 }
95
96 DeviceTypescxx . . $ DeviceTypes#::Typecxx . . $ DeviceTypes#Type# DevicesWidgetcxx . . $ DevicesWidget#::getTypecxx . . $ DevicesWidget#getType(cc50a7541878da72).(int lineNumber)
97 {
98 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(3, "getType " << lineNumber << " " << mLastClick << std::endl);
99 DeviceConfigLinecxx . . $ DeviceConfigLine# * line = mConfigFilecxx . . $ DevicesWidget#mConfigFile.->getDevicecxx . . $ ConfigFile#getDevice(449b59f7b7ccf910).(mDialogToFilecxx . . $ DevicesWidget#mDialogToFile.[cxx . . $ std/map#`operator[]`(bbd415b616967878).lineNumber]);
100 return line->getDeviceTypecxx . . $ DeviceConfigLine#getDeviceType(2700e08780fa2d6b).();
101 }
102
103 void DevicesWidgetcxx . . $ DevicesWidget#::menuDeletecxx . . $ DevicesWidget#menuDelete(49f6e7a06ebc5aa8).()
104 {
105 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(5, "delete " << mLastClick);
106 mConfigFilecxx . . $ DevicesWidget#mConfigFile.->deleteLinecxx . . $ ConfigFile#deleteLine(d4f767463ce0a6b3).(mDialogToFilecxx . . $ DevicesWidget#mDialogToFile.[cxx . . $ std/map#`operator[]`(bbd415b616967878).mLastClickcxx . . $ DeviceMenuProcessor#mLastClick.]);
107 initializecxx . . $ DevicesWidget#initialize(49f6e7a06ebc5aa8).();
108 }
109
110 void DevicesWidgetcxx . . $ DevicesWidget#::menuPropertiescxx . . $ DevicesWidget#menuProperties(49f6e7a06ebc5aa8).()
111 {
112 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(3, "properties " << mLastClick);
113 mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine. = mConfigFilecxx . . $ DevicesWidget#mConfigFile.->getDevicecxx . . $ ConfigFile#getDevice(449b59f7b7ccf910).(mDialogToFilecxx . . $ DevicesWidget#mDialogToFile.[cxx . . $ std/map#`operator[]`(bbd415b616967878).mLastClickcxx . . $ DeviceMenuProcessor#mLastClick.]);
114 mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine.->setNewcxx . . $ ConfigLine#setNew(b45ddcbc8423892c).(false);
115 GenericDevicePropertiescxx . . $ GenericDeviceProperties# * mProp = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
116
117 try
118 {
119 mProp = GenericDevicePropertiescxx . . $ GenericDeviceProperties#::classFactorycxx . . $ GenericDeviceProperties#classFactory(a94d470fa14a4f70).(*mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine., this);
120 }
121 catch (hsExceptioncxx . . $ hsException# e)
122 {
123 stdcxx . . $ std/::stringcxx . . $ std/string# msgcxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f). = ecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)..whatcxx . . $ hsException#what(a9f41ea0e82d88cf).();
124 QMessageBoxcxx . . $ QMessageBox#::criticalcxx . . $ QMessageBox#critical(a9e3742e6f7b4147).(this, "Invalid Device Line"cxx . . $ QString#QString(85c52e162fed56f9)., msgcxx . . $ QString#QString(85c52e162fed56f9)..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).() , QMessageBoxcxx . . $ QFlags#QFlags(9b289cee16747614).::Okcxx . . $ QMessageBox#Ok.);
125 }
126 catch (...)
127 {
128 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(2, "exception caught in class factory (properties) ");
129 }
130
131 if (mProp != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
132 {
133 connectcxx . . $ QObject#connect(158df1d9a01a3410).(mProp, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(updateLine(bool)), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(updateDevice(bool)));
134 mProp->setVisiblecxx . . $ QDialog#setVisible(b45ddcbc8423892c).(true);
135 }
136 }
137
138 void DevicesWidgetcxx . . $ DevicesWidget#::doAddDevicecxx . . $ DevicesWidget#doAddDevice(b45ddcbc8423892c).(bool keep)
139 {
140 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(5,"Update Line ");
141
142 stdcxx . . $ std/::stringstreamcxx . . $ std/stringstream# newLinecxx . . $ std/__cxx11/basic_stringstream#basic_stringstream(49f6e7a06ebc5aa8).;
143 newLine <<cxx . . $ std/`operator<<`(88df5bef833f7f83). ConfigurationEditorcxx . . $ ConfigurationEditor#::normalizeNumcxx . . $ ConfigurationEditor#normalizeNum(5b54a3efe1460b8a).(mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine.->getTokencxx . . $ ConfigLine#getToken(ffc0d510d034206b).(0),4,16);
144 newLine <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine.->getMultiTokencxx . . $ ConfigLine#getMultiToken(8a983bf2cc533e5e).(1,0) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n";
145 mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine.->replaceLinecxx . . $ ConfigLine#replaceLine(9c546c94e5fcce4e).(newLine.strcxx . . $ std/__cxx11/basic_stringstream#str(d33e1a6fd36255f7).());
146
147 if (mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
148 {
149 if (keep && mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine.->isNewcxx . . $ ConfigLine#isNew(50ce9a9e25b4a850).())
150 mConfigFilecxx . . $ DevicesWidget#mConfigFile.->addDevcxx . . $ ConfigFile#addDev(7f38ef9bc46b32f0).(mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine.);
151 mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
152 }
153 initializecxx . . $ DevicesWidget#initialize(49f6e7a06ebc5aa8).();
154 }
155
156 bool DevicesWidgetcxx . . $ DevicesWidget#::isUniquecxx . . $ DevicesWidget#isUnique(c9120223c4466434).(stdcxx . . $ std/::stringcxx . . $ std/string# devno)
157 {
158 return (mConfigFilecxx . . $ DevicesWidget#mConfigFile.->getDevicecxx . . $ ConfigFile#getDevice(73336e9f92c2174d).(devno) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
159 }
160
161 void DevicesWidgetcxx . . $ DevicesWidget#::initializecxx . . $ DevicesWidget#initialize(49f6e7a06ebc5aa8).()
162 {
163 int lastSys = mConfigFilecxx . . $ DevicesWidget#mConfigFile.->getLastSyscxx . . $ ConfigFile#getLastSys(b126dc7c1de90089).();
164 QStandardItemModelcxx . . $ QStandardItemModel# * model = new QStandardItemModelcxx . . $ QStandardItemModel#QStandardItemModel(ea15c0ea3584af89).(0,1);
165 model->clearcxx . . $ QStandardItemModel#clear(49f6e7a06ebc5aa8).();
166 QStringListcxx . . $ QStringList# labels = (QStringListcxx . . $ QStringList#QStringList(49f6e7a06ebc5aa8).() <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "Device"cxx . . $ QString#QString(85c52e162fed56f9).);
167 model->setHorizontalHeaderLabelscxx . . $ QStandardItemModel#setHorizontalHeaderLabels(631c0101495f0328).(labels);
168 QStandardItemcxx . . $ QStandardItem# *parentItem = model->invisibleRootItemcxx . . $ QStandardItemModel#invisibleRootItem(c0cc2a7c3bad46fb).();
169 mDialogToFilecxx . . $ DevicesWidget#mDialogToFile..clearcxx . . $ std/map#clear(49f6e7a06ebc5aa8).();
170
171 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(5, "DeviceDlg::initilize from " <<lastSys+1 << " to " << mConfigFile->size());
172 int lineNum=-1;
173 for (int i=lastSys+1; i<mConfigFilecxx . . $ DevicesWidget#mConfigFile.->sizecxx . . $ ConfigFile#size(455f465bc33b4cdf).(); i++)
174 {
175 const DeviceConfigLinecxx . . $ DeviceConfigLine# * line = mConfigFilecxx . . $ DevicesWidget#mConfigFile.->getDevicecxx . . $ ConfigFile#getDevice(449b59f7b7ccf910).(i);
176 hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(5,"line=" << line->getLine() << line->isRemark());
177 if (line->isRemarkcxx . . $ ConfigLine#isRemark(50ce9a9e25b4a850).()) continue;
178
179 stdcxx . . $ std/::stringcxx . . $ std/string# strLine = linecxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).->getTokencxx . . $ ConfigLine#getToken(ffc0d510d034206b).(0);
180 strLine.resizecxx . . $ std/__cxx11/basic_string#resize(cc73ddaffac1a975).(10,' ');
181 strLine +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). line->getTokencxx . . $ ConfigLine#getToken(ffc0d510d034206b).(1).c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).();
182 strLine.resizecxx . . $ std/__cxx11/basic_string#resize(cc73ddaffac1a975).(20,' ');
183 strLine +=cxx . . $ std/__cxx11/basic_string#`operator+=`(978ca1133b5f6e74). line->getMultiTokencxx . . $ ConfigLine#getMultiToken(8a983bf2cc533e5e).(2,0).c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).();
184 strLine.resizecxx . . $ std/__cxx11/basic_string#resize(cc73ddaffac1a975).(133,' ');
185 QStandardItemcxx . . $ QStandardItem# * item = new QStandardItemcxx . . $ QStandardItem#(strLinecxx . . $ QString#QString(85c52e162fed56f9)..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).());
186 item->setIconcxx . . $ QStandardItem#setIcon(71dcdac178620ed6).(DeviceTypescxx . . $ DeviceTypes#::instancecxx . . $ DeviceTypes#instance(c065a99473e12f8e).().getIconcxx . . $ DeviceTypes#getIcon(bb7825627a920bdb).(line->getDeviceTypecxx . . $ DeviceConfigLine#getDeviceType(2700e08780fa2d6b).()));
187
188 parentItem->appendRowcxx . . $ QStandardItem#appendRow(317b3a1fa3b6b2ce).(item);
189 ++lineNum;
190 mDialogToFilecxx . . $ DevicesWidget#mDialogToFile.[cxx . . $ std/map#`operator[]`(bbd415b616967878).lineNum] = i;
191 }
192 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setModelcxx . . $ QTableView#setModel(c6e1f1e42522b780).(model);
193 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setColumnWidthcxx . . $ QTableView#setColumnWidth(3e454b8ccf442868).(0,800);
194 QFontcxx . . $ QFont# fontcxx . . $ QFont#QFont(7ae16150a604556).("Mono"cxx . . $ QString#QString(85c52e162fed56f9)., 10);
195 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setFontcxx . . $ QWidget#setFont(d0a4bd0c8524b912).(font);
196 for (int i=0; i<model->rowCountcxx . . $ QStandardItemModel#rowCount(e3878d4d6cd9529c).(); i++)
197 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setRowHeightcxx . . $ QTableView#setRowHeight(3e454b8ccf442868).(i,18);
198 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setGridStylecxx . . $ QTableView#setGridStyle(de7d79e7246fa26d).(Qtcxx . . $ Qt/::NoPencxx . . $ Qt/NoPen.);
199 mConfigViewcxx . . $ DevicesWidget#mConfigView.->setEditTriggerscxx . . $ QAbstractItemView#setEditTriggers(cbe1d262190fb0b).(QAbstractItemViewcxx . . $ QFlags#QFlags(9b289cee16747614).::NoEditTriggerscxx . . $ QAbstractItemView#NoEditTriggers.);
200 }
201
202 void DevicesWidgetcxx . . $ DevicesWidget#::updateDevicecxx . . $ DevicesWidget#updateDevice(b45ddcbc8423892c).(bool done)
203 {
204 if (!done || mCandidateLinecxx . . $ DeviceMenuProcessor#mCandidateLine. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!)
205 {
206 mClickRowcxx . . $ DeviceMenuProcessor#mClickRow. = -1;
207 return;
208 }
209 initializecxx . . $ DevicesWidget#initialize(49f6e7a06ebc5aa8).();
210 mClickRowcxx . . $ DeviceMenuProcessor#mClickRow. = -1;
211 }
212