added popup menu to delete task + data + favorite

closed #325
This commit is contained in:
riderkick 2016-07-21 05:03:44 +08:00
parent ff46066203
commit f0b0ef0595
7 changed files with 46 additions and 2 deletions

View File

@ -88,6 +88,7 @@ type
FSortColumn: Integer;
FSortDirection, FIsAuto, FIsRunning: Boolean;
function GetFavoritesCount: Integer; inline;
function GetFavorite(const Index: Integer): TFavoriteContainer;
public
Items: TFavoriteContainers;
favoritesFile: TIniFileRun;
@ -136,6 +137,7 @@ type
property SortColumn: Integer read FSortColumn write FSortColumn;
property isAuto: Boolean read FIsAuto write FIsAuto;
property isRunning: Boolean read FIsRunning write FIsRunning;
property Favorite[const Index: Integer]: TFavoriteContainer read GetFavorite; default;
end;
resourcestring
@ -477,6 +479,11 @@ begin
Result := Items.Count;
end;
function TFavoriteManager.GetFavorite(const Index: Integer): TFavoriteContainer;
begin
Result := Items[Index];
end;
constructor TFavoriteManager.Create;
begin
inherited Create;

View File

@ -4259,6 +4259,10 @@ object MainForm: TMainForm
Enabled = False
OnClick = miDownloadDeleteTaskClick
end
object miDownloadDeleteTaskDataFavorite: TMenuItem
Caption = 'Task + Data + Favorite'
OnClick = miDownloadDeleteTaskClick
end
end
object miDownloadDeleteCompleted: TMenuItem
Caption = 'Delete all completed tasks'

View File

@ -238,6 +238,7 @@
{"hash":78392485,"name":"tmainform.midownloaddelete.caption","sourcebytes":[68,101,108,101,116,101],"value":"Delete"},
{"hash":165093305,"name":"tmainform.midownloaddeletetask.caption","sourcebytes":[84,97,115,107,32,111,110,108,121],"value":"Task only"},
{"hash":42869105,"name":"tmainform.midownloaddeletetaskdata.caption","sourcebytes":[84,97,115,107,32,43,32,68,97,116,97],"value":"Task + Data"},
{"hash":267175541,"name":"tmainform.midownloaddeletetaskdatafavorite.caption","sourcebytes":[84,97,115,107,32,43,32,68,97,116,97,32,43,32,70,97,118,111,114,105,116,101],"value":"Task + Data + Favorite"},
{"hash":235571507,"name":"tmainform.midownloaddeletecompleted.caption","sourcebytes":[68,101,108,101,116,101,32,97,108,108,32,99,111,109,112,108,101,116,101,100,32,116,97,115,107,115],"value":"Delete all completed tasks"},
{"hash":180320563,"name":"tmainform.midownloadmergecompleted.caption","sourcebytes":[77,101,114,103,101,32,99,111,109,112,108,101,116,101,100,32,116,97,115,107,115],"value":"Merge completed tasks"},
{"hash":27371647,"name":"tmainform.midownloadviewmangainfo.caption","sourcebytes":[86,105,101,119,32,109,97,110,103,97,32,105,110,102,111],"value":"View manga info"},

View File

@ -74,6 +74,7 @@ type
lbOptionMangaCustomRenameHint: TLabel;
lbOptionMangaCustomRename: TLabel;
MenuItem10: TMenuItem;
miDownloadDeleteTaskDataFavorite: TMenuItem;
miTrayExit: TMenuItem;
miTrayRestore: TMenuItem;
miTrayShowDropBox: TMenuItem;
@ -1669,7 +1670,8 @@ begin
if vtDownload.Selected[xNode] then begin
DLManager.StopTask(xNode^.Index, False, True);
with DLManager.Items[xNode^.Index] do begin
if (Sender = miDownloadDeleteTaskData) and (ChapterName.Count > 0) then begin
if (Sender = miDownloadDeleteTaskData) or (Sender = miDownloadDeleteTaskDataFavorite)
and (ChapterName.Count > 0) then begin
for i := 0 to ChapterName.Count - 1 do begin
f := CleanAndExpandDirectory(DownloadInfo.SaveTo + ChapterName[i]);
if FileExistsUTF8(f + '.zip') then
@ -1683,6 +1685,25 @@ begin
end;
RemoveDirUTF8(DownloadInfo.SaveTo);
end;
if (Sender = miDownloadDeleteTaskDataFavorite) and
(FavoriteManager.Items.Count <> 0) and
(FavoriteManager.isRunning = False) then
try
FavoriteManager.Lock;
for i := 0 to FavoriteManager.Count - 1 do
begin
if SameText(DLManager[xNode^.Index].DownloadInfo.Link, FavoriteManager[i].FavoriteInfo.Link)
and SameText(DLManager[xNode^.Index].DownloadInfo.Website, FavoriteManager[i].FavoriteInfo.Website) then
begin
FavoriteManager.Items[i].Free;
FavoriteManager.Items.Delete(i);
UpdateVtFavorites;
Break;
end;
end;
finally
FavoriteManager.LockRelease;
end;
DLManager.Items[xNode^.Index].Free;
DLManager.Items.Delete(xNode^.Index);
end;

View File

@ -1433,6 +1433,10 @@ msgstr "Task only"
msgid "Task + Data"
msgstr "Task + Data"
#: tmainform.midownloaddeletetaskdatafavorite.caption
msgid "Task + Data + Favorite"
msgstr ""
#: tmainform.midownloaddisable.caption
msgid "Disable"
msgstr "Disable"

View File

@ -1414,6 +1414,10 @@ msgstr "Daftar saja"
msgid "Task + Data"
msgstr "Daftar dan data"
#: tmainform.midownloaddeletetaskdatafavorite.caption
msgid "Task + Data + Favorite"
msgstr "Daftar, data dan kesukaan"
#: tmainform.midownloaddisable.caption
msgid "Disable"
msgstr "Matikan"
@ -2094,4 +2098,3 @@ msgstr "Sinkronisasi data"
#: uupdatethread.rs_updatinglist
msgid "Updating list"
msgstr "Memperbarui daftar"

View File

@ -1345,6 +1345,10 @@ msgstr ""
msgid "Task + Data"
msgstr ""
#: tmainform.midownloaddeletetaskdatafavorite.caption
msgid "Task + Data + Favorite"
msgstr ""
#: tmainform.midownloaddisable.caption
msgid "Disable"
msgstr ""