IDE: messages: save/load filters

git-svn-id: trunk@45333 -
This commit is contained in:
mattias 2014-06-04 09:33:21 +00:00
parent 340073d065
commit 0fef9cf75d
2 changed files with 83 additions and 3 deletions

View File

@ -57,7 +57,7 @@ type
TMessageLineUrgencies = set of TMessageLineUrgency;
const
MessageLineUrgencyNames: array[TMessageLineUrgency] of string = (
'?',
'None',
'Progress',
'Debug',
'Verbose',
@ -648,6 +648,8 @@ var
function CompareMsgLinesSrcPos(MsgLine1, MsgLine2: Pointer): integer;
function StrToMsgLineUrgency(const s: string): TMessageLineUrgency;
function dbgs(u: TMessageLineUrgency): string; overload;
function dbgs(f: TMessageLineFlag): string; overload;
function dbgs(Flags: TMessageLineFlags): string; overload;
@ -678,6 +680,13 @@ begin
Result:=0;
end;
function StrToMsgLineUrgency(const s: string): TMessageLineUrgency;
begin
for Result:=Low(TMessageLineUrgency) to high(TMessageLineUrgency) do
if SysUtils.CompareText(s,MessageLineUrgencyNames[Result])=0 then exit;
Result:=mluNone;
end;
function dbgs(u: TMessageLineUrgency): string;
begin
Result:='';

View File

@ -188,6 +188,8 @@ type
procedure ClearFilterMsgTypes;
function IndexOfFilterMsgType(Line: TMessageLine): integer;
property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure ConsistencyCheck;
end;
@ -467,14 +469,39 @@ end;
procedure TLMsgViewFilters.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
var
NewCnt: Integer;
ActiveIndex: Integer;
i: Integer;
Filter: TLMsgViewFilter;
begin
Clear;
NewCnt:=XMLConfig.GetValue(Path+'Count',1);
ActiveIndex:=XMLConfig.GetValue(Path+'Active',1);
for i:=1 to NewCnt do begin
if i>Count then begin
Filter:=TLMsgViewFilter.Create;
Add(Filter);
end else begin
Filter:=Filters[i-1];
end;
Filter.LoadFromXMLConfig(XMLConfig,Path+'Filter'+IntToStr(i)+'/');
end;
if (ActiveIndex>0) and (ActiveIndex<=Count) then
ActiveFilter:=Filters[ActiveIndex-1];
for i:=Count downto NewCnt+1 do
Delete(i-1);
end;
procedure TLMsgViewFilters.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
var
i: Integer;
begin
XMLConfig.SetDeleteValue(Path+'Count',Count,1);
XMLConfig.SetDeleteValue(Path+'Active',IndexOf(ActiveFilter)+1,1);
for i:=1 to Count do
Filters[i-1].SaveToXMLConfig(XMLConfig,Path+'Filter'+IntToStr(i)+'/');
end;
{ TXMLOptionsStorage }
@ -873,6 +900,50 @@ begin
Result:=-1;
end;
procedure TLMsgViewFilter.LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
var
NewCnt: Integer;
i: Integer;
p: String;
SubTool: String;
MsgId: Integer;
begin
fCaption:=XMLConfig.GetValue(Path+'Caption','Default');
FMinUrgency:=StrToMsgLineUrgency(XMLConfig.GetValue(Path+'MinUrgency',
MessageLineUrgencyNames[mluHint]));
FFilterNotesWithoutPos:=XMLConfig.GetValue(Path+'FilterNotesWithoutPos',true);
NewCnt:=XMLConfig.GetValue(Path+'MsgType/Count',0);
ClearFilterMsgTypes;
for i:=1 to NewCnt do begin
p:=Path+'MsgType/Item'+IntToStr(i)+'/';
SubTool:=XMLConfig.GetValue(p+'SubTool',SubToolFPC);
MsgId:=XMLConfig.GetValue(p+'MsgId',0);
if (SubTool='') or (MsgId=0) then continue;
AddFilterMsgType(SubTool,MsgId);
end;
end;
procedure TLMsgViewFilter.SaveToXMLConfig(XMLConfig: TXMLConfig;
const Path: string);
var
i: Integer;
p: String;
Item: TLMVFilterMsgType;
begin
XMLConfig.SetDeleteValue(Path+'Caption',Caption,'Default');
XMLConfig.SetDeleteValue(Path+'MinUrgency',
MessageLineUrgencyNames[MinUrgency],MessageLineUrgencyNames[mluHint]);
XMLConfig.SetDeleteValue(Path+'FilterNotesWithoutPos',FilterNotesWithoutPos,true);
XMLConfig.SetDeleteValue(Path+'MsgType/Count',FilterMsgTypeCount,0);
for i:=1 to FilterMsgTypeCount do begin
Item:=FilterMsgTypes[i-1];
p:=Path+'MsgType/Item'+IntToStr(i)+'/';
XMLConfig.SetDeleteValue(p+'SubTool',Item.SubTool,SubToolFPC);
XMLConfig.SetDeleteValue(p+'MsgId',Item.MsgID,0);
end;
end;
procedure TLMsgViewFilter.ConsistencyCheck;
procedure E(Msg: string);