More work-in-progress towards getting settings saved/restored.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43067 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -140,10 +140,11 @@ Application Debugger :
|
|||||||
|
|
||||||
# settings
|
# settings
|
||||||
BreakpointSetting.cpp
|
BreakpointSetting.cpp
|
||||||
|
GUITeamUISettings.cpp
|
||||||
SettingsManager.cpp
|
SettingsManager.cpp
|
||||||
TeamSettings.cpp
|
TeamSettings.cpp
|
||||||
TeamUISettings.cpp
|
TeamUISettings.cpp
|
||||||
GUITeamUISettings.cpp
|
TeamUISettingsFactory.cpp
|
||||||
|
|
||||||
# settings/generic
|
# settings/generic
|
||||||
Setting.cpp
|
Setting.cpp
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
|
GUITeamUISettings::GUITeamUISettings()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GUITeamUISettings::GUITeamUISettings(const char* settingsID)
|
GUITeamUISettings::GUITeamUISettings(const char* settingsID)
|
||||||
:
|
:
|
||||||
fID(settingsID)
|
fID(settingsID)
|
||||||
@@ -25,6 +30,13 @@ GUITeamUISettings::~GUITeamUISettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
team_ui_settings_type
|
||||||
|
GUITeamUISettings::Type() const
|
||||||
|
{
|
||||||
|
return TEAM_UI_SETTINGS_TYPE_GUI;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
GUITeamUISettings::ID() const
|
GUITeamUISettings::ID() const
|
||||||
{
|
{
|
||||||
@@ -45,6 +57,10 @@ status_t
|
|||||||
GUITeamUISettings::WriteTo(BMessage& archive) const
|
GUITeamUISettings::WriteTo(BMessage& archive) const
|
||||||
{
|
{
|
||||||
status_t error = archive.AddString("ID", fID);
|
status_t error = archive.AddString("ID", fID);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = archive.AddInt32("type", Type());
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ class BMessage;
|
|||||||
|
|
||||||
class GUITeamUISettings : public TeamUISettings {
|
class GUITeamUISettings : public TeamUISettings {
|
||||||
public:
|
public:
|
||||||
|
GUITeamUISettings();
|
||||||
GUITeamUISettings(const char* settingsID);
|
GUITeamUISettings(const char* settingsID);
|
||||||
GUITeamUISettings(const GUITeamUISettings&
|
GUITeamUISettings(const GUITeamUISettings&
|
||||||
other);
|
other);
|
||||||
// throws std::bad_alloc
|
// throws std::bad_alloc
|
||||||
~GUITeamUISettings();
|
~GUITeamUISettings();
|
||||||
|
|
||||||
|
virtual team_ui_settings_type Type() const;
|
||||||
virtual const char* ID() const;
|
virtual const char* ID() const;
|
||||||
virtual status_t SetTo(const BMessage& archive);
|
virtual status_t SetTo(const BMessage& archive);
|
||||||
virtual status_t WriteTo(BMessage& archive) const;
|
virtual status_t WriteTo(BMessage& archive) const;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "BreakpointSetting.h"
|
#include "BreakpointSetting.h"
|
||||||
#include "Team.h"
|
#include "Team.h"
|
||||||
#include "TeamUISettings.h"
|
#include "TeamUISettings.h"
|
||||||
|
#include "TeamUISettingsFactory.h"
|
||||||
#include "UserBreakpoint.h"
|
#include "UserBreakpoint.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -103,7 +104,14 @@ TeamSettings::SetTo(const BMessage& archive)
|
|||||||
// add UI settings
|
// add UI settings
|
||||||
for (int32 i = 0; archive.FindMessage("uisettings", i, &childArchive)
|
for (int32 i = 0; archive.FindMessage("uisettings", i, &childArchive)
|
||||||
== B_OK; i++) {
|
== B_OK; i++) {
|
||||||
|
TeamUISettings* setting = NULL;
|
||||||
|
error = TeamUISettingsFactory::Create(childArchive, setting);
|
||||||
|
if (error == B_OK && !fUISettings.AddItem(setting))
|
||||||
|
error = B_NO_MEMORY;
|
||||||
|
if (error != B_OK) {
|
||||||
|
delete setting;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -117,9 +125,9 @@ TeamSettings::WriteTo(BMessage& archive) const
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
BMessage childArchive;
|
||||||
for (int32 i = 0; BreakpointSetting* breakpoint = fBreakpoints.ItemAt(i);
|
for (int32 i = 0; BreakpointSetting* breakpoint = fBreakpoints.ItemAt(i);
|
||||||
i++) {
|
i++) {
|
||||||
BMessage childArchive;
|
|
||||||
error = breakpoint->WriteTo(childArchive);
|
error = breakpoint->WriteTo(childArchive);
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
@@ -128,6 +136,17 @@ TeamSettings::WriteTo(BMessage& archive) const
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int32 i = 0; TeamUISettings* uiSetting = fUISettings.ItemAt(i);
|
||||||
|
i++) {
|
||||||
|
error = uiSetting->WriteTo(childArchive);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = archive.AddMessage("uisettings", &childArchive);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,18 @@
|
|||||||
class BMessage;
|
class BMessage;
|
||||||
|
|
||||||
|
|
||||||
|
enum team_ui_settings_type {
|
||||||
|
TEAM_UI_SETTINGS_TYPE_GUI,
|
||||||
|
TEAM_UI_SETTINGS_TYPE_CLI
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class TeamUISettings {
|
class TeamUISettings {
|
||||||
public:
|
public:
|
||||||
TeamUISettings();
|
TeamUISettings();
|
||||||
virtual ~TeamUISettings();
|
virtual ~TeamUISettings();
|
||||||
|
|
||||||
|
virtual team_ui_settings_type Type() const = 0;
|
||||||
virtual const char* ID() const = 0;
|
virtual const char* ID() const = 0;
|
||||||
virtual status_t SetTo(const BMessage& archive) = 0;
|
virtual status_t SetTo(const BMessage& archive) = 0;
|
||||||
virtual status_t WriteTo(BMessage& archive) const = 0;
|
virtual status_t WriteTo(BMessage& archive) const = 0;
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Rene Gollent, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "TeamUISettingsFactory.h"
|
||||||
|
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
|
#include "GUITeamUISettings.h"
|
||||||
|
|
||||||
|
|
||||||
|
TeamUISettingsFactory::TeamUISettingsFactory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TeamUISettingsFactory::~TeamUISettingsFactory()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
TeamUISettingsFactory::Create(const BMessage& archive, TeamUISettings*&
|
||||||
|
settings)
|
||||||
|
{
|
||||||
|
int32 type;
|
||||||
|
status_t error = archive.FindInt32("type", &type);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case TEAM_UI_SETTINGS_TYPE_GUI:
|
||||||
|
settings = new(std::nothrow) GUITeamUISettings();
|
||||||
|
if (settings == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
error = settings->SetTo(archive);
|
||||||
|
if (error != B_OK) {
|
||||||
|
delete settings;
|
||||||
|
settings = NULL;
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TEAM_UI_SETTINGS_TYPE_CLI:
|
||||||
|
// TODO: implement once we have a CLI interface
|
||||||
|
// (and corresponding settings)
|
||||||
|
return B_UNSUPPORTED;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return B_BAD_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Rene Gollent, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef TEAM_UI_SETTINGS_FACTORY_H
|
||||||
|
#define TEAM_UI_SETTINGS_FACTORY_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BMessage;
|
||||||
|
class TeamUISettings;
|
||||||
|
|
||||||
|
class TeamUISettingsFactory {
|
||||||
|
public:
|
||||||
|
TeamUISettingsFactory();
|
||||||
|
~TeamUISettingsFactory();
|
||||||
|
|
||||||
|
static status_t Create(const BMessage& archive,
|
||||||
|
TeamUISettings*& settings);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TEAM_UI_SETTINGS_FACTORY_H
|
||||||
Reference in New Issue
Block a user