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

📄 ulocalrss.pas

📁 自己写的一个 RSS 阅读器
💻 PAS
📖 第 1 页 / 共 2 页
字号:
  fNode:=theNode;
	fItems := TList.Create;
end;
function TLocalRssItems.IndexOfLink(ALink:WideString):integer;
var i:Integer;
begin
  Result:=-1;
  for  i:= 0 to fItems.Count - 1 do
  if TLocalRssItem(fItems[i]).FLink=ALink then
    begin
      Result:=i;
      Exit;
    end;
end;
function TLocalRssItems.IndexOfTitle(ATitle:String):integer;
var i:Integer;
begin
  Result:=-1;
  for  i:= 0 to fItems.Count - 1 do
  if TLocalRssItem(fItems[i]).FTitle=ATitle then
    begin
      Result:=i;
      Exit;
    end;
end;
procedure TLocalRssItems.Add(item: TObject);
begin
	fItems.Add(item);
end;
function TLocalRssItems.Add:TLocalRssItem;
var Item:TLocalRssItem;
  index:Integer;
begin
  item:=TLocalRssItem.Create(Self,fNode.appendChild(fNode.ownerDocument.createElement('item')));
  index:=fItems.Add(item);
  Result:=Get_Item(Index);
end;
function TLocalRssItems.Get_Count: integer; begin Result := fItems.Count; end;
procedure TLocalRssItems.Delete(Index:integer);
begin
  fNode.removeChild(TLocalRssItem(fItems[Index]).FNode);
  fItems.Delete(Index);
end;
procedure TLocalRssItems.Delete(Item:TLocalRssItem);
var i:Integer;
begin
  for  i:= 0 to fItems.Count - 1 do    // Iterate
  begin
    if TLocalRssItem(fItems[i])=Item then
    begin
       Delete(i);
       Break;
    end;
  end;    // for
end;
function TLocalRssItems.Get_Item(Index: Integer): TLocalRssItem;
begin
	Result := TLocalRssItem(fItems[index]);
end;

{ TLocalRssItem }

constructor TLocalRssItem.Create(AOnwer:TComponent;theNode: IXmlDOMNode);
var
	str : WideString;
  tmpNode : IXmlDOMNode;
begin
  inherited Create(AOnwer);
  FAuthor:='';
  FTitle:='';
  FGuid:='';
  FLink:='';
  FDescription:='';
  FCategory := '';

  Fdelete := False;
  FReaded := False;

  if assigned(theNode) then begin
    FNode:=theNode;

    if getNodeVal(thenode, 'readed')='true' then
      FReaded:=True;
    str:=GetNodeVal(thenode, 'received');
    if str='' then
      FReceivedDate:=TW3CDTF.CreateDateTime(0)
    else
      FReceivedDate:=TW3CDTF.Create(str);
      
    FAuthor := getNodeVal(thenode, 'author');
    if FAuthor = '' then FAuthor := getNodeVal(thenode, 'dc:creator');
    FCategory := getNodeVal(thenode, 'category');

    str := getNodeVal(thenode, 'title');
    FTitle := ExtractNonHTML(str);
    FLink := getNodeVal(thenode, 'link');
    FGuid := getNodeVal(thenode, 'guid');
    if FGuid = '' then FGuid := FLink;
    if FGuid = '' then FGuid := FTitle;
    try
      str := getNodeVal(thenode, 'pubDate');
      FPubDate := TW3CDTF.Create(str)
    except
      FPubDate := TW3CDTF.CreateDateTime(0);
    end; 
    try
      tmpNode := thenode.selectSingleNode('body');
      if Assigned(tmpnode) then begin
        FDescription := tmpNode.XML;
        if (FDescription = '<body/>') or (FDescription = '') then
        	FDescription := getNodeVal(thenode, 'description');
      end else
    		FDescription := getNodeVal(thenode, 'description');
    except
      FDescription := getNodeVal(thenode, 'description');
    end;
  end
  else
  	FPubDate := TW3CDTF.CreateDatetime(0);
end;

