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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/*
* File: DevicesPane.h
*
* Author: Jacob Dekel
* Created on: Aug 7, 2009
*
* Copyright (c) 2009-2013 Jacob Dekel
* $Id$
*
* This object displays the devices pane during hercules run time
*
* 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, either version 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef DEVICESPANE_H
#define DEVICESPANE_H
#include "DeviceTypes.h"
#include "DeviceListView.h"
#include "StatusUpdateCollector.h"
#include "DeviceMenuProcessor.h"
#include <QtWidgets/QWidget>
#include "ui_Devices.h"
#include <QGridLayout>
#include <QScrollArea>
#include <QLabel>
#include <utility>
#include <vector>
#include <map>
typedef std::pair<int,int> TokenPair;
class VisualizedDeviceEntry;
/*
NOTE: look for BEGIN_DEVICE_CLASS_QUERY in hercules source
note: DEVA=0180 3390 DASD 1001 /media/Data/Hercules/zLinux/CentOS-4.7/180.cckd [3339 cyls]
*/
struct DynDeviceLine
{
char DEV[3];
char action;
char eq;
char devNo[4];
char pad1;
char devTypeN[4];
char pad2;
char devType[4];
char pid3;
char statusBytes[4];
};
template <class Key, class T> class dbgmap
{
public:
dbgmap()
{
mMap = new std::map<Key, T>();
}
typedef typename std::map<const Key, T>::iterator iterator ;
typedef typename std::map<Key, T>::const_iterator const_iterator ;
std::pair< iterator, bool > insert(std::pair< const Key, T> t)
{
return mMap->insert(t);
}
void clear()
{
mMap->clear();
}
typename std::map<Key, T>::iterator begin() const
{
return mMap->begin();
}
iterator end() const
{
return mMap->end();
}
iterator find(const Key& k)
{
return mMap->find(k);
}
void erase(iterator p)
{
mMap->erase(p);
}
size_t size()
{
return mMap->size();
}
T& operator[] (const Key& k)
{
return (*mMap)[k];
}
private:
std::map<Key,T> *mMap;
};
class MainWindow;
class DeviceConfigLine;
class DevicesRename;
class DevicesPane : public DeviceMenuProcessor, public StatusUpdateCollector
{
Q_OBJECT
public:
DevicesPane(QWidget *parent = 0);
virtual ~DevicesPane();
virtual bool notify(const QByteArray& statusLine);
void clear();
public slots:
void mousePressed(QModelIndex index);
void menuRename();
void menuDelete();
void doAddDevice(bool);
void updateDevice(bool);
void menuProperties();
void doRename(QString oldDevNum, QString newDevNum);
void menuInterrupt();
void menuStatus();
void menuTraceCCW();
void rejected();
protected:
virtual bool isRealDev(int lineNumber);
virtual bool canAddSYSG();
virtual bool isConfig() { return false; }
virtual bool realDevice();
virtual DeviceTypes::Type getType(int lineNumber);
virtual void doLoadTape(QString& tapeFileName);
virtual bool hasConfig();
virtual bool traced();
private:
Ui::DevicesClass ui;
MainWindow * mMainWindow;
QGridLayout * mLayout;
QScrollArea * mScrollArea;
DeviceListView * mListView;
std::vector<TokenPair> mTokens;
std::map<int, VisualizedDeviceEntry> mDevices;
QStandardItemModel * mModel;
DevicesRename * mRenameDlg;
int mOldDevNum;
QSize sizeHint() const;
void clearDevices(QWidget * parent);
void resizeEvent ( QResizeEvent * event );
void adjustSize();
VisualizedDeviceEntry * getDeviceEntry();
QString textFromValue(int value) const;
int getNextDev(std::map<int, VisualizedDeviceEntry>::iterator it) const;
QIcon * mYellowIcon;
QIcon * mYellowHighIcon;
signals:
void restartDevices();
};
#endif // DEVICES_H
|