diff --git a/src/ciphermodel.cpp b/src/ciphermodel.cpp index ff130eaca264c5035c21e98b70f55b6426e2f42d..38f7430abe95eb2c96be81d9d14d20c7a7b1509b 100644 --- a/src/ciphermodel.cpp +++ b/src/ciphermodel.cpp @@ -39,6 +39,7 @@ public: static QVector<QByteArray> m_slSupportedCiphers; static QHash<QString,int> m_shMapping ; static bool m_sIsLoaded ; + bool m_UseDefault ; static void loadCiphers(); }; @@ -47,7 +48,7 @@ bool CipherModelPrivate::m_sIsLoaded = false; QVector<QByteArray> CipherModelPrivate::m_slSupportedCiphers; QHash<QString,int> CipherModelPrivate::m_shMapping; -CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent) +CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent),m_UseDefault(true) { if (!CipherModelPrivate::m_sIsLoaded) { const QStringList cs = DBus::ConfigurationManager::instance().getSupportedCiphers(DRing::Account::ProtocolNames::IP2IP); @@ -60,6 +61,7 @@ CipherModelPrivate::CipherModelPrivate(Account* parent) : m_pAccount(parent) foreach(const QString& cipher, parent->d_ptr->accountDetail(DRing::Account::ConfProperties::TLS::CIPHERS).split(' ')) { m_lChecked[m_shMapping[cipher]] = true; + m_UseDefault = false; } } @@ -133,3 +135,19 @@ bool CipherModel::setData( const QModelIndex& index, const QVariant &value, int } return false; } + +bool CipherModel::useDefault() const +{ + return d_ptr->m_UseDefault; +} + +void CipherModel::setUseDefault(bool value) +{ + d_ptr->m_UseDefault = value; + if (value) { + for (int i =0; i < d_ptr->m_slSupportedCiphers.size();i++) { + d_ptr->m_lChecked[i] = false; + } + emit dataChanged(index(0,0),index(d_ptr->m_slSupportedCiphers.size()-1,0)); + } +} diff --git a/src/ciphermodel.h b/src/ciphermodel.h index 1a44bc1a4f7856821bbf79b0b75cb76c9735de14..c340071e77a350c24ba79e1d9d46569b8ebcdbdc 100644 --- a/src/ciphermodel.h +++ b/src/ciphermodel.h @@ -42,6 +42,8 @@ class LIB_EXPORT CipherModel : public QAbstractListModel { public: + Q_PROPERTY(bool useDefault READ useDefault WRITE setUseDefault) + //Model functions virtual QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const override; virtual int rowCount ( const QModelIndex& parent = QModelIndex() ) const override; @@ -49,6 +51,12 @@ public: virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) override; virtual QHash<int,QByteArray> roleNames() const override; + //Getter + bool useDefault() const; + + //Setter + void setUseDefault(bool value); + private: //Private constructor, can only be called by 'Account'