⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uopml.pas

📁 自己写的一个 RSS 阅读器
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  otl:TOutlineType;
begin
  newNode:=fBodyNode.appendChild(fBodyNode.ownerDocument.createElement('folder'));
  SetNodeAttrVal(newNode,'type','folder');
  otl:= TOutlineType.Create(fBodyNode,newNode);
  fItems.Add(otl);
  Result := otl;
end;

function TBodyType.Get_Items: TOutlineTypeList;
begin
  Result := fItems;
end;

{ TOutlineType }

function TOutlineType.Get_Type_: WideString;
begin
  Result := FType_;
end;

procedure TOutlineType.Set_Type_(Value: WideString);
begin
  FType_:=Value;
  SetNodeAttrVal(fNode,'type',Value);
end;

function TOutlineType.Get_Title: string;
begin
  Result := FTitle;
end;

function TOutlineType.Get_Text: string;
begin
  Result := fText;
end;

procedure TOutlineType.Set_Title(Value: string);
begin
  FTitle:=Value;
  SetNodeAttrVal(fNode,'title',Value);
end;
procedure TOutlineType.Set_Text(Value: string);
begin
  fText:=Value;
  SetNodeAttrVal(fNode,'text',Value);
end;

function TOutlineType.Get_XmlUrl: WideString;
begin
  Result := FXmlUrl;
end;

procedure TOutlineType.Set_XmlUrl(Value: WideString);
begin
  FXmlUrl:=Value;
  SetNodeAttrVal(fNode,'xmlUrl',Value);
end;

function TOutlineType.Get_Description:WideString;
begin
  Result := FDescription;
end;

procedure TOutlineType.Set_Description(Value:WideString);
begin
  FDescription:=Value;
  SetNodeAttrVal(fNode,'description',Value);
end;

function TOutlineType.Get_FileName: widestring;
begin
  Result := FFileName;
end;

procedure TOutlineType.Set_FileName(Value: widestring);
begin
  FFileName:=Value;
  SetNodeAttrVal(fNode,'fileName',Value);
end;

function TOutlineType.Get_LastPurge: TDateTime;
begin
  Result := StrToDate(FLastPurge);
end;

procedure TOutlineType.Set_LastPurge(Value: TDateTime);
var
  t : TW3CDTF;
begin
  t := TW3CDTF.CreateDateTime(Value);
  try
    FLastPurge:=t.ToRFC822String;
    SetNodeAttrVal(fNode,'lastPurge',t.ToRFC822String);
  finally
    t.Free;
  end;
end;

function TOutlineType.Get_RefreshInterval: Integer;
begin
  Result:=StrToInt(FRefreshInterval);
end;

procedure TOutlineType.Set_RefreshInterval(Value: Integer);
begin
  FRefreshInterval:=IntToStr(Value);
  SetNodeAttrVal(fNode,'refreshInterval',Value);
end;

function TOutlineType.Get_Purge: Integer;
begin
  Result := StrToInt(FPurge);
end;

procedure TOutlineType.Set_Purge(Value: Integer);
begin
  FPurge:=IntToStr(Value);
  SetNodeAttrVal(fNode,'purge',Value);
end;


function TOutlineType.Get_HtmlUrl: WideString;
begin
  Result := fNode.attributes.getNamedItem('htmlUrl').Text;
  if Result = '' then
  	Result := fNode.attributes.getNamedItem('url').Text;
end;

procedure TOutlineType.Set_HtmlUrl(Value: WideString);
begin
  FHtmlUrl:=Value;
  SetNodeAttrVal(fNode,'htmlUrl',Value);
end;

constructor TOutlineType.Create(theBodyNode,theNode:IXMLDOMNode);
var
  i:Integer;
