diff --git a/src/blackmisc/blackmisc.pro b/src/blackmisc/blackmisc.pro index cffd68ea6..440090445 100644 --- a/src/blackmisc/blackmisc.pro +++ b/src/blackmisc/blackmisc.pro @@ -53,6 +53,7 @@ SOURCES += *.cpp \ $$PWD/input/*.cpp \ $$PWD/math/*.cpp \ $$PWD/network/*.cpp \ + $$PWD/network/settings/*.cpp \ $$PWD/pq/*.cpp \ $$PWD/simulation/*.cpp \ $$PWD/simulation/data/*.cpp \ diff --git a/src/blackmisc/network/network.h b/src/blackmisc/network/network.h index 05af23235..a6c59026b 100644 --- a/src/blackmisc/network/network.h +++ b/src/blackmisc/network/network.h @@ -41,5 +41,6 @@ #include "blackmisc/network/user.h" #include "blackmisc/network/userlist.h" #include "blackmisc/network/voicecapabilities.h" +#include "blackmisc/network/settings/networksettings.h" #endif // guard diff --git a/src/blackmisc/network/registermetadatanetwork.cpp b/src/blackmisc/network/registermetadatanetwork.cpp index 81473ea74..be8fd864f 100644 --- a/src/blackmisc/network/registermetadatanetwork.cpp +++ b/src/blackmisc/network/registermetadatanetwork.cpp @@ -42,6 +42,7 @@ namespace BlackMisc CUser::registerMetadata(); CUserList::registerMetadata(); CVoiceCapabilities::registerMetadata(); + Settings::CNetworkSettings::registerMetadata(); } } // ns } // ns diff --git a/src/blackmisc/network/settings/networksettings.cpp b/src/blackmisc/network/settings/networksettings.cpp new file mode 100644 index 000000000..3e0a4df0c --- /dev/null +++ b/src/blackmisc/network/settings/networksettings.cpp @@ -0,0 +1,53 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "networksettings.h" +#include +#include +#include "blackmisc/stringutils.h" + +namespace BlackMisc +{ + namespace Network + { + namespace Settings + { + QString CNetworkSettings::convertToQString(bool i18n) const + { + Q_UNUSED(i18n); + return QStringLiteral("dyn.offset: ") % boolToYesNo(this->isUsingDynamicOffsetTimes()); + } + + CVariant CNetworkSettings::propertyByIndex(const CPropertyIndex &index) const + { + if (index.isMyself()) { return CVariant::from(*this); } + const ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexDynamicOffsetTime: return CVariant::fromValue(m_dynamicOffsetTimes); + default: break; + } + return CValueObject::propertyByIndex(index); + } + + void CNetworkSettings::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) + { + if (index.isMyself()) { (*this) = variant.to(); return; } + const ColumnIndex i = index.frontCasted(); + switch (i) + { + case IndexDynamicOffsetTime: this->setDynamicOffsetTimes(variant.toBool()); break; + default: break; + } + CValueObject::setPropertyByIndex(index, variant); + } + + } // ns + } // ns +} // ns diff --git a/src/blackmisc/network/settings/networksettings.h b/src/blackmisc/network/settings/networksettings.h new file mode 100644 index 000000000..46c67a3b2 --- /dev/null +++ b/src/blackmisc/network/settings/networksettings.h @@ -0,0 +1,73 @@ +/* Copyright (C) 2018 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKMISC_NETWORK_SETTINGS_NETWORKSETTINGS_H +#define BLACKMISC_NETWORK_SETTINGS_NETWORKSETTINGS_H + +#include "blackmisc/blackmiscexport.h" +#include "blackmisc/metaclass.h" +#include "blackmisc/propertyindex.h" +#include "blackmisc/valueobject.h" +#include "blackmisc/variant.h" + +#include +#include +#include + +namespace BlackMisc +{ + namespace Network + { + namespace Settings + { + //! Network settings + class BLACKMISC_EXPORT CNetworkSettings : public CValueObject + { + public: + //! Properties by index + enum ColumnIndex + { + IndexDynamicOffsetTime = CPropertyIndex::GlobalIndexCNetworkSettings, + }; + + //! Constructor + CNetworkSettings() {} + + //! Dynamic offset values? + bool isUsingDynamicOffsetTimes() const { return m_dynamicOffsetTimes; } + + //! Dynamic offset values? + void setDynamicOffsetTimes(bool dynamic) { m_dynamicOffsetTimes = dynamic; } + + //! \copydoc BlackMisc::Mixin::String::toQString + QString convertToQString(bool i18n = false) const; + + //! \copydoc BlackMisc::Mixin::Index::propertyByIndex + CVariant propertyByIndex(const CPropertyIndex &index) const; + + //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex + void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant); + + private: + bool m_dynamicOffsetTimes = false; + + BLACK_METACLASS( + CNetworkSettings, + BLACK_METAMEMBER(dynamicOffsetTimes) + ); + }; + } // ns + } // ns +} // ns + +Q_DECLARE_METATYPE(BlackMisc::Network::Settings::CNetworkSettings) + +#endif // guard diff --git a/src/blackmisc/propertyindex.h b/src/blackmisc/propertyindex.h index ff9acdc98..f6ebc9021 100644 --- a/src/blackmisc/propertyindex.h +++ b/src/blackmisc/propertyindex.h @@ -122,9 +122,10 @@ namespace BlackMisc GlobalIndexCRole = 6300, GlobalIndexCServer = 6400, GlobalIndexCFsdSetup = 6500, - GlobalIndexCUrl = 6600, - GlobalIndexCUrlLog = 6700, - GlobalIndexCRemoteFile = 6800, + GlobalIndexCNetworkSettings = 6600, + GlobalIndexCUrl = 6700, + GlobalIndexCUrlLog = 6800, + GlobalIndexCRemoteFile = 6900, GlobalIndexCEcosystem = 7000, GlobalIndexCRawFsdMessage = 7100, GlobalIndexCAircraftModel = 8000,