📄 ulocalrss.pas
字号:
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:='';
FCommentCount := 0;
FCategory := '';
FComment := '';
FCommentRss := '';
FCommentURL := '';
FReaded:=False;
if assigned(theNode) then begin
FNode:=theNode;
if getNodeVal(thenode, 'readed')='true' then
FReaded:=True;
FAuthor := getNodeVal(thenode, 'author');
if FAuthor = '' then FAuthor := getNodeVal(thenode, 'dc:creator');
FCategory := getNodeVal(thenode, 'category');
FComment := getNodeVal(thenode, 'content');
if FComment='' then
FComment := getNodeVal(thenode, 'comment');
FCommentRss := getNodeVal(thenode, 'wfw:commentRss');
str := getNodeVal(thenode, 'slash:comments');
if str = '' then FCommentCount := 0 else FCommentCount := StrToInt(str);
FCommentURL := getNodeVal(thenode, 'comments');
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_Comment: WideString; begin Result := FComment; end;
function TLocalRssItem.Get_CommenTLocalRss: WideString; begin Result := FCommentRss; end;
function TLocalRssItem.Get_CommentCount: integer; begin Result := FCommentCount; end;
function TLocalRssItem.Get_CommentURL: WideString; begin Result := FCommentURL; 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;
procedure TLocalRssItem.Set_Comment(Value:Widestring);
begin
FComment:=Value;
SetNodeVal(FNode,'comment',Value);
end;
procedure TLocalRssItem.Set_CommentCount(Value:Integer);
begin
FCommentCount:=Value;
SetNodeVal(FNode,'commentCount',IntToStr(Value));
end;
procedure TLocalRssItem.Set_CommentURL(Value:Widestring);
begin
FCommentURL:=Value;
SetNodeVal(FNode,'commentUrl',Value);
end;
procedure TLocalRssItem.Set_CommenTLocalRss(Value:Widestring);
begin
FCommentRss:=Value;
SetNodeVal(FNode,'commentRss',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;
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 + -