Don't use newDirs/newDevs for endResetModel()
* These events might not be emitted in all error cases. So it would be wrong to rely on that. * Reduces redundant code.
This commit is contained in:
parent
67723bfa27
commit
ea2e26aace
|
@ -17,8 +17,6 @@ SyncthingDeviceModel::SyncthingDeviceModel(SyncthingConnection &connection, QObj
|
|||
: SyncthingModel(connection, parent)
|
||||
, m_devs(connection.devInfo())
|
||||
{
|
||||
connect(&m_connection, &SyncthingConnection::newConfig, this, &SyncthingDeviceModel::newConfig);
|
||||
connect(&m_connection, &SyncthingConnection::newDevices, this, &SyncthingDeviceModel::newDevices);
|
||||
connect(&m_connection, &SyncthingConnection::devStatusChanged, this, &SyncthingDeviceModel::devStatusChanged);
|
||||
}
|
||||
|
||||
|
@ -288,16 +286,6 @@ int SyncthingDeviceModel::columnCount(const QModelIndex &parent) const
|
|||
}
|
||||
}
|
||||
|
||||
void SyncthingDeviceModel::newConfig()
|
||||
{
|
||||
beginResetModel();
|
||||
}
|
||||
|
||||
void SyncthingDeviceModel::newDevices()
|
||||
{
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void SyncthingDeviceModel::devStatusChanged(const SyncthingDev &, int index)
|
||||
{
|
||||
const QModelIndex modelIndex1(this->index(index, 0, QModelIndex()));
|
||||
|
|
|
@ -39,8 +39,6 @@ public Q_SLOTS:
|
|||
const SyncthingDev *devInfo(const QModelIndex &index) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void newConfig();
|
||||
void newDevices();
|
||||
void devStatusChanged(const SyncthingDev &, int index);
|
||||
|
||||
private:
|
||||
|
|
|
@ -19,8 +19,6 @@ SyncthingDirectoryModel::SyncthingDirectoryModel(SyncthingConnection &connection
|
|||
: SyncthingModel(connection, parent)
|
||||
, m_dirs(connection.dirInfo())
|
||||
{
|
||||
connect(&m_connection, &SyncthingConnection::newConfig, this, &SyncthingDirectoryModel::newConfig);
|
||||
connect(&m_connection, &SyncthingConnection::newDirs, this, &SyncthingDirectoryModel::newDirs);
|
||||
connect(&m_connection, &SyncthingConnection::dirStatusChanged, this, &SyncthingDirectoryModel::dirStatusChanged);
|
||||
}
|
||||
|
||||
|
@ -349,16 +347,6 @@ int SyncthingDirectoryModel::columnCount(const QModelIndex &parent) const
|
|||
}
|
||||
}
|
||||
|
||||
void SyncthingDirectoryModel::newConfig()
|
||||
{
|
||||
beginResetModel();
|
||||
}
|
||||
|
||||
void SyncthingDirectoryModel::newDirs()
|
||||
{
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void SyncthingDirectoryModel::dirStatusChanged(const SyncthingDir &, int index)
|
||||
{
|
||||
const QModelIndex modelIndex1(this->index(index, 0, QModelIndex()));
|
||||
|
|
|
@ -40,8 +40,6 @@ public Q_SLOTS:
|
|||
const SyncthingDir *dirInfo(const QModelIndex &index) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void newConfig();
|
||||
void newDirs();
|
||||
void dirStatusChanged(const SyncthingDir &, int index);
|
||||
|
||||
private:
|
||||
|
|
|
@ -29,8 +29,6 @@ SyncthingDownloadModel::SyncthingDownloadModel(SyncthingConnection &connection,
|
|||
, m_pendingDownloads(0)
|
||||
, m_singleColumnMode(true)
|
||||
{
|
||||
connect(&m_connection, &SyncthingConnection::newConfig, this, &SyncthingDownloadModel::newConfig);
|
||||
connect(&m_connection, &SyncthingConnection::newDirs, this, &SyncthingDownloadModel::newDirs);
|
||||
connect(&m_connection, &SyncthingConnection::downloadProgressChanged, this, &SyncthingDownloadModel::downloadProgressChanged);
|
||||
}
|
||||
|
||||
|
@ -208,14 +206,14 @@ int SyncthingDownloadModel::columnCount(const QModelIndex &parent) const
|
|||
}
|
||||
}
|
||||
|
||||
void SyncthingDownloadModel::newConfig()
|
||||
void SyncthingDownloadModel::handleConfigInvalidated()
|
||||
{
|
||||
beginResetModel();
|
||||
m_pendingDirs.clear();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void SyncthingDownloadModel::newDirs()
|
||||
void SyncthingDownloadModel::handleNewConfigAvailable()
|
||||
{
|
||||
m_pendingDirs.reserve(m_connection.dirInfo().size());
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ Q_SIGNALS:
|
|||
void pendingDownloadsChanged(unsigned int pendingDownloads);
|
||||
|
||||
private Q_SLOTS:
|
||||
void newConfig();
|
||||
void newDirs();
|
||||
void handleConfigInvalidated() override;
|
||||
void handleNewConfigAvailable() override;
|
||||
void downloadProgressChanged();
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "./syncthingmodel.h"
|
||||
|
||||
#include "../connector/syncthingconnection.h"
|
||||
|
||||
namespace Data {
|
||||
|
||||
SyncthingModel::SyncthingModel(SyncthingConnection &connection, QObject *parent)
|
||||
|
@ -7,6 +9,8 @@ SyncthingModel::SyncthingModel(SyncthingConnection &connection, QObject *parent)
|
|||
, m_connection(connection)
|
||||
, m_brightColors(false)
|
||||
{
|
||||
connect(&m_connection, &SyncthingConnection::newConfig, this, &SyncthingModel::handleConfigInvalidated);
|
||||
connect(&m_connection, &SyncthingConnection::newConfigApplied, this, &SyncthingModel::handleNewConfigAvailable);
|
||||
}
|
||||
|
||||
const QVector<int> &SyncthingModel::colorRoles() const
|
||||
|
@ -26,4 +30,14 @@ void SyncthingModel::setBrightColors(bool brightColors)
|
|||
}
|
||||
}
|
||||
|
||||
void SyncthingModel::handleConfigInvalidated()
|
||||
{
|
||||
beginResetModel();
|
||||
}
|
||||
|
||||
void SyncthingModel::handleNewConfigAvailable()
|
||||
{
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
} // namespace Data
|
||||
|
|
|
@ -24,6 +24,11 @@ public:
|
|||
protected:
|
||||
virtual const QVector<int> &colorRoles() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
virtual void handleConfigInvalidated();
|
||||
virtual void handleNewConfigAvailable();
|
||||
|
||||
protected:
|
||||
Data::SyncthingConnection &m_connection;
|
||||
bool m_brightColors;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue