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:
@@ -10,6 +10,8 @@
|
|||||||
#include <SplitView.h>
|
#include <SplitView.h>
|
||||||
|
|
||||||
#include "GUITeamUISettings.h"
|
#include "GUITeamUISettings.h"
|
||||||
|
#include "table/AbstractTable.h"
|
||||||
|
|
||||||
|
|
||||||
/*static*/ status_t
|
/*static*/ status_t
|
||||||
GUISettingsUtils::ArchiveSplitView(const char* sourceName,
|
GUISettingsUtils::ArchiveSplitView(const char* sourceName,
|
||||||
@@ -54,3 +56,34 @@ GUISettingsUtils::UnarchiveSplitView(const char* sourceName,
|
|||||||
view->SetItemCollapsed(i, value.ToBool());
|
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>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractTable;
|
||||||
class BSplitView;
|
class BSplitView;
|
||||||
class GUITeamUISettings;
|
class GUITeamUISettings;
|
||||||
|
|
||||||
@@ -25,6 +26,18 @@ public:
|
|||||||
const char* viewName,
|
const char* viewName,
|
||||||
const GUITeamUISettings* settings,
|
const GUITeamUISettings* settings,
|
||||||
BSplitView* view);
|
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);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user