ledok
This commit is contained in:
parent
7fae3c0bd3
commit
26f8cb58ee
|
@ -9,16 +9,15 @@ public:
|
|||
}
|
||||
QWidget *fdIsSelAll;
|
||||
protected:
|
||||
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override;
|
||||
};
|
||||
void CheckableHeader::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const{
|
||||
void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const override {
|
||||
QHeaderView::paintSection(painter, rect, logicalIndex);
|
||||
if(logicalIndex == 0) fdIsSelAll->setGeometry(rect);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
LoQTreeWidget::LoQTreeWidget(QWidget *parent) : QTreeWidget(parent), m_checkState(CheckNone) {
|
||||
fdIsSelAll = new QCheckBox();
|
||||
fdIsSelAll = new QCheckBox;
|
||||
fdIsSelAll->setStyleSheet("QCheckBox{margin-left: 5px;}");
|
||||
m_header = new CheckableHeader(Qt::Horizontal, fdIsSelAll);
|
||||
setHeader(m_header);
|
||||
|
|
|
@ -142,6 +142,39 @@ QPushButton:hover {background-color: #08b;}
|
|||
|
||||
vBox->addLayout(mHBox);
|
||||
|
||||
m_headerItem = new QTreeWidgetItem();
|
||||
for(int i=1; i<DeviceTable_End; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
|
||||
mDeviceTable->setHeaderItem(m_headerItem);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Check, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Check, 36);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Online, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Online, 48);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_ID, QHeaderView::Stretch);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_IP, QHeaderView::Stretch);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_ScreenSize, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_ScreenSize, 108);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Remark, QHeaderView::Stretch);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Brightness, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Brightness, 108);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Power, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Power, 84);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Password, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Password, 72);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Info, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Info, 72);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Screenshot, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Screenshot, 72);
|
||||
|
||||
connect(mDeviceTable, &LoQTreeWidget::sigCheckStateChanged, this, [=] {
|
||||
gSelCards.clear();
|
||||
int cnt = mDeviceTable->topLevelItemCount();
|
||||
for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) gSelCards.append(static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->mCard);
|
||||
emit sigSelectedDeviceList();
|
||||
});
|
||||
mDeviceTable->hideColumn(0);
|
||||
mDeviceTable->fdIsSelAll->hide();
|
||||
mDeviceTable->sortItems(DeviceTable_ID, Qt::AscendingOrder);
|
||||
|
||||
connect(&mUdpTimer, &QTimer::timeout, this, &DevicePanel::sendGetInfo);
|
||||
connect(&mUdpSocket, &QUdpSocket::readyRead, this, [this] {
|
||||
while(mUdpSocket.hasPendingDatagrams()) {
|
||||
|
@ -237,38 +270,6 @@ QPushButton:hover {background-color: #08b;}
|
|||
}
|
||||
});
|
||||
|
||||
m_headerItem = new QTreeWidgetItem();
|
||||
for(int i=1; i<DeviceTable_End; i++) m_headerItem->setTextAlignment(i, Qt::AlignCenter);
|
||||
mDeviceTable->setHeaderItem(m_headerItem);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Check, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Check, 36);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Online, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Online, 48);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_ID, QHeaderView::Stretch);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_IP, QHeaderView::Stretch);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_ScreenSize, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_ScreenSize, 108);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Remark, QHeaderView::Stretch);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Brightness, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Brightness, 108);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Power, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Power, 84);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Password, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Password, 72);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Info, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Info, 72);
|
||||
mDeviceTable->header()->setSectionResizeMode(DeviceTable_Screenshot, QHeaderView::Fixed);
|
||||
mDeviceTable->setColumnWidth(DeviceTable_Screenshot, 72);
|
||||
|
||||
connect(mDeviceTable, &LoQTreeWidget::sigCheckStateChanged, this, [=] {
|
||||
gSelCards.clear();
|
||||
int cnt = mDeviceTable->topLevelItemCount();
|
||||
for(int i=0; i<cnt; i++) if(mDeviceTable->topLevelItem(i)->checkState(0) == Qt::Checked) gSelCards.append(static_cast<DeviceItem*>(mDeviceTable->topLevelItem(i))->mCard);
|
||||
emit sigSelectedDeviceList();
|
||||
});
|
||||
mDeviceTable->hideColumn(0);
|
||||
mDeviceTable->fdIsSelAll->hide();
|
||||
|
||||
specifyIPDlg = new QDialog(this);
|
||||
specifyIPDlg->setWindowTitle(tr("Specify IP"));
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
|||
hBox->addWidget(txtSearch);
|
||||
|
||||
table = new Table{
|
||||
{"id", "ID", 140},
|
||||
{"id", "ID", 130},
|
||||
{"online", tr("Online"), 40},
|
||||
{"ip", "IP", 100},
|
||||
{"size", tr("Screen Size"), 80},
|
||||
|
@ -66,7 +66,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
|||
connect(fdCheckAll, &QCheckBox::stateChanged, this, [=](int state) {
|
||||
if(state==Qt::PartiallyChecked) return;
|
||||
int cnt = table->rowCount();
|
||||
for(int i=0; i<cnt; i++) table->itemValid(i, colId)->setCheckState((Qt::CheckState) state);
|
||||
for(int rr=0; rr<cnt; rr++) if(! table->isRowHidden(rr)) table->itemValid(rr, colId)->setCheckState((Qt::CheckState) state);
|
||||
});
|
||||
connect(table, &Table::updGeos, this, [=] {
|
||||
fdCheckAll->move(table->verticalHeader()->size().width() + 8, 2);
|
||||
|
@ -78,7 +78,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
|||
item->setCheckState(state);
|
||||
int cnt = table->rowCount();
|
||||
fdCheckAll->blockSignals(true);
|
||||
for(int i=0; i<cnt; i++) if(table->itemValid(i, colId)->checkState()!=state) {
|
||||
for(int rr=0; rr<cnt; rr++) if(! table->isRowHidden(rr) && table->itemValid(rr, colId)->checkState()!=state) {
|
||||
fdCheckAll->setCheckState(Qt::PartiallyChecked);
|
||||
goto end;
|
||||
}
|
||||
|
@ -86,7 +86,11 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
|||
end:fdCheckAll->blockSignals(false);
|
||||
};
|
||||
connect(table, &Table::cellClicked, table, cellClicked);
|
||||
connect(table, &Table::cellEntered, table, cellClicked);
|
||||
connect(table, &Table::cellEntered, table, [=](int row, int column) {
|
||||
if(column!=colId) return;
|
||||
if((QApplication::mouseButtons() & Qt::LeftButton) == 0) return;
|
||||
cellClicked(row, column);
|
||||
});
|
||||
|
||||
auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
btnBox->button(QDialogButtonBox::Ok)->setText(tr("Publish"));
|
||||
|
@ -95,18 +99,18 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
|||
if(mWaitCnt > 0) return;
|
||||
int cnt = table->rowCount();
|
||||
int sentCnt{0};
|
||||
for(int i=0; i<cnt; i++) {
|
||||
auto fdId = table->itemValid(i, colId);
|
||||
for(int rr=0; rr<cnt; rr++) if(! table->isRowHidden(rr)) {
|
||||
auto fdId = table->itemValid(rr, colId);
|
||||
if(fdId->checkState()!=Qt::Checked) continue;
|
||||
if(fdId->data(isSending).toBool()) continue;
|
||||
auto btnUnlock = (QPushButton*) table->cellWidget(i, "encrypt");
|
||||
auto fdRemarks = table->itemValid(i, "remarks");
|
||||
auto btnUnlock = (QPushButton*) table->cellWidget(rr, "encrypt");
|
||||
auto fdRemarks = table->itemValid(rr, "remarks");
|
||||
if(btnUnlock && btnUnlock->property("isLocked").toBool()) {
|
||||
fdRemarks->setText(tr("This screen is encrypted"));
|
||||
fdRemarks->setForeground(Qt::red);
|
||||
continue;
|
||||
}
|
||||
auto fdProgress = (QProgressBar*) table->cellWidget(i, "progress");
|
||||
auto fdProgress = (QProgressBar*) table->cellWidget(rr, "progress");
|
||||
fdProgress->setValue(0);
|
||||
if(sentCnt>=5) {
|
||||
fdRemarks->setText(" "+tr("Waiting")+" ...");
|
||||
|
@ -116,7 +120,7 @@ SendProgramDialog::SendProgramDialog(QString progName, QWidget *parent) : QDialo
|
|||
}
|
||||
fdId->setData(isSending, true);
|
||||
fdRemarks->setText("");
|
||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", table->text(i, "ip"), 3333);
|
||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", table->text(rr, "ip"), 3333);
|
||||
connect(sendProg, &SendProgThread::emErr, fdProgress, [=](QString strTip) {
|
||||
fdId->setData(isSending, false);
|
||||
if(strTip=="OK") {
|
||||
|
@ -155,7 +159,7 @@ void SendProgramDialog::addRow(LedCard card) {
|
|||
|
||||
auto item = table->setText(cnt, "id", card.id);
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
item->setFlags(Qt::ItemIsEnabled);
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsUserCheckable);
|
||||
|
||||
auto fdOnline = new QLabel;
|
||||
fdOnline->setAlignment(Qt::AlignCenter);
|
||||
|
@ -229,20 +233,20 @@ void SendProgramDialog::closeEvent(QCloseEvent *) {
|
|||
void SendProgramDialog::sendNext() {
|
||||
if(mWaitCnt <= 0) return;
|
||||
int cnt = table->rowCount();
|
||||
for(int i=0; i<cnt; i++) {
|
||||
auto fdId = table->itemValid(i, "id");
|
||||
for(int rr=0; rr<cnt; rr++) if(! table->isRowHidden(rr)) {
|
||||
auto fdId = table->itemValid(rr, "id");
|
||||
if(fdId->checkState()!=Qt::Checked) continue;
|
||||
if(fdId->data(isSending).toBool()) continue;
|
||||
auto btnUnlock = (QPushButton*) table->cellWidget(i, "encrypt");
|
||||
auto btnUnlock = (QPushButton*) table->cellWidget(rr, "encrypt");
|
||||
if(btnUnlock && btnUnlock->property("isLocked").toBool()) continue;
|
||||
auto fdRemarks = table->itemValid(i, "remarks");
|
||||
auto fdRemarks = table->itemValid(rr, "remarks");
|
||||
if(! fdRemarks->text().startsWith(" ")) continue;
|
||||
fdRemarks->setText("");
|
||||
auto fdProgress = (QProgressBar*) table->cellWidget(i, "progress");
|
||||
auto fdProgress = (QProgressBar*) table->cellWidget(rr, "progress");
|
||||
fdProgress->setValue(0);
|
||||
fdId->setData(isSending, true);
|
||||
mWaitCnt--;
|
||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", table->text(i, "ip"), 3333);
|
||||
auto sendProg = new SendProgThread(programsDir()+"/"+mProgName+"_tmp", table->text(rr, "ip"), 3333);
|
||||
connect(sendProg, &SendProgThread::emErr, fdProgress, [=](QString strTip) {
|
||||
fdId->setData(isSending, false);
|
||||
if(strTip=="OK") {
|
||||
|
@ -264,6 +268,6 @@ void SendProgramDialog::sendNext() {
|
|||
|
||||
void SendProgramDialog::refresh() {
|
||||
int cnt = gDevicePanel->mDeviceTable->topLevelItemCount();
|
||||
for(int i=0; i<cnt; i++) addRow(static_cast<DeviceItem*>(gDevicePanel->mDeviceTable->topLevelItem(i))->mCard);
|
||||
for(int rr=0; rr<cnt; rr++) addRow(((DeviceItem*)gDevicePanel->mDeviceTable->topLevelItem(rr))->mCard);
|
||||
label->setText(tr("All")+": "+QString::number(cnt));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user