TransmitterSwitchInfo.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #include "TransmitterSwitchInfo.h"
  2. // #include "lhstylemanager.h"
  3. #include <QFile>
  4. ExecPlanItemInfo::ExecPlanItemInfo()
  5. {
  6. ExecType = -1;
  7. WeekDay = 0;
  8. // num = -1;
  9. date = QDate::fromString("1970-01-01","yyyy-MM-dd");
  10. execTime = QTime::fromString("00:00:00","hh:mm:ss");
  11. devName = "未定义";
  12. actionID = 0;
  13. actionName = "未定义";
  14. }
  15. ExecPlanItemInfo::ExecPlanItemInfo(const ExecPlanItemInfo& item)
  16. {
  17. ExecType = item.ExecType;
  18. WeekDay = item.WeekDay;
  19. date = item.date;
  20. execTime = item.execTime;
  21. actionID = item.actionID;
  22. devName = item.devName;
  23. actionName = item.actionName;
  24. }
  25. ExecPlanItemInfo& ExecPlanItemInfo::operator=(const ExecPlanItemInfo& item)
  26. {
  27. if(this == &item)
  28. return *this;
  29. ExecType = item.ExecType;
  30. WeekDay = item.WeekDay;
  31. // num = item.num;
  32. date = item.date;
  33. execTime = item.execTime;
  34. devName = item.devName;
  35. actionID = item.actionID;
  36. actionName = item.actionName;
  37. // dateType = item.dateType;
  38. // cfgDev = item.cfgDev;
  39. return *this;
  40. }
  41. DevTypeInfo::DevTypeInfo()
  42. {
  43. devTypeName = "";
  44. devAction.clear();
  45. devType_MB.clear();
  46. PTTypeCode = -1;
  47. }
  48. DevTypeInfo& DevTypeInfo::operator=(const DevTypeInfo& devInfo)
  49. {
  50. devTypeName = devInfo.devTypeName;
  51. devAction = devInfo.devAction;
  52. devType_MB = devInfo.devType_MB;
  53. PTTypeCode = devInfo.PTTypeCode;
  54. return *this;
  55. }
  56. MapDevType::MapDevType()
  57. {
  58. initDevType();
  59. }
  60. /* 添加支持的设备类型 */
  61. void MapDevType::initDevType()
  62. {
  63. /* 955发射机 */
  64. DevTypeInfo devInfo;
  65. devInfo.devTypeName = "衢州台发射机";
  66. devInfo.PTTypeCode = 955;
  67. devInfo.devAction[1] = "开机";
  68. devInfo.devAction[2] = "关机";
  69. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Main,"主");
  70. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Backup,"备");
  71. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Contingency,"应急");
  72. m_mapDevType.insert(955, devInfo);
  73. /* 其他发射机 */
  74. }
  75. /* 获取某一个发射机类型 */
  76. DevTypeInfo MapDevType::getDevType(int PTTypeCode)
  77. {
  78. if(m_mapDevType.contains(PTTypeCode))
  79. {
  80. return m_mapDevType[PTTypeCode];
  81. }
  82. return DevTypeInfo();
  83. }
  84. DeviceInfo::DeviceInfo()
  85. {
  86. devName = "未定义";
  87. PTTypeCode = -1;
  88. DevType = DevTypeInfo();
  89. DTID = 0;
  90. DID = 0;
  91. ChannelID = 0;
  92. }
  93. DeviceInfo::DeviceInfo(const DeviceInfo& devInfo)
  94. {
  95. devName = devInfo.devName;
  96. PTTypeCode = devInfo.PTTypeCode;
  97. DevType = devInfo.DevType;
  98. DTID = devInfo.DTID;
  99. DID = devInfo.DID;
  100. ChannelID = devInfo.ChannelID;
  101. }
  102. DeviceInfo& DeviceInfo::operator=(const DeviceInfo& devInfo)
  103. {
  104. devName = devInfo.devName;
  105. PTTypeCode = devInfo.PTTypeCode;
  106. DevType = devInfo.DevType;
  107. DTID = devInfo.DTID;
  108. DID = devInfo.DID;
  109. ChannelID = devInfo.ChannelID;
  110. return *this;
  111. }
  112. MapDevice::MapDevice()
  113. {
  114. }
  115. /* 添加一个设备 */
  116. void MapDevice::addDevice(const DeviceInfo& devInfo)
  117. {
  118. /* 先查重 */
  119. if(m_mapDevice.contains(devInfo.devName))
  120. {
  121. return;
  122. }
  123. m_mapDevice.insert(devInfo.devName, devInfo);
  124. }
  125. /* 获取一个设备 */
  126. DeviceInfo MapDevice::getDevice(const QString& devName)
  127. {
  128. if(m_mapDevice.contains(devName))
  129. {
  130. return m_mapDevice[devName];
  131. }
  132. return DeviceInfo();
  133. }
  134. /* 查找一个设备 */
  135. bool MapDevice::findDevice(const QString& devName)
  136. {
  137. return m_mapDevice.contains(devName);
  138. }
  139. /* 根据设备名称获取设备动作 */
  140. bool MapDevice::getDevAction(const QString& devName, QMap<int, QString>& devAction)
  141. {
  142. if(m_mapDevice.contains(devName))
  143. {
  144. devAction = m_mapDevice[devName].DevType.devAction;
  145. return true;
  146. }
  147. return false;
  148. }
  149. /* 删除一个设备 */
  150. void MapDevice::deleteDevice(const QString& devName)
  151. {
  152. if(m_mapDevice.contains(devName))
  153. {
  154. m_mapDevice.remove(devName);
  155. }
  156. }
  157. ExecPlanGlobalConfig::ExecPlanGlobalConfig()
  158. {
  159. m_qssPath = ":/QSS/QSS";
  160. }
  161. /* 设置样式表路径 */
  162. // void ExecPlanGlobalConfig::setQSSPath(const QString& qssPath)
  163. // {
  164. // m_qssPath = qssPath;
  165. // }
  166. /* 获取样式表路径 */
  167. QString ExecPlanGlobalConfig::getQSSPath()
  168. {
  169. if(m_UIStyle == enum_UIStyle::UI_Light)
  170. {
  171. return m_qssPath + m_lightQSS;
  172. }
  173. else if(m_UIStyle == enum_UIStyle::UI_Dark)
  174. {
  175. return m_qssPath + m_darkQSS;
  176. }
  177. return QString();
  178. }
  179. /* 换肤,修改样式表 */
  180. void ExecPlanGlobalConfig::setUIStyle(enum_UIStyle style)
  181. {
  182. m_UIStyle = style;
  183. /* 打开文件OneItem的样式表,发送特殊换肤信号 */
  184. QFile file;
  185. QString qssOneItem = getQSSPath() + "/oneitem.qss";
  186. file.setFileName(qssOneItem);
  187. if(file.open(QIODevice::ReadOnly))
  188. {
  189. QString qss = file.readAll();
  190. file.close();
  191. emit signal_oneItemQssChanged(qss);
  192. }
  193. /* 发送普通换肤信号信号 */
  194. emit signal_qssChanged();
  195. }