begin
  fBodyNode := theBodyNode;
  FItems :=TOutlineTypeList.Create(fBodyNode,theNode);
  fNode:=theNode;

  fHasChild:=False;
  FTitle           := GetNodeAttrVal(fnode, 'title');
  fText            := '';
  FType_           := LowerCase(GetNodeAttrVal(fnode, 'type'));
  FXmlUrl          := '';
  FHtmlUrl         := '';
  FDescription     := GetNodeAttrVal(fnode, 'description');
  FFileName        := '';
  FLastPurge       := '';
  FRefreshInterval := '';

  if FType_='folder' then
  begin
    if (fNode.hasChildNodes)then
    begin
      fHasChild:=True;
      for  i:= 0 to fNode.childNodes.length - 1 do    // Iterate
        fItems.Add(TOutlineType.Create(fBodyNode,fNode.childNodes.item[i]));
    end;
  end
  else
  begin
    FXmlUrl          := GetNodeAttrVal(fnode, 'xmlUrl');
    FHtmlUrl         := GetNodeAttrVal(fnode, 'htmlUrl');
    FFileName        := GetNodeAttrVal(fnode, 'fileName');
    FLastPurge       := GetNodeAttrVal(fnode, 'lastPurge');
    FRefreshInterval := GetNodeAttrVal(fnode, 'refreshInterval');
    if FRefreshInterval = '' then
       RefreshInterval := 0;
    FPurge           := GetNodeAttrVal(fnode, 'purge');
    if FType_='' then
      Type_ := 'rss';
    fText            := GetNodeAttrVal(fnode, 'text');
    if fText='' then
      Text := FTitle;
  end;
end;

procedure TOutlineType.MoveUp;
begin
  fNode.parentNode.insertBefore(fNode,fNode.previousSibling);
end;

procedure TOutlineType.MoveDown;
begin
 fNode.parentNode.insertBefore(fNode.nextSibling,fNode);
end;

procedure TOutlineType.MoveTo(AFolder:TOutlineType);
var
  tNode:IXMLDOMNode;
begin
  if AFolder<>nil then
  begin
    if AFolder.Type_='folder' then
    begin
      tNode := fnode.cloneNode(true);
      fNode.parentNode.removeChild(fNode);
      fNode:=AFolder.fNode.appendChild(tNode);
    end;
  end
  else
  begin
    tNode := fnode.cloneNode(true);
    fNode.parentNode.removeChild(fNode);
    fNode:=fBodyNode.appendChild(tNode)
  end;
end;

procedure TOutlineType.DeleteSelf;
begin
  //fNode.parentNode.removeChild(fNode);
  TOutlineTypeList(Self.Owner).Delete(Self);
end;

{TOutlineTypeList}
constructor TOutlineTypeList.Create(theBodyNode,theNode:IXMLDOMNode);
begin
  fNode:=theNode;
  fBodyNode:=theBodyNode;
	fItems := THashedStringList.Create;
end;
function TOutlineTypeList.IndexOfXmlUrl(aXmlUrl:WideString):integer;
var i:Integer;
begin
  Result:=-1;
  for  i:= 0 to fItems.Count- 1 do
  if TOutlineType(fItems.Objects[i]).FXmlUrl=aXmlUrl then
    begin
      Result:=i;
      Exit;
    end;
end;
function TOutlineTypeList.IndexOfTitle(aTitle:String):integer;
var i:Integer;
begin
  Result:=-1;
  for  i:= 0 to fItems.Count- 1 do
  if TOutlineType(fItems.Objects[i]).FTitle=aTitle then
    begin
      Result:=i;
      Exit;
    end;
end;
procedure TOutlineTypeList.Add(item: TObject);
begin
	fItems.AddObject((item as TOutlineType).FTitle, item);
end;

procedure TOutlineTypeList.Delete(Index:integer);
begin
  fNode.removeChild(TOutlineType(fItems.Objects[Index]).fNode);
  fItems.Delete(Index);
end;

procedure TOutlineTypeList.Delete(outline:TOutlineType);
var i:Integer;
begin
  for  i:= 0 to Count - 1 do    // Iterate
    begin
      if TOutlineType(fItems.Objects[i])=outline then
      begin
        Delete(i);
        Break;
      end;
    end;    // for
end;


function TOutlineTypeList.Add(aType:string):TOutlineType;
var
  item:TOutlineType;
  bodyNode,newOutlineNode:IXMLDOMNode;
begin
  newOutlineNode:=fNode.appendChild(fNode.ownerDocument.createElement(aType));
  if aType='folder' then
    SetNodeAttrVal(newOutlineNode,'type','folder');
  item:=TOutlineType.Create(fBodyNode,newOutlineNode);
  fItems.AddObject('',item);
  Result:=item;
end;

function TOutlineTypeList.Get_Count: integer;
begin
  Result := fItems.Count;
end;

function TOutlineTypeList.Get_Item(Index: Integer): TOutlineType;
begin
	Result := TOutlineType(fItems.Objects[index]);
end;

function TOutlineTypeList.Get_ItemByGuid(guid: string): TOutlineType;
begin
	Result := TOutlineType(fItems.Objects[fItems.IndexOf(guid)]);
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -