mainwindow.cpp 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  1. #include "mainwindow.h"
  2. #include "custommodel.h"
  3. #include "ui_mainwindow.h"
  4. #include "listview_ad.h"
  5. #include "listview_delgate.h"
  6. #include <QStandardItemModel>
  7. #include"../sample_button_slide/CustomButton.h"
  8. #include"../test_drag/mylistwidget.h"
  9. #include <QDir>
  10. #include <QFile>
  11. #include <QTextStream>
  12. #include <iostream>
  13. #include <QMimeData>
  14. #include <QToolTip>
  15. using namespace std;
  16. MainWindow::MainWindow(QWidget *parent)
  17. : QMainWindow(parent)
  18. , ui(new Ui::MainWindow)
  19. {
  20. ui->setupUi(this);
  21. //add_slide;
  22. QWidget *slide_2= ui->slide_2; // 获取ceshi_2_slide控件指针
  23. customB2 = new CustomButton(this); // 创建自定义控件实例
  24. connect(customB2, &CustomButton::click, this, &MainWindow::onWidgetClicked);
  25. // 将自定义控件添加到ceshi_2_slide控件中
  26. QHBoxLayout *layout2 = new QHBoxLayout(slide_2);
  27. layout2->setContentsMargins(0, 0, 0, 0);
  28. layout2->addWidget(customB2);
  29. layout2->setSpacing(0);
  30. //add_slide;
  31. QWidget *slide_3= ui->slide_3; // 获取ceshi_2_slide控件指针
  32. customB3 = new CustomButton(this); // 创建自定义控件实例
  33. connect(customB3, &CustomButton::click, this, &MainWindow::onWidgetClicked);
  34. // 将自定义控件添加到ceshi_2_slide控件中
  35. QHBoxLayout *layout3 = new QHBoxLayout(slide_3);
  36. layout3->setContentsMargins(0, 0, 0, 0);
  37. layout3->addWidget(customB3);
  38. layout3->setSpacing(0);
  39. //add_slide;
  40. QWidget *slide_4= ui->slide_4; // 获取ceshi_2_slide控件指针
  41. customB4 = new CustomButton(this); // 创建自定义控件实例
  42. connect(customB4, &CustomButton::click, this, &MainWindow::onWidgetClicked);
  43. // 将自定义控件添加到ceshi_2_slide控件中
  44. QHBoxLayout *layout4 = new QHBoxLayout(slide_4);
  45. layout4->setContentsMargins(0, 0, 0, 0);
  46. layout4->addWidget(customB4);
  47. layout4->setSpacing(0);
  48. //初始化右侧u
  49. // MyListWidget* my1=new MyListWidget();
  50. // QVBoxLayout *layout5 = new QVBoxLayout();
  51. // layout5->addWidget(my1);
  52. // ui->test_frame->setLayout(layout5);
  53. // connect(my1, &MyListWidget::operationCompleted, this, &MainWindow::handleOperationCompleted);
  54. my1=new MyListWidget();
  55. my1->setObjectName("listWidget");
  56. QVBoxLayout *layout5 = new QVBoxLayout();
  57. layout5->addWidget(my1);
  58. ui->frame->setLayout(layout5);
  59. qDebug()<<"widget_group"<<ui->widget_group1;
  60. connect(my1, &MyListWidget::operationCompleted, this, &MainWindow::handleOperationCompleted);
  61. connect(my1, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_listWidget_customContextMenuRequested(QPoint)));
  62. my2=new MyListWidget();
  63. my2->setObjectName("listWidget_2");
  64. QVBoxLayout *layout6 = new QVBoxLayout();
  65. layout6->addWidget(my2);
  66. ui->frame_4->setLayout(layout6);
  67. connect(my2, &MyListWidget::operationCompleted, this, &MainWindow::handleOperationCompleted);
  68. connect(my2, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_listWidget_2_customContextMenuRequested(QPoint)));
  69. my3=new MyListWidget();
  70. my3->setObjectName("listWidget_3");
  71. QVBoxLayout *layout7 = new QVBoxLayout();
  72. layout7->addWidget(my3);
  73. ui->frame_5->setLayout(layout7);
  74. connect(my3, &MyListWidget::operationCompleted, this, &MainWindow::handleOperationCompleted);
  75. connect(my3, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_listWidget_3_customContextMenuRequested(QPoint)));
  76. my4=new MyListWidget();
  77. my4->setObjectName("listWidget_4");
  78. QVBoxLayout *layout8 = new QVBoxLayout();
  79. layout8->addWidget(my4);
  80. ui->frame_6->setLayout(layout8);
  81. connect(my4, &MyListWidget::operationCompleted, this, &MainWindow::handleOperationCompleted);
  82. connect(my4, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_listWidget_4_customContextMenuRequested(QPoint)));
  83. QString folder = "/users/lal/documents/RedInterstitialData/HotUpdate2";
  84. root_pro_path=folder;
  85. qDebug()<<folder;
  86. QStringList qs=tool::getFilesInFolder(folder);//获取项目名称列表
  87. qDebug()<<qs;
  88. //初始化comboBox
  89. initComboBox(qs);
  90. QString currentPro = ui->comboBox->currentText();
  91. //初始化TreeView
  92. QString jsonPath = folder+"/"+currentPro+"/"+"Hotupdate.json";
  93. qDebug()<<jsonPath;
  94. QJO=tool::readJsonFile(jsonPath);
  95. // 从JSON对象中提取数据
  96. QJA = QJO.value("children").toArray();
  97. ////////////////////////////////////////////////
  98. ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
  99. connect(ui->treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotTreeMenu(QPoint)));
  100. //初始化treeview 和 combobox
  101. QTreeView *treeView=ui->treeView;
  102. QStandardItemModel* model=new QStandardItemModel(treeView);
  103. model->setHorizontalHeaderLabels(QStringList()<<QStringLiteral("名称"));
  104. treeView->setModel(model);
  105. initTreeView(model->invisibleRootItem(),QJA);
  106. qDebug()<<"QJA"<<QJA;
  107. QStandardItemModel *tree_model = qobject_cast<QStandardItemModel*>(ui->treeView->model());
  108. connect(tree_model, &QStandardItemModel::dataChanged, this, &MainWindow::onDataChanged);
  109. bool connected = connect(&_sender, &Dialog::_mySignal, this, &MainWindow::handleSignal);
  110. if(!connected) {
  111. // Handle the error
  112. qDebug()<<"connect failed";
  113. }
  114. //初始化右边
  115. // initRight(QString parentNode,QString childNode);
  116. }
  117. void QTreeView::mousePressEvent(QMouseEvent *event)
  118. {
  119. QModelIndex index = indexAt(event->pos());
  120. if (index.isValid() && index.parent().isValid())
  121. {
  122. // 这是一个二级列表项,你可以在这里处理点击事件
  123. // 例如,获取二级列表项的数据并进行相应的操作
  124. QVariant data = index.data(Qt::DisplayRole);
  125. qDebug() << "Clicked on subitem:" << data.toString();
  126. }
  127. else
  128. {
  129. qDebug() << "Clicked on subitem false";
  130. QTreeView::mousePressEvent(event);
  131. }
  132. }
  133. MainWindow::~MainWindow()
  134. {
  135. delete ui;
  136. }
  137. void MainWindow::readFile(const QString& filePath)//设置打开该窗体时检查路径并加载
  138. {
  139. // 获取文件所在路径
  140. QString dirPath = QFileInfo(filePath).absolutePath();
  141. qDebug() << dirPath;
  142. // 创建路径
  143. QDir dir;
  144. if (!dir.mkpath(dirPath))
  145. {
  146. qDebug() << "无法创建路径:" << dirPath;
  147. return;
  148. }
  149. // 创建文件
  150. QFile file(filePath);
  151. if (!file.open(QIODevice::ReadWrite | QIODevice::Text))
  152. {
  153. qDebug() << "无法创建文件:" << file.errorString();
  154. return;
  155. }
  156. // 使用QTextStream读取文件内容
  157. QTextStream in(&file);
  158. while (!in.atEnd())
  159. {
  160. QString line = in.readLine();
  161. // 处理每一行的内容
  162. // TODO: 添加您的逻辑
  163. qDebug() << line;
  164. }
  165. // 关闭文件
  166. file.close();
  167. }
  168. void MainWindow::on_pushButton_clicked()
  169. {
  170. dialog=new Dialog(this);
  171. dialog->setModal(false);
  172. dialog->show();
  173. }
  174. void MainWindow::on_pushButton_2_clicked()
  175. {
  176. dialog=new Dialog(this);
  177. dialog->setModal(false);
  178. dialog->show();
  179. }
  180. QJsonObject MainWindow::readJsonFile(const QString& filePath)
  181. {
  182. // 打开JSON文件
  183. QFile file(filePath);
  184. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
  185. {
  186. qDebug() << "无法打开文件:" << file.errorString();
  187. return QJsonObject();
  188. }
  189. // 读取文件内容
  190. QByteArray jsonData = file.readAll();
  191. file.close();
  192. // 解析JSON数据
  193. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
  194. if (!jsonDoc.isObject())
  195. {
  196. qDebug() << "无效的JSON文件";
  197. return QJsonObject();;
  198. }
  199. // 获取JSON对象
  200. QJsonObject jsonObj = jsonDoc.object();
  201. return jsonObj;
  202. // 处理其他字段...
  203. }
  204. //初始化treeview 和combobox控件
  205. void MainWindow::initTreeView(QStandardItem* parentItem,const QJsonArray& jsonArray) {
  206. QStringList pro_list;
  207. for (QJsonArray::const_iterator it = jsonArray.constBegin(); it != jsonArray.constEnd(); ++it) {
  208. QJsonValue jsonValue = *it;
  209. qDebug()<<jsonValue;
  210. // 处理每个元素,可以根据需要进行类型检查和值提取
  211. if (jsonValue.isString()) {
  212. QString fileName = jsonValue.toString();
  213. QStandardItem* item = new QStandardItem(fileName);
  214. // if(!fileName.endsWith("json"))
  215. // parentItem->appendRow(item);
  216. // 处理字符串值 s
  217. } else if (jsonValue.isDouble()) {
  218. double doubleValue = jsonValue.toDouble();
  219. // 处理双精度浮点数值
  220. } else if (jsonValue.isObject()) {
  221. QJsonObject objectValue = jsonValue.toObject();
  222. QString name = objectValue["name"].toString();
  223. QStandardItem* item = new QStandardItem(name);
  224. parentItem->appendRow(item);
  225. QJsonArray childrenArray = objectValue["children"].toArray();
  226. pro_list.append(name);
  227. // 处理对象值
  228. initTreeView(item, childrenArray);
  229. }
  230. }
  231. ui->treeView->clearSelection();
  232. ui->treeView->setCurrentIndex(QModelIndex());
  233. }
  234. void MainWindow::slotTreeMenu(const QPoint &pos)
  235. {
  236. // QModelIndex curItem = ui->treeView->indexAt( pos );
  237. // QModelIndex index = curItem.sibling(curItem.row(),0);
  238. // if( !index.isValid() )
  239. // return;
  240. // QMenu *popMenu = new QMenu( this );
  241. // QAction *deleteSeed = new QAction(tr("Delete"), this);
  242. // QString qss = "QMenu{color:#E8E8E8;background:#4D4D4D;margin:2px;}\
  243. // QMenu::item{padding:3px 20px 3px 20px;}\
  244. // QMenu::indicator{width:13px;height:13px;}\
  245. // QMenu::item:selected{color:#E8E8E8;border:0px solid #575757;background:#1E90FF;}\
  246. // QMenu::separator{height:1px;background:#757575;}";
  247. // popMenu->setStyleSheet(qss);
  248. // popMenu->addAction( deleteSeed );
  249. // connect( deleteSeed, SIGNAL(triggered() ), this, SLOT( slotTreeMenuDelete()) );
  250. // popMenu->exec( QCursor::pos() );
  251. // delete popMenu;
  252. }
  253. //删除设定为假删除,在窗体退出的时候才更新json文件,并执行删除操作
  254. /////////到这里
  255. /// ///
  256. /// ////
  257. /// ///
  258. /// //
  259. /// //
  260. /// /
  261. ///
  262. /// //
  263. void MainWindow::slotTreeMenuDelete()
  264. {
  265. // QModelIndex curIndex = ui->treeView->currentIndex();
  266. // QModelIndex index = curIndex.sibling(curIndex.row(),0); //同一行第一列元素的index
  267. // qDebug()<<curIndex;
  268. // qDebug()<<index;
  269. // QStandardItemModel* model = dynamic_cast<QStandardItemModel*>(ui->treeView->model());
  270. // model->removeRow(index.row(), index.parent());
  271. }
  272. void MainWindow::initComboBox(QStringList qs){
  273. ui->comboBox->clear();
  274. ui->comboBox->addItems(qs);
  275. }
  276. void MainWindow::initRight(QString parentNode,QString childNode){
  277. //
  278. QString folder = "/users/lal/documents/RedInterstitialData/HotUpdate2";
  279. QString currentPro = ui->comboBox->currentText();
  280. config_json_path=folder+"/"+currentPro+"/"+parentNode+"/"+childNode+"/config.json";
  281. treeview_path=folder+"/"+currentPro+"/"+parentNode+"/"+childNode;
  282. qDebug()<<config_json_path;
  283. qDebug()<<treeview_path;
  284. RQJA=tool::getJsanArra(config_json_path);
  285. for (int i = 0; i < RQJA.size(); ++i) {
  286. QJsonValueRef value = RQJA[i];
  287. QJsonObject jsonObject = value.toObject();
  288. QJsonValue jsonArrayValue = jsonObject.value("children");
  289. QJsonValue Used=jsonObject.value("selected");
  290. QString used=Used.toString();
  291. QJsonArray jsonArray = jsonArrayValue.toArray();
  292. qDebug()<<jsonArray.size();
  293. CustomButton* temb=nullptr;
  294. QListWidget* rightLw;
  295. if(i==0)
  296. {
  297. rightLw=my1;
  298. }
  299. else if(i==1)
  300. {
  301. temb=customB2;
  302. rightLw=my2;
  303. }
  304. else if(i==2)
  305. {
  306. temb=customB3;
  307. rightLw=my3;
  308. }
  309. else{
  310. temb=customB4;
  311. rightLw=my4;
  312. }
  313. if(used=="1"&&temb)
  314. {
  315. if(temb->dir==Qt::AlignLeft){
  316. temb->pos_right_button();
  317. }
  318. }
  319. if(used=="0"&&temb)
  320. {
  321. if(temb->dir==Qt::AlignRight){
  322. temb->pos_left_button();
  323. }
  324. }
  325. initRightListwidget(rightLw,jsonArray);
  326. }
  327. }
  328. void MainWindow::on_treeView_clicked(const QModelIndex &index)
  329. {
  330. // 获取第一级节点的信息
  331. if(index.parent().isValid())
  332. {
  333. QModelIndex parentIndex = index.parent();
  334. QString parentData = parentIndex.data().toString();
  335. qDebug() << "First-level Node: " << parentData;
  336. // 获取第二级节点的信息
  337. QString childData = index.data().toString();
  338. qDebug() << "Second-level Node: " << childData;
  339. initRight(parentData,childData);
  340. }
  341. }
  342. void MainWindow::initRightListwidget(QListWidget* qw,const QJsonArray& qja)
  343. {
  344. QStringList dataList;
  345. for (const QJsonValue& value : qja) {
  346. if (value.isString()) {
  347. QString stringValue = value.toString();
  348. dataList.append(stringValue);
  349. }
  350. }
  351. qDebug()<<"initRightListwidget";
  352. qDebug()<<"dataList"<<dataList;
  353. qDebug()<<"qw"<<qw;
  354. qw->clear();
  355. qw->addItems(dataList);
  356. }
  357. /////////////////////////////////////////////////////////////////////////////////////////////右侧右击事件
  358. void MainWindow::on_listWidget_customContextMenuRequested(const QPoint &pos)
  359. {
  360. qDebug()<<"1111111";
  361. QListWidgetItem* curItem = my1->itemAt( pos );
  362. if( curItem == NULL )
  363. return;
  364. QMenu *popMenu = new QMenu( this );
  365. QAction *deleteSeed = new QAction(tr("Delete"), this);
  366. QString qss = "QMenu{color:#E8E8E8;background:#4D4D4D;margin:2px;}\
  367. QMenu::item{padding:3px 20px 3px 20px;}\
  368. QMenu::indicator{width:13px;height:13px;}\
  369. QMenu::item:selected{color:#E8E8E8;border:0px solid #575757;background:#1E90FF;}\
  370. QMenu::separator{height:1px;background:#757575;}";
  371. popMenu->setStyleSheet(qss);
  372. popMenu->addAction( deleteSeed );
  373. this->qlw=my1;
  374. connect( deleteSeed, SIGNAL(triggered() ), this, SLOT( deleteSeedSlot()) );
  375. popMenu->exec( QCursor::pos() );
  376. delete popMenu;
  377. delete deleteSeed;
  378. }
  379. void MainWindow::on_listWidget_2_customContextMenuRequested(const QPoint &pos)
  380. {
  381. QListWidgetItem* curItem = my2->itemAt( pos );
  382. if( curItem == NULL )
  383. return;
  384. QMenu *popMenu = new QMenu( this );
  385. QAction *deleteSeed = new QAction(tr("Delete"), this);
  386. popMenu->addAction( deleteSeed );
  387. this->qlw=my2;
  388. connect( deleteSeed, SIGNAL(triggered() ), this, SLOT( deleteSeedSlot()));
  389. popMenu->exec( QCursor::pos() );
  390. delete popMenu;
  391. delete deleteSeed;
  392. }
  393. /////daozheer 可以删除项 还没有修改json文件
  394. void MainWindow::deleteSeedSlot()
  395. {
  396. qDebug()<<"deleteSeedSlot";
  397. QListWidgetItem * item = this->qlw->currentItem();
  398. qDebug()<<this->qlw;
  399. if( item == NULL )
  400. return;
  401. int curIndex = this->qlw->row(item);
  402. qDebug()<<curIndex;
  403. auto curItem=this->qlw->takeItem(curIndex);
  404. qDebug()<<curItem->text();
  405. // updateConfig(ui->listWidget);//更新对应的config.json文件
  406. QString deal_file_path;
  407. QString group_name;
  408. int group_index;
  409. if(qlw->objectName()=="listWidget")
  410. {
  411. group_name="group1";
  412. group_index=0;
  413. }
  414. else if(qlw->objectName()=="listWidget_2")
  415. {
  416. group_name="group2";
  417. group_index=1;
  418. }
  419. else if(qlw->objectName()=="listWidget_3")
  420. {
  421. group_name="group3";
  422. group_index=2;
  423. }
  424. else
  425. {
  426. group_name="group4";
  427. group_index=3;
  428. }
  429. deal_file_path=treeview_path+"/"+group_name+"/"+curItem->text();
  430. QFile file(deal_file_path);
  431. file.remove();
  432. QJsonObject groupObject = RQJA[group_index].toObject();
  433. QJsonArray childrenArray = groupObject["children"].toArray();
  434. childrenArray.removeAt(curIndex);
  435. groupObject["children"] = childrenArray;
  436. RQJA[group_index] = groupObject;
  437. writeBackToConfigJson();
  438. delete item;
  439. }
  440. void MainWindow::on_listWidget_3_customContextMenuRequested(const QPoint &pos)
  441. {
  442. QListWidgetItem* curItem = my3->itemAt( pos );
  443. if( curItem == NULL )
  444. return;
  445. QMenu *popMenu = new QMenu( this );
  446. QAction *deleteSeed = new QAction(tr("Delete"), this);
  447. popMenu->addAction( deleteSeed );
  448. this->qlw=my3;
  449. connect( deleteSeed, SIGNAL(triggered() ), this, SLOT( deleteSeedSlot()) );
  450. popMenu->exec( QCursor::pos() );
  451. delete popMenu;
  452. delete deleteSeed;
  453. }
  454. void MainWindow::on_listWidget_4_customContextMenuRequested(const QPoint &pos)
  455. {
  456. QListWidgetItem* curItem = my4->itemAt( pos );
  457. if( curItem == NULL )
  458. return;
  459. QMenu *popMenu = new QMenu( this );
  460. QAction *deleteSeed = new QAction(tr("Delete"), this);
  461. popMenu->addAction( deleteSeed );
  462. this->qlw=my4;
  463. connect( deleteSeed, SIGNAL(triggered() ), this, SLOT( deleteSeedSlot()) );
  464. popMenu->exec( QCursor::pos() );
  465. delete popMenu;
  466. delete deleteSeed;
  467. }
  468. /////////////////////////////////////////////////////////////////////////////////////////////右侧右击事件
  469. //滑块点击slot函数
  470. void MainWindow::onWidgetClicked()
  471. {
  472. QObject *senderObj = sender(); // 获取发出信号的对象指针
  473. if(RQJA.empty())return;
  474. if (senderObj)
  475. {
  476. QWidget *clickedWidget = qobject_cast<QWidget*>(senderObj); // 将指针转换为QWidget指针
  477. if (clickedWidget)
  478. {
  479. QString widgetName = clickedWidget->parentWidget()->objectName(); // 获取控件的对象名称
  480. if(widgetName=="slide_2")
  481. {
  482. if(customB2->dir==Qt::AlignLeft)
  483. {
  484. //变为1
  485. QJsonValueRef selectedValueRef = RQJA[1].toObject()["selected"];
  486. selectedValueRef = "1";
  487. qDebug()<<RQJA;
  488. }
  489. else{
  490. //变为0
  491. QJsonValueRef selectedValueRef = RQJA[1].toObject()["selected"];
  492. selectedValueRef = "0";
  493. qDebug()<<RQJA;
  494. }
  495. }
  496. else if(widgetName=="slide_3")
  497. {
  498. if(customB3->dir==Qt::AlignLeft)
  499. {
  500. //变为1
  501. QJsonValueRef selectedValueRef = RQJA[2].toObject()["selected"];
  502. selectedValueRef = "1";
  503. qDebug()<<RQJA;
  504. }
  505. else{
  506. //变为0
  507. QJsonValueRef selectedValueRef = RQJA[2].toObject()["selected"];
  508. selectedValueRef = "0";
  509. qDebug()<<RQJA;
  510. }
  511. }
  512. else
  513. {
  514. if(customB4->dir==Qt::AlignLeft)
  515. {
  516. //变为1
  517. QJsonValueRef selectedValueRef = RQJA[3].toObject()["selected"];
  518. selectedValueRef = "1";
  519. qDebug()<<RQJA;
  520. }
  521. else{
  522. //变为0
  523. QJsonValueRef selectedValueRef = RQJA[3].toObject()["selected"];
  524. selectedValueRef = "0";
  525. qDebug()<<RQJA;
  526. }
  527. }
  528. writeBackToConfigJson();
  529. }
  530. }
  531. }
  532. //修改config文件
  533. void MainWindow::writeBackToConfigJson(){
  534. if(!config_json_path.endsWith("json"))return;
  535. qDebug()<<config_json_path;
  536. QFile jsonFile(config_json_path);
  537. if (jsonFile.open(QIODevice::WriteOnly)) {
  538. QJsonDocument jsonDoc(RQJA);
  539. QByteArray jsonData = jsonDoc.toJson();
  540. qint64 bytesWritten = jsonFile.write(jsonData);
  541. if (bytesWritten == -1) {
  542. qDebug() << "Failed to write data to file.";
  543. } else {
  544. qDebug() << "Data written to file successfully.";
  545. }
  546. jsonFile.close();
  547. } else {
  548. qDebug() << "Failed to open file for writing.";
  549. }
  550. }
  551. //重新选择项目进行初始化
  552. void MainWindow::on_comboBox_currentTextChanged(const QString &arg1)
  553. {
  554. clearRight();
  555. QString folder = "/users/lal/documents/RedInterstitialData/HotUpdate2";
  556. QString currentPro = ui->comboBox->currentText();
  557. //初始化TreeView
  558. QString jsonPath = folder+"/"+currentPro+"/"+"Hotupdate.json";
  559. QJO=tool::readJsonFile(jsonPath);
  560. // 从JSON对象中提取数据
  561. QJA = QJO.value("children").toArray();
  562. ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
  563. connect(ui->treeView, &QTreeView::customContextMenuRequested, this, &MainWindow::slotTreeMenu);
  564. //初始化treeview 和 combobox
  565. QTreeView *treeView=ui->treeView;
  566. QStandardItemModel* model=new QStandardItemModel(treeView);
  567. model->setHorizontalHeaderLabels(QStringList()<<QStringLiteral("名称"));
  568. treeView->setModel(model);
  569. initTreeView(model->invisibleRootItem(),QJA);
  570. qDebug()<<"QJA"<<QJA;
  571. QStandardItemModel *tree_model = qobject_cast<QStandardItemModel*>(ui->treeView->model());
  572. connect(tree_model, &QStandardItemModel::dataChanged, this, &MainWindow::onDataChanged);
  573. }
  574. void MainWindow::clearRight()
  575. {
  576. my1->clear();
  577. my2->clear();
  578. my3->clear();
  579. my4->clear();
  580. this->customB2->pos_left_button();
  581. this->customB3->pos_left_button();
  582. this->customB4->pos_left_button();
  583. }
  584. void MainWindow::handleOperationCompleted(QString fromfilePath)
  585. {
  586. QStringList parts = fromfilePath.split("/");
  587. QObject *senderObj = sender();
  588. QListWidget *LW = qobject_cast<QListWidget*>(senderObj);
  589. //QString tofilePath1 = "/Users/lal/QT_pro/build-test_tool1-Qt_6_3_1_for_macOS-Debug/test_tool1.app/Contents/MacOS/~/Documents/RedInterstitialData/HotUpdate2/pro2/tes1/version1/group3";
  590. QString group_name;
  591. int group_index;
  592. if(LW->objectName()=="listWidget")
  593. {
  594. group_name="group1";
  595. group_index=0;
  596. }
  597. else if(LW->objectName()=="listWidget_2")
  598. {
  599. group_name="group2";
  600. group_index=1;
  601. }
  602. else if(LW->objectName()=="listWidget_3")
  603. {
  604. group_name="group3";
  605. group_index=2;
  606. }
  607. else
  608. {
  609. group_name="group4";
  610. group_index=3;
  611. }
  612. QString tofilePath1 = treeview_path+"/"+group_name;
  613. QFile sourceFile(fromfilePath);
  614. QFile targetFile(tofilePath1 + "/" +parts[parts.size()-1]);
  615. if (sourceFile.exists() && QDir(tofilePath1).exists()) {
  616. if (sourceFile.copy(targetFile.fileName())) {
  617. qDebug() << "File copied successfully.";
  618. LW->addItem(parts[parts.size()-1]);
  619. qDebug()<<this->parent();
  620. QJsonObject groupObject = RQJA[group_index].toObject();
  621. QJsonArray childrenArray = groupObject["children"].toArray();
  622. childrenArray.append(parts[parts.size()-1]);
  623. groupObject["children"] = childrenArray;
  624. RQJA[group_index] = groupObject;
  625. writeBackToConfigJson();
  626. } else {
  627. qDebug() << "Failed to copy file.";
  628. QMessageBox::information(this, "失败", "文件名重复");
  629. }
  630. } else {
  631. qDebug() << "Source file or target folder does not exist.";
  632. }
  633. }
  634. void MainWindow::on_pushButton_4_clicked()
  635. {
  636. QList<QStandardItem*> items1;
  637. QStandardItemModel *model1 = static_cast<QStandardItemModel*>(ui->treeView->model());
  638. // QStandardItem* item2 = new QStandardItem(QStringLiteral("新建测试"));
  639. QDateTime currentDateTime = QDateTime::currentDateTime();
  640. QString currentDateTimeString = currentDateTime.toString("yyyy-MM-dd hh:mm:ss");
  641. QStandardItem* item2 = new QStandardItem(currentDateTimeString);
  642. QString add_Path=root_pro_path+"/"+ui->comboBox->currentText();
  643. QDir dir;
  644. if (!dir.exists(add_Path+"/"+currentDateTimeString)) {
  645. if (dir.mkpath(add_Path+"/"+currentDateTimeString)) {
  646. qDebug() << "Folder created successfully.";
  647. QString filePath = add_Path+"/"+"Hotupdate.json";
  648. QFile file(filePath);
  649. if (!file.open(QIODevice::ReadOnly))
  650. {
  651. QString errorString = file.errorString();
  652. qDebug() << "Failed to open file: " << errorString;
  653. // 其他错误处理逻辑
  654. }
  655. QByteArray jsonData = file.readAll();
  656. file.close();
  657. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
  658. if (jsonDoc.isNull()) {
  659. qDebug() << "Failed to parse JSON data.";
  660. return;
  661. }
  662. // 将 JSON 数据转换为对象
  663. QJsonObject jsonObj = jsonDoc.object();
  664. // 使用 jsonObj 进行进一步操作,例如读取特定的键值对
  665. QJsonObject newQ;
  666. QJsonArray newA;
  667. newQ.insert("children",newA);
  668. newQ.insert("name",currentDateTimeString);
  669. QJsonArray qaa=jsonObj["children"].toArray();
  670. qaa.append(newQ);
  671. jsonObj["children"]=qaa;
  672. QJA=qaa;
  673. tool::writeJsonFile(filePath,jsonObj);
  674. items1.append(item2);
  675. model1->appendRow(items1);
  676. } else {
  677. qDebug() << "Failed to create folder.";
  678. }
  679. } else {
  680. qDebug() << "Folder already exists.";
  681. }
  682. }
  683. void MainWindow::on_pushButton_5_clicked()
  684. {
  685. // 获取选择模型
  686. QItemSelectionModel* selectionModel = ui->treeView->selectionModel();
  687. if (selectionModel)
  688. {
  689. // 获取当前选中的节点的索引
  690. QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
  691. QModelIndex parentIndex = selectedIndexes.first().parent();
  692. if(parentIndex.isValid())
  693. {
  694. QMessageBox::information(this, "提示", "请选中一级节点");
  695. return;
  696. }
  697. // 遍历选中的索引列表
  698. foreach (const QModelIndex& index, selectedIndexes)
  699. {
  700. // 打印选中节点的数据
  701. QVariant data = index.data(Qt::DisplayRole);
  702. qDebug() << "Selected Node Data: " << data.toString();
  703. QString add_Path=root_pro_path+"/"+ui->comboBox->currentText()+"/"+data.toString();
  704. QString modify_pro_config = root_pro_path+"/"+ui->comboBox->currentText()+"/"+"Hotupdate.json";
  705. //直接对新增的版本添加config.json group1 group2 group3 group4
  706. qDebug()<<add_Path;
  707. QDir folder(add_Path);
  708. QStringList subFolders = folder.entryList(QDir::Dirs | QDir::NoDotAndDotDot); // 获取文件夹列表
  709. QString folderCount = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"); // 文件夹数目
  710. qDebug() << "Number of sub-folders: " << folderCount;
  711. //新建版本
  712. QDir dir;
  713. QString version_path=add_Path+"/"+"version"+folderCount;
  714. if (dir.exists(version_path))
  715. {
  716. return;
  717. }
  718. if(!dir.mkpath(version_path))
  719. {
  720. return;
  721. }
  722. //新建版本下的子文件夹等
  723. dir.mkpath(version_path+"/"+"group1");
  724. dir.mkpath(version_path+"/"+"group2");
  725. dir.mkpath(version_path+"/"+"group3");
  726. dir.mkpath(version_path+"/"+"group4");
  727. QString filePath = version_path+"/"+"config.json"; // 指定新文件的路径和名称
  728. QJsonArray jsonArray;
  729. for(int i=0;i<4;i++)
  730. {
  731. // add obj
  732. QJsonObject object1;
  733. QJsonArray children1;
  734. object1["children"] = children1;
  735. object1["selected"] = "0";
  736. jsonArray.append(object1);
  737. }
  738. QFile file(filePath);
  739. if (file.open(QIODevice::WriteOnly | QIODevice::Text))
  740. {
  741. QJsonDocument jsonDocument(jsonArray);
  742. QString jsonString = jsonDocument.toJson();
  743. QTextStream stream(&file);
  744. stream << jsonString; // 将JSON文本写入文件
  745. file.close();
  746. qDebug() << "File written successfully!";
  747. }
  748. else
  749. {
  750. qDebug() << "Failed to write the file!";
  751. }
  752. //修改项目根json文件 modify_pro_config
  753. //folderCount
  754. qDebug()<<index.row();
  755. QFile file1(modify_pro_config);
  756. if (!file1.open(QIODevice::ReadOnly))
  757. {
  758. QString errorString = file1.errorString();
  759. qDebug() << "Failed to open file: " << errorString;
  760. // 其他错误处理逻辑
  761. }
  762. QByteArray jsonData = file1.readAll();
  763. file1.close();
  764. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
  765. if (jsonDoc.isNull()) {
  766. qDebug() << "Failed to parse JSON data.";
  767. return;
  768. }
  769. // 将 JSON 数据转换为对象
  770. QJsonObject jsonObj = jsonDoc.object();
  771. QJsonArray parentArray = jsonObj["children"].toArray();
  772. QJsonObject childObject = parentArray[index.row()].toObject();
  773. QJsonArray nestedArray = childObject["children"].toArray();
  774. // {
  775. // "name": "version1"
  776. // }
  777. QJsonObject temo1;
  778. temo1["name"]="version" + folderCount;
  779. nestedArray.append(temo1);
  780. childObject["children"] = nestedArray;
  781. parentArray[index.row()] = childObject;
  782. jsonObj["children"] = parentArray;
  783. qDebug() << "Modified QJsonObject:" << jsonObj;
  784. QJA=parentArray;
  785. tool::writeJsonFile(modify_pro_config,jsonObj);
  786. //
  787. QStandardItemModel* model = dynamic_cast<QStandardItemModel*>(ui->treeView->model());
  788. if (model) {
  789. QStandardItem* parentItem = model->itemFromIndex(index);
  790. if (parentItem) {
  791. QStandardItem* childItem = new QStandardItem("version"+folderCount);
  792. parentItem->appendRow(childItem);
  793. }
  794. }
  795. }
  796. }
  797. }
  798. void MainWindow::on_comboBox_customContextMenuRequested(const QPoint &pos)
  799. {
  800. }
  801. void MainWindow::on_pushButton_9_clicked()
  802. {
  803. // qDebug()<<ui->treeView->currentIndex();
  804. // 获取被选中的节点
  805. QModelIndex selectedIndex = ui->treeView->currentIndex();
  806. if(!selectedIndex.isValid())
  807. {
  808. // 如果没有选中任何节点,则弹出提示框
  809. QMessageBox::information(this, "提示", "没有选中任何节点");
  810. return;
  811. }
  812. // 检查选中的节点是一级节点还是二级节点
  813. if(selectedIndex.parent().isValid())
  814. {
  815. // 如果选中的节点有父节点,那么它是二级节点
  816. // 在这里执行二级节点对应的代码...
  817. QMessageBox::StandardButton reply;
  818. reply = QMessageBox::question(this, "Test", "确定要删除"+selectedIndex.data().toString(),
  819. QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
  820. if (reply == QMessageBox::Yes) {
  821. qDebug() << "Yes was clicked";
  822. qDebug() << "选中的是二级节点";
  823. QModelIndex parentIndex = selectedIndex.parent();
  824. QString del_Path=root_pro_path+"/"+ui->comboBox->currentText()+"/"+parentIndex.data().toString()+"/"+selectedIndex.data().toString();
  825. QString modify_pro_config = root_pro_path+"/"+ui->comboBox->currentText()+"/"+"Hotupdate.json";
  826. //删除文件夹
  827. QDir dir(del_Path);
  828. dir.removeRecursively();
  829. //修改json文件
  830. QFile file1(modify_pro_config);
  831. if (!file1.open(QIODevice::ReadOnly))
  832. {
  833. QString errorString = file1.errorString();
  834. qDebug() << "Failed to open file: " << errorString;
  835. // 其他错误处理逻辑
  836. }
  837. QByteArray jsonData = file1.readAll();
  838. file1.close();
  839. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
  840. if (jsonDoc.isNull()) {
  841. qDebug() << "Failed to parse JSON data.";
  842. return;
  843. }
  844. // 将 JSON 数据转换为对象
  845. QJsonObject jsonObj = jsonDoc.object();
  846. QJsonArray parentArray = jsonObj["children"].toArray();
  847. QJsonObject childObject = parentArray[parentIndex.row()].toObject();
  848. QJsonArray nestedArray = childObject["children"].toArray();
  849. nestedArray.removeAt(selectedIndex.row());
  850. childObject["children"] = nestedArray;
  851. parentArray[parentIndex.row()] = childObject;
  852. jsonObj["children"] = parentArray;
  853. qDebug() << "Modified QJsonObject:" << jsonObj;
  854. tool::writeJsonFile(modify_pro_config,jsonObj);
  855. QStandardItemModel* model = dynamic_cast<QStandardItemModel*>(ui->treeView->model());
  856. if (model) {
  857. QStandardItem* parentItem = model->itemFromIndex(parentIndex);
  858. if (parentItem) {
  859. parentItem->removeRow(selectedIndex.row());
  860. }
  861. }
  862. } else if (reply == QMessageBox::No) {
  863. qDebug() << "No was clicked";
  864. } else {
  865. qDebug() << "Cancel was clicked";
  866. }
  867. }
  868. else
  869. {
  870. // 如果选中的节点没有父节点,那么它是一级节点
  871. // 在这里执行一级节点对应的代码...
  872. QMessageBox::StandardButton reply;
  873. reply = QMessageBox::question(this, "Test", "确定要删除"+selectedIndex.data().toString(),
  874. QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
  875. if (reply == QMessageBox::Yes) {
  876. qDebug() << "Yes was clicked";
  877. qDebug() << "选中的是一级节点";
  878. QString del_Path=root_pro_path+"/"+ui->comboBox->currentText()+"/"+selectedIndex.data().toString();
  879. QString modify_pro_config = root_pro_path+"/"+ui->comboBox->currentText()+"/"+"Hotupdate.json";
  880. //删除文件夹
  881. QDir dir(del_Path);
  882. dir.removeRecursively();
  883. //修改json文件
  884. QFile file1(modify_pro_config);
  885. if (!file1.open(QIODevice::ReadOnly))
  886. {
  887. QString errorString = file1.errorString();
  888. qDebug() << "Failed to open file: " << errorString;
  889. // 其他错误处理逻辑
  890. }
  891. QByteArray jsonData = file1.readAll();
  892. file1.close();
  893. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
  894. if (jsonDoc.isNull()) {
  895. qDebug() << "Failed to parse JSON data.";
  896. return;
  897. }
  898. // 将 JSON 数据转换为对象
  899. QJsonObject jsonObj = jsonDoc.object();
  900. QJsonArray parentArray = jsonObj["children"].toArray();
  901. parentArray.removeAt(selectedIndex.row());
  902. jsonObj["children"] = parentArray;
  903. qDebug() << "Modified QJsonObject:" << jsonObj;
  904. tool::writeJsonFile(modify_pro_config,jsonObj);
  905. QStandardItemModel* model = dynamic_cast<QStandardItemModel*>(ui->treeView->model());
  906. model->removeRow(selectedIndex.row());
  907. } else if (reply == QMessageBox::No) {
  908. qDebug() << "No was clicked";
  909. } else {
  910. qDebug() << "Cancel was clicked";
  911. }
  912. }
  913. }
  914. void MainWindow::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
  915. {
  916. Q_UNUSED(bottomRight);
  917. Q_UNUSED(roles);
  918. // 获取节点的文本
  919. QString text = topLeft.data().toString();
  920. qDebug()<<"datachanged";
  921. if (!topLeft.isValid())
  922. return;
  923. // 获取父节点
  924. QModelIndex parentIndex = topLeft.parent();
  925. if (!parentIndex.isValid()) {
  926. // 如果父节点无效,那么这是一个一级节点
  927. qDebug() << "First-level node text changed: " << topLeft.data().toString();
  928. qDebug() << "Index in tree: " << topLeft.row();
  929. QJsonObject temqjo=QJA[topLeft.row()].toObject();
  930. QString lastname=temqjo["name"].toString();qDebug()<<lastname;
  931. QString oldFolderPath = root_pro_path+"/"+ui->comboBox->currentText()+"/"+lastname;
  932. QString newFolderPath = root_pro_path+"/"+ui->comboBox->currentText()+"/"+topLeft.data().toString();
  933. QDir dir;
  934. if (!dir.rename(oldFolderPath, newFolderPath)) {
  935. QMessageBox::information(this, "提示", "命名重复");
  936. qWarning() << "Failed to rename folder from" << oldFolderPath << "to" << newFolderPath;
  937. QStandardItemModel* model = dynamic_cast<QStandardItemModel*>(ui->treeView->model());
  938. QStandardItem* selectedItem = model->itemFromIndex(topLeft);
  939. selectedItem->setText(lastname);
  940. return;
  941. }
  942. QString modify_pro_config = root_pro_path+"/"+ui->comboBox->currentText()+"/"+"Hotupdate.json";
  943. qDebug()<<oldFolderPath<<newFolderPath;
  944. //修改json文件
  945. QFile file1(modify_pro_config);
  946. if (!file1.open(QIODevice::ReadOnly))
  947. {
  948. QString errorString = file1.errorString();
  949. qDebug() << "Failed to open file: " << errorString;
  950. // 其他错误处理逻辑
  951. }
  952. QByteArray jsonData = file1.readAll();
  953. file1.close();
  954. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
  955. if (jsonDoc.isNull()) {
  956. qDebug() << "Failed to parse JSON data.";
  957. return;
  958. }
  959. file1.close();
  960. // 将 JSON 数据转换为对象
  961. QJsonObject jsonObj = jsonDoc.object();
  962. QJsonArray parentArray = jsonObj["children"].toArray();
  963. QJsonObject tarobj=parentArray[topLeft.row()].toObject();
  964. tarobj["name"]=topLeft.data().toString();
  965. parentArray[topLeft.row()]=tarobj;
  966. jsonObj["children"] = parentArray;
  967. qDebug() << "Modified QJsonObject:" << jsonObj;
  968. tool::writeJsonFile(modify_pro_config,jsonObj);
  969. } else {
  970. // 如果需要获取父节点的信息,可以使用 parentIndex.data().toString()
  971. // 如果父节点有效,那么这是一个二级节点
  972. qDebug() << "Second-level node text changed: " << topLeft.data().toString();
  973. qDebug() << "Parent index in tree: " << parentIndex.row();
  974. qDebug() << "Index in parent's children: " << topLeft.row();
  975. QJsonObject temqjo=QJA[parentIndex.row()].toObject();
  976. QString lastname=temqjo["children"].toArray()[topLeft.row()].toObject()["name"].toString();qDebug()<<lastname;
  977. QString oldFolderPath = root_pro_path+"/"+ui->comboBox->currentText()+"/"+parentIndex.data().toString()+"/"+lastname;
  978. QString newFolderPath = root_pro_path+"/"+ui->comboBox->currentText()+"/"+ parentIndex.data().toString()+"/"+topLeft.data().toString();
  979. QDir dir;
  980. QString filename=topLeft.data().toString();
  981. if (!dir.rename(oldFolderPath, newFolderPath)) {
  982. QMessageBox::information(this, "提示", "命名重复");
  983. qWarning() << "Failed to rename folder from" << oldFolderPath << "to" << newFolderPath;
  984. QStandardItemModel* model = dynamic_cast<QStandardItemModel*>(ui->treeView->model());
  985. QStandardItem* selectedItem = model->itemFromIndex(topLeft);
  986. selectedItem->setText(lastname);
  987. return;
  988. }
  989. QString modify_pro_config = root_pro_path+"/"+ui->comboBox->currentText()+"/"+"Hotupdate.json";
  990. qDebug()<<oldFolderPath<<newFolderPath;
  991. //修改json文件
  992. QFile file1(modify_pro_config);
  993. if (!file1.open(QIODevice::ReadOnly))
  994. {
  995. QString errorString = file1.errorString();
  996. qDebug() << "Failed to open file: " << errorString;
  997. // 其他错误处理逻辑
  998. }
  999. QByteArray jsonData = file1.readAll();
  1000. file1.close();
  1001. QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData);
  1002. if (jsonDoc.isNull()) {
  1003. qDebug() << "Failed to parse JSON data.";
  1004. return;
  1005. }
  1006. // 将 JSON 数据转换为对象
  1007. QJsonObject jsonObj = jsonDoc.object();
  1008. QJsonArray parentArray = jsonObj["children"].toArray();
  1009. QJsonObject tarobj=parentArray[parentIndex.row()].toObject();
  1010. QJsonArray tararr=tarobj["children"].toArray();
  1011. QJsonObject to=tararr[topLeft.row()].toObject();
  1012. to["name"]=filename;
  1013. tararr[topLeft.row()]=to;
  1014. tarobj["children"]=tararr;
  1015. parentArray[parentIndex.row()]=tarobj;
  1016. jsonObj["children"] = parentArray;
  1017. qDebug() << "Modified QJsonObject:" << jsonObj;
  1018. tool::writeJsonFile(modify_pro_config,jsonObj);
  1019. }
  1020. }
  1021. void MainWindow::handleSignal()
  1022. {
  1023. qDebug()<<"handleSignal";
  1024. QString folder = "/users/lal/documents/RedInterstitialData/HotUpdate2";
  1025. QStringList qs=tool::getFilesInFolder(folder);//获取项目名称列表
  1026. qDebug()<<qs;
  1027. initComboBox(qs);
  1028. }