Guest User

ADR

a guest
Jan 8th, 2012
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 69.63 KB | None | 0 0
  1. unit main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ExtCtrls, CheckLst, ComCtrls, ActnCtrls, ToolWin, ActnMan,
  8.   ActnMenus, PlatformDefaultStyleActnCtrls, ActnList, Grids, ForumPoster,
  9.   IdHttp, BandActn, IniFiles, ImgList, IdComponent, RibbonLunaStyleActnCtrls,
  10.   FPResourceString, FPExceptions, adrStringUtils, Buttons, Spin, ActiveX,
  11.   Generics.Collections, StrUtils, Menus, ActnPopup, ImportConfigForm, Themes;
  12.  
  13. type
  14.   TMainForm = class(TForm)
  15.     ActionManager1: TActionManager;
  16.     MainToolBar: TActionToolBar;
  17.     StatusBar: TStatusBar;
  18.     PageControl: TPageControl;
  19.     SendTab: TTabSheet;
  20.     PostTab: TTabSheet;
  21.     PostTab_MsgGBox: TGroupBox;
  22.     PostTab_MsgGBox_TopicLabel: TLabel;
  23.     PostTab_MsgGBox_MsgLabel: TLabel;
  24.     PostTab_TopicEdit: TEdit;
  25.     PostTab_MsgMemo: TMemo;
  26.     ForumsTab: TTabSheet;
  27.     ForumsTab_FoumcConfGBox: TGroupBox;
  28.     ForumsTab_Panel: TPanel;
  29.     ForumsTab_NewBtn: TButton;
  30.     ForumsTab_EditBtn: TButton;
  31.     ForumsTab_DelBtn: TButton;
  32.     ForumsTab_ListBox: TListBox;
  33.     ForumsTab_NameEdit: TEdit;
  34.     ForumsTab_PassEdit: TEdit;
  35.     ForumsTab_LogURLEdit: TEdit;
  36.     ForumsTab_LogEdit: TEdit;
  37.     ForumsTab_Label1: TLabel;
  38.     ForumsTab_Label2: TLabel;
  39.     ForumsTab_Label3: TLabel;
  40.     ForumsTab_Label4: TLabel;
  41.     ForumsTab_Label6: TLabel;
  42.     ForumsTab_Label7: TLabel;
  43.     ForumsTab_EngineCBox: TComboBox;
  44.     ForumsTab_TegsCBox: TComboBox;
  45.     ForumsTab_Splitter1: TSplitter;
  46.     EngineTab: TTabSheet;
  47.     EngineTab_GBox: TGroupBox;
  48.     EngineTab_Splitter0: TSplitter;
  49.     EngineTab_Panel0: TPanel;
  50.     EngineTab_Label9: TLabel;
  51.     EngineTab_NameEdit: TEdit;
  52.     EngineTab_ListBox: TListBox;
  53.     EngineTab_Label10: TLabel;
  54.     PostingAction: TAction;
  55.     ExitAction: TAction;
  56.     EngineTab_Panel1: TPanel;
  57.     SaveAction: TAction;
  58.     ForumImportAction: TAction;
  59.     OpenDialog1: TOpenDialog;
  60.     CustomizeActionBars1: TCustomizeActionBars;
  61.     ToolBarAction: TAction;
  62.     StatusBarAction: TAction;
  63.     ImageList1: TImageList;
  64.     Panel: TPanel;
  65.     Proc_StatusLabel: TLabel;
  66.     Proc_AllPrgsBar: TProgressBar;
  67.     Label2: TLabel;
  68.     Label3: TLabel;
  69.     Proc_AllLabel: TLabel;
  70.     Proc_CompitLabel: TLabel;
  71.     Panel1: TPanel;
  72.     Proc_ContBtn: TButton;
  73.     Proc_CancBtn: TButton;
  74.     ForumsTab_ComentEdit: TEdit;
  75.     ForumsTab_Label9: TLabel;
  76.     ConfTab: TTabSheet;
  77.     EngineTab_ComentEdit: TEdit;
  78.     EngineTab_Label7: TLabel;
  79.     Conf_GeneralGBox: TGroupBox;
  80.     Panel3: TPanel;
  81.     EngineTab_Label8: TLabel;
  82.     EngineTab_PassEdit: TEdit;
  83.     EngineTab_LoginEdit: TEdit;
  84.     Label7: TLabel;
  85.     Label8: TLabel;
  86.     EngineTab_NewBtn: TButton;
  87.     EngineTab_DelBtn: TButton;
  88.     EngineTab_EditBtn: TButton;
  89.     Label11: TLabel;
  90.     EngineTab_TopicMsgEdit: TEdit;
  91.     EngineTab_TopicTitleEdit: TEdit;
  92.     Label12: TLabel;
  93.     EngineTab_MsgTitleEdit: TEdit;
  94.     Label9: TLabel;
  95.     Label10: TLabel;
  96.     EngineTab_MsgMsgEdit: TEdit;
  97.     Label13: TLabel;
  98.     ForumsTab_LoginBtnEdit: TEdit;
  99.     ForumsTab_TopicBtnEdit: TEdit;
  100.     ForumsTab_MsgBtnEdit: TEdit;
  101.     ForumsTab_Label11: TLabel;
  102.     ForumsTab_Label10: TLabel;
  103.     ForumsTab_Label5: TLabel;
  104.     BooksTab: TTabSheet;
  105.     BooksTab_StringGrid: TStringGrid;
  106.     BooksTab_GroupBox: TGroupBox;
  107.     EngineTab_Label14: TLabel;
  108.     EngineTab_TegsCBox: TComboBox;
  109.     SendTab_TopPanel: TPanel;
  110.     SendTab_BottomPanel: TPanel;
  111.     SendTab_BookGBox: TGroupBox;
  112.     SendTabTab_EngineGBox: TGroupBox;
  113.     SendTab_ForumGBox: TGroupBox;
  114.     Splitter2: TSplitter;
  115.     Splitter3: TSplitter;
  116.     SendTab_BookTegsActCBox: TCheckBox;
  117.     SendTab_Label14: TLabel;
  118.     SendTab_Label15: TLabel;
  119.     SendTab_Label16: TLabel;
  120.     SendTab_Label17: TLabel;
  121.     SendTab_ForumTegsActCBox: TCheckBox;
  122.     SendTab_Label18: TLabel;
  123.     SendTab_Label19: TLabel;
  124.     SendTab_EngineTegsActCBox: TCheckBox;
  125.     SendTab_TypeBookGBox: TGroupBox;
  126.     SendTab_TypeBookCBox: TComboBox;
  127.     BitBtn1: TBitBtn;
  128.     ActionMainMenuBar1: TActionMainMenuBar;
  129.     SendTab_DisplayBookGrid: TStringGrid;
  130.     SendTab_BookExcpTegsCBox: TComboBox;
  131.     SendTab_BookNeedTegsCBox: TComboBox;
  132.     SendTab_ForumExcpTegsCBox: TComboBox;
  133.     SendTab_ForumNeedTegsCBox: TComboBox;
  134.     SendTab_EngineNeedTegsCBox: TComboBox;
  135.     SendTab_EngineExcpTegsCBox: TComboBox;
  136.     RqsListUpdTimer: TTimer;
  137.     ConfTab_SendGBox: TGroupBox;
  138.     ConfTab_RqtListUpdDelaySEdit: TSpinEdit;
  139.     Label14: TLabel;
  140.     Label4: TLabel;
  141.     Proc_DoneLabel: TLabel;
  142.     Label6: TLabel;
  143.     Proc_ErrorLabel: TLabel;
  144.     PostingCancelAction: TAction;
  145.     Proc_LogListBox: TListBox;
  146.     DisplGrid_BookmarkNameAction: TAction;
  147.     DisplGrid_BookmarkTypeAction: TAction;
  148.     DisplGrid_BookmarkTegsAction: TAction;
  149.     DisplGrid_ForumNameAction: TAction;
  150.     DisplGrid_ForumTegsAction: TAction;
  151.     DisplGrid_EngineNameAction: TAction;
  152.     DisplGrid_EngineTegsAction: TAction;
  153.     BooksTab_NameEdit: TEdit;
  154.     BooksTab_TypeCBox: TComboBox;
  155.     BooksTab_URIEdit: TEdit;
  156.     BooksTab_TegsCBox: TComboBox;
  157.     SendTab_DispGridPopupBar: TPopupActionBar;
  158.     N1: TMenuItem;
  159.     N2: TMenuItem;
  160.     URI1: TMenuItem;
  161.     N7: TMenuItem;
  162.     N5: TMenuItem;
  163.     N6: TMenuItem;
  164.     N3: TMenuItem;
  165.     N4: TMenuItem;
  166.     procedure FormCreate(Sender: TObject);
  167.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  168.     procedure ExitActionExecute(Sender: TObject);
  169.     procedure ToolBarActionExecute(Sender: TObject);
  170.     procedure StatusBarActionExecute(Sender: TObject);
  171.     procedure Proc_ContBtnClick(Sender: TObject);
  172.     procedure PostLogStatusActionExecute(Sender: TObject);
  173.     procedure ForumsTab_NewBtnClick(Sender: TObject);
  174.     procedure ForumsTab_ListBoxClick(Sender: TObject);
  175.     procedure ForumsTab_EditBtnClick(Sender: TObject);
  176.     procedure ForumsTab_DelBtnClick(Sender: TObject);
  177.     procedure EngineTab_NewBtnClick(Sender: TObject);
  178.     procedure EngineTab_DelBtnClick(Sender: TObject);
  179.     procedure EngineTab_EditBtnClick(Sender: TObject);
  180.     procedure EngineTab_ListBoxClick(Sender: TObject);
  181.     procedure BooksTab_StringGridSelectCell(Sender: TObject;
  182.       ACol, ARow: Integer; var CanSelect: Boolean);
  183.     procedure SaveActionExecute(Sender: TObject);
  184.     procedure SendTabShow(Sender: TObject);
  185.     procedure PostingActionExecute(Sender: TObject);
  186.     procedure RunDelayListUpd(Sender: TObject);
  187.     procedure RqsListUpdTimerTimer(Sender: TObject);
  188.     procedure ConfTab_RqtListUpdDelaySEditChange(Sender: TObject);
  189.     procedure PostingCancelActionExecute(Sender: TObject);
  190.     procedure SendTab_TypeBookCBoxChange(Sender: TObject);
  191.     procedure tegs_TegsActCBoxClick(Sender: TObject);
  192.     procedure tegs_TegsCBoxKeyPress(Sender: TObject; var Key: Char);
  193.     procedure tegs_TegsCBoxEnter(Sender: TObject);
  194.     procedure SendTab_DisplayBookGridMouseDown(Sender: TObject;
  195.       Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  196.     procedure ForumImportActionExecute(Sender: TObject);
  197.     procedure SendTab_DisplayBookGridDrawCell(Sender: TObject; ACol,
  198.       ARow: Integer; Rect: TRect; State: TGridDrawState);
  199.     procedure DisplGrid_BookmarkNameActionExecute(Sender: TObject);
  200.     procedure DisplGrid_BookmarkTypeActionExecute(Sender: TObject);
  201.     procedure DisplGrid_BookmarkTegsActionExecute(Sender: TObject);
  202.     procedure DisplGrid_ForumNameActionExecute(Sender: TObject);
  203.     procedure DisplGrid_ForumTegsActionExecute(Sender: TObject);
  204.     procedure DisplGrid_EngineNameActionExecute(Sender: TObject);
  205.     procedure DisplGrid_EngineTegsActionExecute(Sender: TObject);
  206.     procedure FormResize(Sender: TObject);
  207.     procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer;
  208.       var Resize: Boolean);
  209.     procedure BooksTab_NameEditExit(Sender: TObject);
  210.     procedure BooksTab_TypeCBoxExit(Sender: TObject);
  211.     procedure BooksTab_URIEditExit(Sender: TObject);
  212.     procedure BooksTab_TegsCBoxExit(Sender: TObject);
  213.   private type
  214.     TImportDialogType = (irEngineName, irForumName, irForumURI, irBookURI);
  215.  
  216.     TColRec = record
  217.     private
  218.       FVisible: boolean;
  219.       procedure SetVisible(const Value: boolean);
  220.     public
  221.       Width: integer;
  222.       Index:integer;
  223.       property Visible: boolean read FVisible write SetVisible;
  224.     end;
  225.  
  226.     TRequestListCol = (rlNumber, rlChecked, rlBookmarkName, rlBookmarkType,
  227.       rlBookmarkURI, rlBookmarkTegs, rlForumName, rlForumTegs, rlEngineName,
  228.       rlEngineTegs);
  229.   private
  230.     const
  231.       RequestColStr: array [TRequestListCol] of string=
  232.         ('Number','Checked','BookmarkName','BookmarkType','BookmarkURI',
  233.          'BookmarkTegs','ForumName','ForumTegs','EngineName','EngineTegs');
  234.       RequestColCaption: array [TRequestListCol] of string=
  235.         ('№','Ак','Назва закладки','Тип закладки','URI закладки',
  236.          'Теги закладки','Назва форуму','Теги форуму','Назва двигуна',
  237.          'Теги двигуна');
  238.       ColWidthKoef = 1000;
  239.       ColWidthIndexMax: integer = ColWidthKoef * 8;
  240.     var
  241.       FPath: string;
  242.       FPoster: TForumsPoster;
  243.       FSession: integer;
  244.       FDisplBooksCount:integer;
  245.       FDisplColParam: array [TRequestListCol] of TColRec;
  246.     procedure Save;
  247.     procedure Load;
  248.  
  249.     procedure WriteToLog(const Msg: string);
  250.  
  251.     function GetForumConf: TForumConf;
  252.     procedure SetForumConf(const Rec: TForumConf); overload;
  253.     procedure SetForumConf(const Name: string); overload;
  254.     procedure UpdForumConf(const Name: string = '');
  255.     procedure EnbForumConf(AEnabled: Boolean); // Enabled
  256.     procedure NulForumConf;
  257.  
  258.     function GetEngineConf: TEngineConf;
  259.     procedure SetEngineConf(const Rec: TEngineConf); overload;
  260.     procedure SetEngineConf(const Name: string); overload;
  261.     procedure UpdEngineConf(const Name: string = '');
  262.     procedure EnbEngineConf(AEnabled: Boolean);
  263.     procedure NulEngineConf;
  264.  
  265.     procedure BookInit;
  266.     procedure UpdBookConf();
  267.  
  268.     procedure DrawCheck(R: TRect; AState: TCheckBoxState;
  269.       AEnabled: Boolean; ACanvas:TCanvas); overload; //це з CheckLst.TCheckList
  270.     procedure DrawCheck(ARow:integer); overload;
  271.     procedure SortStringGrid(Grid: TStringGrid; const ACell: Integer;
  272.       UpToDown: Boolean=false); overload;
  273.     procedure SortStringGrid(Grid: TStringGrid; const ACell: Integer;
  274.       UpToDown: Boolean; TopValue:string; InCell:integer); overload;
  275.  
  276.     procedure SetProgressPosition(const Status:TRqtStatusConteyner);
  277.     procedure PostingBegin(Sender:TObject; Max:integer);
  278.     procedure PostingProgress(Sender: TObject; const Status: TRqtStatusConteyner);
  279.     procedure PostingEnd(Sender:TObject);
  280.  
  281.     procedure ThreadLogAdd(Sender: TObject; const Item: TRqtThreadLogConteyner;
  282.         Action: TCollectionNotification);
  283.  
  284.  
  285.     function tegs_GetCBoxItems(const Tegs: TTegsList; const AllTegs: TTegsList): string; overload;
  286.     function tegs_GetCBoxItems(const Tegs: string;
  287.         AllTegs: TTegsList; Key:Char=#0): string; overload;
  288.     procedure tegs_TegsUpdate(ComboBox: TComboBox; Key: Char=#0);
  289.     procedure tegs_AllTegsUpdate;
  290.     function  tegs_ComboBoxFromIndex(Index:integer):TComboBox;
  291.  
  292.     //SendTab_DisplayGrid;
  293.     procedure disp_UpdRqsList;
  294.     procedure disp_GetColWidth;
  295.     procedure disp_SetColWidth;
  296.     function  disp_EnbColWidth:integer;
  297.     procedure disp_SetGrid(ABookmarks, UnMarkedBooks:TStrings); overload;
  298.     procedure disp_SetGrid; overload;
  299.  
  300.     function  ShowImportReplaseDialog(DialogType: TImportDialogType;
  301.       out UseFromAll: Boolean; const Str: string; const AFile:string):integer;
  302.   public
  303.     { Public declarations }
  304.   end;
  305.  
  306. var
  307.   MainForm: TMainForm;
  308.   NullComboBox: TComboBox;  //це для тегів
  309.  
  310. const        //bookList
  311.   blName=1;
  312.   blType=2;
  313.   blURI=3;
  314.   blTegs=4;
  315.  
  316.   mrReplase=20;
  317.   mrNoReplase=21;
  318.   mrRename=22;
  319.  
  320. implementation
  321.  
  322. {$R *.dfm}
  323.  
  324. const
  325.   FCheckWidth=8;
  326.   FCheckHeight=8;
  327.  
  328. procedure TMainForm.BookInit;
  329. begin
  330.   BooksTab_NameEdit.Parent:=BooksTab_StringGrid;
  331.   BooksTab_TypeCBox.Parent:=BooksTab_StringGrid;
  332.   BooksTab_URIEdit.Parent :=BooksTab_StringGrid;
  333.   BooksTab_TegsCBox.Parent:=BooksTab_StringGrid;
  334. end;
  335.  
  336. procedure TMainForm.BooksTab_NameEditExit(Sender: TObject);
  337. var
  338.  buff:TBookmarkConf;
  339. begin
  340.   with BooksTab_StringGrid do
  341.     if (Cells[Col,Row]<>BooksTab_NameEdit.Text) then
  342.     begin
  343.       buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
  344.       buff.Name:=BooksTab_NameEdit.Text;
  345.       FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
  346.       Cells[Col,Row]:=BooksTab_NameEdit.Text;
  347.     end;
  348.  
  349.   BooksTab_NameEdit.Visible:=false;
  350. end;
  351.  
  352. procedure TMainForm.BooksTab_StringGridSelectCell(Sender: TObject;
  353.   ACol, ARow: Integer; var CanSelect: Boolean);
  354.  
  355.   procedure SetEdit(Edit:TEdit);
  356.   begin
  357.     Edit.Text:=BooksTab_StringGrid.Cells[ACol, ARow];
  358.     Edit.Visible:=true;
  359.     Edit.SetFocus;
  360.   end;
  361.  
  362.   procedure SetCBox(CBox:TComboBox);
  363.   begin
  364.     if CBox.Style=csDropDownList then
  365.       CBox.ItemIndex:= CBox.Items.IndexOf(BooksTab_StringGrid.Cells[ACol, ARow])
  366.     else
  367.       CBox.Text:= BooksTab_StringGrid.Cells[ACol, ARow];
  368.     CBox.SetFocus;
  369.   end;
  370.  
  371.   procedure SetControl(Control:TControl);
  372.   begin
  373.     Control.Left  :=  BooksTab_StringGrid.CellRect(ACol,ARow).Left;
  374.     Control.Top   :=  BooksTab_StringGrid.CellRect(ACol,ARow).Top;
  375.     Control.Width :=  BooksTab_StringGrid.CellRect(ACol,ARow).Right -
  376.       BooksTab_StringGrid.CellRect(ACol,ARow).Left;
  377.     Control.Height:=  BooksTab_StringGrid.CellRect(ACol,ARow).Bottom -
  378.       BooksTab_StringGrid.CellRect(ACol,ARow).Top;
  379.     Control.Visible:=true;
  380.     if Control is TEdit then
  381.       SetEdit(TEdit(Control))
  382.     else
  383.       SetCBox(TComboBox(Control));
  384.   end;
  385.  
  386. begin
  387.   case ACol of
  388.     blName: SetControl(BooksTab_NameEdit);
  389.     blType: SetControl(BooksTab_TypeCBox);
  390.     blURI:  SetControl(BooksTab_URIEdit);
  391.     blTegs: SetControl(BooksTab_TegsCBox);
  392.   end;
  393. end;
  394.  
  395. procedure TMainForm.BooksTab_TegsCBoxExit(Sender: TObject);
  396. var
  397.  buff:TBookmarkConf;
  398. begin
  399.   with BooksTab_StringGrid do
  400.     if (Cells[Col,Row]<>BooksTab_TegsCBox.Text) then
  401.     begin
  402.       buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
  403.       buff.Tegs.TegsStr:=BooksTab_TegsCBox.Text;
  404.       FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
  405.       Cells[Col,Row]:=BooksTab_TegsCBox.Text;
  406.     end;
  407.   BooksTab_TegsCBox.Visible:=false;
  408. end;
  409.  
  410. procedure TMainForm.BooksTab_TypeCBoxExit(Sender: TObject);
  411. var
  412.  buff:TBookmarkConf;
  413. begin
  414.   with BooksTab_StringGrid do
  415.     if (Cells[Col,Row]<>BooksTab_TypeCBox.Text) then
  416.     begin
  417.       buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
  418.       buff.isMsg:=BooksTab_TypeCBox.Text=BooksTab_TypeCBox.Items.Strings[0];
  419.       FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
  420.       Cells[Col,Row]:=BooksTab_TypeCBox.Text;
  421.     end;
  422.  
  423.   BooksTab_TypeCBox.Visible:=false;
  424. end;
  425.  
  426. procedure TMainForm.BooksTab_URIEditExit(Sender: TObject);
  427. var
  428.  buff:TBookmarkConf;
  429. begin
  430.   with BooksTab_StringGrid, FPoster.DBList do
  431.     if Cells[Col,Row]<>BooksTab_URIEdit.Text then
  432.     begin
  433.       if BooksTab_URIEdit.Text='' then
  434.       begin
  435.         if MessageDlg('Видалити цей запис?', mtWarning,
  436.           mbOKCancel,-1)=mrOk then
  437.         begin
  438.           Bookmarks.Delete(Cells[Col,Row]);
  439.           UpdBookConf();
  440.         end;
  441.         BooksTab_URIEdit.Visible:=false;
  442.         Exit;
  443.       end;
  444.  
  445.       if Bookmarks.Contains(BooksTab_URIEdit.Text) then
  446.       begin
  447.         MessageDlg('Поле URI має бути унікальним!', mtWarning,
  448.           [mbOK],-1);
  449.         Exit;
  450.       end;
  451.  
  452.       buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
  453.       buff.URI:=BooksTab_URIEdit.Text;
  454.       Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
  455.  
  456.       Cells[Col,Row]:=BooksTab_URIEdit.Text;
  457.       UpdBookConf;
  458.     end;
  459.  
  460.   BooksTab_URIEdit.Visible:=false;
  461. end;
  462.  
  463. procedure TMainForm.ConfTab_RqtListUpdDelaySEditChange(Sender: TObject);
  464. begin
  465.   try
  466.     RqsListUpdTimer.Interval:=TSpinEdit(Sender).Value;
  467.   except
  468.     on E:EConvertError do
  469.       if not (E is EConvertError) then
  470.         raise;
  471.   end;
  472. end;
  473.  
  474. procedure TMainForm.DrawCheck(ARow: integer);
  475. const
  476.   State:array[#0..#1] of TCheckBoxState=(cbUnchecked,cbChecked);
  477. begin
  478.   if Length(SendTab_DisplayBookGrid.Cells[FDisplColParam[rlChecked].Index,
  479.     ARow])=1
  480.   then
  481.     DrawCheck(SendTab_DisplayBookGrid.CellRect(FDisplColParam[rlChecked].Index,
  482.       ARow), State[(SendTab_DisplayBookGrid.Cells[FDisplColParam[rlChecked].Index,
  483.       ARow])[1]],True, SendTab_DisplayBookGrid.Canvas);
  484. end;
  485.  
  486. procedure TMainForm.DisplGrid_BookmarkNameActionExecute(Sender: TObject);
  487. begin
  488.   disp_GetColWidth;
  489.   FDisplColParam[rlBookmarkName].Visible:= DisplGrid_BookmarkNameAction.Checked;
  490.   disp_SetGrid;
  491. end;
  492.  
  493. procedure TMainForm.DisplGrid_BookmarkTegsActionExecute(Sender: TObject);
  494. begin
  495.   disp_GetColWidth;
  496.   FDisplColParam[rlBookmarkTegs].Visible:= DisplGrid_BookmarkTegsAction.Checked;
  497.   disp_SetGrid;
  498. end;
  499.  
  500. procedure TMainForm.DisplGrid_BookmarkTypeActionExecute(Sender: TObject);
  501. begin
  502.   disp_GetColWidth;
  503.   FDisplColParam[rlBookmarkType].Visible:= DisplGrid_BookmarkTypeAction.Checked;
  504.   disp_SetGrid;
  505. end;
  506.  
  507. procedure TMainForm.DisplGrid_EngineNameActionExecute(Sender: TObject);
  508. begin
  509.   disp_GetColWidth;
  510.   FDisplColParam[rlEngineName].Visible:= DisplGrid_EngineNameAction.Checked;
  511.   disp_SetGrid;
  512. end;
  513.  
  514. procedure TMainForm.DisplGrid_EngineTegsActionExecute(Sender: TObject);
  515. begin
  516.   disp_GetColWidth;
  517.   FDisplColParam[rlEngineTegs].Visible:= DisplGrid_EngineTegsAction.Checked;
  518.   disp_SetGrid;
  519. end;
  520.  
  521. procedure TMainForm.DisplGrid_ForumNameActionExecute(Sender: TObject);
  522. begin
  523.   disp_GetColWidth;
  524.   FDisplColParam[rlForumName].Visible:= DisplGrid_ForumNameAction.Checked;
  525.   disp_SetGrid;
  526. end;
  527.  
  528. procedure TMainForm.DisplGrid_ForumTegsActionExecute(Sender: TObject);
  529. begin
  530.   disp_GetColWidth;
  531.   FDisplColParam[rlForumTegs].Visible:= DisplGrid_ForumTegsAction.Checked;
  532.   disp_SetGrid;
  533. end;
  534.  
  535. procedure TMainForm.DrawCheck(R: TRect; AState: TCheckBoxState;
  536.   AEnabled: Boolean; ACanvas:TCanvas);
  537. const
  538.   FCheckWidth:integer= 20;
  539.   FCheckHeight:integer= 20;
  540.   Flat:boolean= false;
  541. var
  542.   DrawState: Integer;
  543.   DrawRect: TRect;
  544.   OldBrushColor: TColor;
  545.   OldBrushStyle: TBrushStyle;
  546.   OldPenColor: TColor;
  547.   ElementDetails: TThemedElementDetails;
  548. begin
  549.   DrawRect.Left := R.Left + (R.Right - R.Left - FCheckWidth) div 2;
  550.   DrawRect.Top := R.Top + (R.Bottom - R.Top - FCheckHeight) div 2;
  551.   DrawRect.Right := DrawRect.Left + FCheckWidth;
  552.   DrawRect.Bottom := DrawRect.Top + FCheckHeight;
  553.   with ACanvas do
  554.   begin
  555.     if ThemeControl(Self) then
  556.     begin
  557.       case AState of
  558.         cbChecked:
  559.           if AEnabled then
  560.             ElementDetails := StyleServices.GetElementDetails(tbCheckBoxCheckedNormal)
  561.           else
  562.             ElementDetails := StyleServices.GetElementDetails(tbCheckBoxCheckedDisabled);
  563.         cbUnchecked:
  564.           if AEnabled then
  565.             ElementDetails := StyleServices.GetElementDetails(tbCheckBoxUncheckedNormal)
  566.           else
  567.             ElementDetails := StyleServices.GetElementDetails(tbCheckBoxUncheckedDisabled)
  568.         else // cbGrayed
  569.           if AEnabled then
  570.             ElementDetails := StyleServices.GetElementDetails(tbCheckBoxMixedNormal)
  571.           else
  572.             ElementDetails := StyleServices.GetElementDetails(tbCheckBoxMixedDisabled);
  573.       end;
  574.       StyleServices.DrawElement(Handle, ElementDetails, R);
  575.     end
  576.     else
  577.     begin
  578.       case AState of
  579.         cbChecked:
  580.           DrawState := DFCS_BUTTONCHECK or DFCS_CHECKED;
  581.         cbUnchecked:
  582.           DrawState := DFCS_BUTTONCHECK;
  583.         else // cbGrayed
  584.           DrawState := DFCS_BUTTON3STATE or DFCS_CHECKED;
  585.       end;
  586.       if not AEnabled then
  587.         DrawState := DrawState or DFCS_INACTIVE;
  588.       DrawFrameControl(Handle, DrawRect, DFC_BUTTON, DrawState);
  589.     end;
  590.  
  591.     if Flat then
  592.     begin
  593.       { Clip the 3d checkbox }
  594.       OldBrushStyle := Brush.Style;
  595.       OldBrushColor := Brush.Color;
  596.       OldPenColor := Pen.Color;
  597.  
  598.       Brush.Style := bsClear;
  599.       Pen.Color := Color;
  600.       with DrawRect do
  601.         Rectangle(Left, Top, Right, Bottom);
  602.  
  603.       { Draw flat rectangle in-place of clipped 3d checkbox above }
  604.       Brush.Style := bsClear;
  605.       Pen.Color := clBtnShadow;
  606.       with DrawRect do
  607.         Rectangle(Left + 1, Top + 1, Right - 1, Bottom - 1);
  608.       Brush.Style := OldBrushStyle;
  609.       Brush.Color := OldBrushColor;
  610.       Pen.Color := OldPenColor;
  611.     end;
  612.   end;
  613. end;
  614.  
  615. function TMainForm.disp_EnbColWidth: integer;
  616. var
  617.   I: TRequestListCol;
  618. begin
  619.   Result:=0;
  620.   for I := rlBookmarkName to High(FDisplColParam) do
  621.     if FDisplColParam[i].Visible and (FDisplColParam[i].Index<>-1) then
  622.       inc(Result,FDisplColParam[i].Width);
  623. end;
  624.  
  625. procedure TMainForm.EnbEngineConf(AEnabled: Boolean);
  626. begin
  627.   if EngineTab_NameEdit.Enabled <> AEnabled then
  628.   begin
  629.     EngineTab_NameEdit.Enabled := AEnabled;
  630.     EngineTab_ComentEdit.Enabled := AEnabled;
  631.     EngineTab_LoginEdit.Enabled := AEnabled;
  632.     EngineTab_PassEdit.Enabled := AEnabled;
  633.     EngineTab_MsgTitleEdit.Enabled := AEnabled;
  634.     EngineTab_MsgMsgEdit.Enabled := AEnabled;
  635.     EngineTab_TopicTitleEdit.Enabled := AEnabled;
  636.     EngineTab_TopicMsgEdit.Enabled := AEnabled;
  637.   end;
  638.   if not AEnabled then
  639.     NulEngineConf;
  640. end;
  641.  
  642. procedure TMainForm.EnbForumConf(AEnabled: Boolean);
  643. begin
  644.   if ForumsTab_NameEdit.Enabled <> AEnabled then
  645.   begin
  646.     ForumsTab_NameEdit.Enabled := AEnabled;
  647.     ForumsTab_ComentEdit.Enabled := AEnabled;
  648.     ForumsTab_LogEdit.Enabled := AEnabled;
  649.     ForumsTab_PassEdit.Enabled := AEnabled;
  650.     ForumsTab_LogURLEdit.Enabled := AEnabled;
  651.     ForumsTab_LoginBtnEdit.Enabled := AEnabled;
  652.     ForumsTab_MsgBtnEdit.Enabled := AEnabled;
  653.     ForumsTab_TopicBtnEdit.Enabled := AEnabled;
  654.     ForumsTab_EngineCBox.Enabled := AEnabled;
  655.     ForumsTab_TegsCBox.Enabled := AEnabled;
  656.     ForumsTab_EditBtn.Enabled := AEnabled;
  657.     ForumsTab_DelBtn.Enabled := AEnabled;
  658.   end;
  659.   if not AEnabled then
  660.     NulForumConf;
  661. end;
  662.  
  663. procedure TMainForm.EngineTab_DelBtnClick(Sender: TObject);
  664. var
  665.   n: Integer;
  666. begin
  667.   n := EngineTab_ListBox.ItemIndex;
  668.   if n > -1 then
  669.   begin
  670.     FPoster.DBList.Engines.Delete(EngineTab_ListBox.Items.Strings[n]);
  671.     if n > 1 then
  672.       UpdEngineConf(EngineTab_ListBox.Items.Strings[n - 1])
  673.     else
  674.       UpdEngineConf();
  675.   end
  676.   else
  677.     EnbEngineConf(False);
  678. end;
  679.  
  680. procedure TMainForm.EngineTab_EditBtnClick(Sender: TObject);
  681. var
  682.   Rec: TEngineConf;
  683.   LastName: string;
  684. begin
  685.   Rec := GetEngineConf;
  686.   LastName:= EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex];
  687.   if Rec.Name = '' then
  688.     ShowMessage(SMsgNulName)
  689.   else
  690.     if not ((LastName <> Rec.Name)
  691.       and FPoster.DBList.Engines.Contains(Rec.Name)
  692.       and (MessageDlg(Format(SMsgOverwriteSite, [Rec.Name]),mtWarning,
  693.         mbOKCancel,-1) <> mrOk))
  694.     then
  695.       with FPoster.DBList.Engines do
  696.       begin
  697.         if (LastName<>Rec.Name)
  698.           and Contains(Rec.Name)
  699.         then
  700.           Delete(Rec.Name);
  701.         ItemsFromName[LastName]:= Rec;
  702.         UpdEngineConf(Rec.Name);
  703.       end;
  704. end;
  705.  
  706. procedure TMainForm.EngineTab_ListBoxClick(Sender: TObject);
  707. begin
  708.   if EngineTab_ListBox.ItemIndex>=0 then
  709.     SetEngineConf(EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex])
  710.   else
  711.     NulEngineConf;
  712. end;
  713.  
  714. procedure TMainForm.EngineTab_NewBtnClick(Sender: TObject);
  715. var
  716.   Rec: TEngineConf;
  717. begin
  718.   Rec.Name := GenName(SDefEngineName, FPoster.DBList.Engines.ListOfNames);
  719.   Rec.Tegs := TTegsList.Create;
  720.   FPoster.DBList.Engines.Add(Rec);
  721.   UpdEngineConf(Rec.Name);
  722. end;
  723.  
  724. procedure TMainForm.ExitActionExecute(Sender: TObject);
  725. begin
  726.   close;
  727. end;
  728.  
  729. procedure TMainForm.FormCanResize(Sender: TObject; var NewWidth,
  730.   NewHeight: Integer; var Resize: Boolean);
  731. begin
  732.   if NewWidth<>Width then
  733.     disp_GetColWidth;
  734. end;
  735.  
  736. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
  737. begin
  738.   FPoster.Request.Terminate;
  739.   Save;
  740.   ActionManager1.FileName := FPath + SPathActItemsSave;
  741.   FPoster.Free;
  742. end;
  743.  
  744. procedure TMainForm.FormCreate(Sender: TObject);
  745. begin
  746.   FPath := ExtractFilePath(ParamStr(0));
  747.   with BooksTab_StringGrid do
  748.   begin
  749.     ColWidths[0] := 24;
  750.     ColWidths[blName] := 130;
  751.     ColWidths[blType] := 90;
  752.     ColWidths[blURI]  := 170;
  753.     ColWidths[blTegs] := 130;
  754.     Rows[0].Text := '№'#10'Назва'#10'Тип'#10'URI'#10'Теги';
  755.     Cells[0, 1] := '1';
  756.   end;
  757.   SendTab_DisplayBookGrid.ColWidths[0]:=32;
  758.   SendTab_DisplayBookGrid.ColWidths[1]:=18;
  759.  
  760.   FPoster := TForumsPoster.Create;
  761.   with FPoster.DBList, FPoster, FPoster.Request do
  762.   begin
  763.     ForumsSavePath := FPath + SPathForumSave;
  764.     EngineSavePath := FPath + SPathEngineSave;
  765.     BooksSavePath := FPath + SPathBookSave;
  766.     OnWorkBegin :=  PostingBegin;
  767.     OnWork  :=  PostingProgress;
  768.     OnWorkEnd :=  PostingEnd;
  769.     OnThreadEvent := ThreadLogAdd;
  770.   end;
  771.  
  772.  
  773.   try
  774.     Load;
  775.   except
  776.     on E: Exception do
  777.       if not (E is EFOpenError) then
  778.         raise;
  779.   end;
  780.  
  781.   BookInit;
  782.  
  783.   UpdEngineConf();
  784.   UpdForumConf();
  785.   UpdBookConf();
  786.  
  787.   NullComboBox:=TComboBox.Create(Self); //це для тегів
  788.   NullComboBox.Visible:=false;
  789.   NullComboBox.Parent:=Self;
  790.  
  791.   FSession:=0;
  792.   FDisplBooksCount:=0;
  793. end;
  794.  
  795. procedure TMainForm.FormResize(Sender: TObject);
  796. begin
  797.   disp_SetColWidth;
  798. end;
  799.  
  800. procedure TMainForm.ForumImportActionExecute(Sender: TObject);
  801. type
  802.   TErrType = (etUnknown, etNone, etFileItem, etFileVersion);
  803.   TFileError = record
  804.     FileName: string;
  805.     FileType: TFPConfDB.TConfType;
  806.     FileVersion: Double;
  807.     ErrType: TErrType;
  808.     Items: Pointer;
  809.     ItemsError: array of integer;
  810.   end;
  811.   TFileErrorArray = TArray<TFileError>;
  812.  
  813.   TImportDialogResult = (drUnknown, drReplase, drNoReplase, drRename, drAbort);
  814.  
  815.   procedure LoadFileItem(Engines:TEngineConfArray;
  816.     var FileError:TFileError); overload;
  817.   var
  818.     IntArray:TArray<Integer>;
  819.     I,J:integer;
  820.   begin
  821.     I:=0;
  822.     FPoster.DBList.Engines.AddRange(Engines, IntArray);
  823.     for J := 0 to High(IntArray) do
  824.       if IntArray[J]<0 then
  825.         inc(I);
  826.     if I<>0 then
  827.     begin
  828.       FileError.ErrType:=etFileItem;
  829.       FileError.Items:=nil;
  830.       SetLength(TEngineConfArray(FileError.Items),I);
  831.       SetLength(FileError.ItemsError,I);
  832.       for J := 0 to I-1 do
  833.         if IntArray[J]<0 then
  834.         begin
  835.           Dec(I);
  836.           FileError.ItemsError[I]:=IntArray[J];
  837.           TEngineConfArray(FileError.Items)[I]:=Engines[J];
  838.         end;
  839.     end;
  840.   end;
  841.  
  842.   procedure LoadFileItem(Forums:TForumConfArray;
  843.     var FileError:TFileError); overload;
  844.   var
  845.     IntArray:TArray<Integer>;
  846.     I,J:integer;
  847.   begin
  848.     I:=0;
  849.     FPoster.DBList.Forums.AddRange(Forums, IntArray);
  850.     for J := 0 to High(IntArray) do
  851.       if IntArray[J]<0 then
  852.         inc(I);
  853.     if I<>0 then
  854.     begin
  855.       FileError.ErrType:=etFileItem;
  856.       FileError.Items:=nil;
  857.       SetLength(TEngineConfArray(FileError.Items),I);
  858.       SetLength(FileError.ItemsError,I);
  859.       for J := 0 to I-1 do
  860.         if IntArray[J]<0 then
  861.         begin
  862.           Dec(I);
  863.           FileError.ItemsError[I]:=IntArray[J];
  864.           TForumConfArray(FileError.Items)[I]:=Forums[J];
  865.         end;
  866.     end;
  867.   end;
  868.  
  869.   procedure LoadFileItem(Bookmarks:TBookmarkConfArray;
  870.     var FileError:TFileError); overload;
  871.   var
  872.     IntArray:TArray<Integer>;
  873.     I,J:integer;
  874.   begin
  875.     I:=0;
  876.     FPoster.DBList.Bookmarks.AddRange(Bookmarks, IntArray);
  877.     for J := 0 to High(IntArray) do
  878.       if IntArray[J]<0 then
  879.         inc(I);
  880.     if I<>0 then
  881.     begin
  882.       FileError.ErrType:=etFileItem;
  883.       FileError.Items:=nil;
  884.       SetLength(TBookmarkConfArray(FileError.Items),I);
  885.       SetLength(FileError.ItemsError,I);
  886.       for J := 0 to I-1 do
  887.         if IntArray[J]<0 then
  888.         begin
  889.           Dec(I);
  890.           FileError.ItemsError[I]:=IntArray[J];
  891.           TBookmarkConfArray(FileError.Items)[I]:=Bookmarks[J];
  892.         end;
  893.     end;
  894.   end;
  895.  
  896.   function LoadFile(const FileName:string;
  897.     TryLoad:boolean=False):TFileError;   overload;
  898.   var
  899.     EngineArray: TEngineConfArray;
  900.     ForumArray: TForumConfArray;
  901.     BookmarkArray: TBookmarkConfArray;
  902.   begin
  903.     Result.FileName:= FileName;
  904.     Result.FileType:= TFPConfDB.CheckConfType(FileName);
  905.     Result.FileVersion:=  TFPConfDB.CheckConfVersion(FileName);
  906.     Result.ErrType:= etUnknown;
  907.     case Result.FileType of
  908.       ctUnknown: raise EFPException.Create('Unknown file type');
  909.       ctEngine:
  910.       begin
  911.         EngineArray:=TFPConfDB.LoadEngine(FileName);
  912.         if (not TryLoad) and (Result.FileVersion<>TFPConfDB.EngineVersion) then
  913.         begin
  914.           Result.ErrType:=etFileVersion;
  915.           Result.Items:=EngineArray;
  916.           Exit;
  917.         end;
  918.         LoadFileItem(EngineArray, Result);
  919.         SetLength(EngineArray,0);
  920.       end;
  921.       ctForum:
  922.       begin
  923.         ForumArray:=TFPConfDB.LoadForum(FileName);
  924.         if (not TryLoad) and (Result.FileVersion<>TFPConfDB.ForumVersion) then
  925.         begin
  926.           Result.ErrType:=etFileVersion;
  927.           Result.Items:=ForumArray;
  928.           Exit;
  929.         end;
  930.         LoadFileItem(ForumArray, Result);
  931.         SetLength(ForumArray,0);
  932.       end;
  933.       ctBookmark:
  934.       begin
  935.         BookmarkArray:=TFPConfDB.LoadBookmark(FileName);
  936.         if (not TryLoad) and (Result.FileVersion<>TFPConfDB.BookmarkVersion) then
  937.         begin
  938.           Result.ErrType:=etFileVersion;
  939.           Result.Items:=BookmarkArray;
  940.           Exit;
  941.         end;
  942.         LoadFileItem(BookmarkArray, Result);
  943.         SetLength(BookmarkArray,0);
  944.       end;
  945.     end;
  946.     if Result.ErrType=etUnknown then
  947.       Result.ErrType:=etNone;
  948.   end;
  949.  
  950.   function ReloadFileItem(const FileError:TFileError; index:integer):TFileError;
  951.   var
  952.     Engines:TEngineConfArray;
  953.     Forums:TForumConfArray;
  954.     Bookmarks:TBookmarkConfArray;
  955.   begin
  956.     Result:=FileError;
  957.     Result.Items:=nil;
  958.     Result.ErrType:=etNone;
  959.     case FileError.FileType of
  960.       ctUnknown: raise Exception.Create('ctUnknown in ReloadFileItem');
  961.       ctEngine:
  962.       begin
  963.         SetLength(Engines,1);
  964.         Engines[0]:=TEngineConfArray(FileError.Items)[index];
  965.         LoadFileItem(Engines, Result);
  966.         SetLength(Engines,0);
  967.       end;
  968.       ctForum:
  969.       begin
  970.         SetLength(Forums,1);
  971.         Forums[0]:=TForumConfArray(FileError.Items)[index];
  972.         LoadFileItem(Forums, Result);
  973.         SetLength(Forums,0);
  974.       end;
  975.       ctBookmark:
  976.       begin
  977.         SetLength(Bookmarks,1);
  978.         Bookmarks[0]:=TBookmarkConfArray(FileError.Items)[index];
  979.         LoadFileItem(Bookmarks, Result);
  980.         SetLength(Bookmarks,0);
  981.       end;
  982.     end;
  983.   end;
  984.  
  985.   function LoadAll(Files, LoadError:TStrings):TFileErrorArray;
  986.   var
  987.     FEList: TList<TFileError>;
  988.     I: Integer;
  989.     buff: TFileError;
  990.   begin
  991.     FEList := TList<TFileError>.Create;
  992.     try
  993.       for I := 0 to Files.Count-1 do
  994.         try
  995.           buff:=LoadFile(Files.Strings[i]);
  996.           if buff.ErrType<>etNone then
  997.             FEList.Add(buff);
  998.         except
  999.           on E:EFPException do
  1000.             LoadError.Add('"' + Files.Strings[i] + '": ' + E.Message)
  1001.         end;
  1002.       Result:=FEList.ToArray;
  1003.     finally
  1004.       FEList.Free;
  1005.     end;
  1006.   end;
  1007.  
  1008.   function DoDialog(DlgType:TImportDialogType; AName, AFile:string;
  1009.     var LastResult:TImportDialogResult):TImportDialogResult;
  1010.   var
  1011.     isFromAll:boolean;
  1012.   begin
  1013.     Result:=drUnknown;
  1014.     if LastResult=drUnknown then
  1015.     begin
  1016.       case ShowImportReplaseDialog(DlgType,isFromAll,AName,AFile) of
  1017.         mrReplase: Result:=drReplase;
  1018.         mrNoReplase: Result:=drNoReplase;
  1019.         mrRename: Result:=drRename;
  1020.         mrAbort:  Result:=drAbort;
  1021.       end;
  1022.       if isFromAll then
  1023.         LastResult:=Result;
  1024.     end
  1025.     else
  1026.       Result:=LastResult;
  1027.   end;
  1028.  
  1029.   function NeedReadFile(const ErrFile:TFileError):boolean;
  1030.   var
  1031.     ConfVersion: double;
  1032.     ToConfName: string;
  1033.   begin
  1034.     result:=false;
  1035.     ConfVersion:=0;
  1036.     case ErrFile.FileType of
  1037.       ctUnknown: raise Exception.Create('ctUnknown in NeedReadFile');
  1038.       ctEngine:
  1039.       begin
  1040.         ConfVersion:=TFPConfDB.EngineVersion;
  1041.         ToConfName:=SToEngine;
  1042.       end;
  1043.       ctForum:
  1044.       begin
  1045.         ConfVersion:=TFPConfDB.ForumVersion;
  1046.         ToConfName:=SToForum;
  1047.       end;
  1048.       ctBookmark:
  1049.       begin
  1050.         ConfVersion:=TFPConfDB.BookmarkVersion;
  1051.         ToConfName:=SToBookmark;
  1052.       end;
  1053.     end;
  1054.     if ErrFile.FileVersion <> ConfVersion then
  1055.       if Abs(ErrFile.FileVersion-ConfVersion)<1 then  //різниця в мінорні версії
  1056.         if MessageDlg(Format(SWrgDBVersionMinorDelta,
  1057.           [ToConfName, ErrFile.FileVersion, ConfVersion]),
  1058.           mtWarning, mbAbortIgnore,-1)<>mrAbort
  1059.         then
  1060.           Result:= True
  1061.       else
  1062.         MessageBox(0, PChar(Format(SErrDBVersionMajorDelta,
  1063.           [ToConfName, ErrFile.FileVersion, ConfVersion])),
  1064.           PChar(SErrLoadFileTitle), MB_OK or MB_ICONSTOP or MB_TASKMODAL)
  1065.     else
  1066.       Result:=true;
  1067.   end;
  1068.  
  1069.   procedure ComplitedImport(ErrorFile:TFileError;
  1070.     var DlgTMP:TImportDialogResult; LoadErrors:TStrings);   overload;
  1071.   var
  1072.     J: Integer; //обробляє решту
  1073.     buff:TFileError;
  1074.   begin
  1075.     try
  1076.       with FPoster.DBList, ErrorFile do
  1077.         case ErrType of
  1078.           etUnknown: raise Exception.Create('etUnknown in ComplitedImport: 1');
  1079.           etNone: ;
  1080.           etFileItem:
  1081.             case ErrorFile.FileType of
  1082.               ctUnknown: raise Exception.Create('ctUnknown in ComplitedImport: 3');
  1083.               ctEngine:
  1084.                 for J := 0 to High(ErrorFile.ItemsError) do
  1085.                   case DoDialog(irEngineName,
  1086.                                 TEngineConfArray(Items)[J].Name,
  1087.                                 ErrorFile.FileName,
  1088.                                 DlgTmp) of
  1089.                     drUnknown:
  1090.                       raise Exception.Create('drUnknown in ComplitedImport: 4');
  1091.                     drReplase:
  1092.                       Engines.ItemsFromName[TEngineConfArray(Items)[J].Name]
  1093.                         := TEngineConfArray(Items)[J];
  1094.                     drNoReplase:;
  1095.                     drRename:
  1096.                     begin
  1097.                       TEngineConfArray(Items)[J].Name:= GenName(
  1098.                         TEngineConfArray(Items)[J].Name, Engines.ListOfNames);
  1099.                       ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
  1100.                         LoadErrors);
  1101.                     end;
  1102.                     drAbort: exit;
  1103.                   end;
  1104.               ctForum:
  1105.                 for J := 0 to High(ItemsError) do
  1106.                   case DoDialog(irForumName,
  1107.                                 TForumConfArray(Items)[J].Name,
  1108.                                 ErrorFile.FileName,
  1109.                                 DlgTmp) of
  1110.                     drUnknown:
  1111.                       raise Exception.Create('drUnknown in'
  1112.                         + ' ComplitedImport: 5');
  1113.                     drReplase:
  1114.                       if ItemsError[J]=arIdentExists then
  1115.                         Forums.ItemsFromName[TForumConfArray(Items)[J].Name] :=
  1116.                           TForumConfArray(Items)[J]
  1117.                       else   //arSubIdentExists
  1118.                         Forums.ItemsFromURI[TForumConfArray(Items)[J].LogURI]:=
  1119.                           TForumConfArray(Items)[J];
  1120.                     drNoReplase:;
  1121.                     drRename:
  1122.                       if ItemsError[J]=arIdentExists then
  1123.                       begin
  1124.                         TForumConfArray(Items)[J].Name:=
  1125.                           GenName(TForumConfArray(Items)[J].Name,
  1126.                           Forums.ListOfNames);
  1127.                         ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
  1128.                           LoadErrors);
  1129.                       end
  1130.                       else
  1131.                       begin
  1132.                         TForumConfArray(Items)[J].LogURI:=
  1133.                           GenName(TForumConfArray(Items)[J].LogURI,
  1134.                           Forums.ListOfURI);
  1135.                         ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
  1136.                           LoadErrors);
  1137.                       end;
  1138.                     drAbort: exit;
  1139.                   end;
  1140.               ctBookmark:
  1141.                 for J := 0 to High(ItemsError) do
  1142.                   case DoDialog(irBookURI,
  1143.                                 TBookmarkConfArray(Items)[J].URI,
  1144.                                 ErrorFile.FileName,
  1145.                                 DlgTmp) of
  1146.                     drUnknown:
  1147.                       raise Exception.Create('drUnknown in'
  1148.                         + ' ComplitedImport: 6');
  1149.                     drReplase:
  1150.                       FPoster.DBList.Bookmarks.ItemsFromURI[
  1151.                         TBookmarkConfArray(Items)[J].Name]:=
  1152.                         TBookmarkConfArray(Items)[J];
  1153.                     drNoReplase:;
  1154.                     drRename:
  1155.                     begin
  1156.                       TBookmarkConfArray(Items)[J].URI:=
  1157.                         GenName(TBookmarkConfArray(Items)[J].URI,
  1158.                         FPoster.DBList.Bookmarks.ListOfURI);
  1159.                       ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
  1160.                         LoadErrors);
  1161.                     end;
  1162.                     drAbort: exit;
  1163.                   end;
  1164.             end;
  1165.           etFileVersion:
  1166.             if NeedReadFile(ErrorFile) then
  1167.               try
  1168.                 buff:=LoadFile(ErrorFile.FileName, True);
  1169.                 ComplitedImport(buff, DlgTmp, LoadErrors);
  1170.               except
  1171.                 on E:EFPException do
  1172.                   LoadErrors.Add('"'+ErrorFile.FileName+'": '+E.Message);
  1173.               end;
  1174.         end;
  1175.     finally
  1176.       case ErrorFile.FileType of
  1177.         ctEngine: SetLength(TEngineConfArray(ErrorFile.Items),0);
  1178.         ctForum: SetLength(TForumConfArray(ErrorFile.Items),0);
  1179.         ctBookmark: SetLength(TBookmarkConfArray(ErrorFile.Items),0);
  1180.         ctUnknown: raise Exception.Create('ctUnknown in CoplitedImport: 7');
  1181.       end;
  1182.       SetLength(ErrorFile.ItemsError,0);
  1183.       end;
  1184.   end;
  1185.  
  1186.   procedure ComplitedImport(ErrorFiles:TFileErrorArray;
  1187.     LoadErrors:TStrings);   overload;
  1188.   var
  1189.     I: Integer;
  1190.     DlgTmp:TImportDialogResult;
  1191.   begin
  1192.     DlgTmp:=drUnknown;
  1193.     for I := 0 to High(ErrorFiles) do
  1194.       ComplitedImport(ErrorFiles[i], DlgTmp, LoadErrors);
  1195.   end;
  1196.  
  1197. var
  1198.   Strings: TStrings;
  1199. begin
  1200.   if OpenDialog1.Execute then
  1201.   begin
  1202.     Strings := TStringList.Create;
  1203.     try
  1204.       ComplitedImport(LoadAll(OpenDialog1.Files,Strings),Strings);
  1205.     finally
  1206.       Strings.Free;
  1207.       UpdForumConf();
  1208.       UpdEngineConf();
  1209.       UpdBookConf();
  1210.     end;
  1211.   end;
  1212. end;
  1213.  
  1214. procedure TMainForm.ForumsTab_DelBtnClick(Sender: TObject);
  1215. var
  1216.   n: Integer;
  1217.   Rec: TForumConf;
  1218. begin
  1219.   n := ForumsTab_ListBox.ItemIndex;
  1220.   if n > -1 then
  1221.   begin
  1222.     FPoster.DBList.Forums.Delete(ForumsTab_ListBox.Items.Strings[n]);
  1223.     if n > 1 then
  1224.       UpdForumConf(ForumsTab_ListBox.Items.Strings[n - 1])
  1225.     else
  1226.       UpdForumConf();
  1227.   end
  1228.   else
  1229.     SetForumConf(Rec);
  1230. end;
  1231.  
  1232. procedure TMainForm.ForumsTab_EditBtnClick(Sender: TObject);
  1233. var
  1234.   Rec: TForumConf;
  1235.   LastName: string;
  1236. begin
  1237.   Rec := GetForumConf;
  1238.   LastName:=ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex];
  1239.   if Rec.Name = '' then
  1240.     ShowMessage(SMsgNulName)
  1241.   else
  1242.     if not ((LastName <> Rec.Name)
  1243.       and FPoster.DBList.Forums.Contains(Rec.Name)
  1244.       and  (MessageDlg(Format(SMsgOverwriteSite, [Rec.Name]),mtWarning,
  1245.           mbOKCancel,-1) <> mrOk))
  1246.     then
  1247.       with FPoster.DBList.Forums do
  1248.         begin
  1249.           if (LastName<>Rec.Name)
  1250.             and Contains(Rec.Name)
  1251.           then
  1252.             Delete(Rec.Name);
  1253.           ItemsFromName[LastName]:= Rec;
  1254.           UpdForumConf(Rec.Name);
  1255.         end;
  1256. end;
  1257.  
  1258. procedure TMainForm.ForumsTab_ListBoxClick(Sender: TObject);
  1259. begin
  1260.   if ForumsTab_ListBox.ItemIndex>=0 then
  1261.     SetForumConf(ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex])
  1262.   else
  1263.     NulForumConf;
  1264. end;
  1265.  
  1266. procedure TMainForm.ForumsTab_NewBtnClick(Sender: TObject);
  1267. var
  1268.   Rec: TForumConf;
  1269. begin
  1270.   Rec.Name := GenName(SDefSiteName, FPoster.DBList.Forums.ListOfNames);
  1271.   Rec.Tegs := TTegsList.Create;
  1272.   FPoster.DBList.Forums.Add(Rec);
  1273.   UpdForumConf(Rec.Name);
  1274. end;
  1275.  
  1276.  
  1277. function TMainForm.tegs_GetCBoxItems(const Tegs: string;
  1278.     AllTegs: TTegsList; Key:Char=#0): string;
  1279. var
  1280.   FTegs: TTegsList;
  1281. begin
  1282.   FTegs := TTegsList.Create(false);
  1283.   try
  1284.     FTegs.TegsStr := Tegs;
  1285.     if not ((Tegs='') or (((TrimRight(Tegs[Length(Tegs)-1])=',')) or (Key=','))
  1286.       and (Key<>#8))
  1287.     then
  1288.       FTegs.TegsList.Delete(FTegs.TegsList.Count-1);
  1289.     result := tegs_GetCBoxItems(FTegs, AllTegs);
  1290.   finally
  1291.     FTegs.Free;
  1292.   end;
  1293. end;
  1294.  
  1295. procedure TMainForm.disp_GetColWidth;
  1296.  
  1297.   function GetSum:integer;
  1298.   var
  1299.     I:TRequestListCol;
  1300.   begin
  1301.     Result:=0;
  1302.     for I := rlBookmarkName to High(FDisplColParam) do
  1303.       Inc(Result,FDisplColParam[i].Width);
  1304.   end;
  1305.  
  1306.   function GetColsWidth:integer;
  1307.   var
  1308.     I: TRequestListCol;
  1309.   begin
  1310.     Result:=0;
  1311.     for I := rlBookmarkName to High(FDisplColParam) do
  1312.       if FDisplColParam[i].Visible and (FDisplColParam[i].Index<>-1) then
  1313.         inc(Result, SendTab_DisplayBookGrid.ColWidths[FDisplColParam[i].Index]);
  1314.   end;
  1315.  
  1316. var
  1317.   I:TRequestListCol;
  1318.   J:integer;
  1319. begin
  1320.   J:=disp_EnbColWidth;
  1321.   with SendTab_DisplayBookGrid do
  1322.     for I := rlBookmarkName to High(FDisplColParam) do
  1323.       if FDisplColParam[i].Visible
  1324.         and (FDisplColParam[i].Index>1)
  1325.       then
  1326.         FDisplColParam[i].Width:=(J * //коефіціент
  1327.           ColWidths[FDisplColParam[i].Index]) div GetColsWidth; //процент
  1328.  
  1329.   while GetSum<ColWidthIndexMax do
  1330.     for I := rlBookmarkName to High(FDisplColParam) do
  1331.       if FDisplColParam[i].Width<ColWidthKoef then
  1332.       begin
  1333.         inc(FDisplColParam[i].Width);
  1334.         break;
  1335.       end;
  1336.   while GetSum>ColWidthIndexMax do
  1337.     for I := rlBookmarkName to High(FDisplColParam) do
  1338.       if FDisplColParam[i].Width>ColWidthKoef then
  1339.       begin
  1340.         Dec(FDisplColParam[i].Width);
  1341.         break;
  1342.       end;
  1343.  
  1344. end;
  1345.  
  1346. function TMainForm.tegs_GetCBoxItems(const Tegs: TTegsList; const AllTegs: TTegsList): string;
  1347. var
  1348.   I: Integer;
  1349.   s: string;
  1350. begin
  1351.   result := '';
  1352.   s := Tegs.TegsStr;
  1353.  
  1354.   if (s <> '') then
  1355.     s := s + ', ';
  1356.   for I := 0 to AllTegs.TegsList.Count - 1 do
  1357.     if not Tegs.TegInList(AllTegs.TegsList.Strings[I]) then
  1358.       result := result + s + AllTegs.TegsList.Strings[I] + #13#10;
  1359. end;
  1360.  
  1361. function TMainForm.GetEngineConf: TEngineConf;
  1362. begin
  1363.   with result do
  1364.   begin
  1365.     Name := EngineTab_NameEdit.Text;
  1366.     Coment := EngineTab_ComentEdit.Text;
  1367.     LogUser := EngineTab_LoginEdit.Text;
  1368.     LogPass := EngineTab_PassEdit.Text;
  1369.     MsgTitle := EngineTab_MsgTitleEdit.Text;
  1370.     MsgMess := EngineTab_MsgMsgEdit.Text;
  1371.     TopicTitle := EngineTab_TopicTitleEdit.Text;
  1372.     TopicMsg := EngineTab_TopicMsgEdit.Text;
  1373.     Tegs := TTegsList.Create;
  1374.     Tegs.TegsStr := EngineTab_TegsCBox.Text;
  1375.   end;
  1376. end;
  1377.  
  1378. function TMainForm.GetForumConf: TForumConf;
  1379. begin
  1380.   with result do
  1381.   begin
  1382.     Name := ForumsTab_NameEdit.Text;
  1383.     Coment := ForumsTab_ComentEdit.Text;
  1384.     LogName := ForumsTab_LogEdit.Text;
  1385.     LogPass := ForumsTab_PassEdit.Text;
  1386.     LogURI := ForumsTab_LogURLEdit.Text;
  1387.     LogBtn := ForumsTab_LoginBtnEdit.Text;
  1388.     MsgBtn := ForumsTab_MsgBtnEdit.Text;
  1389.     TopicBtn := ForumsTab_TopicBtnEdit.Text;
  1390.     EngineName := ForumsTab_EngineCBox.Text;
  1391.     Tegs := TTegsList.Create;
  1392.     Tegs.TegsStr := ForumsTab_TegsCBox.Text;
  1393.   end;
  1394. end;
  1395.  
  1396. procedure TMainForm.Load;
  1397. var
  1398.   ini: TIniFile;
  1399.   J: TRequestListCol;
  1400. const
  1401.   p0: string = 'Form';
  1402.   p1: string = 'DisplColParam';
  1403.   p2: string = 'MessageTab';
  1404.   p3: string = 'ForumConfTab';
  1405.   p4: string = 'EngineConfTab';
  1406.   p5: string = 'Else';
  1407. begin
  1408.   FPoster.DBList.LoadFromFile;
  1409.   FDisplColParam[rlNumber].Visible:=true;
  1410.   FDisplColParam[rlChecked].Visible:=true;
  1411.   FDisplColParam[rlBookmarkName].Visible:=DisplGrid_BookmarkNameAction.Checked;
  1412.   FDisplColParam[rlBookmarkType].Visible:=DisplGrid_BookmarkTypeAction.Checked;
  1413.   FDisplColParam[rlBookmarkURI].Visible:=True;//DisplGrid_BookmarkURIAction.Checked;
  1414.   FDisplColParam[rlBookmarkTegs].Visible:=DisplGrid_BookmarkTegsAction.Checked;
  1415.   FDisplColParam[rlForumName].Visible:=DisplGrid_ForumNameAction.Checked;
  1416.   FDisplColParam[rlForumTegs].Visible:=DisplGrid_ForumTegsAction.Checked;
  1417.   FDisplColParam[rlEngineName].Visible:=DisplGrid_EngineNameAction.Checked;
  1418.   FDisplColParam[rlEngineTegs].Visible:=DisplGrid_EngineTegsAction.Checked;
  1419.  
  1420.   ini := TIniFile.Create(ExtractFilePath(FPath) + SPathItemsSave);
  1421.   try
  1422.     PostTab_MsgMemo.Lines.LoadFromFile(ExtractFilePath(FPath) +
  1423.       SPathMsgSave);
  1424.     with ini do
  1425.     begin
  1426.       width := ReadInteger(p0, 'Width', width);
  1427.       Height := ReadInteger(p0, 'Heigth', Height);
  1428.       Left := ReadInteger(p0, 'Left', Left);
  1429.       Top := ReadInteger(p0, 'Top', Top);
  1430.  
  1431. (*
  1432.         if SectionExists(p1+'/Visible') then
  1433.         begin
  1434.           for J := rlBookmarkName to High(TRequestListCol) do
  1435.             FDisplColParam[j].Visible:=ReadBool(p1+'/Visible',RequestColStr[J],false);
  1436.           DisplGrid_BookmarkNameAction.Checked:=FDisplColParam[rlBookmarkName].Visible;
  1437.           DisplGrid_BookmarkTypeAction.Checked:=FDisplColParam[rlBookmarkType].Visible;
  1438.           //DisplGrid_BookmarkURIAction.Checked:=FDisplColParam[rlBookmarkURI].Visible;
  1439.           DisplGrid_BookmarkTegsAction.Checked:=FDisplColParam[rlBookmarkTegs].Visible;
  1440.           DisplGrid_ForumNameAction.Checked:=FDisplColParam[rlForumName].Visible;
  1441.           DisplGrid_ForumTegsAction.Checked:=FDisplColParam[rlForumTegs].Visible;
  1442.           DisplGrid_EngineNameAction.Checked:=FDisplColParam[rlEngineName].Visible;
  1443.           DisplGrid_EngineTegsAction.Checked:=FDisplColParam[rlEngineTegs].Visible;
  1444.         end;
  1445. *)
  1446.       for J := rlBookmarkName to High(TRequestListCol) do
  1447.         FDisplColParam[j].Width:=ReadInteger(p1+'/Width',RequestColStr[J],ColWidthKoef);
  1448.  
  1449.  
  1450.       PostTab_TopicEdit.Text := ReadString(p2, 'Title', '');
  1451.  
  1452.       ForumsTab_ListBox.width := ReadInteger(p3, 'ListBoxWidth',
  1453.         ForumsTab_ListBox.width);
  1454.       with ForumsTab_ListBox do
  1455.         ItemIndex := Items.IndexOf(ReadString(p3, 'ActForum', ''));
  1456.  
  1457.       EngineTab_ListBox.width := ReadInteger(p4, 'ListBoxWidth',
  1458.         EngineTab_ListBox.width);
  1459.       with EngineTab_ListBox do
  1460.         ItemIndex:= Items.IndexOf(ReadString(p4, 'ActEngine', ''));
  1461.  
  1462.       { else }
  1463.       StatusBarAction.Checked := ReadBool(p5, 'StatusBar', true);
  1464.       StatusBar.Visible := StatusBarAction.Checked;
  1465.       ToolBarAction.Checked := ReadBool(p5, 'ToolBar', true);
  1466.       MainToolBar.Visible := ToolBarAction.Checked;
  1467.     end;
  1468.   finally
  1469.     ini.Free;
  1470.   end;
  1471. end;
  1472.  
  1473. procedure TMainForm.NulEngineConf;
  1474. begin
  1475.   EngineTab_NameEdit.Text := '';
  1476.   EngineTab_ComentEdit.Text := '';
  1477.   EngineTab_LoginEdit.Text := '';
  1478.   EngineTab_PassEdit.Text := '';
  1479.   EngineTab_MsgTitleEdit.Text := '';
  1480.   EngineTab_MsgMsgEdit.Text := '';
  1481.   EngineTab_TopicTitleEdit.Text := '';
  1482.   EngineTab_TopicMsgEdit.Text := '';
  1483.   EngineTab_TegsCBox.Text := '';
  1484.   EngineTab_TegsCBox.Items.Clear;
  1485. end;
  1486.  
  1487. procedure TMainForm.NulForumConf;
  1488. begin
  1489.   ForumsTab_NameEdit.Text := '';
  1490.   ForumsTab_ComentEdit.Text := '';
  1491.   ForumsTab_LogEdit.Text := '';
  1492.   ForumsTab_PassEdit.Text := '';
  1493.   ForumsTab_LogURLEdit.Text := '';
  1494.   ForumsTab_LoginBtnEdit.Text := '';
  1495.   ForumsTab_MsgBtnEdit.Text := '';
  1496.   ForumsTab_TopicBtnEdit.Text := '';
  1497.   ForumsTab_TegsCBox.Text := '';
  1498.   ForumsTab_TegsCBox.Items.Clear;
  1499. end;
  1500.  
  1501. procedure TMainForm.PostingActionExecute(Sender: TObject);
  1502. var
  1503.   I:Integer;
  1504.   Prm:TRqtParam;
  1505.   Str:string;
  1506. begin
  1507.   with SendTab_DisplayBookGrid, FPoster.Request, FPoster.DBList do
  1508.   begin
  1509.     ClearList;
  1510.     for I := 1 to RowCount-1 do
  1511.       if Cells[FDisplColParam[rlChecked].Index,i]=#1 then
  1512.       begin
  1513.         Str:=BookToRqtPrm(Bookmarks.ItemsFromURI[
  1514.           Cells[FDisplColParam[rlBookmarkURI].Index,i]],  Prm,PostTab_TopicEdit.Text,
  1515.             PostTab_MsgMemo.Text);
  1516.         if str<>'' then
  1517.           WriteToLog(Str);
  1518.         if Pos(SErrMsgPrefix,Str)=0 then
  1519.           AddToList(Prm);
  1520.       end;
  1521.     if ListCount=0 then
  1522.       MessageBox(0,PChar(SMsgNulBookSelect), 'ForumsPoster: Список пустий...',
  1523.         MB_OK or MB_ICONSTOP or MB_TASKMODAL)
  1524.     else
  1525.       Posting;
  1526.   end;
  1527. end;
  1528.  
  1529. procedure TMainForm.PostingBegin(Sender: TObject; Max: integer);
  1530. var
  1531.   buff:TRqtStatusConteyner;
  1532. begin
  1533.   PageControl.Visible:=false;
  1534.   Panel.Visible:=true;
  1535.   Proc_AllLabel.Caption:=intToStr(Max);
  1536.   Proc_AllPrgsBar.Max:=max;
  1537.   PostingCancelAction.Enabled:=true;
  1538.   Proc_ContBtn.Enabled:=false;
  1539.   Proc_AllPrgsBar.Enabled:=true;
  1540.   Proc_StatusLabel.Caption:=SProcWaitFromSendRequest;
  1541.  
  1542.   TFPRequest.SetNullStatus(buff);
  1543.   SetProgressPosition(buff);
  1544.  
  1545.   WriteToLog(Format(SLogSessionBegin,[TimeToStr(Time),DateToStr(Date),FSession]));
  1546. end;
  1547.  
  1548. procedure TMainForm.PostingCancelActionExecute(Sender: TObject);
  1549. begin
  1550.   Proc_CancBtn.Enabled := false;
  1551.   FPoster.Request.Terminate;
  1552. end;
  1553.  
  1554. procedure TMainForm.PostingEnd(Sender: TObject);
  1555. begin
  1556.   PostingCancelAction.Enabled:=false;
  1557.   Proc_ContBtn.Enabled:=true;
  1558.   Proc_AllPrgsBar.Enabled:=false;
  1559.   if TFPRequest(Sender).Terminated then
  1560.     Proc_StatusLabel.Caption:=SProcSendRequestTerminated
  1561.   else
  1562.     Proc_StatusLabel.Caption:=SProcSendRequestDone;
  1563.  
  1564.   WriteToLog(Format(SLogSessionEnd,[TimeToStr(Time),DateToStr(Date),FSession]));
  1565.   WriteToLog('');
  1566.   WriteToLog('');
  1567.   inc(FSession);
  1568. end;
  1569.  
  1570. procedure TMainForm.PostingProgress(Sender: TObject; const Status: TRqtStatusConteyner);
  1571. begin
  1572.   SetProgressPosition(Status);
  1573. end;
  1574.  
  1575. procedure TMainForm.PostLogStatusActionExecute(Sender: TObject);
  1576. begin
  1577.   //
  1578. end;
  1579.  
  1580. procedure TMainForm.Proc_ContBtnClick(Sender: TObject);
  1581. begin
  1582.   Panel.Visible := false;
  1583.   PageControl.Visible:= true;
  1584. end;
  1585.  
  1586. procedure TMainForm.RqsListUpdTimerTimer(Sender: TObject);
  1587. begin
  1588.   RqsListUpdTimer.Enabled:=false;
  1589.   disp_UpdRqsList;
  1590. end;
  1591.  
  1592. procedure TMainForm.Save;
  1593. var
  1594.   ini: TIniFile;
  1595.   I:TRequestListCol;
  1596. const
  1597.   p0: string = 'Form';
  1598.   p1: string = 'DisplColParam';
  1599.   p2: string = 'MessageTab';
  1600.   p3: string = 'ForumConfTab';
  1601.   p4: string = 'EngineConfTab';
  1602.   p5: string = 'Else';
  1603. begin
  1604.   if not DirectoryExists(FPath + SPathConf) then
  1605.   begin
  1606.     CreateDir(FPath + SPathConf);
  1607.   end;
  1608.  
  1609.   FPoster.DBList.SaveToFile;
  1610.   ini := TIniFile.Create(ExtractFilePath(FPath) + SPathItemsSave);
  1611.   try
  1612.     PostTab_MsgMemo.Lines.SaveToFile(ExtractFilePath(FPath) +
  1613.       SPathMsgSave);
  1614.  
  1615.     with ini do
  1616.     begin
  1617.       if WindowState=wsNormal then
  1618.       begin
  1619.         WriteInteger(p0, 'Width', width);
  1620.         WriteInteger(p0, 'Heigth', Height);
  1621.         WriteInteger(p0, 'Left', Left);
  1622.         WriteInteger(p0, 'Top', Top);
  1623.       end;
  1624.  
  1625.       disp_GetColWidth;
  1626.       for I := TRequestListCol(2) to High(TRequestListCol) do
  1627.       begin
  1628.         WriteInteger(p1+'/Width',RequestColStr[i],FDisplColParam[i].Width);
  1629.         WriteBool(p1+'/Visible',RequestColStr[i],FDisplColParam[i].Visible);
  1630.       end;
  1631.  
  1632.  
  1633.       WriteString(p2, 'Title', PostTab_TopicEdit.Text);
  1634.  
  1635.       WriteInteger(p3, 'ListBoxWidth', ForumsTab_ListBox.width);
  1636.  
  1637.       with ForumsTab_ListBox do
  1638.         if ItemIndex > -1 then
  1639.           WriteString(p3, 'ActForum', Items[ItemIndex])
  1640.         else
  1641.           WriteString(p3, 'ActForum', '');
  1642.  
  1643.       WriteInteger(p4, 'ListBoxWidth', EngineTab_ListBox.width);
  1644.  
  1645.       with EngineTab_ListBox do
  1646.         if ItemIndex > -1 then
  1647.           WriteString(p4, 'ActEngine', Items[ItemIndex])
  1648.         else
  1649.           WriteString(p4, 'ActEngine', '');
  1650.       WriteBool(p5, 'StatusBar', StatusBarAction.Checked);
  1651.       WriteBool(p5, 'ToolBar', ToolBarAction.Checked);
  1652.     end;
  1653.   finally
  1654.     ini.Free;
  1655.   end;
  1656. end;
  1657.  
  1658. procedure TMainForm.SaveActionExecute(Sender: TObject);
  1659. begin
  1660.   FPoster.DBList.SaveToFile;
  1661. end;
  1662.  
  1663.  
  1664. procedure TMainForm.SetEngineConf(const Rec: TEngineConf);
  1665. begin
  1666.   with Rec do
  1667.   begin
  1668.     EngineTab_NameEdit.Text := Name;
  1669.     EngineTab_ComentEdit.Text := Coment;
  1670.     EngineTab_LoginEdit.Text := LogUser;
  1671.     EngineTab_PassEdit.Text := LogPass;
  1672.     EngineTab_MsgTitleEdit.Text := MsgTitle;
  1673.     EngineTab_MsgMsgEdit.Text := MsgMess;
  1674.     EngineTab_TopicTitleEdit.Text := TopicTitle;
  1675.     EngineTab_TopicMsgEdit.Text := TopicMsg;
  1676.     EngineTab_TegsCBox.Text := Tegs.TegsStr;
  1677.     EngineTab_TegsCBox.Items.Text :=
  1678.       tegs_GetCBoxItems(Tegs, FPoster.DBList.Engines.GetTegsList);
  1679.   end;
  1680. end;
  1681.  
  1682. procedure TMainForm.SendTabShow(Sender: TObject);
  1683. begin
  1684.   tegs_AllTegsUpdate;
  1685.   disp_UpdRqsList;
  1686. end;
  1687.  
  1688. function TMainForm.tegs_ComboBoxFromIndex(Index: integer): TComboBox;
  1689. begin
  1690.   case index of
  1691.     1: result:= SendTab_BookNeedTegsCBox;
  1692.     2: result:= SendTab_ForumNeedTegsCBox;
  1693.     3: result:= SendTab_EngineNeedTegsCBox;
  1694.     4: result:= SendTab_BookExcpTegsCBox;
  1695.     5: result:= SendTab_ForumExcpTegsCBox;
  1696.     6: result:= SendTab_EngineExcpTegsCBox;
  1697. //    7: result:= BooksTab_TegsCBox;
  1698.     8: result:= ForumsTab_TegsCBox;
  1699.     9: result:= EngineTab_TegsCBox;
  1700.     else result:= nil;
  1701.   end;
  1702. end;
  1703.  
  1704. procedure TMainForm.disp_SetColWidth;
  1705. var
  1706.   I:TRequestListCol;
  1707.   J:integer;
  1708. begin
  1709.   J:=disp_EnbColWidth;
  1710.   with SendTab_DisplayBookGrid do
  1711.     for I := rlBookmarkName to High(FDisplColParam) do
  1712.       if (FDisplColParam[i].Visible)
  1713.         and (FDisplColParam[i].Index>1)
  1714.       then
  1715.         if (FDisplColParam[i].Width>10) then
  1716.           ColWidths[FDisplColParam[i].Index]:=FDisplColParam[i].Width *
  1717.             (SendTab_DisplayBookGrid.Width-ColWidths[0]-ColWidths[1]-12)
  1718.             div j
  1719.         else
  1720.           ColWidths[FDisplColParam[i].Index]:=10;
  1721. end;
  1722.  
  1723. procedure TMainForm.disp_SetGrid;
  1724. var
  1725.   ABoormark, UnMarked:TStrings;
  1726.   I:integer;
  1727. begin
  1728.   ABoormark:=TStringList.Create;
  1729.   UnMarked:=TStringList.Create;
  1730.   try
  1731.     if FDisplColParam[rlBookmarkURI].Index<>-1 then
  1732.       with SendTab_DisplayBookGrid do
  1733.         for I := 1 to RowCount-1 do
  1734.           if Cells[FDisplColParam[rlBookmarkURI].Index,i]<>'' then
  1735.           begin
  1736.             ABoormark.Add(Cells[FDisplColParam[rlBookmarkURI].Index,i]);
  1737.             if Cells[FDisplColParam[rlChecked].Index,i]<>#1 then
  1738.               UnMarked.Add(Cells[FDisplColParam[rlBookmarkURI].Index,i]);
  1739.           end;
  1740.     disp_SetGrid(ABoormark,UnMarked);
  1741.   finally
  1742.     ABoormark.Free;
  1743.     UnMarked.Free;
  1744.   end;
  1745. end;
  1746.  
  1747. procedure TMainForm.disp_SetGrid(ABookmarks, UnMarkedBooks: TStrings);
  1748.  
  1749.   procedure SetValue(ACol:TRequestListCol; ARow:integer; const Value:string);
  1750.   begin
  1751.     if (FDisplColParam[ACol].Index<>-1) and (ARow<>-1)
  1752.       and FDisplColParam[ACol].Visible
  1753.     then
  1754.       SendTab_DisplayBookGrid.Cells[FDisplColParam[ACol].Index,ARow]:=Value;
  1755.   end;
  1756.  
  1757.   procedure UpdateGridColums;
  1758.   var
  1759.     i: integer;
  1760.     J: TRequestListCol;
  1761.   begin
  1762.     with SendTab_DisplayBookGrid do
  1763.     begin
  1764.       FDisplColParam[rlNumber].Index:=0;
  1765.       FDisplColParam[rlChecked].Index:=1;
  1766.       i:=2;
  1767.       disp_GetColWidth;
  1768.       for J := rlBookmarkName to High(FDisplColParam) do
  1769.         if FDisplColParam[J].Visible then
  1770.         begin
  1771.           FDisplColParam[J].Index:=i;
  1772.           inc(i);
  1773.         end;
  1774.       SendTab_DisplayBookGrid.ColCount:=i;
  1775.       disp_SetColWidth;
  1776.     end;
  1777.   end;
  1778.  
  1779. const
  1780.   BookType: array [boolean] of string = (SBookTypeTopic,SBookTypeMsg);
  1781. var
  1782.   I,j:integer;
  1783.   I1: TRequestListCol;
  1784.   TB:TBookmarkConf;
  1785.   TF:TForumConf;
  1786. begin
  1787.   UpdateGridColums;
  1788.   with SendTab_DisplayBookGrid do
  1789.   begin
  1790.     if ABookmarks.Count>0 then
  1791.       RowCount:=ABookmarks.Count+1
  1792.     else
  1793.     begin
  1794.       RowCount:=2;
  1795.       Rows[1].clear;
  1796.     end;
  1797.  
  1798.     for I1 := Low(TRequestListCol) to High(TRequestListCol) do
  1799.       SetValue(I1,0,RequestColCaption[I1]);
  1800.  
  1801.     i:=1;
  1802.     for J:=0 to ABookmarks.Count-1 do
  1803.     begin
  1804.       TB:=FPoster.DBList.Bookmarks.ItemsFromURI[ABookmarks.Strings[j]];
  1805.       with SendTab_TypeBookCBox, FPoster.DBList do
  1806.         if (ItemIndex=2) or (TB.isMsg and (ItemIndex=0))
  1807.           or (not TB.isMsg and (ItemIndex=1))
  1808.         then
  1809.         begin
  1810.           SetValue(rlNumber,i,IntToStr(i));
  1811.           if UnMarkedBooks.IndexOf(TB.URI)<>-1 then
  1812.             SetValue(rlChecked,i,#0)
  1813.           else
  1814.             SetValue(rlChecked,i,#1);
  1815.           SetValue(rlBookmarkName,i,TB.Name);
  1816.           SetValue(rlBookmarkURI, i,TB.URI);
  1817.           SetValue(rlBookmarkTegs,i,TB.Tegs.TegsStr);
  1818.           SetValue(rlBookmarkType,i,BookType[TB.isMsg]);
  1819.           if Forums.ContainsFromURI(TB.URI) then
  1820.           begin
  1821.             TF:=Forums.ItemsFromURI[TB.URI];
  1822.             SetValue(rlForumName,   i,TF.Name);
  1823.             SetValue(rlForumTegs,   i,TF.Tegs.TegsStr);
  1824.             SetValue(rlEngineName,  i,TF.EngineName);
  1825.             if Engines.Contains(TF.EngineName) then
  1826.               SetValue(rlEngineTegs,  i,Engines.ItemsFromName[
  1827.                 TF.EngineName].Tegs.TegsStr);
  1828.           end;
  1829.           inc(i);
  1830.         end;
  1831.     end;
  1832.     if i>1 then
  1833.       RowCount:=i
  1834.     else
  1835.     begin
  1836.       RowCount:=2;
  1837.       Rows[1].clear;
  1838.     end;
  1839.   end;
  1840.   FDisplBooksCount:=ABookmarks.Count;
  1841. end;
  1842.  
  1843. procedure TMainForm.tegs_AllTegsUpdate;
  1844. begin
  1845.   tegs_TegsUpdate(SendTab_BookNeedTegsCBox, #0);
  1846.   tegs_TegsUpdate(SendTab_ForumNeedTegsCBox, #0);
  1847.   tegs_TegsUpdate(SendTab_EngineNeedTegsCBox, #0);
  1848. end;
  1849.  
  1850. procedure TMainForm.tegs_TegsCBoxEnter(Sender: TObject);
  1851. begin
  1852.   tegs_TegsUpdate(TComboBox(Sender));
  1853. end;
  1854.  
  1855. procedure TMainForm.tegs_TegsCBoxKeyPress(Sender: TObject;
  1856.   var Key: Char);
  1857. begin                                                    
  1858.   if (CharInSet(Key, [',', #8, #$D])) //#8 - backspase #$D - enter
  1859.   and (TComboBox(Sender).SelStart = Length(TComboBox(Sender).Text))
  1860.   then
  1861.     tegs_TegsUpdate(TComboBox(Sender),Key);
  1862.  
  1863.   if key=#$D then
  1864.   begin
  1865.     with TComboBox(Sender) do
  1866.       if SelLength<>0 then
  1867.       begin
  1868.         SelStart:=Length(Text);
  1869.         SelLength:=0;
  1870.       end;
  1871. //      else
  1872. //        case TComboBox(Sender).Tag of
  1873. //          7 : BooksTab_NewBtn.Click;
  1874. //        end;
  1875.      Key:=#0;
  1876.   end;
  1877. end;
  1878.  
  1879. procedure TMainForm.tegs_TegsUpdate(ComboBox: TComboBox;  Key: Char=#0);
  1880. var
  1881.   AllTegs:TTegsList;
  1882.   CBox2:TComboBox;
  1883. begin
  1884.   case ComboBox.Tag of
  1885.     1,4,7,10: AllTegs:=FPoster.DBList.Bookmarks.GetTegsList;
  1886.     2,5,8:    AllTegs:=FPoster.DBList.Forums.GetTegsList;
  1887.     3,6,9:    AllTegs:=FPoster.DBList.Engines.GetTegsList;
  1888.     else      AllTegs:=nil;
  1889.   end;
  1890.  
  1891.   if ComboBox.Tag<7 then       //4,5,6 - cписок непотрібних тегів
  1892.     if ComboBox.Tag>3 then     //1-3 бокси йдуть в парі. так і оброб'ляються...
  1893.       CBox2:=tegs_ComboBoxFromIndex(ComboBox.Tag-3)
  1894.     else
  1895.       CBox2:=tegs_ComboBoxFromIndex(ComboBox.Tag+3)
  1896.   else
  1897.   begin
  1898.     CBox2:=NullComboBox;       //інші бокси йдуть без пари.
  1899.     CBox2.Clear;               //а це для функи
  1900.   end;
  1901.  
  1902.  
  1903.   AllTegs.DeleteTegs(ComboBox.Text);
  1904.   AllTegs.DeleteTegs(CBox2.Text);
  1905.  
  1906.   ComboBox.Items.Text := tegs_GetCBoxItems(ComboBox.Text, AllTegs,Key);
  1907.   ComboBox.SelStart := Length(ComboBox.Text);
  1908.  
  1909.   CBox2.Items.Text := tegs_GetCBoxItems(CBox2.Text, AllTegs,Key);
  1910.   CBox2.SelStart := Length(CBox2.Text);
  1911. end;
  1912.  
  1913. procedure TMainForm.RunDelayListUpd(Sender: TObject);
  1914. begin
  1915.   RqsListUpdTimer.Enabled:=false;
  1916.   RqsListUpdTimer.Enabled:=true;
  1917. end;
  1918.  
  1919. procedure TMainForm.tegs_TegsActCBoxClick(Sender: TObject);
  1920. begin
  1921.   tegs_ComboBoxFromIndex(TCheckBox(Sender).Tag).Enabled:=
  1922.       SendTab_BookTegsActCBox.Checked;
  1923.   tegs_ComboBoxFromIndex(TCheckBox(Sender).Tag+3).Enabled:=
  1924.       SendTab_BookTegsActCBox.Checked;
  1925.   RunDelayListUpd(nil);
  1926. end;
  1927.  
  1928. procedure TMainForm.SendTab_DisplayBookGridDrawCell(Sender: TObject; ACol,
  1929.   ARow: Integer; Rect: TRect; State: TGridDrawState);
  1930. begin
  1931.   if (ACol=FDisplColParam[rlChecked].Index) and (ARow>0) then
  1932.     DrawCheck(ARow);
  1933. end;
  1934.  
  1935. procedure TMainForm.SendTab_DisplayBookGridMouseDown(Sender: TObject;
  1936.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1937. var
  1938.   ACol,ARow:integer;
  1939. begin
  1940.   if (Button=mbLeft)  then
  1941.     with SendTab_DisplayBookGrid do
  1942.     begin
  1943.       MouseToCell(X,Y,ACol,ARow);
  1944.       if (ARow > FDisplBooksCount) or (ARow < 1) then exit;
  1945.       if (ACol=FDisplColParam[rlChecked].Index) and (ARow >= 0)
  1946.         and (ARow <= RowCount)
  1947.       then
  1948.       begin
  1949.         if Cells[ACol,ARow]=#0 then
  1950.           Cells[Col,ARow]:=#1
  1951.         else
  1952.           Cells[ACol,ARow]:=#0;
  1953.       end;
  1954.     end;
  1955. end;
  1956.  
  1957. procedure TMainForm.SendTab_TypeBookCBoxChange(Sender: TObject);
  1958. begin
  1959.   disp_UpdRqsList;
  1960. end;
  1961.  
  1962. procedure TMainForm.SetEngineConf(const Name: string);
  1963. begin
  1964.   if EngineTab_ListBox.Items.IndexOf(Name) <> -1 then
  1965.   begin
  1966.     EngineTab_ListBox.ItemIndex := EngineTab_ListBox.Items.IndexOf(Name);
  1967.     SetEngineConf(FPoster.DBList.Engines.ItemsFromName[Name]);
  1968.   end;
  1969. end;
  1970.  
  1971. procedure TMainForm.SetForumConf(const Name: string);
  1972. begin
  1973.   if ForumsTab_ListBox.Items.IndexOf(Name) <> -1 then
  1974.   begin
  1975.     ForumsTab_ListBox.ItemIndex := ForumsTab_ListBox.Items.IndexOf(Name);
  1976.     SetForumConf(FPoster.DBList.Forums.ItemsFromName[Name]);
  1977.   end
  1978.   else
  1979.   NulForumConf;
  1980. end;
  1981.  
  1982. procedure TMainForm.SetProgressPosition(const Status: TRqtStatusConteyner);
  1983. begin
  1984.   Proc_DoneLabel.Caption:=intToStr(Status.Done);
  1985.   Proc_ErrorLabel.Caption:=IntToStr(Status.Error+Status.Terminated);
  1986.   Proc_CompitLabel.Caption:=IntToStr(Status.Summ);
  1987.   Proc_AllPrgsBar.Position:=Status.Summ;
  1988. end;
  1989.  
  1990. function TMainForm.ShowImportReplaseDialog(DialogType: TImportDialogType;
  1991.   out UseFromAll: Boolean; const Str: string; const AFile:string): integer;
  1992. begin
  1993.   with DublicateDialogForm do
  1994.     case DialogType of
  1995.       irEngineName:
  1996.       begin
  1997.         TitleText.Caption:=Format(SDlgTitleText,[SToEngine, SFromName, str]);
  1998.         ReplaseText.Caption:=Format(SDlgReplaseConf,[str, AFile]);
  1999.         RenameText.Caption:=Format(SDlgRenameText,[Str, Str+'(2)']);
  2000.       end;
  2001.       irForumName:
  2002.       begin
  2003.         TitleText.Caption:=Format(SDlgTitleText,[SToForum, SFromName, str]);
  2004.         RenameText.Caption:=Format(SDlgRenameText,[Str, Str+'(2)']);
  2005.       end;
  2006.       irForumURI:
  2007.       begin
  2008.         TitleText.Caption:=Format(SDlgTitleText,[SToForum, SToURI, str]);
  2009.         RenameText.Caption:=Format(SDlgRenameURIText,[Str, Str+'(2)']);
  2010.       end;
  2011.       irBookURI:
  2012.       begin
  2013.         TitleText.Caption:=Format(SDlgTitleText,[SToBookmark, SToURI, str]);
  2014.         RenameText.Caption:=Format(SDlgRenameText,[Str, Str+'(2)'])
  2015.       end;
  2016.     end;
  2017.   Result:=DublicateDialogForm.ShowModal;
  2018.   UseFromAll:=DublicateDialogForm.FromAllCBox.Checked;
  2019. end;
  2020.  
  2021. procedure TMainForm.SortStringGrid(Grid: TStringGrid; const ACell: Integer;
  2022.   UpToDown: Boolean; TopValue: string; InCell: integer);
  2023. var
  2024.   I: Integer;
  2025.   S: string;
  2026. begin
  2027.   SortStringGrid(Grid,ACell,UpToDown);
  2028.   with Grid do
  2029.   begin
  2030.     if Cols[InCell].IndexOf(TopValue)<>-1 then
  2031.       for I := Cols[InCell].IndexOf(TopValue) downto 2 do
  2032.       begin
  2033.         S:=Rows[i].Text;
  2034.         Rows[i].Text:=Rows[i-1].Text;
  2035.         Rows[i-1].Text:=s;
  2036.       end;
  2037.   end;
  2038. end;
  2039.  
  2040. procedure TMainForm.SortStringGrid(Grid:TStringGrid;
  2041.      const ACell: Integer; UpToDown: Boolean);
  2042.  
  2043.   procedure obmin(const i1, i2, CollMax: Integer);
  2044.   var
  2045.     s: string;
  2046.   begin
  2047.     with Grid do
  2048.     begin
  2049.       S:=Rows[i1].Text;
  2050.       Rows[i1].Text:=Rows[i2].Text;
  2051.       Rows[i2].Text:=s;
  2052.     end;
  2053.   end;
  2054.  
  2055. var
  2056.   I: Integer;
  2057.   J: Integer;
  2058.   CollMax:integer;
  2059. begin
  2060.   with Grid do
  2061.   begin
  2062.     CollMax:=ColCount-1;
  2063.     if UpToDown then
  2064.       for I := 1 to RowCount - 1 do
  2065.         for J := I + 1 to RowCount - 1 do
  2066.           if Cells[ACell, I] < Cells[ACell, J] then
  2067.             obmin(I, J, CollMax)
  2068.           else
  2069.         else
  2070.           for I := 1 to RowCount - 1 do
  2071.             for J := I + 1 to RowCount - 1 do
  2072.               if Cells[ACell, I] > Cells[ACell, J] then
  2073.                 obmin(I, J, CollMax);
  2074.   end;
  2075. end;
  2076.  
  2077. procedure TMainForm.SetForumConf(const Rec: TForumConf);
  2078. begin
  2079.   with Rec do
  2080.   begin
  2081.     ForumsTab_NameEdit.Text := Name;
  2082.     ForumsTab_ComentEdit.Text := Coment;
  2083.     ForumsTab_LogEdit.Text := LogName;
  2084.     ForumsTab_PassEdit.Text := LogPass;
  2085.     ForumsTab_LogURLEdit.Text := LogURI;
  2086.     ForumsTab_LoginBtnEdit.Text := LogBtn;
  2087.     ForumsTab_MsgBtnEdit.Text := MsgBtn;
  2088.     ForumsTab_TopicBtnEdit.Text := TopicBtn;
  2089.     ForumsTab_EngineCBox.ItemIndex := ForumsTab_EngineCBox.Items.IndexOf
  2090.       (EngineName);
  2091.     ForumsTab_TegsCBox.Text := Tegs.TegsStr;
  2092.     ForumsTab_TegsCBox.Items.Text :=
  2093.       tegs_GetCBoxItems(Tegs, FPoster.DBList.Forums.GetTegsList);
  2094.   end;
  2095. end;
  2096.  
  2097. procedure TMainForm.StatusBarActionExecute(Sender: TObject);
  2098. begin
  2099.   StatusBar.Visible := StatusBarAction.Checked;
  2100. end;
  2101.  
  2102. procedure TMainForm.ThreadLogAdd(Sender: TObject;
  2103.   const Item: TRqtThreadLogConteyner; Action: TCollectionNotification);
  2104. var
  2105.   str:string;
  2106. begin
  2107.   if Action=cnAdded then
  2108.   begin
  2109.     case Item.ItemType of
  2110.       itError:    str:='Error';
  2111.       itWarning:  str:='Warring';
  2112.       itDone:     str:='Event';
  2113.       itTerminated:str:='Terminated';
  2114.       itEvent:    str:='Event';
  2115.       itNone:     str:='None';
  2116.     end;
  2117.  
  2118.     WriteToLog(Format('[%s][ID:%d][%s] %s',[TimeToStr(Item.Time),Item.ThreadId,
  2119.                                             str, Item.Item]));
  2120.   end;
  2121. end;
  2122.  
  2123. procedure TMainForm.ToolBarActionExecute(Sender: TObject);
  2124. begin
  2125.   MainToolBar.Visible := ToolBarAction.Checked;
  2126. end;
  2127.  
  2128. procedure TMainForm.UpdBookConf();
  2129. var
  2130.   I: Integer;
  2131.   Tmp:TBookmarkConf;
  2132. const
  2133.   DefURI:string='http://';
  2134. begin
  2135.   with FPoster.DBList, BooksTab_StringGrid do
  2136.   begin
  2137.     if not Bookmarks.Contains(DefURI) then
  2138.     begin
  2139.       Tmp.URI:=DefURI;
  2140.       Tmp.Name:='';
  2141.       Tmp.isMsg:=false;
  2142.       Tmp.Tegs:=nil;
  2143.       Bookmarks.Add(Tmp)
  2144.     end;
  2145.     if Bookmarks.Count > 0 then
  2146.     begin
  2147.       RowCount := Bookmarks.Count + 1;
  2148.       for I := 0 to Bookmarks.Count - 1 do
  2149.       begin
  2150.         Cells[0,I+1]:=IntToStr(I + 1);
  2151.         Cells[blName, I+1] := Bookmarks[I].Name;
  2152.         if Bookmarks[i].isMsg then
  2153.           Cells[blType, I+1]:=SBookTypeMsg
  2154.         else
  2155.           Cells[blType, I+1]:=SBookTypeTopic;
  2156.         Cells[blURI, I+1] := Bookmarks[I].URI;
  2157.         Cells[blTegs, I+1] := Bookmarks[I].Tegs.TegsStr;
  2158.       end;
  2159.  
  2160.       SortStringGrid(BooksTab_StringGrid, blURI, False, DefURI, blURI);
  2161.     end
  2162.     else
  2163.     begin
  2164.       RowCount := 2;
  2165.       Rows[1].Text := '';
  2166.     end;
  2167.   end;
  2168. end;
  2169.  
  2170. procedure TMainForm.UpdEngineConf(const Name: string);
  2171. var
  2172.   str: string;
  2173. begin
  2174.   if EngineTab_ListBox.ItemIndex > -1 then
  2175.     str := EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex];
  2176.  
  2177.   EngineTab_ListBox.Items.Text := FPoster.DBList.Engines.ListOfNames;
  2178.   ForumsTab_EngineCBox.Items.Text := EngineTab_ListBox.Items.Text;
  2179.   // ForumsTab_EngineCBox.Items.Insert(0,'');
  2180.  
  2181.   if EngineTab_ListBox.Count <= 0 then
  2182.   begin
  2183.     EnbEngineConf(false);
  2184.     exit;
  2185.   end;
  2186.   if Name <> '' then
  2187.     EngineTab_ListBox.ItemIndex := EngineTab_ListBox.Items.IndexOf(Name)
  2188.   else if EngineTab_ListBox.Items.IndexOf(str) <> -1 then
  2189.     EngineTab_ListBox.ItemIndex := EngineTab_ListBox.Items.IndexOf(str)
  2190.   else if EngineTab_ListBox.Count > 0 then
  2191.     EngineTab_ListBox.ItemIndex := 0;
  2192.  
  2193.   SetEngineConf(EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex]);
  2194.   EnbEngineConf(true);
  2195. end;
  2196.  
  2197. procedure TMainForm.UpdForumConf(const Name: string = '');
  2198. var
  2199.   str: string;
  2200. begin
  2201.   if ForumsTab_ListBox.ItemIndex > -1 then
  2202.     str := ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex];
  2203.  
  2204.   ForumsTab_ListBox.Items.Text := FPoster.DBList.Forums.ListOfNames;
  2205.  
  2206.   if ForumsTab_ListBox.Count = 0 then
  2207.   begin
  2208.     EnbForumConf(false);
  2209.     exit;
  2210.   end;
  2211.   if Name <> '' then
  2212.     ForumsTab_ListBox.ItemIndex := ForumsTab_ListBox.Items.IndexOf(Name)
  2213.   else if ForumsTab_ListBox.Items.IndexOf(str) <> -1 then
  2214.     ForumsTab_ListBox.ItemIndex := ForumsTab_ListBox.Items.IndexOf(str)
  2215.   else if ForumsTab_ListBox.Count > 0 then
  2216.     ForumsTab_ListBox.ItemIndex := 0;
  2217.  
  2218.   SetForumConf(ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex]);
  2219.   EnbForumConf(true);
  2220. end;
  2221.  
  2222. procedure TMainForm.disp_UpdRqsList;
  2223. var
  2224.   SL,CheckMem:TStrings;
  2225.   I,J: integer;
  2226.   Tegs:TTegsArray;
  2227. begin
  2228.   CheckMem:=TStringList.Create;
  2229.   try
  2230.     with SendTab_DisplayBookGrid do
  2231.       for I := 1 to RowCount-1 do
  2232.         if Cells[FDisplColParam[rlChecked].Index,i]=#0 then
  2233.           CheckMem.Add(Cells[FDisplColParam[rlChecked].Index,i]);
  2234.  
  2235.     for I := 0 to 2 do
  2236.       for j := 0 to 1 do
  2237.         Tegs[i,j]:=TTegsList.Create;
  2238.     try
  2239.       if SendTab_BookTegsActCBox.Checked then
  2240.       begin
  2241.         Tegs[0,0].TegsStr:=SendTab_BookNeedTegsCBox.Text;
  2242.         Tegs[0,1].TegsStr:=SendTab_BookExcpTegsCBox.Text;
  2243.       end;
  2244.       if SendTab_ForumTegsActCBox.Checked then
  2245.       begin
  2246.         Tegs[1,0].TegsStr:=SendTab_ForumNeedTegsCBox.Text;
  2247.         Tegs[1,1].TegsStr:=SendTab_ForumExcpTegsCBox.Text;
  2248.       end;
  2249.       if SendTab_EngineTegsActCBox.Checked then
  2250.       begin
  2251.         Tegs[2,0].TegsStr:=SendTab_EngineNeedTegsCBox.Text;
  2252.         Tegs[2,1].TegsStr:=SendTab_EngineExcpTegsCBox.Text;
  2253.       end;
  2254.  
  2255.       SL:=FPoster.DBList.TegsFilter(Tegs);
  2256.  
  2257.     finally
  2258.       for I := 0 to 2 do
  2259.         for j := 0 to 1 do
  2260.           Tegs[i,j].Free;
  2261.     end;
  2262.  
  2263.     disp_SetGrid(SL,CheckMem);
  2264.   finally
  2265.     CheckMem.Free;
  2266.   end;
  2267. end;
  2268.  
  2269. procedure TMainForm.WriteToLog(const Msg: string);
  2270. begin
  2271.   Proc_LogListBox.Items.Add(Msg);
  2272.   if (Proc_LogListBox.ItemIndex  = Proc_LogListBox.Items.Count - 2) then
  2273.     Proc_LogListBox.ItemIndex  :=  Proc_LogListBox.Items.Count - 1;
  2274. end;
  2275.  
  2276. { TMainForm.TColRec }
  2277.  
  2278. procedure TMainForm.TColRec.SetVisible(const Value: boolean);
  2279. begin
  2280.   FVisible := Value;
  2281.   if not Value then
  2282.     Index:=-1;
  2283. end;
  2284.  
  2285. end.
Advertisement
Add Comment
Please, Sign In to add comment