Show find-replace progress bar
This commit is contained in:
parent
a7aa93b9e9
commit
fb91a094fc
@ -139,6 +139,9 @@ void FindReplaceDialog::on_field_currentIndexChanged(int index)
|
|||||||
void FindReplaceDialog::on_buttonBox_accepted()
|
void FindReplaceDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
FieldAttrib fieldAttrib = fieldAttrib_.at(field->currentIndex());
|
FieldAttrib fieldAttrib = fieldAttrib_.at(field->currentIndex());
|
||||||
|
action_->protocolField = QString("%1 %2")
|
||||||
|
.arg(protocol->currentText())
|
||||||
|
.arg(field->currentText());
|
||||||
action_->protocolNumber = protocolId_;
|
action_->protocolNumber = protocolId_;
|
||||||
action_->fieldIndex = fieldAttrib.index;
|
action_->fieldIndex = fieldAttrib.index;
|
||||||
action_->fieldBitSize = fieldAttrib.bitSize;
|
action_->fieldBitSize = fieldAttrib.bitSize;
|
||||||
|
@ -45,6 +45,7 @@ private:
|
|||||||
|
|
||||||
struct FindReplaceDialog::Action
|
struct FindReplaceDialog::Action
|
||||||
{
|
{
|
||||||
|
QString protocolField;
|
||||||
quint32 protocolNumber;
|
quint32 protocolNumber;
|
||||||
quint32 fieldIndex;
|
quint32 fieldIndex;
|
||||||
int fieldBitSize;
|
int fieldBitSize;
|
||||||
|
@ -312,11 +312,18 @@ void StreamsWidget::on_actionFind_Replace_triggered()
|
|||||||
|
|
||||||
FindReplaceDialog findReplace(&action, this);
|
FindReplaceDialog findReplace(&action, this);
|
||||||
if (findReplace.exec() == QDialog::Accepted) {
|
if (findReplace.exec() == QDialog::Accepted) {
|
||||||
|
QProgressDialog progress(this);
|
||||||
|
progress.setLabelText(tr("Replacing %1 ...").arg(action.protocolField));
|
||||||
|
progress.setWindowModality(Qt::WindowModal);
|
||||||
int c, fc = 0, sc = 0; // replace counts
|
int c, fc = 0, sc = 0; // replace counts
|
||||||
Port &port = plm->port(currentPortIndex_);
|
Port &port = plm->port(currentPortIndex_);
|
||||||
// TODO: progress bar
|
// TODO: progress bar
|
||||||
if (action.selectedStreamsOnly) {
|
if (action.selectedStreamsOnly) {
|
||||||
foreach(QModelIndex index, selectionModel->selectedRows()) {
|
QModelIndexList selected = selectionModel->selectedRows();
|
||||||
|
int count = selected.size();
|
||||||
|
progress.setMaximum(count);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
QModelIndex index = selected.at(i);
|
||||||
Stream *stream = port.mutableStreamByIndex(index.row(), false);
|
Stream *stream = port.mutableStreamByIndex(index.row(), false);
|
||||||
c = stream->protocolFieldReplace(action.protocolNumber,
|
c = stream->protocolFieldReplace(action.protocolNumber,
|
||||||
action.fieldIndex,
|
action.fieldIndex,
|
||||||
@ -329,9 +336,13 @@ void StreamsWidget::on_actionFind_Replace_triggered()
|
|||||||
fc += c;
|
fc += c;
|
||||||
sc++;
|
sc++;
|
||||||
}
|
}
|
||||||
|
progress.setValue(i+1);
|
||||||
|
if (progress.wasCanceled())
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int count = tvStreamList->model()->rowCount();
|
int count = tvStreamList->model()->rowCount();
|
||||||
|
progress.setMaximum(count);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
Stream *stream = port.mutableStreamByIndex(i, false);
|
Stream *stream = port.mutableStreamByIndex(i, false);
|
||||||
c = stream->protocolFieldReplace(action.protocolNumber,
|
c = stream->protocolFieldReplace(action.protocolNumber,
|
||||||
@ -345,6 +356,9 @@ void StreamsWidget::on_actionFind_Replace_triggered()
|
|||||||
fc += c;
|
fc += c;
|
||||||
sc++;
|
sc++;
|
||||||
}
|
}
|
||||||
|
progress.setValue(i+1);
|
||||||
|
if (progress.wasCanceled())
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user