From ad53b9bb3e6ca8468463c5a969d1aae848d893b9 Mon Sep 17 00:00:00 2001 From: execjosh Date: Sun, 28 Aug 2011 21:05:34 +0900 Subject: [PATCH] Rename "PhantomConfig" to "Config" --- src/{phantomconfig.cpp => config.cpp} | 66 +++++++++++++-------------- src/{phantomconfig.h => config.h} | 10 ++-- src/phantom.h | 4 +- src/phantomjs.pro | 4 +- 4 files changed, 42 insertions(+), 42 deletions(-) rename src/{phantomconfig.cpp => config.cpp} (77%) rename src/{phantomconfig.h => config.h} (96%) diff --git a/src/phantomconfig.cpp b/src/config.cpp similarity index 77% rename from src/phantomconfig.cpp rename to src/config.cpp index 8eb30494..5ee78fde 100644 --- a/src/phantomconfig.cpp +++ b/src/config.cpp @@ -28,18 +28,18 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "phantomconfig.h" +#include "config.h" #include #include // public: -PhantomConfig::PhantomConfig() +Config::Config() { resetToDefaults(); } -void PhantomConfig::load() +void Config::load() { resetToDefaults(); @@ -53,7 +53,7 @@ void PhantomConfig::load() loadConfigFile(getLocalConfigFilePath()); } -void PhantomConfig::loadConfigFile(const QString &filePath) +void Config::loadConfigFile(const QString &filePath) { QSettings settings(filePath, QSettings::IniFormat); QStringList keys = settings.allKeys(); @@ -101,62 +101,62 @@ void PhantomConfig::loadConfigFile(const QString &filePath) } } -bool PhantomConfig::autoLoadImages() const +bool Config::autoLoadImages() const { return m_autoLoadImages; } -void PhantomConfig::setAutoLoadImages(const bool value) +void Config::setAutoLoadImages(const bool value) { m_autoLoadImages = value; } -QString PhantomConfig::cookieFile() const +QString Config::cookieFile() const { return m_cookieFile; } -void PhantomConfig::setCookieFile(const QString &value) +void Config::setCookieFile(const QString &value) { m_cookieFile = value; } -bool PhantomConfig::diskCacheEnabled() const +bool Config::diskCacheEnabled() const { return m_diskCacheEnabled; } -void PhantomConfig::setDiskCacheEnabled(const bool value) +void Config::setDiskCacheEnabled(const bool value) { m_diskCacheEnabled = value; } -bool PhantomConfig::ignoreSslErrors() const +bool Config::ignoreSslErrors() const { return m_ignoreSslErrors; } -void PhantomConfig::setIgnoreSslErrors(const bool value) +void Config::setIgnoreSslErrors(const bool value) { m_ignoreSslErrors = value; } -bool PhantomConfig::localAccessRemote() const +bool Config::localAccessRemote() const { return m_localAccessRemote; } -void PhantomConfig::setLocalAccessRemote(const bool value) +void Config::setLocalAccessRemote(const bool value) { m_localAccessRemote = value; } -QString PhantomConfig::outputEncoding() const +QString Config::outputEncoding() const { return m_outputEncoding; } -void PhantomConfig::setOutputEncoding(const QString &value) +void Config::setOutputEncoding(const QString &value) { if (value.isEmpty()) { return; @@ -165,17 +165,17 @@ void PhantomConfig::setOutputEncoding(const QString &value) m_outputEncoding = value; } -bool PhantomConfig::pluginsEnabled() const +bool Config::pluginsEnabled() const { return m_pluginsEnabled; } -void PhantomConfig::setPluginsEnabled(const bool value) +void Config::setPluginsEnabled(const bool value) { m_pluginsEnabled = value; } -void PhantomConfig::setProxy(const QString &value) +void Config::setProxy(const QString &value) { QString proxyHost = value; int proxyPort = 1080; @@ -193,22 +193,22 @@ void PhantomConfig::setProxy(const QString &value) setProxyPort(proxyPort); } -QString PhantomConfig::proxyHost() const +QString Config::proxyHost() const { return m_proxyHost; } -int PhantomConfig::proxyPort() const +int Config::proxyPort() const { return m_proxyPort; } -QString PhantomConfig::scriptEncoding() const +QString Config::scriptEncoding() const { return m_scriptEncoding; } -void PhantomConfig::setScriptEncoding(const QString &value) +void Config::setScriptEncoding(const QString &value) { if (value.isEmpty()) { return; @@ -218,7 +218,7 @@ void PhantomConfig::setScriptEncoding(const QString &value) } // private: -void PhantomConfig::resetToDefaults() +void Config::resetToDefaults() { m_autoLoadImages = true; m_cookieFile = QString(); @@ -232,40 +232,40 @@ void PhantomConfig::resetToDefaults() m_scriptEncoding = "UTF-8"; } -void PhantomConfig::setProxyHost(const QString &value) +void Config::setProxyHost(const QString &value) { m_proxyHost = value; } -void PhantomConfig::setProxyPort(const int value) +void Config::setProxyPort(const int value) { m_proxyPort = value; } -QString PhantomConfig::getGlobalConfigFilePath() const +QString Config::getGlobalConfigFilePath() const { return joinPaths(QDir::homePath(), CONFIG_FILE_NAME); } -QString PhantomConfig::getLocalConfigFilePath() const +QString Config::getLocalConfigFilePath() const { return joinPaths(QDir::currentPath(), CONFIG_FILE_NAME); } // private: (static) -bool PhantomConfig::asBool(const QVariant &value) +bool Config::asBool(const QVariant &value) { QString strVal = asString(value).toLower(); return strVal == "true" || strVal == "1" || strVal == "yes"; } -QString PhantomConfig::asString(const QVariant &value) +QString Config::asString(const QVariant &value) { return value.toString().trimmed(); } -QString PhantomConfig::joinPaths(const QString &path1, const QString &path2) +QString Config::joinPaths(const QString &path1, const QString &path2) { QString joinedPath; @@ -280,9 +280,9 @@ QString PhantomConfig::joinPaths(const QString &path1, const QString &path2) return normalisePath(joinedPath); } -QString PhantomConfig::normalisePath(const QString &path) +QString Config::normalisePath(const QString &path) { return path.isEmpty() ? path : QDir::fromNativeSeparators(path); } -const QString PhantomConfig::CONFIG_FILE_NAME = ".phantomjsrc"; +const QString Config::CONFIG_FILE_NAME = ".phantomjsrc"; diff --git a/src/phantomconfig.h b/src/config.h similarity index 96% rename from src/phantomconfig.h rename to src/config.h index 688d67cc..31fba5b0 100644 --- a/src/phantomconfig.h +++ b/src/config.h @@ -28,16 +28,16 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef PHANTOMCONFIG_H -#define PHANTOMCONFIG_H +#ifndef CONFIG_H +#define CONFIG_H #include #include -class PhantomConfig +class Config { public: - PhantomConfig(); + Config(); void load(); void loadConfigFile(const QString &filePath); @@ -97,4 +97,4 @@ private: static const QString CONFIG_FILE_NAME; }; -#endif // PHANTOMCONFIG_H +#endif // CONFIG_H diff --git a/src/phantom.h b/src/phantom.h index 3fab2038..3deb3b17 100644 --- a/src/phantom.h +++ b/src/phantom.h @@ -38,7 +38,7 @@ class WebPage; #include "networkaccessmanager.h" #include "filesystem.h" #include "encoding.h" -#include "phantomconfig.h" +#include "config.h" class Phantom: public QObject { @@ -90,7 +90,7 @@ private: QVariantMap m_defaultPageSettings; FileSystem m_filesystem; QList > m_pages; - PhantomConfig m_config; + Config m_config; }; #endif // PHANTOM_H diff --git a/src/phantomjs.pro b/src/phantomjs.pro index 33ac3b3a..8a520a94 100644 --- a/src/phantomjs.pro +++ b/src/phantomjs.pro @@ -21,7 +21,7 @@ HEADERS += csconverter.h \ filesystem.h \ terminal.h \ encoding.h \ - phantomconfig.h + config.h SOURCES += phantom.cpp \ webpage.cpp \ main.cpp \ @@ -33,7 +33,7 @@ SOURCES += phantom.cpp \ filesystem.cpp \ terminal.cpp \ encoding.cpp \ - phantomconfig.cpp + config.cpp OTHER_FILES = bootstrap.js usage.txt