qt/LedOK/progpanel.cpp

450 lines
20 KiB
C++
Raw Normal View History

2022-08-25 18:37:24 +08:00
#include "progpanel.h"
#include "globaldefine.h"
2022-10-27 15:07:45 +08:00
#include "tools.h"
2023-04-18 14:14:46 +08:00
#include "gutil/qgui.h"
#include "cfg.h"
2022-08-25 18:37:24 +08:00
#include "player/playwin.h"
2023-04-18 14:14:46 +08:00
#include "program/progcreatedlg.h"
#include "program/progeditorwin.h"
#include "program/copydirthread.h"
2022-08-25 18:37:24 +08:00
#include <QApplication>
#include <QHeaderView>
#include <QMessageBox>
2023-04-18 14:14:46 +08:00
#include <QStandardPaths>
#include <QProgressBar>
2022-08-25 18:37:24 +08:00
2022-09-30 18:08:39 +08:00
ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
2022-08-25 18:37:24 +08:00
setAttribute(Qt::WA_DeleteOnClose);
setAutoFillBackground(true);
QPalette pal;
pal.setBrush(QPalette::Window, QColor(0xeeeeee));
setPalette(pal);
auto vBox = new QVBoxLayout(this);
vBox->setContentsMargins(0, 0, 0, 0);
vBox->setSpacing(0);
auto hBox = new QHBoxLayout();
hBox->setContentsMargins(6,6,6,6);
hBox->setSpacing(6);
vBox->addLayout(hBox);
bnNew = new QPushButton(tr("New"));
bnNew->setFixedSize(88, 38);
bnNew->setProperty("ssType", "progManageTool");
hBox->addWidget(bnNew);
2022-09-30 18:08:39 +08:00
connect(bnNew, &QPushButton::clicked, this, [this] {
2023-04-18 14:14:46 +08:00
ProgCreateDlg dlg("", 512, 256, "", "", this);
2022-09-30 18:08:39 +08:00
if(dlg.exec() != QDialog::Accepted) return;
if(checkIfNameRepeated(dlg.fdName->text())) return;
2023-04-18 14:14:46 +08:00
auto splitWidths = dlg.fdSplitWidths->text().split(" ", Qt::SkipEmptyParts);
QList<int> widths; int max = 0, ttl = 0;
foreach(auto splitWidth, splitWidths) {
int val = splitWidth.toInt();
if(val==0) continue;
if(max < val) max = val;
ttl += val;
widths.append(val);
}
auto width = dlg.fdWidth->value();
if(max) {
while(ttl < width) {
widths.append(max);
ttl += max;
}
if(ttl > width) widths.last() -= ttl - width;
}
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), width, dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, mProgTree, this);
2022-09-30 18:08:39 +08:00
item->save();//保存pro.json
mProgTree->adjustCheckState();
2023-04-24 15:02:08 +08:00
ProgEditorWin editor(item, gMainWin);
editor.exec();
2022-09-30 18:08:39 +08:00
});
2022-08-25 18:37:24 +08:00
bnEdit = new QPushButton(tr("Edit"));
bnEdit->setFixedSize(QSize(88, 38));
bnEdit->setProperty("ssType", "progManageTool");
bnEdit->setEnabled(false);
hBox->addWidget(bnEdit);
connect(bnEdit, SIGNAL(clicked(bool)), this, SLOT(onEditClicked(bool)));
bnDelete = new QPushButton(tr("Delete"));
bnDelete->setFixedSize(QSize(88, 38));
bnDelete->setProperty("ssType", "progManageTool");
bnDelete->setEnabled(false);
hBox->addWidget(bnDelete);
connect(bnDelete, SIGNAL(clicked(bool)), this, SLOT(onDeleteClicked(bool)));
bnImport = new QPushButton(tr("Import"));
2023-04-18 14:14:46 +08:00
bnImport->setFixedSize(88, 38);
2022-08-25 18:37:24 +08:00
bnImport->setProperty("ssType", "progManageTool");
hBox->addWidget(bnImport);
2022-09-30 18:08:39 +08:00
connect(bnImport, &QPushButton::clicked, this, [this] {
2023-04-18 14:14:46 +08:00
QString dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(dir.isEmpty()) return;
QString progsDir = programsDir();
if(dir.contains(progsDir, Qt::CaseInsensitive)) {
QMessageBox::warning(this, tr("Tip"), tr("The imported directory is already in the working directory, so there is no need to import it again!"));
return;
}
QStringList progDirs;
if(QFileInfo::exists(dir + "/pro.json")) progDirs.append(dir);
else {
QStringList subdirNames = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
foreach(QString subdirName, subdirNames) {
auto subdir = dir + "/" + subdirName;
if(! QFileInfo::exists(subdir + "/pro.json")) continue;
if(QFileInfo::exists(progsDir + "/" + subdirName)) {
auto res = QMessageBox::information(gMainWin, tr("Tip Info"), subdirName + tr(":solution(s) already exist.are you sure you want to overwrite the existing solution(s)?"), QMessageBox::Yes, QMessageBox::No);
if(res == QMessageBox::No) continue;
}
progDirs.append(subdir);
}
if(progDirs.isEmpty()) return;
}
ProgPortDlg dlg(this, tr("Import"));
dlg.table->setRowCount(progDirs.count());
for(int i=0; i<progDirs.count(); i++) {
dlg.table->setItem(i, 0, new QTableWidgetItem(QFileInfo(progDirs[i]).fileName()));
dlg.table->setCellWidget(i, 1, new QProgressBar);
}
connect(dlg.bnOK, &QPushButton::clicked, this, [=, &dlg] {
for(int i=0; i<progDirs.count(); i++) ((QProgressBar*)dlg.table->cellWidget(i, 1))->setMaximum(dirFileSize(progDirs[i]));
auto thread = new CopyDirThread();
thread->dirSrcs = progDirs;
thread->dirDst = progsDir;
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
});
thread->start();
});
dlg.exec();
mProgTree->clear();
QStringList progNames = QDir(mProgsDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
foreach(QString pro_name, progNames) {
QFile jFile(mProgsDir + "/" + pro_name + "/pro.json");
if(! jFile.exists()) continue;
if(! jFile.open(QIODevice::ReadOnly)) continue;
auto data = jFile.readAll();
jFile.close();
m_pwPorgramItemList.append(new ProgItem(mProgsDir, QJsonDocument::fromJson(data).object(), mProgTree,this));
}
2022-09-30 18:08:39 +08:00
});
2022-08-25 18:37:24 +08:00
bnExport = new QPushButton(tr("Export"));
bnExport->setFixedSize(QSize(88, 38));
bnExport->setEnabled(false);
bnExport->setProperty("ssType", "progManageTool");
hBox->addWidget(bnExport);
2023-04-18 14:14:46 +08:00
connect(bnExport, &QPushButton::clicked, this, [=] {
int cnt = mProgTree->topLevelItemCount();
QStringList progNames;
for(int i=0; i<cnt; i++) if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) progNames.append(static_cast<ProgItem*>(mProgTree->topLevelItem(i))->mName);
if(progNames.isEmpty()) return;
ProgPortDlg dlg(this, tr("Export"));
dlg.table->setRowCount(progNames.count());
for(int i=0; i<progNames.count(); i++) {
dlg.table->setItem(i, 0, new QTableWidgetItem(progNames[i]));
dlg.table->setCellWidget(i, 1, new QProgressBar);
}
connect(dlg.bnOK, &QPushButton::clicked, this, [=, &dlg] {
QString dirDst = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(dirDst.isEmpty()) return;
auto progsDir = programsDir();
auto thread = new CopyDirThread();
for(int i=0; i<progNames.count(); i++) {
auto dir = progsDir+"/"+progNames[i];
((QProgressBar*)dlg.table->cellWidget(i, 1))->setMaximum(dirFileSize(dir));
thread->dirSrcs.append(dir);
}
thread->dirDst = dirDst;
connect(thread, &CopyDirThread::sigProgress, &dlg, [&dlg](int i, int value) {
((QProgressBar*)dlg.table->cellWidget(i, 1))->setValue(value);
});
thread->start();
});
dlg.exec();
});
2022-08-25 18:37:24 +08:00
bnSend = new QPushButton(tr("Send"));
bnSend->setFixedSize(QSize(88, 38));
bnSend->setProperty("ssType", "progManageTool");
bnSend->setEnabled(false);
bnSend->hide();
hBox->addWidget(bnSend);
btnPlay = new QPushButton(tr("Play")+"/"+tr("Stop"));
btnPlay->setFixedSize(QSize(88, 38));
btnPlay->setProperty("ssType", "progManageTool");
hBox->addWidget(btnPlay);
connect(btnPlay, &QPushButton::clicked, this, [this](){
if(PlayWin::self!=nullptr) PlayWin::self->close();
else {
2022-09-30 18:08:39 +08:00
int cnt = mProgTree->topLevelItemCount();
for(int i=0; i<cnt; i++) if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i));
2022-10-27 15:07:45 +08:00
QString dir = mProgsDir+"/"+item->mName+"_tmp";
2022-08-25 18:37:24 +08:00
QFile file(dir+"/program");
if(! file.open(QIODevice::ReadOnly | QIODevice::Text)) return;
QString value = file.readAll();
file.close();
QJsonParseError jsErr;
QJsonObject prog = QJsonDocument::fromJson(value.toUtf8(), &jsErr).object();
if(jsErr.error) return;
if(PlayWin::self!=nullptr) PlayWin::self->close();
2023-04-18 14:14:46 +08:00
if(item->mSplitWidths.isEmpty()) PlayWin::self = PlayWin::newIns(item->mWidth, item->mHeight, dir, prog);
else PlayWin::self = PlayWin::newIns(item->mMaxWidth, item->mHeight * item->mSplitWidths.size(), dir, prog);
2022-08-25 18:37:24 +08:00
break;
}
}
});
hBox->addStretch();
auto txtSearch = new QLineEdit(this);
txtSearch->setFixedSize(QSize(240, 36));
QAction *search = new QAction(txtSearch);
2023-04-18 14:14:46 +08:00
search->setIcon(QIcon(":/res/program/bnSearch.png"));
2022-08-25 18:37:24 +08:00
txtSearch->addAction(search, QLineEdit::LeadingPosition);
txtSearch->setClearButtonEnabled(true);
txtSearch->setStyleSheet("border: 2px solid #aaaaaa;");
hBox->addWidget(txtSearch);
connect(txtSearch,SIGNAL(textChanged(const QString &)),this,SLOT(FilterProgram(const QString &)));
2022-09-30 18:08:39 +08:00
mProgTree = new LoQTreeWidget();
mProgTree->setIndentation(10);
mProgTree->setSortingEnabled(true);
2022-08-25 18:37:24 +08:00
m_headerItem = new QTreeWidgetItem();
for(int i=1; i<ENUM_PROGRAMLISTHEADERITEM_END; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_CHECK, Qt::DisplayRole, "");
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_NAME, Qt::DisplayRole, tr("Name"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_RESOLUTION, Qt::DisplayRole, tr("Resolution"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SIZE, Qt::DisplayRole, tr("File Size"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_LASTTIME, Qt::DisplayRole, tr("Last Modify"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, Qt::DisplayRole, tr("Usb playback"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SEND, Qt::DisplayRole, tr("Publish"));
2022-09-30 18:08:39 +08:00
mProgTree->setHeaderItem(m_headerItem);
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_CHECK, QHeaderView::Fixed);
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_NAME, QHeaderView::Stretch);
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_RESOLUTION, QHeaderView::Stretch);
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_SIZE, QHeaderView::Stretch);
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_LASTTIME, QHeaderView::Stretch);
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, QHeaderView::Fixed);
mProgTree->header()->setSectionResizeMode(ENUM_PROGRAMLISTHEADERITEM_SEND, QHeaderView::Fixed);
mProgTree->header()->setStretchLastSection(false);
mProgTree->setColumnWidth(ENUM_PROGRAMLISTHEADERITEM_CHECK, 66);
mProgTree->setColumnWidth(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, 100);
mProgTree->setColumnWidth(ENUM_PROGRAMLISTHEADERITEM_SEND, 72);
vBox->addWidget(mProgTree);
connect(mProgTree, &LoQTreeWidget::sigCheckStateChanged, this, [this](int f){
2022-08-25 18:37:24 +08:00
switch(f) {
case LoQTreeWidget::CheckNone:
bnEdit->setEnabled(false);
bnDelete->setEnabled(false);
bnExport->setEnabled(false);
bnSend->setEnabled(false);
break;
case LoQTreeWidget::CheckOne:
bnEdit ->setEnabled(true);
bnDelete->setEnabled(true);
bnExport->setEnabled(true);
bnSend ->setEnabled(true);
break;
case LoQTreeWidget::CheckMulti:
bnEdit ->setEnabled(false);
bnDelete->setEnabled(true);
bnExport->setEnabled(true);
bnSend ->setEnabled(true);
break;
default: break;
}
});
QString doc_path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
if(!doc_path.isEmpty()) {
QString app_path = doc_path + "/" + QApplication::applicationName();
2022-10-27 15:07:45 +08:00
mProgsDir = app_path + "/NPrograms";
if(!QFileInfo::exists(mProgsDir)) {
2022-08-25 18:37:24 +08:00
QDir app_dir(app_path);
app_dir.mkdir("NPrograms");
app_dir.mkdir("ApkStore");
}
}
//connect(search, SIGNAL(triggered(bool)), this, SLOT(FilterProgram()));
//查找根路径下的项目文件夹查找文件夹下的节目pro.json信息包括节目名称大小像素备注等信息
2022-10-27 15:07:45 +08:00
if(!mProgsDir.isEmpty()) {
QDir root_dir(mProgsDir);
2022-08-25 18:37:24 +08:00
QStringList pro_list = root_dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
foreach(QString pro_name, pro_list) {
2022-10-27 15:07:45 +08:00
QDir pro_dir(mProgsDir + "/" + pro_name);
2022-08-25 18:37:24 +08:00
if(pro_dir.exists("pro.json")) {
QFile fPro(pro_dir.path() + "/pro.json");
fPro.open(QIODevice::ReadOnly);
QJsonDocument pro = QJsonDocument::fromJson(fPro.readAll());
fPro.close();
2022-10-27 15:07:45 +08:00
m_pwPorgramItemList.append(new ProgItem(mProgsDir, pro.object(), mProgTree,this));
2022-08-25 18:37:24 +08:00
}
}
}
2022-09-30 18:08:39 +08:00
if(settings.value("ProgramListSortOrder").toInt()==0) mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::AscendingOrder);
else mProgTree->sortByColumn(settings.value("ProgramListSortColumn").toInt(),Qt::SortOrder::DescendingOrder);
2022-08-25 18:37:24 +08:00
// ui->wProgramList->setSortingEnabled( false ); //不使能QT的自动排序
// ui->wProgramList->header()->setSortIndicatorShown( true ); // 设置三角标识符可见
// ui->wProgramList->header()->setSectionsClickable( true ); // 设置标题栏单击响应使能
// connect( ui->wProgramList->header(), SIGNAL( sectionClicked(int) ), this, SLOT( OnClickColumn(int) ) );
}
void ProgPanel::OnClickColumn(int iColumn) {
2022-09-30 18:08:39 +08:00
if(iColumn!=ENUM_PROGRAMLISTHEADERITEM_CHECK && iColumn!=ENUM_PROGRAMLISTHEADERITEM_SEND) mProgTree->sortByColumn(iColumn, mProgTree->header()->sortIndicatorOrder());
2022-08-25 18:37:24 +08:00
}
void ProgPanel::changeEvent(QEvent *event) {
QWidget::changeEvent(event);
if(event->type() == QEvent::LanguageChange) transUi();
}
void ProgPanel::transUi() {
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_CHECK, 0, "");
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_NAME, 0, tr("Name"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_RESOLUTION, 0, tr("Resolution"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SIZE, 0, tr("File Size"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_LASTTIME, 0, tr("Last Modify"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT, 0, tr("Usb playback"));
m_headerItem->setData(ENUM_PROGRAMLISTHEADERITEM_SEND, 0, tr("Publish"));
bnNew->setText(tr("New"));
bnEdit->setText(tr("Edit"));
bnDelete->setText(tr("Delete"));
bnImport->setText(tr("Import"));
bnExport->setText(tr("Export"));
bnSend->setText(tr("Send"));
btnPlay->setText(tr("Play")+"/"+tr("Stop"));
for(int i=0;i<m_pwPorgramItemList.count();i++) m_pwPorgramItemList.at(i)->refreshLable();
}
void ProgPanel::onEditClicked(bool){
2022-09-30 18:08:39 +08:00
int cnt = mProgTree->topLevelItemCount();
2022-08-25 18:37:24 +08:00
for(int i=0; i<cnt; i++) {
2022-09-30 18:08:39 +08:00
if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i));
2022-10-27 15:07:45 +08:00
auto editor = new ProgEditorWin(item, gMainWin);
editor->show();
2022-08-25 18:37:24 +08:00
break;
}
}
}
bool ProgPanel::checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip){
2022-09-30 18:08:39 +08:00
int cnt = mProgTree->topLevelItemCount();
2022-08-25 18:37:24 +08:00
for(int i=0; i<cnt; i++) {
2022-09-30 18:08:39 +08:00
auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i));
2022-08-25 18:37:24 +08:00
if(item == skip) continue;
2022-10-27 15:07:45 +08:00
if(name == item->mName) {
2022-08-25 18:37:24 +08:00
QMessageBox::warning(this, tr("Warning"), tr("Program name conflicted"));
return true;
}
}
return false;
}
2023-04-18 14:14:46 +08:00
void ProgPanel::onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks, QList<int> &splitWidths, int max)
2022-08-25 18:37:24 +08:00
{
if(checkIfNameRepeated(name)) return;
2023-04-18 14:14:46 +08:00
auto item = new ProgItem(mProgsDir, name, res.width(), res.height(), remarks, splitWidths, max, mProgTree, this);
2022-08-25 18:37:24 +08:00
item->save();//保存pro.json
2022-09-30 18:08:39 +08:00
mProgTree->adjustCheckState();
2022-10-27 15:07:45 +08:00
auto editor = new ProgEditorWin(item, gMainWin);
editor->show();
2022-08-25 18:37:24 +08:00
}
void ProgPanel::onDeleteClicked(bool){
auto res = QMessageBox::information(this, tr("Tip Info"), tr("You will delete the selected solution(s),are you sure?"), QMessageBox::Ok, QMessageBox::Cancel);
if(res == QMessageBox::Ok) {
2022-09-30 18:08:39 +08:00
int cnt = mProgTree->topLevelItemCount();
QList<ProgItem*> list;
2022-08-25 18:37:24 +08:00
for(int i=0; i<cnt; i++) {
2022-09-30 18:08:39 +08:00
if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) {
auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i));
2022-08-25 18:37:24 +08:00
list.push_back(item);
}
}
while(!list.isEmpty()) {
2022-09-30 18:08:39 +08:00
auto item = list.takeFirst();
2022-08-25 18:37:24 +08:00
item->del();
delete item;
}
2022-09-30 18:08:39 +08:00
mProgTree->adjustCheckState();
2022-08-25 18:37:24 +08:00
}
}
void ProgPanel::FilterProgram(const QString &strtemp){
if (strtemp.isEmpty()) //显示全部
{
2022-09-30 18:08:39 +08:00
for (int i = 0; i< mProgTree->topLevelItemCount(); ++i)
2022-08-25 18:37:24 +08:00
{
2022-09-30 18:08:39 +08:00
QTreeWidgetItem* topItem = mProgTree->topLevelItem(i);
mProgTree->setRowHidden(i,mProgTree->indexFromItem(topItem->parent()),false);
2022-08-25 18:37:24 +08:00
}
}
else
{
2022-09-30 18:08:39 +08:00
QList<QTreeWidgetItem*> resultList = mProgTree->findItems(strtemp, Qt::MatchContains,ENUM_PROGRAMLISTHEADERITEM_NAME); //搜索结果
2022-08-25 18:37:24 +08:00
if (resultList.size() > 0)
{
2022-09-30 18:08:39 +08:00
for (int i = 0; i< mProgTree->topLevelItemCount(); ++i)
2022-08-25 18:37:24 +08:00
{
2022-09-30 18:08:39 +08:00
QTreeWidgetItem* topItem = mProgTree->topLevelItem(i);
2022-08-25 18:37:24 +08:00
if (resultList.contains(topItem))
2022-09-30 18:08:39 +08:00
mProgTree->setRowHidden(i,mProgTree->indexFromItem(topItem->parent()),false); //显示匹配的结果
2022-08-25 18:37:24 +08:00
else
2022-09-30 18:08:39 +08:00
mProgTree->setRowHidden(i,mProgTree->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
2022-08-25 18:37:24 +08:00
}
}
else {
2022-09-30 18:08:39 +08:00
QList<QTreeWidgetItem*> resultList1 = mProgTree->findItems(strtemp, Qt::MatchContains,ENUM_PROGRAMLISTHEADERITEM_RESOLUTION); //搜索结果
2022-08-25 18:37:24 +08:00
if (resultList1.size() > 0){
2022-09-30 18:08:39 +08:00
for (int i = 0; i< mProgTree->topLevelItemCount(); ++i){
QTreeWidgetItem* topItem = mProgTree->topLevelItem(i);
if (resultList1.contains(topItem)) mProgTree->setRowHidden(i,mProgTree->indexFromItem(topItem->parent()),false); //显示匹配的结果
else mProgTree->setRowHidden(i,mProgTree->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
2022-08-25 18:37:24 +08:00
}
}
else {
2022-09-30 18:08:39 +08:00
for (int i = 0; i< mProgTree->topLevelItemCount(); ++i){
QTreeWidgetItem* topItem = mProgTree->topLevelItem(i);
mProgTree->setRowHidden(i,mProgTree->indexFromItem(topItem->parent()),true); //隐藏不匹配的结果
2022-08-25 18:37:24 +08:00
}
}
}
}
}
2023-04-25 16:30:58 +08:00
ProgPortDlg::ProgPortDlg(QWidget *parent, QString title) : QDialog(parent) {
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
2023-04-18 14:14:46 +08:00
resize(600, 400);
2023-04-25 16:30:58 +08:00
setWindowTitle(title);
2023-04-18 14:14:46 +08:00
auto vBox = new VBox(this);
2023-04-25 16:30:58 +08:00
vBox->setContentsMargins(0, 0, 0, 6);
2023-04-18 14:14:46 +08:00
table = new QTableWidget(0, 2);
table->setSelectionMode(QTableWidget::NoSelection);
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
table->setAlternatingRowColors(true);
table->horizontalHeader()->setBackgroundRole(QPalette::Window);
table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
table->horizontalHeader()->resizeSection(1, 200);
table->setHorizontalHeaderLabels({tr("Solution Name"), tr("Progress")});
vBox->addWidget(table);
2023-04-25 16:30:58 +08:00
auto hBox = new HBox(vBox);
2023-04-18 14:14:46 +08:00
hBox->addStretch();
bnOK = new QPushButton(title);
hBox->addWidget(bnOK);
auto bnDone = new QPushButton(tr("Done"));
connect(bnDone, &QPushButton::clicked, this, &BaseDlg::accept);
hBox->addWidget(bnDone);
}