void ConfigHelper::onConnectionStateChanged(bool running) { Connection *c = qobject_cast<Connection*>(sender()); if (!c) { return; } if (running) { emit message(c->getName() + " " + tr("connected")); } else { emit message(c->getName() + " " + tr("disconnected")); } QFont font; font.setBold(running); int size = model->rowCount(); int row = 0; for (; row < size; ++row) { if(model->data(model->index(row, 0), Qt::UserRole).value<Connection *>() == c) { break; } } if(row == size) { //row doesn't exist (already deleted) return; } int cols = model->columnCount(); for (int i = 0; i < cols; ++i) { model->item(row, i)->setFont(font); } emit rowStatusChanged(row, running); }
void ConnectionTableModel::onConnectionStateChanged(bool running) { ConnectionItem *item = qobject_cast<ConnectionItem*>(sender()); int row = items.indexOf(item); emit dataChanged(this->index(row, 0), this->index(row, rowCount() - 1)); emit rowStatusChanged(row, running); }
void ConnectionTableModel::onConnectionStateChanged(bool running) { ConnectionItem* item = qobject_cast<ConnectionItem*>(sender()); int row = items.indexOf(item); QModelIndex statusIndex = this->index(row, 2); emit dataChanged(statusIndex, statusIndex); emit rowStatusChanged(row, running); }