function TLocalRssItem.Get_Author: string; begin Result := FAuthor; end;
function TLocalRssItem.Get_Category: string; begin Result := FCategory; end;
function TLocalRssItem.Get_Creator: WideString; begin Result := Get_Author(); end;
function TLocalRssItem.Get_Description: string; begin Result := FDescription; end;
function TLocalRssItem.Get_Guid: WideString; begin Result := FGuid; end;
function TLocalRssItem.Get_Link: WideString; begin Result := FLink; end;
function TLocalRssItem.Get_PubDate: TW3CDTF; begin Result := FPubDate; end;
function TLocalRssItem.Get_Title: string; begin Result := FTitle; end;
procedure TLocalRssItem.Set_PubDate(Value:TW3CDTF);
begin
  FPubDate:=Value;
  SetNodeVal(FNode,'pubDate',Value.ToRFC822String);
end;
procedure TLocalRssItem.Set_Title(Value:string);
begin
  FTitle:=Value;
  SetNodeVal(FNode,'title',Value);
end;
procedure TLocalRssItem.Set_Link(Value:WideString);
begin
  FLink:=Value;
  SetNodeVal(FNode,'link',Value);
end;
procedure TLocalRssItem.Set_Guid(Value:Widestring);
begin
  FGuid:=Value;
  SetNodeVal(FNode,'guid',Value);
end;
procedure TLocalRssItem.Set_Description(Value:string);
begin
  FDescription:=Value;
  SetNodeVal(FNode,'description',Value);
end;
procedure TLocalRssItem.Set_Author(Value:string);
begin
  FAuthor:=Value;
  SetNodeVal(FNode,'author',Value);
end;
procedure TLocalRssItem.Set_Category(Value:string);
begin
  FCategory:=Value;
  SetNodeVal(FNode,'category',Value);
end;
procedure TLocalRssItem.Set_Creator(Value:Widestring);
begin
  Set_Author(Value);
end;

function TLocalRssItem.Get_Readed:Boolean;begin Result:=FReaded;end;
procedure TLocalRssItem.Set_Readed(Value:Boolean);
begin
  FReaded:=Value;
  if Value then
     SetNodeVal(FNode,'readed','true')
  else
     SetNodeVal(FNode,'readed','false')
end;

function TLocalRssItem.Get_ReceivedDate:TW3CDTF;begin Result:=FReceivedDate;end;
procedure TLocalRssItem.Set_ReceivedDate(Value:TW3CDTF);
begin
  FReceivedDate:=Value;
  SetNodeVal(FNode,'received',Value.ToRFC822String);
end;

procedure TLocalRssItem.Set_Delete(Value:Boolean);
begin
  if Value then
    TLocalRssItems(Self.Owner).Delete(Self);
end;

constructor TLocalRSSImage.Create(AOnwer:TComponent;theNode: IXMLDOMNode);
var
	node : IXmlDOMNode;
begin
  inherited Create(AOnwer);
	try
    fNode:=theNode;
    FHeight := '0';
    FTitle := '';
    FLink := '';
    FURL := '';
    FWidth := '0';
    node := theNode;
  	if Assigned(node) then begin
		  FTitle := GetNodeVal(fNode,'title');
		  FLink := GetNodeVal(fNode,'link');
		  FURL := GetNodeVal(fNode,'url');
		  FWidth := GetNodeVal(fNode,'width');
		  FHeight := GetNodeVal(fNode,'height');
		end;
  except
//    Result := '';
  end;
end;

function TLocalRSSImage.Get_Height: WideString;
begin
	Result := FHeight;
end;

function TLocalRSSImage.Get_Link: WideString;
begin
	Result := FLink;
end;

function TLocalRSSImage.Get_Title: WideString;
begin
  Result := ExtractNonHTML(Ftitle);
end;

function TLocalRSSImage.Get_URL: WideString;
begin
	Result := FUrl;
end;

function TLocalRSSImage.Get_Width: WideString;
begin
	Result := FWidth;
end;

procedure TLocalRSSImage.Set_Title(Value:WideString);
begin
  FTitle:=Value;
  SetNodeVal(fNode,'title',Value);
end;
procedure TLocalRSSImage.Set_Link(Value:WideString);
begin
  FLink:=Value;
  SetNodeVal(fNode,'link',Value);
end;
procedure TLocalRSSImage.Set_URL(Value:WideString);
begin
  FURL:=Value;
  SetNodeVal(fNode,'url',Value);
end;
procedure TLocalRSSImage.Set_Width(Value:WideString);
begin
  FWidth:=Value;
  SetNodeVal(fNode,'width',Value);
end;
procedure TLocalRSSImage.Set_Height(Value:WideString);
begin
  FHeight:=Value;
  SetNodeVal(fNode,'height',Value);
end;

end.

⌨️ 快捷键说明

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