From 3742570d134bf007c454413fc834e15b4f8843e8 Mon Sep 17 00:00:00 2001 From: wumu <mayi@mayi.com> Date: 星期五, 15 十一月 2024 23:17:24 +0800 Subject: [PATCH] 1115 --- internal_system_v1/converinfo2.cpp | 343 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 280 insertions(+), 63 deletions(-) diff --git a/internal_system_v1/converinfo2.cpp b/internal_system_v1/converinfo2.cpp index a51a114..c19c391 100644 --- a/internal_system_v1/converinfo2.cpp +++ b/internal_system_v1/converinfo2.cpp @@ -15,8 +15,9 @@ ui->setupUi(this); m_menu = nullptr; //initUi(); - readInfo(); // 鍔犺浇琛ㄦ牸 + //readInfo(); // 鍔犺浇琛ㄦ牸 addMenu(); // 澧炲姞鑿滃崟 + disableWheelEvent(); // 绂佺敤涓嬫媺妗嗙殑婊氳疆浜嬩欢 // 鑷�傚簲澶勭悊 ui->treeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); @@ -49,7 +50,7 @@ it4->setCheckState(0,Qt::Checked); // 澶嶉�夋鐘舵�佸鐞� - connect(ui->treeWidget,QOverload<QTreeWidgetItem*,int>::of(QTreeWidget::itemClicked),this,[=](QTreeWidgetItem* it,int index){ + connect(ui->treeWidget,QOverload<QTreeWidgetItem*,int>::of(&QTreeWidget::itemClicked),this,[=](QTreeWidgetItem* it,int index){ qDebug()<<it<<index; if(it == top1){ qDebug()<<"鐐瑰嚮浜嗙爜铓侀泦鍥�"; @@ -63,12 +64,14 @@ m_menu = new QMenu(this); m_menu->addAction("鍒犻櫎"); m_menu->addAction("澧炲姞"); + m_menu->addAction("淇濆瓨瀵煎嚭"); ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showMenu(QPoint))); connect(m_menu->actions().at(0),SIGNAL(triggered(bool)),this,SLOT(deleteInfo())); connect(m_menu->actions().at(1),SIGNAL(triggered(bool)),this,SLOT(addInfo())); + connect(m_menu->actions().at(2),SIGNAL(triggered(bool)),this,SLOT(saveInfo())); // 鍗曚綅鍐呭淇敼 // 鍙宠竟鍙紪杈戝唴瀹� @@ -90,19 +93,92 @@ { if(m_curItem==nullptr)return; qDebug()<<"娣诲姞鍏徃淇℃伅,鍦ㄨ妭鐐癸細"<<m_curItem->text(0); + on_pushButton_laodFile_clicked(); } void ConverInfo2::deleteInfo() { if(m_curItem==nullptr)return; qDebug()<<"鍒犻櫎鍏徃淇℃伅,鑺傜偣锛�"<<m_curItem->text(0); + auto resList = m_curItem->takeChildren(); + + qDebug()<<"鍒犻櫎鏁伴噺:"<<resList.size(); +} + +void ConverInfo2::saveInfo() +{ + if(m_curItem==nullptr)return; + qDebug()<<"淇濆瓨鍏徃淇℃伅,鑺傜偣锛�"<<m_curItem->text(0); + QString name = m_curItem->text(0); + if(name.contains("(鏈骇)")){ + name = name.split("(鏈骇)").at(0); + }else if(name.contains("(姹囨��)")){ + name = name.split("(姹囨��)").at(0); + name = name + "(姹囨��)"; + } + qDebug()<<"淇濆瓨鍏徃鍚�:"<<name; + ComInfo cif = m_nameAndComInfos[name]; + ExportToFile etf(this); + etf.saveToExcelFromComInfo(cif); + } void ConverInfo2::on_treeWidget_doubleClicked(const QModelIndex &index) { QString name = index.model()->data(index).toString(); qDebug()<<"鍙屽嚮"<<index<<name; - ComInfo curCominfo = m_nameAndComInfos[name]; + + ComInfo curCominfo; // 涓嶈鐩存帴缁欏�硷紝鍙兘浼氬鑷村娣诲姞鏂扮殑鍚嶅瓧杩涙潵 + if(name.contains("(鏈骇)")){ + QStringList sps = name.split("(鏈骇)"); + name = sps.at(0); + curCominfo = m_nameAndComInfos[name]; + }else if(name.contains("(姹囨��)")){ + name = name.split("(姹囨��)").at(0); + qDebug()<<"姹囨�诲鐞�:"; + // 鍋氫竴涓眹鎬荤殑澶勭悊锛屾妸鎵�鏈変笅绾х殑閮界疮鍔犺捣鏉� + ComInfo allCominfo = m_nameAndComInfos[name]; + for(QString cur:m_treeNodes[name]){ + if(name != cur){ + ComInfo &tmp = m_nameAndComInfos[cur]; + allCominfo.organazationNum += tmp.organazationNum; + allCominfo.realNum += tmp.realNum; + allCominfo.professionalNum += tmp.professionalNum; + allCominfo.CIANum += tmp.CIANum; + allCominfo.masterNum += tmp.masterNum; + allCominfo.undergraduatesNum += tmp.undergraduatesNum; + allCominfo.juniorNum += tmp.juniorNum; + allCominfo.seniorNum += tmp.seniorNum; + allCominfo.intermediateNum += tmp.intermediateNum; + allCominfo.primaryNum += tmp.primaryNum; + allCominfo.noTitleNum += tmp.noTitleNum; + allCominfo.upFiftyOldNum += tmp.upFiftyOldNum; + allCominfo.upThirtyOldNum += tmp.upThirtyOldNum; + allCominfo.downThirtyOldNum += tmp.downThirtyOldNum; + allCominfo.auditNum += tmp.auditNum; + allCominfo.accountingNum += tmp.accountingNum; + allCominfo.economyNum += tmp.economyNum; + allCominfo.lawNum += tmp.lawNum; + allCominfo.managerNum += tmp.managerNum; + allCominfo.itNum += tmp.itNum; + allCominfo.engineeringNum += tmp.engineeringNum; + allCominfo.otherNum += tmp.otherNum; + } + + } + curCominfo = allCominfo; + // 澶勭悊瀹屼簡涔嬪悗锛岃繕闇�瑕佸崟鐙捣涓�涓眹鎬荤殑鍚嶅瓧 + name = name + "(姹囨��)"; + strcpy(curCominfo.name,name.toLocal8Bit().data()); + m_nameAndComInfos[name] = curCominfo; + + // 鍒锋柊缁勫悎涓嬫媺妗嗙殑鍒楄〃 + emit updateComboListSignal(m_nameAndComInfos); + + }else{ + curCominfo = m_nameAndComInfos[name]; + } + //ComInfo curCominfo = m_nameAndComInfos[name]; // 涓�銆佸崟浣嶅熀鏈儏鍐� ui->lineEdit_creditCode->setText(curCominfo.creditCode); ui->lineEdit_name->setText(QString::fromLocal8Bit( curCominfo.name)); @@ -203,11 +279,15 @@ it.next(); list.append(it.fileInfo().absoluteFilePath()); } + int allSize = list.size(); + float cntIdx=1.0; foreach(QString str, list) { qDebug() << str; int index = str.indexOf("鍐呭缁�01琛�"); qDebug()<<"index:"<<index; + + if(index > 0){ QAxObject excel("ket.Application"); if(!excel.setControl("ket" @@ -268,8 +348,8 @@ QVariant name = valRows[9].toList().at(8); if(name.isValid()){ ui->label_name->setText(name.toString()); - QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); - top1->setText(0,name.toString()); + //QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); + //top1->setText(0,name.toString()); strcpy(curComInfo.name,name.toString().toLocal8Bit().data()); }else{ @@ -520,136 +600,137 @@ // 鍥涖�佸唴瀹′汉鍛橀厤澶囧熀鏈儏鍐� // 缂栧埗鏁� - QVariant organazationNum = valRows[56].toList().at(4); + //QVariant organazationNum = valRows[56].toList().at(4); + QVariant organazationNum = valRows[60].toList().at(4); if(organazationNum.isValid()){ curComInfo.organazationNum = organazationNum.toInt(); qDebug()<<"organazationNum"<<organazationNum; } // 瀹炴湁浜哄憳鏁� - QVariant realNum = valRows[56].toList().at(4); + QVariant realNum = valRows[60].toList().at(6); if(realNum.isValid()){ curComInfo.realNum = realNum.toInt(); qDebug()<<"realNum"<<realNum; } // 涓撹亴浜哄憳鏁� - QVariant professionalNum = valRows[56].toList().at(4); + QVariant professionalNum = valRows[60].toList().at(8); if(professionalNum.isValid()){ curComInfo.professionalNum = professionalNum.toInt(); qDebug()<<"professionalNum"<<professionalNum; } // 鎷ユ湁CIA浜哄憳鏁� - QVariant CIANum = valRows[56].toList().at(4); + QVariant CIANum = valRows[61].toList().at(6); if(CIANum.isValid()){ curComInfo.CIANum = CIANum.toInt(); qDebug()<<"CIANum"<<CIANum; } // 瀛﹀巻锛氱澹強浠ヤ笂 浜哄憳鏁� - QVariant masterNum = valRows[56].toList().at(4); + QVariant masterNum = valRows[62].toList().at(6); if(masterNum.isValid()){ curComInfo.masterNum = masterNum.toInt(); qDebug()<<"masterNum"<<masterNum; } // 澶у鏈 - QVariant undergraduatesNum = valRows[56].toList().at(4); + QVariant undergraduatesNum = valRows[63].toList().at(6); if(undergraduatesNum.isValid()){ curComInfo.undergraduatesNum = undergraduatesNum.toInt(); qDebug()<<"undergraduatesNum"<<undergraduatesNum; } // 涓撶鍙婁互涓� - QVariant juniorNum = valRows[56].toList().at(4); + QVariant juniorNum = valRows[64].toList().at(6); if(juniorNum.isValid()){ curComInfo.juniorNum = juniorNum.toInt(); qDebug()<<"juniorNum"<<juniorNum; } // 鑱岀О 楂樼骇鑱岀О - QVariant seniorNum = valRows[56].toList().at(4); + QVariant seniorNum = valRows[65].toList().at(6); if(seniorNum.isValid()){ curComInfo.seniorNum = seniorNum.toInt(); qDebug()<<"seniorNum"<<seniorNum; } // 涓骇鑱岀О - QVariant intermediateNum = valRows[56].toList().at(4); + QVariant intermediateNum = valRows[66].toList().at(6); if(intermediateNum.isValid()){ curComInfo.intermediateNum = intermediateNum.toInt(); qDebug()<<"intermediateNum"<<intermediateNum; } // 鍒濈骇鑱岀О - QVariant primaryNum = valRows[56].toList().at(4); + QVariant primaryNum = valRows[67].toList().at(6); if(primaryNum.isValid()){ curComInfo.primaryNum = primaryNum.toInt(); qDebug()<<"primaryNum"<<primaryNum; } // 鏃犺亴绉� - QVariant noTitleNum = valRows[56].toList().at(4); + QVariant noTitleNum = valRows[68].toList().at(6); if(noTitleNum.isValid()){ curComInfo.noTitleNum = noTitleNum.toInt(); qDebug()<<"noTitleNum"<<noTitleNum; } // 骞撮緞缁撴瀯 50宀佷互涓� - QVariant upFiftyOldNum = valRows[56].toList().at(4); + QVariant upFiftyOldNum = valRows[69].toList().at(6); if(upFiftyOldNum.isValid()){ curComInfo.upFiftyOldNum = upFiftyOldNum.toInt(); qDebug()<<"upFiftyOldNum"<<upFiftyOldNum; } // 30-50宀� - QVariant upThirtyOldNum = valRows[56].toList().at(4); + QVariant upThirtyOldNum = valRows[70].toList().at(6); if(upThirtyOldNum.isValid()){ curComInfo.upThirtyOldNum = upThirtyOldNum.toInt(); qDebug()<<"upThirtyOldNum"<<upThirtyOldNum; } // 30宀佷互涓� - QVariant downThirtyOldNum = valRows[56].toList().at(4); + QVariant downThirtyOldNum = valRows[71].toList().at(6); if(downThirtyOldNum.isValid()){ curComInfo.downThirtyOldNum = downThirtyOldNum.toInt(); qDebug()<<"downThirtyOldNum"<<downThirtyOldNum; } // 鐭ヨ瘑缁撴瀯 瀹¤ - QVariant auditNum = valRows[56].toList().at(4); + QVariant auditNum = valRows[72].toList().at(6); if(auditNum.isValid()){ curComInfo.auditNum = auditNum.toInt(); qDebug()<<"auditNum"<<auditNum; } // 浼氳 - QVariant accountingNum = valRows[56].toList().at(4); + QVariant accountingNum = valRows[73].toList().at(6); if(accountingNum.isValid()){ curComInfo.accountingNum = accountingNum.toInt(); qDebug()<<"accountingNum"<<accountingNum; } // 缁忔祹 - QVariant economyNum = valRows[56].toList().at(4); + QVariant economyNum = valRows[74].toList().at(6); if(economyNum.isValid()){ curComInfo.economyNum = economyNum.toInt(); qDebug()<<"economyNum"<<economyNum; } // 娉曞緥 - QVariant lawNum = valRows[56].toList().at(4); + QVariant lawNum = valRows[75].toList().at(6); if(lawNum.isValid()){ curComInfo.lawNum = lawNum.toInt(); qDebug()<<"lawNum"<<lawNum; } // 绠$悊 - QVariant managerNum = valRows[56].toList().at(4); + QVariant managerNum = valRows[76].toList().at(6); if(managerNum.isValid()){ curComInfo.managerNum = managerNum.toInt(); qDebug()<<"managerNum"<<managerNum; } // 淇℃伅鎶�鏈� - QVariant itNum = valRows[56].toList().at(4); + QVariant itNum = valRows[77].toList().at(6); if(itNum.isValid()){ curComInfo.itNum = itNum.toInt(); qDebug()<<"itNum"<<itNum; } // 宸ョ▼ - QVariant engineeringNum = valRows[56].toList().at(4); + QVariant engineeringNum = valRows[78].toList().at(6); if(engineeringNum.isValid()){ curComInfo.engineeringNum = engineeringNum.toInt(); qDebug()<<"engineeringNum"<<engineeringNum; } // 鍏朵粬 - QVariant otherNum = valRows[56].toList().at(4); + QVariant otherNum = valRows[79].toList().at(6); if(otherNum.isValid()){ curComInfo.otherNum = otherNum.toInt(); qDebug()<<"otherNum"<<otherNum; @@ -686,14 +767,40 @@ // 鏈�鍚庡瓨鍒癿ap涓� m_nameAndComInfos[name.toString()]=curComInfo; + // 娣诲姞鏍戝舰鍒楄〃鑺傜偣 + //addTreeWidgetNode(upName,name); + + if(upName.isValid()){ + if(name.isValid()){ + m_treeNodes[upName.toString()].push_back(name.toString()); + } + }else{ + if(name.isValid()){ + m_treeNodes[name.toString()].push_back(name.toString()); + } + } + } wbs->dynamicCall("Close()"); excel.dynamicCall("Quit(void)"); + + qDebug()<<"鍗曚綅淇℃伅鏁伴噺锛�"<<m_nameAndComInfos.size(); } + + // 鎺у埗鏄剧ず杩涘害鐩稿叧 + emit loadProgress((cntIdx/allSize)*100); + cntIdx++; } + createTreeNode(); // 鏋勫缓鏍戝舰鑺傜偣 + + // 鍙戝皠 鍔犺浇瀹屾垚鐨勪俊鍙� + emit loadFinished(); + + // 鏇存柊鍏朵粬鐣岄潰鐨勫叕鍙镐俊鎭笅鎷夋 + emit updateComboListSignal(m_nameAndComInfos); // QAxObject excel("./debug/Data/闄勪欢2_鍐呭缁�01琛╛鍗曚綅鍙婂唴閮ㄥ璁℃満鏋勫熀鏈儏鍐佃〃-1.301鐗�(1).xls"); // excel.setProperty("Visible",true); @@ -711,12 +818,14 @@ m_menu->addAction("鍒犻櫎"); m_menu->addAction("澧炲姞"); + m_menu->addAction("淇濆瓨瀵煎嚭"); ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeWidget,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showMenu(QPoint))); connect(m_menu->actions().at(0),SIGNAL(triggered(bool)),this,SLOT(deleteInfo())); connect(m_menu->actions().at(1),SIGNAL(triggered(bool)),this,SLOT(addInfo())); + connect(m_menu->actions().at(2),SIGNAL(triggered(bool)),this,SLOT(saveInfo())); } void ConverInfo2::on_pushButton_commit_clicked() @@ -1013,7 +1122,7 @@ qDebug()<<"excel:"<<excel.className(); QAxObject * wbs = excel.querySubObject("WorkBooks"); qDebug()<<"wbs:"<<wbs->className(); - QAxObject * wb = wbs->querySubObject("Open(QString&)",path); + QAxObject * wb = wbs->querySubObject("Open(QString&)",path); // 鍝釜瀵硅薄鏄疧pen鐨勮繑鍥炲�硷紝鍝釜灏卞彲浠ヤ繚瀛� //QAxObject* pWorkBook = excel.querySubObject("ActiveWorkBook"); //QAxObject* pWorkSheets = pWorkBook->querySubObject("Sheets");//鑾峰彇宸ヤ綔琛� //QAxObject * shs = wb->querySubObject("Sheets"); // WorkSheets 涔熷彲浠� @@ -1305,6 +1414,30 @@ qDebug()<<"financeDepartment"<<financeDepartment; } // 娉曞姟閮ㄩ棬銆佸唴閮ㄦ帶鍒堕儴闂ㄣ�佺邯妫�閮ㄩ棬銆佸叾浠栭儴闂� + // 闇�瑕佺壒娈婅幏鍙� + QAxObject *checkBox = sheet->querySubObject("CheckBoxes(const QString&)", QString::fromLocal8Bit("璐㈠姟閮ㄩ棬")); + if(checkBox){ + qDebug()<<"鍙栧埌璐㈠姟閮ㄩ棬"<<checkBox->property("Value2").toInt()<<checkBox->property("Value").toInt()<<checkBox->property("Value2").toBool(); + if(checkBox->property("Value").toBool()){ + qDebug()<<"璐㈠姟閮ㄩ棬鍕鹃��"; + }else{ + qDebug()<<"璐㈠姟閮ㄩ棬鏈嬀閫�"; + } + }else{ + qDebug()<<"鏈彇鍒拌储鍔¢儴闂�"; + } + + QAxObject *checkBox1 = sheet->querySubObject("CheckBoxes(const QString&)", QString::fromLocal8Bit("娉曞姟閮ㄩ棬")); + if(checkBox1){ + qDebug()<<"鍙栧埌娉曞姟閮ㄩ棬"<<checkBox1->property("Value").toInt(); + if(checkBox1->property("Value").toBool()){ + qDebug()<<"娉曞姟閮ㄩ棬鍕鹃��"; + }else{ + qDebug()<<"娉曞姟閮ㄩ棬鏈嬀閫�"; + } + }else{ + qDebug()<<"鏈彇鍒版硶鍔¢儴闂�"; + } // 鍐呭鏈烘瀯灞傜骇 QVariant intavalAuditLeval = valRows[56].toList().at(4); @@ -1484,42 +1617,17 @@ // 娣诲姞宸﹁竟鏍戝舰鍥剧浉鍏� // 鑿滃崟鐩稿叧 褰撲笂绾у叕鍙镐负绌轰笂绾ф椂锛岃嚜宸卞綋鑷繁鐨勪笂绾э紝骞朵笖缃楀垪杩涘幓褰� 鏈骇 + addTreeWidgetNode(upName,name); - if(upName.isValid()) // 鏈夋晥 - { - // 鍒ゆ柇椤跺眰鏍戣妭鐐规槸鍚﹀凡缁忓瓨鍦� - QTreeWidgetItem *top = nullptr; - for(int k=0;k<ui->treeWidget->topLevelItemCount();++k){ - QTreeWidgetItem *tmp = ui->treeWidget->topLevelItem(k); - qDebug()<<k<<tmp->text(0)<<upName.toString(); - if(upName.toString()+"(姹囨��)" == tmp->text(0)){ - top = tmp; - break; - } - } - if(name.isValid()){ - if(top){ // 瀛樺湪锛屽垯娣诲姞鍒板瀛愬垪琛ㄤ腑 - QTreeWidgetItem *top1 = new QTreeWidgetItem(top); - top1->setText(0,name.toString()); - }else{ // 涓嶅瓨鍦紝鍒欐柊寤轰竴涓垪琛� - QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); - top1->setText(0,name.toString()+"(姹囨��)"); - QTreeWidgetItem *top2 = new QTreeWidgetItem(top1); - top2->setText(0,name.toString()+"(鏈骇)"); - } - } - - - }else{ - qDebug()<<"娌″彂鐜颁笂涓�绾э紝鍙兘鑷繁褰�"<<name; - if(name.isValid()){ - QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); - top1->setText(0,name.toString()+"(姹囨��)"); - QTreeWidgetItem *top2 = new QTreeWidgetItem(top1); - top2->setText(0,name.toString()+"(鏈骇)"); - } - - } +// if(upName.isValid()){ +// if(name.isValid()){ +// m_treeNodes[upName.toString()].push_back(name.toString()); +// } +// }else{ +// if(name.isValid()){ +// m_treeNodes[name.toString()].push_back(name.toString()); +// } +// } } @@ -1527,8 +1635,100 @@ excel.dynamicCall("Quit(void)"); qDebug()<<"鍗曚綅淇℃伅鏁伴噺锛�"<<m_nameAndComInfos.size(); + emit updateComboListSignal(m_nameAndComInfos); // 鏇存柊缁勫悎涓嬫媺妗嗙殑鍗曚綅淇℃伅 } +void ConverInfo2::createTreeNode(){ + qDebug()<<"鏋勫缓鏍戝舰鍒楄〃"<<m_treeNodes.size(); + for(auto iter=m_treeNodes.begin();iter != m_treeNodes.end();iter++) + { + // 鍏堟瀯寤轰竴涓瘡绾х殑鐖惰妭鐐� + addTreeWidgetNode(iter.key(),iter.key()); + // 鍐嶆坊鍔犲瀛愯妭鐐� + for(QString node:iter.value()){ + qDebug()<<iter.key()<<node; + if(iter.key() != node){ + addTreeWidgetNode(iter.key(),node); + } + } + } +} + +void ConverInfo2::disableWheelEvent() +{ + ui->comboBox_ChiefDesignerLevel->installEventFilter(this); + ui->comboBox_comType->installEventFilter(this); + ui->comboBox_employmentMode->installEventFilter(this); + ui->comboBox_hasChiefDesigner->installEventFilter(this); + ui->comboBox_hasSetIntervalAudit->installEventFilter(this); + ui->comboBox_hasSetSeparateIA->installEventFilter(this); + ui->comboBox_hasUpLegal->installEventFilter(this); + ui->comboBox_intavalAuditLeval->installEventFilter(this); + ui->comboBox_leadingOrganization->installEventFilter(this); + ui->comboBox_scale->installEventFilter(this); + ui->comboBox_standardType->installEventFilter(this); +} + +bool ConverInfo2::eventFilter(QObject *watched, QEvent *event) +{ + QString cls = watched->metaObject()->className(); + if(cls == "QComboBox"){ + //qDebug()<<"鍙戠幇涓嬫媺妗�"; + if(event->type() == QEvent::Wheel){ + //qDebug()<<"浣跨敤浜嗘粴杞�"; + return true; // 杩斿洖鐪熻〃绀虹鐢紝杩斿洖鍋囧垯鑳界敤 + } + }else{ + qDebug()<<"鍏朵粬绫诲瀷:"<<cls; + } + + return QMainWindow::eventFilter(watched,event); + +} +void ConverInfo2::addTreeWidgetNode(QVariant upName,QVariant name){ + // 娣诲姞宸﹁竟鏍戝舰鍥剧浉鍏� + // 鑿滃崟鐩稿叧 褰撲笂绾у叕鍙镐负绌轰笂绾ф椂锛岃嚜宸卞綋鑷繁鐨勪笂绾э紝骞朵笖缃楀垪杩涘幓褰� 鏈骇 + + if(upName.isValid()) // 鏈夋晥 + { + // 鍒ゆ柇椤跺眰鏍戣妭鐐规槸鍚﹀凡缁忓瓨鍦� + QTreeWidgetItem *top = nullptr; + for(int k=0;k<ui->treeWidget->topLevelItemCount();++k){ + QTreeWidgetItem *tmp = ui->treeWidget->topLevelItem(k); + qDebug()<<k<<tmp->text(0)<<upName.toString(); + int pos = tmp->text(0).indexOf(upName.toString()+"(姹囨��)"); + if(upName.toString()+"(姹囨��)" == tmp->text(0) || pos != -1){ + top = tmp; + break; + } + } + if(name.isValid()){ + if(top){ // 瀛樺湪锛屽垯娣诲姞鍒板瀛愬垪琛ㄤ腑 + QTreeWidgetItem *top1 = new QTreeWidgetItem(top); + top1->setText(0,name.toString()); + top->setText(0,upName.toString()+"(姹囨��)涓嬬骇鏁�:"+QString::number(top->childCount()-1)); + }else{ // 涓嶅瓨鍦紝鍒欐柊寤轰竴涓垪琛� + QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); + top1->setText(0,name.toString()+"(姹囨��)"); + QTreeWidgetItem *top2 = new QTreeWidgetItem(top1); + top2->setText(0,name.toString()+"(鏈骇)"); + top1->setText(0,name.toString()+"(姹囨��)涓嬬骇鏁�:"+QString::number(top1->childCount()-1)); + } + } + + + }else{ + qDebug()<<"娌″彂鐜颁笂涓�绾э紝鍙兘鑷繁褰�"<<name; + if(name.isValid()){ + QTreeWidgetItem *top1 = new QTreeWidgetItem(ui->treeWidget); + top1->setText(0,name.toString()+"(姹囨��)"); + QTreeWidgetItem *top2 = new QTreeWidgetItem(top1); + top2->setText(0,name.toString()+"(鏈骇)"); + top1->setText(0,name.toString()+"(姹囨��)涓嬬骇鏁�:"+QString::number(top1->childCount()-1)); + } + + } +} void ConverInfo2::on_pushButton_laodFile_clicked() { QString path = QFileDialog::getOpenFileName(this,"閫夋嫨琛ㄦ牸:鍗曚綅鍙婂唴閮ㄥ璁℃満鏋勫熀鏈儏鍐佃〃","./","excel(*鍩烘湰鎯呭喌琛�*.xls)"); @@ -1537,3 +1737,20 @@ readExcelFromPath(path); } } + +void ConverInfo2::showExcelSlot() +{ + readInfo(); // 鍔犺浇琛ㄦ牸 +} + +void ConverInfo2::on_pushButton_save_to_file_clicked() +{ + QString name = ui->lineEdit_name->text(); + if(name.size()== 0){ + QMessageBox::information(this,"鍗曚綅鍚嶇О涓虹┖,璇峰厛閫変腑涓�瀹跺崟浣�","璇峰厛閫変腑涓�瀹跺崟浣�"); + return; + } + ExportToFile etf(this); + ComInfo cif = m_nameAndComInfos[name]; + etf.saveToExcelFromComInfo(cif); +} -- Gitblit v1.8.0