TransmitterSwitchInfo.cpp 5.0 KB

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