home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / Chip_2002-05_cd1.bin / zkuste / delphi / kompon / d5 / CAKDIR.ZIP / CakListView.pas < prev    next >
Pascal/Delphi Source File  |  2001-04-24  |  4KB  |  121 lines

  1. unit CakListView;
  2.  
  3. // Common Archiver Kit (CAK) List View
  4. // Common Interface for Compression/Decompression components.
  5.  
  6. //Copyright (C) Joseph Leung 2001 (lycj@yahoo.com)
  7. //
  8. //This library is free software; you can redistribute it and/or
  9. //modify it under the terms of the GNU Lesser General Public
  10. //License as published by the Free Software Foundation; either
  11. //version 2.1 of the License, or (at your option) any later version.
  12. //
  13. //This library is distributed in the hope that it will be useful,
  14. //but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. //Lesser General Public License for more details.
  17. //
  18. //You should have received a copy of the GNU Lesser General Public
  19. //License along with this library; if not, write to the Free Software
  20. //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  
  22. // ver 0.1.0.0
  23. // lastupdate 3.19.2001
  24.  
  25. interface
  26.  
  27. uses
  28.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  29.   ComCtrls, CakDir;
  30.  
  31.  
  32. type
  33.   TCakListView = class(TListView)
  34.   private
  35.     { Private declarations }
  36.   protected
  37.     { Protected declarations }
  38.   public
  39.     CakDir : TCakDir;
  40.     procedure ReloadCAK;
  41.     constructor Create( AOwner: TComponent ); override;
  42.     destructor Destroy; override;
  43.  
  44.     { Public declarations }
  45.   published
  46.  
  47.      property CakitDir : TCakDir read CakDir write CakDir;
  48.     { Published declarations }
  49.   end;
  50.  
  51. procedure Register;
  52.  
  53. implementation
  54.  
  55. const listwidth : array[0..8] of integer = (150,100,50,120,50,40,70,200,200);
  56.       listname  : array[0..8] of string =
  57.                   ('File name','Type','Size','Time',
  58.                   'Comp','%','CRC',
  59.                   'Defpath','FileArchive');
  60.                           
  61. procedure TCakListView.ReloadCAK;
  62. var aListitem : TListitem;
  63.     i : integer;
  64. begin
  65.         if not assigned(CakDir) then exit;
  66.         items.Clear;
  67.         SmallImages := CakDir.ImageS;
  68.         LargeImages := Cakdir.ImageL;
  69.         if CakDir.Total_Contents > 500 then
  70.                  if MessageDlg(
  71.                  'Large file list will takelong time to load, '+#13+#10+
  72.                  'are you sure want to load it?' +#13+#10+
  73.                  'You can extract/add/test without loading the list.'
  74.                  , mtConfirmation, [mbYes, mbNo], 0) = MrNo then
  75.                         exit;
  76.         items.BeginUpdate;
  77.         for i := 0 to CakDir.Total_Contents -1 do
  78.                 begin
  79.                 aListitem := items.Add;
  80.                 with CakDir.Archive_Contents[i] do
  81.                 begin
  82.                    aListitem.Caption := _Filename;
  83.                    aListitem.ImageIndex := _FileIcon;
  84.                    if _Encrypted then
  85.                    aListitem.SubItems.Add('*' + _FileType) else
  86.                    aListitem.SubItems.Add(_FileType);
  87.                    aListitem.SubItems.Add(inttostr(_FileSize));
  88.                    aListitem.SubItems.Add(Datetimetostr(_Filetime));
  89.                    aListitem.SubItems.Add(inttostr(_FilePackedSize));
  90.                    aListitem.SubItems.Add(inttostr(_FileRatio) + '%');
  91.                    aListitem.SubItems.Add(_FileCRC);
  92.                    aListitem.SubItems.Add(_FileDefpath);
  93.                    aListitem.SubItems.Add(_FileArchive);
  94.                 end;
  95.                 end;
  96.         items.EndUpdate;
  97. end;
  98.  
  99. constructor TCakListview.Create( AOwner: TComponent );
  100. var aListcolumn : TListColumn;
  101.     i : integer;
  102. begin
  103.      inherited Create( AOwner );
  104.      for i := 0 to 8 do
  105.      begin
  106.      aListcolumn := Columns.Add;
  107.      aListcolumn.Width := Listwidth[i];
  108.      aListcolumn.Caption := Listname[i]; 
  109.      end;
  110. end;
  111. destructor TCakListview.Destroy;
  112. begin
  113.      inherited Destroy;
  114. end;
  115. procedure Register;
  116. begin
  117.   RegisterComponents('QZip', [TCakListView]);
  118. end;
  119.  
  120. end.
  121.