Add utility functions for saving/restoring the state of a Table.
For the time being, these are simple wrappers around BColumnListView's {Save,Load}State() functions.
This commit is contained in:
parent
0c07f01eb6
commit
29ca41d541
@ -10,6 +10,8 @@
|
||||
#include <SplitView.h>
|
||||
|
||||
#include "GUITeamUISettings.h"
|
||||
#include "table/AbstractTable.h"
|
||||
|
||||
|
||||
/*static*/ status_t
|
||||
GUISettingsUtils::ArchiveSplitView(const char* sourceName,
|
||||
@ -54,3 +56,34 @@ GUISettingsUtils::UnarchiveSplitView(const char* sourceName,
|
||||
view->SetItemCollapsed(i, value.ToBool());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*static*/ status_t
|
||||
GUISettingsUtils::ArchiveTableSettings(const char* sourceName,
|
||||
const char* viewName, GUITeamUISettings* settings, AbstractTable* table)
|
||||
{
|
||||
BString settingName;
|
||||
BMessage data;
|
||||
|
||||
settingName.SetToFormat("%s%sTable", sourceName, viewName);
|
||||
table->SaveState(&data);
|
||||
if (!settings->AddSettings(settingName.String(), data))
|
||||
return B_NO_MEMORY;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
/*static*/ void
|
||||
GUISettingsUtils::UnarchiveTableSettings(const char* sourceName,
|
||||
const char* viewName, const GUITeamUISettings* settings,
|
||||
AbstractTable* table)
|
||||
{
|
||||
BString settingName;
|
||||
BMessage data;
|
||||
|
||||
settingName.SetToFormat("%s%sTable", sourceName, viewName);
|
||||
if (settings->Settings(settingName.String(), data) == B_OK)
|
||||
table->LoadState(&data);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
class AbstractTable;
|
||||
class BSplitView;
|
||||
class GUITeamUISettings;
|
||||
|
||||
@ -25,6 +26,18 @@ public:
|
||||
const char* viewName,
|
||||
const GUITeamUISettings* settings,
|
||||
BSplitView* view);
|
||||
|
||||
static status_t ArchiveTableSettings(const char* sourceName,
|
||||
const char* viewName,
|
||||
GUITeamUISettings* settings,
|
||||
AbstractTable* table);
|
||||
|
||||
static void UnarchiveTableSettings(const char* sourceName,
|
||||
const char* viewName,
|
||||
const GUITeamUISettings* settings,
|
||||
AbstractTable* table);
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user