Removed / Consolidated unnecessary header files

This commit is contained in:
Jonathan White 2021-07-11 21:30:20 -04:00
parent 6b14b5dc27
commit 9b2b861a2a
9 changed files with 25 additions and 127 deletions

View File

@ -36,7 +36,6 @@ set(keepassx_SOURCES
core/Base32.cpp core/Base32.cpp
core/Bootstrap.cpp core/Bootstrap.cpp
core/Clock.cpp core/Clock.cpp
core/Compare.cpp
core/Config.cpp core/Config.cpp
core/CsvParser.cpp core/CsvParser.cpp
core/CustomData.cpp core/CustomData.cpp

View File

@ -18,8 +18,8 @@
#include "BrowserEntryConfig.h" #include "BrowserEntryConfig.h"
#include "browser/Variant.h"
#include "core/Entry.h" #include "core/Entry.h"
#include "core/Tools.h"
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
@ -105,7 +105,7 @@ bool BrowserEntryConfig::load(const Entry* entry)
void BrowserEntryConfig::save(Entry* entry) void BrowserEntryConfig::save(Entry* entry)
{ {
QVariantMap v = qo2qv(this); QVariantMap v = Tools::qo2qvm(this);
QJsonObject o = QJsonObject::fromVariantMap(v); QJsonObject o = QJsonObject::fromVariantMap(v);
QByteArray json = QJsonDocument(o).toJson(QJsonDocument::Compact); QByteArray json = QJsonDocument(o).toJson(QJsonDocument::Compact);
entry->customData()->set(KEEPASSXCBROWSER_NAME, json); entry->customData()->set(KEEPASSXCBROWSER_NAME, json);

View File

@ -29,7 +29,7 @@ if(WITH_XC_BROWSER)
BrowserSettings.cpp BrowserSettings.cpp
BrowserShared.cpp BrowserShared.cpp
NativeMessageInstaller.cpp NativeMessageInstaller.cpp
Variant.cpp) )
add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES}) add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES})
target_link_libraries(keepassxcbrowser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN2_LIBRARIES}) target_link_libraries(keepassxcbrowser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN2_LIBRARIES})

View File

@ -1,38 +0,0 @@
/*
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QJsonObject>
#include <QMetaProperty>
QVariantMap qo2qv(const QObject* object, const QStringList& ignoredProperties)
{
QVariantMap result;
const QMetaObject* metaobject = object->metaObject();
int count = metaobject->propertyCount();
for (int i = 0; i < count; ++i) {
QMetaProperty metaproperty = metaobject->property(i);
const char* name = metaproperty.name();
if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) {
continue;
}
QVariant value = object->property(name);
result[QLatin1String(name)] = value;
}
return result;
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VARIANT_H
#define VARIANT_H
#include <QVariantMap>
QVariantMap qo2qv(const QObject* object,
const QStringList& ignoredProperties = QStringList(QString(QLatin1String("objectName"))));
#endif // VARIANT_H

View File

@ -1,16 +0,0 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

View File

@ -25,6 +25,7 @@
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QImageReader> #include <QImageReader>
#include <QLocale> #include <QLocale>
#include <QMetaProperty>
#include <QRegularExpression> #include <QRegularExpression>
#include <QStringList> #include <QStringList>
#include <QUrl> #include <QUrl>
@ -342,4 +343,23 @@ namespace Tools
return subbed; return subbed;
} }
QVariantMap qo2qvm(const QObject* object, const QStringList& ignoredProperties)
{
QVariantMap result;
const QMetaObject* metaobject = object->metaObject();
int count = metaobject->propertyCount();
for (int i = 0; i < count; ++i) {
QMetaProperty metaproperty = metaobject->property(i);
const char* name = metaproperty.name();
if (ignoredProperties.contains(QLatin1String(name)) || (!metaproperty.isReadable())) {
continue;
}
QVariant value = object->property(name);
result[QLatin1String(name)] = value;
}
return result;
}
} // namespace Tools } // namespace Tools

View File

@ -72,6 +72,8 @@ namespace Tools
return version; return version;
} }
QVariantMap qo2qvm(const QObject* object, const QStringList& ignoredProperties = {"objectName"});
} // namespace Tools } // namespace Tools
#endif // KEEPASSX_TOOLS_H #endif // KEEPASSX_TOOLS_H

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) 2018 KeePassXC Team <team@keepassxc.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSXC_TESTGLOBAL_H
#define KEEPASSXC_TESTGLOBAL_H
#include "core/Group.h"
namespace QTest
{
template <> inline char* toString(const Group::TriState& triState)
{
QString value;
if (triState == Group::Inherit) {
value = "null";
} else if (triState == Group::Enable) {
value = "true";
} else {
value = "false";
}
return qstrdup(value.toLocal8Bit().constData());
}
} // namespace QTest
#endif // KEEPASSXC_TESTGLOBAL_H