Permalink
Browse files

Merge pull request #635 from x1596357/fix/data-usage-not-automaticall…

…y-updated

Update data usage in real time
  • Loading branch information...
librehat committed Jan 4, 2018
2 parents 32efa49 + 65810f5 commit 2104cb782216ffd49d6489cfb41a86f7a91f98d5
Showing with 11 additions and 0 deletions.
  1. +1 −0 src/connectionitem.cpp
  2. +1 −0 src/connectionitem.h
  3. +8 −0 src/connectiontablemodel.cpp
  4. +1 −0 src/connectiontablemodel.h
View
@@ -10,6 +10,7 @@ ConnectionItem::ConnectionItem(Connection *_con, QObject *parent) :
con->setParent(this);
connect(con, &Connection::stateChanged, this, &ConnectionItem::onConnectionStateChanged);
connect(con, &Connection::stateChanged, this, &ConnectionItem::stateChanged);
connect(con, &Connection::dataUsageChanged, this, &ConnectionItem::dataUsageChanged);
connect(con, &Connection::latencyAvailable, this, &ConnectionItem::onConnectionPingFinished);
connect(con, &Connection::latencyAvailable, this, &ConnectionItem::latencyChanged);
connect(con, &Connection::startFailed, this, &ConnectionItem::onStartFailed);
View
@@ -39,6 +39,7 @@ class ConnectionItem : public QObject
signals:
void message(const QString&);
void stateChanged(bool);
void dataUsageChanged(const quint64 &current, const quint64 &total);
void latencyChanged();
private:
@@ -106,6 +106,7 @@ bool ConnectionTableModel::appendConnection(Connection *con, const QModelIndex &
connect(newItem, &ConnectionItem::message, this, &ConnectionTableModel::message);
connect(newItem, &ConnectionItem::stateChanged, this, &ConnectionTableModel::onConnectionStateChanged);
connect(newItem, &ConnectionItem::latencyChanged, this, &ConnectionTableModel::onConnectionLatencyChanged);
connect(newItem, &ConnectionItem::dataUsageChanged, this, &ConnectionTableModel::onConnectionDataUsageChanged);
beginInsertRows(parent, items.count(), items.count());
items.append(newItem);
endInsertRows();
@@ -149,3 +150,10 @@ void ConnectionTableModel::onConnectionLatencyChanged()
int row = items.indexOf(item);
emit dataChanged(this->index(row, 3), this->index(row, 3));
}
void ConnectionTableModel::onConnectionDataUsageChanged()
{
ConnectionItem *item = qobject_cast<ConnectionItem*>(sender());
int row = items.indexOf(item);
emit dataChanged(this->index(row, 5), this->index(row, 6));
}
@@ -58,6 +58,7 @@ public slots:
private slots:
void onConnectionStateChanged(bool running);
void onConnectionLatencyChanged();
void onConnectionDataUsageChanged();
};
#endif // CONNECTIONTABLEMODEL_H

0 comments on commit 2104cb7

Please sign in to comment.