Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #635 from x1596357/fix/data-usage-not-automaticall…
Browse files Browse the repository at this point in the history
…y-updated

Update data usage in real time
  • Loading branch information
librehat authored Jan 4, 2018
2 parents 32efa49 + 65810f5 commit 2104cb7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/connectionitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/connectionitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions src/connectiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));
}
1 change: 1 addition & 0 deletions src/connectiontablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.