[KPhotoAlbum] [PATCH 4/8] Cleanup: Made the use of WindowType more direct as a Settings key.
Michael Witten
mfwitten at MIT.EDU
Sun Sep 21 08:46:40 BST 2008
It seems more useful to implemtn WindowType as a const char*; it
should be relatively easy to change it back to an enum if need
be; for now, why waste the cycles converting enum (int) values
to strings with a function call?
Signed-off-by: Michael Witten <mfwitten at mit.edu>
---
Settings/SettingsData.cpp | 16 +++++-----------
Settings/SettingsData.h | 5 +++--
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/Settings/SettingsData.cpp b/Settings/SettingsData.cpp
index c037fd3..b5bd01a 100644
--- a/Settings/SettingsData.cpp
+++ b/Settings/SettingsData.cpp
@@ -59,6 +59,9 @@ static bool _smoothScale = true;
using namespace Settings;
+const WindowType Settings::MainWindow = "MainWindow";
+const WindowType Settings::ConfigWindow = "ConfigWindow";
+
SettingsData* SettingsData::_instance = 0;
SettingsData* SettingsData::instance()
@@ -360,7 +363,7 @@ void SettingsData::setAlbumCategory( const QString& category )
void SettingsData::setWindowGeometry( WindowType win, const QRect& geometry )
{
KConfigGroup group = KGlobal::config()->group("Window Geometry");
- group.writeEntry( windowTypeToString( win ), geometry );
+ group.writeEntry( win, geometry );
group.sync();
}
@@ -368,7 +371,7 @@ QRect SettingsData::windowGeometry( WindowType win ) const
{
KSharedConfigPtr config = KGlobal::config();
QRect rect( 0,0, 800, 600 );
- return config->group("Window Geometry").readEntry<QRect>( windowTypeToString( win ), rect );
+ return config->group("Window Geometry").readEntry<QRect>( win, rect );
}
bool SettingsData::ready()
@@ -489,15 +492,6 @@ void SettingsData::setHistogramSize( const QSize& size )
emit histogramSizeChanged( size );
}
-const char* SettingsData::windowTypeToString( WindowType tp ) const
-{
- switch (tp) {
- case MainWindow: return "MainWindow";
- case ConfigWindow: return "ConfigWindow";
- }
- return "";
-}
-
QString SettingsData::groupForDatabase( const char* setting ) const
{
return STR("%1 - %2").arg( setting ).arg( imageDirectory() );
diff --git a/Settings/SettingsData.h b/Settings/SettingsData.h
index aae4095..3fb37d7 100644
--- a/Settings/SettingsData.h
+++ b/Settings/SettingsData.h
@@ -79,7 +79,9 @@ namespace Settings
Aspect_2_3 = 5,
Aspect_9_16 = 6
};
- enum WindowType { MainWindow = 0, ConfigWindow = 1 };
+
+ typedef const char* WindowType;
+ extern const WindowType MainWindow, ConfigWindow;
class SettingsData :public QObject {
Q_OBJECT
@@ -220,7 +222,6 @@ public:
void setWindowGeometry( WindowType, const QRect& geometry );
QRect windowGeometry( WindowType ) const;
- const char* windowTypeToString( WindowType tp ) const;
QString groupForDatabase( const char* setting ) const;
--
1.6.0.2.296.gfe33b
More information about the Kphotoalbum
mailing list