TransmitterSwitchInfo.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. ChannelID = devInfo.ChannelID;
  102. }
  103. DeviceInfo& DeviceInfo::operator=(const DeviceInfo& devInfo)
  104. {
  105. devName = devInfo.devName;
  106. PTTypeCode = devInfo.PTTypeCode;
  107. DevType = devInfo.DevType;
  108. DTID = devInfo.DTID;
  109. DID = devInfo.DID;
  110. ChannelID = devInfo.ChannelID;
  111. return *this;
  112. }
  113. MapDevice::MapDevice()
  114. {
  115. }
  116. /* 添加一个设备 */
  117. void MapDevice::addDevice(const DeviceInfo& devInfo)
  118. {
  119. /* 先查重 */
  120. if(m_mapDevice.contains(devInfo.devName))
  121. {
  122. return;
  123. }
  124. m_mapDevice.insert(devInfo.devName, devInfo);
  125. }
  126. /* 获取一个设备 */
  127. DeviceInfo MapDevice::getDevice(const QString& devName)
  128. {
  129. if(m_mapDevice.contains(devName))
  130. {
  131. return m_mapDevice[devName];
  132. }
  133. return DeviceInfo();
  134. }
  135. /* 查找一个设备 */
  136. bool MapDevice::findDevice(const QString& devName)
  137. {
  138. return m_mapDevice.contains(devName);
  139. }
  140. /* 根据设备名称获取设备动作 */
  141. bool MapDevice::getDevAction(const QString& devName, QMap<int, QString>& devAction)
  142. {
  143. if(m_mapDevice.contains(devName))
  144. {
  145. devAction = m_mapDevice[devName].DevType.devAction;
  146. return true;
  147. }
  148. return false;
  149. }
  150. /* 删除一个设备 */
  151. void MapDevice::deleteDevice(const QString& devName)
  152. {
  153. if(m_mapDevice.contains(devName))
  154. {
  155. m_mapDevice.remove(devName);
  156. }
  157. }
  158. ExecPlanGlobalConfig::ExecPlanGlobalConfig()
  159. {
  160. m_qssPath = ":/QSS/QSS";
  161. }
  162. /* 设置样式表路径 */
  163. // void ExecPlanGlobalConfig::setQSSPath(const QString& qssPath)
  164. // {
  165. // m_qssPath = qssPath;
  166. // }
  167. /* 获取样式表路径 */
  168. QString ExecPlanGlobalConfig::getQSSPath()
  169. {
  170. if(m_UIStyle == enum_UIStyle::UI_Light)
  171. {
  172. return m_qssPath + m_lightQSS;
  173. }
  174. else if(m_UIStyle == enum_UIStyle::UI_Dark)
  175. {
  176. return m_qssPath + m_darkQSS;
  177. }
  178. return QString();
  179. }
  180. /* 换肤,修改样式表 */
  181. void ExecPlanGlobalConfig::setUIStyle(enum_UIStyle style)
  182. {
  183. m_UIStyle = style;
  184. /* 打开文件OneItem的样式表,发送特殊换肤信号 */
  185. QFile file;
  186. QString qssOneItem = getQSSPath() + "/oneitem.qss";
  187. file.setFileName(qssOneItem);
  188. if(file.open(QIODevice::ReadOnly))
  189. {
  190. QString qss = file.readAll();
  191. file.close();
  192. emit signal_oneItemQssChanged(qss);
  193. }
  194. /* 发送普通换肤信号信号 */
  195. emit signal_qssChanged();
  196. /* 处理事件,让UI接收到换肤信号 */
  197. QEventLoop loop;
  198. loop.processEvents();
  199. }