Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit main;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, CheckLst, ComCtrls, ActnCtrls, ToolWin, ActnMan,
- ActnMenus, PlatformDefaultStyleActnCtrls, ActnList, Grids, ForumPoster,
- IdHttp, BandActn, IniFiles, ImgList, IdComponent, RibbonLunaStyleActnCtrls,
- FPResourceString, FPExceptions, adrStringUtils, Buttons, Spin, ActiveX,
- Generics.Collections, StrUtils, Menus, ActnPopup, ImportConfigForm, Themes;
- type
- TMainForm = class(TForm)
- ActionManager1: TActionManager;
- MainToolBar: TActionToolBar;
- StatusBar: TStatusBar;
- PageControl: TPageControl;
- SendTab: TTabSheet;
- PostTab: TTabSheet;
- PostTab_MsgGBox: TGroupBox;
- PostTab_MsgGBox_TopicLabel: TLabel;
- PostTab_MsgGBox_MsgLabel: TLabel;
- PostTab_TopicEdit: TEdit;
- PostTab_MsgMemo: TMemo;
- ForumsTab: TTabSheet;
- ForumsTab_FoumcConfGBox: TGroupBox;
- ForumsTab_Panel: TPanel;
- ForumsTab_NewBtn: TButton;
- ForumsTab_EditBtn: TButton;
- ForumsTab_DelBtn: TButton;
- ForumsTab_ListBox: TListBox;
- ForumsTab_NameEdit: TEdit;
- ForumsTab_PassEdit: TEdit;
- ForumsTab_LogURLEdit: TEdit;
- ForumsTab_LogEdit: TEdit;
- ForumsTab_Label1: TLabel;
- ForumsTab_Label2: TLabel;
- ForumsTab_Label3: TLabel;
- ForumsTab_Label4: TLabel;
- ForumsTab_Label6: TLabel;
- ForumsTab_Label7: TLabel;
- ForumsTab_EngineCBox: TComboBox;
- ForumsTab_TegsCBox: TComboBox;
- ForumsTab_Splitter1: TSplitter;
- EngineTab: TTabSheet;
- EngineTab_GBox: TGroupBox;
- EngineTab_Splitter0: TSplitter;
- EngineTab_Panel0: TPanel;
- EngineTab_Label9: TLabel;
- EngineTab_NameEdit: TEdit;
- EngineTab_ListBox: TListBox;
- EngineTab_Label10: TLabel;
- PostingAction: TAction;
- ExitAction: TAction;
- EngineTab_Panel1: TPanel;
- SaveAction: TAction;
- ForumImportAction: TAction;
- OpenDialog1: TOpenDialog;
- CustomizeActionBars1: TCustomizeActionBars;
- ToolBarAction: TAction;
- StatusBarAction: TAction;
- ImageList1: TImageList;
- Panel: TPanel;
- Proc_StatusLabel: TLabel;
- Proc_AllPrgsBar: TProgressBar;
- Label2: TLabel;
- Label3: TLabel;
- Proc_AllLabel: TLabel;
- Proc_CompitLabel: TLabel;
- Panel1: TPanel;
- Proc_ContBtn: TButton;
- Proc_CancBtn: TButton;
- ForumsTab_ComentEdit: TEdit;
- ForumsTab_Label9: TLabel;
- ConfTab: TTabSheet;
- EngineTab_ComentEdit: TEdit;
- EngineTab_Label7: TLabel;
- Conf_GeneralGBox: TGroupBox;
- Panel3: TPanel;
- EngineTab_Label8: TLabel;
- EngineTab_PassEdit: TEdit;
- EngineTab_LoginEdit: TEdit;
- Label7: TLabel;
- Label8: TLabel;
- EngineTab_NewBtn: TButton;
- EngineTab_DelBtn: TButton;
- EngineTab_EditBtn: TButton;
- Label11: TLabel;
- EngineTab_TopicMsgEdit: TEdit;
- EngineTab_TopicTitleEdit: TEdit;
- Label12: TLabel;
- EngineTab_MsgTitleEdit: TEdit;
- Label9: TLabel;
- Label10: TLabel;
- EngineTab_MsgMsgEdit: TEdit;
- Label13: TLabel;
- ForumsTab_LoginBtnEdit: TEdit;
- ForumsTab_TopicBtnEdit: TEdit;
- ForumsTab_MsgBtnEdit: TEdit;
- ForumsTab_Label11: TLabel;
- ForumsTab_Label10: TLabel;
- ForumsTab_Label5: TLabel;
- BooksTab: TTabSheet;
- BooksTab_StringGrid: TStringGrid;
- BooksTab_GroupBox: TGroupBox;
- EngineTab_Label14: TLabel;
- EngineTab_TegsCBox: TComboBox;
- SendTab_TopPanel: TPanel;
- SendTab_BottomPanel: TPanel;
- SendTab_BookGBox: TGroupBox;
- SendTabTab_EngineGBox: TGroupBox;
- SendTab_ForumGBox: TGroupBox;
- Splitter2: TSplitter;
- Splitter3: TSplitter;
- SendTab_BookTegsActCBox: TCheckBox;
- SendTab_Label14: TLabel;
- SendTab_Label15: TLabel;
- SendTab_Label16: TLabel;
- SendTab_Label17: TLabel;
- SendTab_ForumTegsActCBox: TCheckBox;
- SendTab_Label18: TLabel;
- SendTab_Label19: TLabel;
- SendTab_EngineTegsActCBox: TCheckBox;
- SendTab_TypeBookGBox: TGroupBox;
- SendTab_TypeBookCBox: TComboBox;
- BitBtn1: TBitBtn;
- ActionMainMenuBar1: TActionMainMenuBar;
- SendTab_DisplayBookGrid: TStringGrid;
- SendTab_BookExcpTegsCBox: TComboBox;
- SendTab_BookNeedTegsCBox: TComboBox;
- SendTab_ForumExcpTegsCBox: TComboBox;
- SendTab_ForumNeedTegsCBox: TComboBox;
- SendTab_EngineNeedTegsCBox: TComboBox;
- SendTab_EngineExcpTegsCBox: TComboBox;
- RqsListUpdTimer: TTimer;
- ConfTab_SendGBox: TGroupBox;
- ConfTab_RqtListUpdDelaySEdit: TSpinEdit;
- Label14: TLabel;
- Label4: TLabel;
- Proc_DoneLabel: TLabel;
- Label6: TLabel;
- Proc_ErrorLabel: TLabel;
- PostingCancelAction: TAction;
- Proc_LogListBox: TListBox;
- DisplGrid_BookmarkNameAction: TAction;
- DisplGrid_BookmarkTypeAction: TAction;
- DisplGrid_BookmarkTegsAction: TAction;
- DisplGrid_ForumNameAction: TAction;
- DisplGrid_ForumTegsAction: TAction;
- DisplGrid_EngineNameAction: TAction;
- DisplGrid_EngineTegsAction: TAction;
- BooksTab_NameEdit: TEdit;
- BooksTab_TypeCBox: TComboBox;
- BooksTab_URIEdit: TEdit;
- BooksTab_TegsCBox: TComboBox;
- SendTab_DispGridPopupBar: TPopupActionBar;
- N1: TMenuItem;
- N2: TMenuItem;
- URI1: TMenuItem;
- N7: TMenuItem;
- N5: TMenuItem;
- N6: TMenuItem;
- N3: TMenuItem;
- N4: TMenuItem;
- procedure FormCreate(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure ExitActionExecute(Sender: TObject);
- procedure ToolBarActionExecute(Sender: TObject);
- procedure StatusBarActionExecute(Sender: TObject);
- procedure Proc_ContBtnClick(Sender: TObject);
- procedure PostLogStatusActionExecute(Sender: TObject);
- procedure ForumsTab_NewBtnClick(Sender: TObject);
- procedure ForumsTab_ListBoxClick(Sender: TObject);
- procedure ForumsTab_EditBtnClick(Sender: TObject);
- procedure ForumsTab_DelBtnClick(Sender: TObject);
- procedure EngineTab_NewBtnClick(Sender: TObject);
- procedure EngineTab_DelBtnClick(Sender: TObject);
- procedure EngineTab_EditBtnClick(Sender: TObject);
- procedure EngineTab_ListBoxClick(Sender: TObject);
- procedure BooksTab_StringGridSelectCell(Sender: TObject;
- ACol, ARow: Integer; var CanSelect: Boolean);
- procedure SaveActionExecute(Sender: TObject);
- procedure SendTabShow(Sender: TObject);
- procedure PostingActionExecute(Sender: TObject);
- procedure RunDelayListUpd(Sender: TObject);
- procedure RqsListUpdTimerTimer(Sender: TObject);
- procedure ConfTab_RqtListUpdDelaySEditChange(Sender: TObject);
- procedure PostingCancelActionExecute(Sender: TObject);
- procedure SendTab_TypeBookCBoxChange(Sender: TObject);
- procedure tegs_TegsActCBoxClick(Sender: TObject);
- procedure tegs_TegsCBoxKeyPress(Sender: TObject; var Key: Char);
- procedure tegs_TegsCBoxEnter(Sender: TObject);
- procedure SendTab_DisplayBookGridMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- procedure ForumImportActionExecute(Sender: TObject);
- procedure SendTab_DisplayBookGridDrawCell(Sender: TObject; ACol,
- ARow: Integer; Rect: TRect; State: TGridDrawState);
- procedure DisplGrid_BookmarkNameActionExecute(Sender: TObject);
- procedure DisplGrid_BookmarkTypeActionExecute(Sender: TObject);
- procedure DisplGrid_BookmarkTegsActionExecute(Sender: TObject);
- procedure DisplGrid_ForumNameActionExecute(Sender: TObject);
- procedure DisplGrid_ForumTegsActionExecute(Sender: TObject);
- procedure DisplGrid_EngineNameActionExecute(Sender: TObject);
- procedure DisplGrid_EngineTegsActionExecute(Sender: TObject);
- procedure FormResize(Sender: TObject);
- procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer;
- var Resize: Boolean);
- procedure BooksTab_NameEditExit(Sender: TObject);
- procedure BooksTab_TypeCBoxExit(Sender: TObject);
- procedure BooksTab_URIEditExit(Sender: TObject);
- procedure BooksTab_TegsCBoxExit(Sender: TObject);
- private type
- TImportDialogType = (irEngineName, irForumName, irForumURI, irBookURI);
- TColRec = record
- private
- FVisible: boolean;
- procedure SetVisible(const Value: boolean);
- public
- Width: integer;
- Index:integer;
- property Visible: boolean read FVisible write SetVisible;
- end;
- TRequestListCol = (rlNumber, rlChecked, rlBookmarkName, rlBookmarkType,
- rlBookmarkURI, rlBookmarkTegs, rlForumName, rlForumTegs, rlEngineName,
- rlEngineTegs);
- private
- const
- RequestColStr: array [TRequestListCol] of string=
- ('Number','Checked','BookmarkName','BookmarkType','BookmarkURI',
- 'BookmarkTegs','ForumName','ForumTegs','EngineName','EngineTegs');
- RequestColCaption: array [TRequestListCol] of string=
- ('№','Ак','Назва закладки','Тип закладки','URI закладки',
- 'Теги закладки','Назва форуму','Теги форуму','Назва двигуна',
- 'Теги двигуна');
- ColWidthKoef = 1000;
- ColWidthIndexMax: integer = ColWidthKoef * 8;
- var
- FPath: string;
- FPoster: TForumsPoster;
- FSession: integer;
- FDisplBooksCount:integer;
- FDisplColParam: array [TRequestListCol] of TColRec;
- procedure Save;
- procedure Load;
- procedure WriteToLog(const Msg: string);
- function GetForumConf: TForumConf;
- procedure SetForumConf(const Rec: TForumConf); overload;
- procedure SetForumConf(const Name: string); overload;
- procedure UpdForumConf(const Name: string = '');
- procedure EnbForumConf(AEnabled: Boolean); // Enabled
- procedure NulForumConf;
- function GetEngineConf: TEngineConf;
- procedure SetEngineConf(const Rec: TEngineConf); overload;
- procedure SetEngineConf(const Name: string); overload;
- procedure UpdEngineConf(const Name: string = '');
- procedure EnbEngineConf(AEnabled: Boolean);
- procedure NulEngineConf;
- procedure BookInit;
- procedure UpdBookConf();
- procedure DrawCheck(R: TRect; AState: TCheckBoxState;
- AEnabled: Boolean; ACanvas:TCanvas); overload; //це з CheckLst.TCheckList
- procedure DrawCheck(ARow:integer); overload;
- procedure SortStringGrid(Grid: TStringGrid; const ACell: Integer;
- UpToDown: Boolean=false); overload;
- procedure SortStringGrid(Grid: TStringGrid; const ACell: Integer;
- UpToDown: Boolean; TopValue:string; InCell:integer); overload;
- procedure SetProgressPosition(const Status:TRqtStatusConteyner);
- procedure PostingBegin(Sender:TObject; Max:integer);
- procedure PostingProgress(Sender: TObject; const Status: TRqtStatusConteyner);
- procedure PostingEnd(Sender:TObject);
- procedure ThreadLogAdd(Sender: TObject; const Item: TRqtThreadLogConteyner;
- Action: TCollectionNotification);
- function tegs_GetCBoxItems(const Tegs: TTegsList; const AllTegs: TTegsList): string; overload;
- function tegs_GetCBoxItems(const Tegs: string;
- AllTegs: TTegsList; Key:Char=#0): string; overload;
- procedure tegs_TegsUpdate(ComboBox: TComboBox; Key: Char=#0);
- procedure tegs_AllTegsUpdate;
- function tegs_ComboBoxFromIndex(Index:integer):TComboBox;
- //SendTab_DisplayGrid;
- procedure disp_UpdRqsList;
- procedure disp_GetColWidth;
- procedure disp_SetColWidth;
- function disp_EnbColWidth:integer;
- procedure disp_SetGrid(ABookmarks, UnMarkedBooks:TStrings); overload;
- procedure disp_SetGrid; overload;
- function ShowImportReplaseDialog(DialogType: TImportDialogType;
- out UseFromAll: Boolean; const Str: string; const AFile:string):integer;
- public
- { Public declarations }
- end;
- var
- MainForm: TMainForm;
- NullComboBox: TComboBox; //це для тегів
- const //bookList
- blName=1;
- blType=2;
- blURI=3;
- blTegs=4;
- mrReplase=20;
- mrNoReplase=21;
- mrRename=22;
- implementation
- {$R *.dfm}
- const
- FCheckWidth=8;
- FCheckHeight=8;
- procedure TMainForm.BookInit;
- begin
- BooksTab_NameEdit.Parent:=BooksTab_StringGrid;
- BooksTab_TypeCBox.Parent:=BooksTab_StringGrid;
- BooksTab_URIEdit.Parent :=BooksTab_StringGrid;
- BooksTab_TegsCBox.Parent:=BooksTab_StringGrid;
- end;
- procedure TMainForm.BooksTab_NameEditExit(Sender: TObject);
- var
- buff:TBookmarkConf;
- begin
- with BooksTab_StringGrid do
- if (Cells[Col,Row]<>BooksTab_NameEdit.Text) then
- begin
- buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
- buff.Name:=BooksTab_NameEdit.Text;
- FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
- Cells[Col,Row]:=BooksTab_NameEdit.Text;
- end;
- BooksTab_NameEdit.Visible:=false;
- end;
- procedure TMainForm.BooksTab_StringGridSelectCell(Sender: TObject;
- ACol, ARow: Integer; var CanSelect: Boolean);
- procedure SetEdit(Edit:TEdit);
- begin
- Edit.Text:=BooksTab_StringGrid.Cells[ACol, ARow];
- Edit.Visible:=true;
- Edit.SetFocus;
- end;
- procedure SetCBox(CBox:TComboBox);
- begin
- if CBox.Style=csDropDownList then
- CBox.ItemIndex:= CBox.Items.IndexOf(BooksTab_StringGrid.Cells[ACol, ARow])
- else
- CBox.Text:= BooksTab_StringGrid.Cells[ACol, ARow];
- CBox.SetFocus;
- end;
- procedure SetControl(Control:TControl);
- begin
- Control.Left := BooksTab_StringGrid.CellRect(ACol,ARow).Left;
- Control.Top := BooksTab_StringGrid.CellRect(ACol,ARow).Top;
- Control.Width := BooksTab_StringGrid.CellRect(ACol,ARow).Right -
- BooksTab_StringGrid.CellRect(ACol,ARow).Left;
- Control.Height:= BooksTab_StringGrid.CellRect(ACol,ARow).Bottom -
- BooksTab_StringGrid.CellRect(ACol,ARow).Top;
- Control.Visible:=true;
- if Control is TEdit then
- SetEdit(TEdit(Control))
- else
- SetCBox(TComboBox(Control));
- end;
- begin
- case ACol of
- blName: SetControl(BooksTab_NameEdit);
- blType: SetControl(BooksTab_TypeCBox);
- blURI: SetControl(BooksTab_URIEdit);
- blTegs: SetControl(BooksTab_TegsCBox);
- end;
- end;
- procedure TMainForm.BooksTab_TegsCBoxExit(Sender: TObject);
- var
- buff:TBookmarkConf;
- begin
- with BooksTab_StringGrid do
- if (Cells[Col,Row]<>BooksTab_TegsCBox.Text) then
- begin
- buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
- buff.Tegs.TegsStr:=BooksTab_TegsCBox.Text;
- FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
- Cells[Col,Row]:=BooksTab_TegsCBox.Text;
- end;
- BooksTab_TegsCBox.Visible:=false;
- end;
- procedure TMainForm.BooksTab_TypeCBoxExit(Sender: TObject);
- var
- buff:TBookmarkConf;
- begin
- with BooksTab_StringGrid do
- if (Cells[Col,Row]<>BooksTab_TypeCBox.Text) then
- begin
- buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
- buff.isMsg:=BooksTab_TypeCBox.Text=BooksTab_TypeCBox.Items.Strings[0];
- FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
- Cells[Col,Row]:=BooksTab_TypeCBox.Text;
- end;
- BooksTab_TypeCBox.Visible:=false;
- end;
- procedure TMainForm.BooksTab_URIEditExit(Sender: TObject);
- var
- buff:TBookmarkConf;
- begin
- with BooksTab_StringGrid, FPoster.DBList do
- if Cells[Col,Row]<>BooksTab_URIEdit.Text then
- begin
- if BooksTab_URIEdit.Text='' then
- begin
- if MessageDlg('Видалити цей запис?', mtWarning,
- mbOKCancel,-1)=mrOk then
- begin
- Bookmarks.Delete(Cells[Col,Row]);
- UpdBookConf();
- end;
- BooksTab_URIEdit.Visible:=false;
- Exit;
- end;
- if Bookmarks.Contains(BooksTab_URIEdit.Text) then
- begin
- MessageDlg('Поле URI має бути унікальним!', mtWarning,
- [mbOK],-1);
- Exit;
- end;
- buff:=FPoster.DBList.Bookmarks.ItemsFromURI[Cells[blURI,Row]];
- buff.URI:=BooksTab_URIEdit.Text;
- Bookmarks.ItemsFromURI[Cells[blURI,Row]]:=buff;
- Cells[Col,Row]:=BooksTab_URIEdit.Text;
- UpdBookConf;
- end;
- BooksTab_URIEdit.Visible:=false;
- end;
- procedure TMainForm.ConfTab_RqtListUpdDelaySEditChange(Sender: TObject);
- begin
- try
- RqsListUpdTimer.Interval:=TSpinEdit(Sender).Value;
- except
- on E:EConvertError do
- if not (E is EConvertError) then
- raise;
- end;
- end;
- procedure TMainForm.DrawCheck(ARow: integer);
- const
- State:array[#0..#1] of TCheckBoxState=(cbUnchecked,cbChecked);
- begin
- if Length(SendTab_DisplayBookGrid.Cells[FDisplColParam[rlChecked].Index,
- ARow])=1
- then
- DrawCheck(SendTab_DisplayBookGrid.CellRect(FDisplColParam[rlChecked].Index,
- ARow), State[(SendTab_DisplayBookGrid.Cells[FDisplColParam[rlChecked].Index,
- ARow])[1]],True, SendTab_DisplayBookGrid.Canvas);
- end;
- procedure TMainForm.DisplGrid_BookmarkNameActionExecute(Sender: TObject);
- begin
- disp_GetColWidth;
- FDisplColParam[rlBookmarkName].Visible:= DisplGrid_BookmarkNameAction.Checked;
- disp_SetGrid;
- end;
- procedure TMainForm.DisplGrid_BookmarkTegsActionExecute(Sender: TObject);
- begin
- disp_GetColWidth;
- FDisplColParam[rlBookmarkTegs].Visible:= DisplGrid_BookmarkTegsAction.Checked;
- disp_SetGrid;
- end;
- procedure TMainForm.DisplGrid_BookmarkTypeActionExecute(Sender: TObject);
- begin
- disp_GetColWidth;
- FDisplColParam[rlBookmarkType].Visible:= DisplGrid_BookmarkTypeAction.Checked;
- disp_SetGrid;
- end;
- procedure TMainForm.DisplGrid_EngineNameActionExecute(Sender: TObject);
- begin
- disp_GetColWidth;
- FDisplColParam[rlEngineName].Visible:= DisplGrid_EngineNameAction.Checked;
- disp_SetGrid;
- end;
- procedure TMainForm.DisplGrid_EngineTegsActionExecute(Sender: TObject);
- begin
- disp_GetColWidth;
- FDisplColParam[rlEngineTegs].Visible:= DisplGrid_EngineTegsAction.Checked;
- disp_SetGrid;
- end;
- procedure TMainForm.DisplGrid_ForumNameActionExecute(Sender: TObject);
- begin
- disp_GetColWidth;
- FDisplColParam[rlForumName].Visible:= DisplGrid_ForumNameAction.Checked;
- disp_SetGrid;
- end;
- procedure TMainForm.DisplGrid_ForumTegsActionExecute(Sender: TObject);
- begin
- disp_GetColWidth;
- FDisplColParam[rlForumTegs].Visible:= DisplGrid_ForumTegsAction.Checked;
- disp_SetGrid;
- end;
- procedure TMainForm.DrawCheck(R: TRect; AState: TCheckBoxState;
- AEnabled: Boolean; ACanvas:TCanvas);
- const
- FCheckWidth:integer= 20;
- FCheckHeight:integer= 20;
- Flat:boolean= false;
- var
- DrawState: Integer;
- DrawRect: TRect;
- OldBrushColor: TColor;
- OldBrushStyle: TBrushStyle;
- OldPenColor: TColor;
- ElementDetails: TThemedElementDetails;
- begin
- DrawRect.Left := R.Left + (R.Right - R.Left - FCheckWidth) div 2;
- DrawRect.Top := R.Top + (R.Bottom - R.Top - FCheckHeight) div 2;
- DrawRect.Right := DrawRect.Left + FCheckWidth;
- DrawRect.Bottom := DrawRect.Top + FCheckHeight;
- with ACanvas do
- begin
- if ThemeControl(Self) then
- begin
- case AState of
- cbChecked:
- if AEnabled then
- ElementDetails := StyleServices.GetElementDetails(tbCheckBoxCheckedNormal)
- else
- ElementDetails := StyleServices.GetElementDetails(tbCheckBoxCheckedDisabled);
- cbUnchecked:
- if AEnabled then
- ElementDetails := StyleServices.GetElementDetails(tbCheckBoxUncheckedNormal)
- else
- ElementDetails := StyleServices.GetElementDetails(tbCheckBoxUncheckedDisabled)
- else // cbGrayed
- if AEnabled then
- ElementDetails := StyleServices.GetElementDetails(tbCheckBoxMixedNormal)
- else
- ElementDetails := StyleServices.GetElementDetails(tbCheckBoxMixedDisabled);
- end;
- StyleServices.DrawElement(Handle, ElementDetails, R);
- end
- else
- begin
- case AState of
- cbChecked:
- DrawState := DFCS_BUTTONCHECK or DFCS_CHECKED;
- cbUnchecked:
- DrawState := DFCS_BUTTONCHECK;
- else // cbGrayed
- DrawState := DFCS_BUTTON3STATE or DFCS_CHECKED;
- end;
- if not AEnabled then
- DrawState := DrawState or DFCS_INACTIVE;
- DrawFrameControl(Handle, DrawRect, DFC_BUTTON, DrawState);
- end;
- if Flat then
- begin
- { Clip the 3d checkbox }
- OldBrushStyle := Brush.Style;
- OldBrushColor := Brush.Color;
- OldPenColor := Pen.Color;
- Brush.Style := bsClear;
- Pen.Color := Color;
- with DrawRect do
- Rectangle(Left, Top, Right, Bottom);
- { Draw flat rectangle in-place of clipped 3d checkbox above }
- Brush.Style := bsClear;
- Pen.Color := clBtnShadow;
- with DrawRect do
- Rectangle(Left + 1, Top + 1, Right - 1, Bottom - 1);
- Brush.Style := OldBrushStyle;
- Brush.Color := OldBrushColor;
- Pen.Color := OldPenColor;
- end;
- end;
- end;
- function TMainForm.disp_EnbColWidth: integer;
- var
- I: TRequestListCol;
- begin
- Result:=0;
- for I := rlBookmarkName to High(FDisplColParam) do
- if FDisplColParam[i].Visible and (FDisplColParam[i].Index<>-1) then
- inc(Result,FDisplColParam[i].Width);
- end;
- procedure TMainForm.EnbEngineConf(AEnabled: Boolean);
- begin
- if EngineTab_NameEdit.Enabled <> AEnabled then
- begin
- EngineTab_NameEdit.Enabled := AEnabled;
- EngineTab_ComentEdit.Enabled := AEnabled;
- EngineTab_LoginEdit.Enabled := AEnabled;
- EngineTab_PassEdit.Enabled := AEnabled;
- EngineTab_MsgTitleEdit.Enabled := AEnabled;
- EngineTab_MsgMsgEdit.Enabled := AEnabled;
- EngineTab_TopicTitleEdit.Enabled := AEnabled;
- EngineTab_TopicMsgEdit.Enabled := AEnabled;
- end;
- if not AEnabled then
- NulEngineConf;
- end;
- procedure TMainForm.EnbForumConf(AEnabled: Boolean);
- begin
- if ForumsTab_NameEdit.Enabled <> AEnabled then
- begin
- ForumsTab_NameEdit.Enabled := AEnabled;
- ForumsTab_ComentEdit.Enabled := AEnabled;
- ForumsTab_LogEdit.Enabled := AEnabled;
- ForumsTab_PassEdit.Enabled := AEnabled;
- ForumsTab_LogURLEdit.Enabled := AEnabled;
- ForumsTab_LoginBtnEdit.Enabled := AEnabled;
- ForumsTab_MsgBtnEdit.Enabled := AEnabled;
- ForumsTab_TopicBtnEdit.Enabled := AEnabled;
- ForumsTab_EngineCBox.Enabled := AEnabled;
- ForumsTab_TegsCBox.Enabled := AEnabled;
- ForumsTab_EditBtn.Enabled := AEnabled;
- ForumsTab_DelBtn.Enabled := AEnabled;
- end;
- if not AEnabled then
- NulForumConf;
- end;
- procedure TMainForm.EngineTab_DelBtnClick(Sender: TObject);
- var
- n: Integer;
- begin
- n := EngineTab_ListBox.ItemIndex;
- if n > -1 then
- begin
- FPoster.DBList.Engines.Delete(EngineTab_ListBox.Items.Strings[n]);
- if n > 1 then
- UpdEngineConf(EngineTab_ListBox.Items.Strings[n - 1])
- else
- UpdEngineConf();
- end
- else
- EnbEngineConf(False);
- end;
- procedure TMainForm.EngineTab_EditBtnClick(Sender: TObject);
- var
- Rec: TEngineConf;
- LastName: string;
- begin
- Rec := GetEngineConf;
- LastName:= EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex];
- if Rec.Name = '' then
- ShowMessage(SMsgNulName)
- else
- if not ((LastName <> Rec.Name)
- and FPoster.DBList.Engines.Contains(Rec.Name)
- and (MessageDlg(Format(SMsgOverwriteSite, [Rec.Name]),mtWarning,
- mbOKCancel,-1) <> mrOk))
- then
- with FPoster.DBList.Engines do
- begin
- if (LastName<>Rec.Name)
- and Contains(Rec.Name)
- then
- Delete(Rec.Name);
- ItemsFromName[LastName]:= Rec;
- UpdEngineConf(Rec.Name);
- end;
- end;
- procedure TMainForm.EngineTab_ListBoxClick(Sender: TObject);
- begin
- if EngineTab_ListBox.ItemIndex>=0 then
- SetEngineConf(EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex])
- else
- NulEngineConf;
- end;
- procedure TMainForm.EngineTab_NewBtnClick(Sender: TObject);
- var
- Rec: TEngineConf;
- begin
- Rec.Name := GenName(SDefEngineName, FPoster.DBList.Engines.ListOfNames);
- Rec.Tegs := TTegsList.Create;
- FPoster.DBList.Engines.Add(Rec);
- UpdEngineConf(Rec.Name);
- end;
- procedure TMainForm.ExitActionExecute(Sender: TObject);
- begin
- close;
- end;
- procedure TMainForm.FormCanResize(Sender: TObject; var NewWidth,
- NewHeight: Integer; var Resize: Boolean);
- begin
- if NewWidth<>Width then
- disp_GetColWidth;
- end;
- procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- FPoster.Request.Terminate;
- Save;
- ActionManager1.FileName := FPath + SPathActItemsSave;
- FPoster.Free;
- end;
- procedure TMainForm.FormCreate(Sender: TObject);
- begin
- FPath := ExtractFilePath(ParamStr(0));
- with BooksTab_StringGrid do
- begin
- ColWidths[0] := 24;
- ColWidths[blName] := 130;
- ColWidths[blType] := 90;
- ColWidths[blURI] := 170;
- ColWidths[blTegs] := 130;
- Rows[0].Text := '№'#10'Назва'#10'Тип'#10'URI'#10'Теги';
- Cells[0, 1] := '1';
- end;
- SendTab_DisplayBookGrid.ColWidths[0]:=32;
- SendTab_DisplayBookGrid.ColWidths[1]:=18;
- FPoster := TForumsPoster.Create;
- with FPoster.DBList, FPoster, FPoster.Request do
- begin
- ForumsSavePath := FPath + SPathForumSave;
- EngineSavePath := FPath + SPathEngineSave;
- BooksSavePath := FPath + SPathBookSave;
- OnWorkBegin := PostingBegin;
- OnWork := PostingProgress;
- OnWorkEnd := PostingEnd;
- OnThreadEvent := ThreadLogAdd;
- end;
- try
- Load;
- except
- on E: Exception do
- if not (E is EFOpenError) then
- raise;
- end;
- BookInit;
- UpdEngineConf();
- UpdForumConf();
- UpdBookConf();
- NullComboBox:=TComboBox.Create(Self); //це для тегів
- NullComboBox.Visible:=false;
- NullComboBox.Parent:=Self;
- FSession:=0;
- FDisplBooksCount:=0;
- end;
- procedure TMainForm.FormResize(Sender: TObject);
- begin
- disp_SetColWidth;
- end;
- procedure TMainForm.ForumImportActionExecute(Sender: TObject);
- type
- TErrType = (etUnknown, etNone, etFileItem, etFileVersion);
- TFileError = record
- FileName: string;
- FileType: TFPConfDB.TConfType;
- FileVersion: Double;
- ErrType: TErrType;
- Items: Pointer;
- ItemsError: array of integer;
- end;
- TFileErrorArray = TArray<TFileError>;
- TImportDialogResult = (drUnknown, drReplase, drNoReplase, drRename, drAbort);
- procedure LoadFileItem(Engines:TEngineConfArray;
- var FileError:TFileError); overload;
- var
- IntArray:TArray<Integer>;
- I,J:integer;
- begin
- I:=0;
- FPoster.DBList.Engines.AddRange(Engines, IntArray);
- for J := 0 to High(IntArray) do
- if IntArray[J]<0 then
- inc(I);
- if I<>0 then
- begin
- FileError.ErrType:=etFileItem;
- FileError.Items:=nil;
- SetLength(TEngineConfArray(FileError.Items),I);
- SetLength(FileError.ItemsError,I);
- for J := 0 to I-1 do
- if IntArray[J]<0 then
- begin
- Dec(I);
- FileError.ItemsError[I]:=IntArray[J];
- TEngineConfArray(FileError.Items)[I]:=Engines[J];
- end;
- end;
- end;
- procedure LoadFileItem(Forums:TForumConfArray;
- var FileError:TFileError); overload;
- var
- IntArray:TArray<Integer>;
- I,J:integer;
- begin
- I:=0;
- FPoster.DBList.Forums.AddRange(Forums, IntArray);
- for J := 0 to High(IntArray) do
- if IntArray[J]<0 then
- inc(I);
- if I<>0 then
- begin
- FileError.ErrType:=etFileItem;
- FileError.Items:=nil;
- SetLength(TEngineConfArray(FileError.Items),I);
- SetLength(FileError.ItemsError,I);
- for J := 0 to I-1 do
- if IntArray[J]<0 then
- begin
- Dec(I);
- FileError.ItemsError[I]:=IntArray[J];
- TForumConfArray(FileError.Items)[I]:=Forums[J];
- end;
- end;
- end;
- procedure LoadFileItem(Bookmarks:TBookmarkConfArray;
- var FileError:TFileError); overload;
- var
- IntArray:TArray<Integer>;
- I,J:integer;
- begin
- I:=0;
- FPoster.DBList.Bookmarks.AddRange(Bookmarks, IntArray);
- for J := 0 to High(IntArray) do
- if IntArray[J]<0 then
- inc(I);
- if I<>0 then
- begin
- FileError.ErrType:=etFileItem;
- FileError.Items:=nil;
- SetLength(TBookmarkConfArray(FileError.Items),I);
- SetLength(FileError.ItemsError,I);
- for J := 0 to I-1 do
- if IntArray[J]<0 then
- begin
- Dec(I);
- FileError.ItemsError[I]:=IntArray[J];
- TBookmarkConfArray(FileError.Items)[I]:=Bookmarks[J];
- end;
- end;
- end;
- function LoadFile(const FileName:string;
- TryLoad:boolean=False):TFileError; overload;
- var
- EngineArray: TEngineConfArray;
- ForumArray: TForumConfArray;
- BookmarkArray: TBookmarkConfArray;
- begin
- Result.FileName:= FileName;
- Result.FileType:= TFPConfDB.CheckConfType(FileName);
- Result.FileVersion:= TFPConfDB.CheckConfVersion(FileName);
- Result.ErrType:= etUnknown;
- case Result.FileType of
- ctUnknown: raise EFPException.Create('Unknown file type');
- ctEngine:
- begin
- EngineArray:=TFPConfDB.LoadEngine(FileName);
- if (not TryLoad) and (Result.FileVersion<>TFPConfDB.EngineVersion) then
- begin
- Result.ErrType:=etFileVersion;
- Result.Items:=EngineArray;
- Exit;
- end;
- LoadFileItem(EngineArray, Result);
- SetLength(EngineArray,0);
- end;
- ctForum:
- begin
- ForumArray:=TFPConfDB.LoadForum(FileName);
- if (not TryLoad) and (Result.FileVersion<>TFPConfDB.ForumVersion) then
- begin
- Result.ErrType:=etFileVersion;
- Result.Items:=ForumArray;
- Exit;
- end;
- LoadFileItem(ForumArray, Result);
- SetLength(ForumArray,0);
- end;
- ctBookmark:
- begin
- BookmarkArray:=TFPConfDB.LoadBookmark(FileName);
- if (not TryLoad) and (Result.FileVersion<>TFPConfDB.BookmarkVersion) then
- begin
- Result.ErrType:=etFileVersion;
- Result.Items:=BookmarkArray;
- Exit;
- end;
- LoadFileItem(BookmarkArray, Result);
- SetLength(BookmarkArray,0);
- end;
- end;
- if Result.ErrType=etUnknown then
- Result.ErrType:=etNone;
- end;
- function ReloadFileItem(const FileError:TFileError; index:integer):TFileError;
- var
- Engines:TEngineConfArray;
- Forums:TForumConfArray;
- Bookmarks:TBookmarkConfArray;
- begin
- Result:=FileError;
- Result.Items:=nil;
- Result.ErrType:=etNone;
- case FileError.FileType of
- ctUnknown: raise Exception.Create('ctUnknown in ReloadFileItem');
- ctEngine:
- begin
- SetLength(Engines,1);
- Engines[0]:=TEngineConfArray(FileError.Items)[index];
- LoadFileItem(Engines, Result);
- SetLength(Engines,0);
- end;
- ctForum:
- begin
- SetLength(Forums,1);
- Forums[0]:=TForumConfArray(FileError.Items)[index];
- LoadFileItem(Forums, Result);
- SetLength(Forums,0);
- end;
- ctBookmark:
- begin
- SetLength(Bookmarks,1);
- Bookmarks[0]:=TBookmarkConfArray(FileError.Items)[index];
- LoadFileItem(Bookmarks, Result);
- SetLength(Bookmarks,0);
- end;
- end;
- end;
- function LoadAll(Files, LoadError:TStrings):TFileErrorArray;
- var
- FEList: TList<TFileError>;
- I: Integer;
- buff: TFileError;
- begin
- FEList := TList<TFileError>.Create;
- try
- for I := 0 to Files.Count-1 do
- try
- buff:=LoadFile(Files.Strings[i]);
- if buff.ErrType<>etNone then
- FEList.Add(buff);
- except
- on E:EFPException do
- LoadError.Add('"' + Files.Strings[i] + '": ' + E.Message)
- end;
- Result:=FEList.ToArray;
- finally
- FEList.Free;
- end;
- end;
- function DoDialog(DlgType:TImportDialogType; AName, AFile:string;
- var LastResult:TImportDialogResult):TImportDialogResult;
- var
- isFromAll:boolean;
- begin
- Result:=drUnknown;
- if LastResult=drUnknown then
- begin
- case ShowImportReplaseDialog(DlgType,isFromAll,AName,AFile) of
- mrReplase: Result:=drReplase;
- mrNoReplase: Result:=drNoReplase;
- mrRename: Result:=drRename;
- mrAbort: Result:=drAbort;
- end;
- if isFromAll then
- LastResult:=Result;
- end
- else
- Result:=LastResult;
- end;
- function NeedReadFile(const ErrFile:TFileError):boolean;
- var
- ConfVersion: double;
- ToConfName: string;
- begin
- result:=false;
- ConfVersion:=0;
- case ErrFile.FileType of
- ctUnknown: raise Exception.Create('ctUnknown in NeedReadFile');
- ctEngine:
- begin
- ConfVersion:=TFPConfDB.EngineVersion;
- ToConfName:=SToEngine;
- end;
- ctForum:
- begin
- ConfVersion:=TFPConfDB.ForumVersion;
- ToConfName:=SToForum;
- end;
- ctBookmark:
- begin
- ConfVersion:=TFPConfDB.BookmarkVersion;
- ToConfName:=SToBookmark;
- end;
- end;
- if ErrFile.FileVersion <> ConfVersion then
- if Abs(ErrFile.FileVersion-ConfVersion)<1 then //різниця в мінорні версії
- if MessageDlg(Format(SWrgDBVersionMinorDelta,
- [ToConfName, ErrFile.FileVersion, ConfVersion]),
- mtWarning, mbAbortIgnore,-1)<>mrAbort
- then
- Result:= True
- else
- MessageBox(0, PChar(Format(SErrDBVersionMajorDelta,
- [ToConfName, ErrFile.FileVersion, ConfVersion])),
- PChar(SErrLoadFileTitle), MB_OK or MB_ICONSTOP or MB_TASKMODAL)
- else
- Result:=true;
- end;
- procedure ComplitedImport(ErrorFile:TFileError;
- var DlgTMP:TImportDialogResult; LoadErrors:TStrings); overload;
- var
- J: Integer; //обробляє решту
- buff:TFileError;
- begin
- try
- with FPoster.DBList, ErrorFile do
- case ErrType of
- etUnknown: raise Exception.Create('etUnknown in ComplitedImport: 1');
- etNone: ;
- etFileItem:
- case ErrorFile.FileType of
- ctUnknown: raise Exception.Create('ctUnknown in ComplitedImport: 3');
- ctEngine:
- for J := 0 to High(ErrorFile.ItemsError) do
- case DoDialog(irEngineName,
- TEngineConfArray(Items)[J].Name,
- ErrorFile.FileName,
- DlgTmp) of
- drUnknown:
- raise Exception.Create('drUnknown in ComplitedImport: 4');
- drReplase:
- Engines.ItemsFromName[TEngineConfArray(Items)[J].Name]
- := TEngineConfArray(Items)[J];
- drNoReplase:;
- drRename:
- begin
- TEngineConfArray(Items)[J].Name:= GenName(
- TEngineConfArray(Items)[J].Name, Engines.ListOfNames);
- ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
- LoadErrors);
- end;
- drAbort: exit;
- end;
- ctForum:
- for J := 0 to High(ItemsError) do
- case DoDialog(irForumName,
- TForumConfArray(Items)[J].Name,
- ErrorFile.FileName,
- DlgTmp) of
- drUnknown:
- raise Exception.Create('drUnknown in'
- + ' ComplitedImport: 5');
- drReplase:
- if ItemsError[J]=arIdentExists then
- Forums.ItemsFromName[TForumConfArray(Items)[J].Name] :=
- TForumConfArray(Items)[J]
- else //arSubIdentExists
- Forums.ItemsFromURI[TForumConfArray(Items)[J].LogURI]:=
- TForumConfArray(Items)[J];
- drNoReplase:;
- drRename:
- if ItemsError[J]=arIdentExists then
- begin
- TForumConfArray(Items)[J].Name:=
- GenName(TForumConfArray(Items)[J].Name,
- Forums.ListOfNames);
- ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
- LoadErrors);
- end
- else
- begin
- TForumConfArray(Items)[J].LogURI:=
- GenName(TForumConfArray(Items)[J].LogURI,
- Forums.ListOfURI);
- ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
- LoadErrors);
- end;
- drAbort: exit;
- end;
- ctBookmark:
- for J := 0 to High(ItemsError) do
- case DoDialog(irBookURI,
- TBookmarkConfArray(Items)[J].URI,
- ErrorFile.FileName,
- DlgTmp) of
- drUnknown:
- raise Exception.Create('drUnknown in'
- + ' ComplitedImport: 6');
- drReplase:
- FPoster.DBList.Bookmarks.ItemsFromURI[
- TBookmarkConfArray(Items)[J].Name]:=
- TBookmarkConfArray(Items)[J];
- drNoReplase:;
- drRename:
- begin
- TBookmarkConfArray(Items)[J].URI:=
- GenName(TBookmarkConfArray(Items)[J].URI,
- FPoster.DBList.Bookmarks.ListOfURI);
- ComplitedImport(ReloadFileItem(ErrorFile,J),DlgTMP,
- LoadErrors);
- end;
- drAbort: exit;
- end;
- end;
- etFileVersion:
- if NeedReadFile(ErrorFile) then
- try
- buff:=LoadFile(ErrorFile.FileName, True);
- ComplitedImport(buff, DlgTmp, LoadErrors);
- except
- on E:EFPException do
- LoadErrors.Add('"'+ErrorFile.FileName+'": '+E.Message);
- end;
- end;
- finally
- case ErrorFile.FileType of
- ctEngine: SetLength(TEngineConfArray(ErrorFile.Items),0);
- ctForum: SetLength(TForumConfArray(ErrorFile.Items),0);
- ctBookmark: SetLength(TBookmarkConfArray(ErrorFile.Items),0);
- ctUnknown: raise Exception.Create('ctUnknown in CoplitedImport: 7');
- end;
- SetLength(ErrorFile.ItemsError,0);
- end;
- end;
- procedure ComplitedImport(ErrorFiles:TFileErrorArray;
- LoadErrors:TStrings); overload;
- var
- I: Integer;
- DlgTmp:TImportDialogResult;
- begin
- DlgTmp:=drUnknown;
- for I := 0 to High(ErrorFiles) do
- ComplitedImport(ErrorFiles[i], DlgTmp, LoadErrors);
- end;
- var
- Strings: TStrings;
- begin
- if OpenDialog1.Execute then
- begin
- Strings := TStringList.Create;
- try
- ComplitedImport(LoadAll(OpenDialog1.Files,Strings),Strings);
- finally
- Strings.Free;
- UpdForumConf();
- UpdEngineConf();
- UpdBookConf();
- end;
- end;
- end;
- procedure TMainForm.ForumsTab_DelBtnClick(Sender: TObject);
- var
- n: Integer;
- Rec: TForumConf;
- begin
- n := ForumsTab_ListBox.ItemIndex;
- if n > -1 then
- begin
- FPoster.DBList.Forums.Delete(ForumsTab_ListBox.Items.Strings[n]);
- if n > 1 then
- UpdForumConf(ForumsTab_ListBox.Items.Strings[n - 1])
- else
- UpdForumConf();
- end
- else
- SetForumConf(Rec);
- end;
- procedure TMainForm.ForumsTab_EditBtnClick(Sender: TObject);
- var
- Rec: TForumConf;
- LastName: string;
- begin
- Rec := GetForumConf;
- LastName:=ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex];
- if Rec.Name = '' then
- ShowMessage(SMsgNulName)
- else
- if not ((LastName <> Rec.Name)
- and FPoster.DBList.Forums.Contains(Rec.Name)
- and (MessageDlg(Format(SMsgOverwriteSite, [Rec.Name]),mtWarning,
- mbOKCancel,-1) <> mrOk))
- then
- with FPoster.DBList.Forums do
- begin
- if (LastName<>Rec.Name)
- and Contains(Rec.Name)
- then
- Delete(Rec.Name);
- ItemsFromName[LastName]:= Rec;
- UpdForumConf(Rec.Name);
- end;
- end;
- procedure TMainForm.ForumsTab_ListBoxClick(Sender: TObject);
- begin
- if ForumsTab_ListBox.ItemIndex>=0 then
- SetForumConf(ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex])
- else
- NulForumConf;
- end;
- procedure TMainForm.ForumsTab_NewBtnClick(Sender: TObject);
- var
- Rec: TForumConf;
- begin
- Rec.Name := GenName(SDefSiteName, FPoster.DBList.Forums.ListOfNames);
- Rec.Tegs := TTegsList.Create;
- FPoster.DBList.Forums.Add(Rec);
- UpdForumConf(Rec.Name);
- end;
- function TMainForm.tegs_GetCBoxItems(const Tegs: string;
- AllTegs: TTegsList; Key:Char=#0): string;
- var
- FTegs: TTegsList;
- begin
- FTegs := TTegsList.Create(false);
- try
- FTegs.TegsStr := Tegs;
- if not ((Tegs='') or (((TrimRight(Tegs[Length(Tegs)-1])=',')) or (Key=','))
- and (Key<>#8))
- then
- FTegs.TegsList.Delete(FTegs.TegsList.Count-1);
- result := tegs_GetCBoxItems(FTegs, AllTegs);
- finally
- FTegs.Free;
- end;
- end;
- procedure TMainForm.disp_GetColWidth;
- function GetSum:integer;
- var
- I:TRequestListCol;
- begin
- Result:=0;
- for I := rlBookmarkName to High(FDisplColParam) do
- Inc(Result,FDisplColParam[i].Width);
- end;
- function GetColsWidth:integer;
- var
- I: TRequestListCol;
- begin
- Result:=0;
- for I := rlBookmarkName to High(FDisplColParam) do
- if FDisplColParam[i].Visible and (FDisplColParam[i].Index<>-1) then
- inc(Result, SendTab_DisplayBookGrid.ColWidths[FDisplColParam[i].Index]);
- end;
- var
- I:TRequestListCol;
- J:integer;
- begin
- J:=disp_EnbColWidth;
- with SendTab_DisplayBookGrid do
- for I := rlBookmarkName to High(FDisplColParam) do
- if FDisplColParam[i].Visible
- and (FDisplColParam[i].Index>1)
- then
- FDisplColParam[i].Width:=(J * //коефіціент
- ColWidths[FDisplColParam[i].Index]) div GetColsWidth; //процент
- while GetSum<ColWidthIndexMax do
- for I := rlBookmarkName to High(FDisplColParam) do
- if FDisplColParam[i].Width<ColWidthKoef then
- begin
- inc(FDisplColParam[i].Width);
- break;
- end;
- while GetSum>ColWidthIndexMax do
- for I := rlBookmarkName to High(FDisplColParam) do
- if FDisplColParam[i].Width>ColWidthKoef then
- begin
- Dec(FDisplColParam[i].Width);
- break;
- end;
- end;
- function TMainForm.tegs_GetCBoxItems(const Tegs: TTegsList; const AllTegs: TTegsList): string;
- var
- I: Integer;
- s: string;
- begin
- result := '';
- s := Tegs.TegsStr;
- if (s <> '') then
- s := s + ', ';
- for I := 0 to AllTegs.TegsList.Count - 1 do
- if not Tegs.TegInList(AllTegs.TegsList.Strings[I]) then
- result := result + s + AllTegs.TegsList.Strings[I] + #13#10;
- end;
- function TMainForm.GetEngineConf: TEngineConf;
- begin
- with result do
- begin
- Name := EngineTab_NameEdit.Text;
- Coment := EngineTab_ComentEdit.Text;
- LogUser := EngineTab_LoginEdit.Text;
- LogPass := EngineTab_PassEdit.Text;
- MsgTitle := EngineTab_MsgTitleEdit.Text;
- MsgMess := EngineTab_MsgMsgEdit.Text;
- TopicTitle := EngineTab_TopicTitleEdit.Text;
- TopicMsg := EngineTab_TopicMsgEdit.Text;
- Tegs := TTegsList.Create;
- Tegs.TegsStr := EngineTab_TegsCBox.Text;
- end;
- end;
- function TMainForm.GetForumConf: TForumConf;
- begin
- with result do
- begin
- Name := ForumsTab_NameEdit.Text;
- Coment := ForumsTab_ComentEdit.Text;
- LogName := ForumsTab_LogEdit.Text;
- LogPass := ForumsTab_PassEdit.Text;
- LogURI := ForumsTab_LogURLEdit.Text;
- LogBtn := ForumsTab_LoginBtnEdit.Text;
- MsgBtn := ForumsTab_MsgBtnEdit.Text;
- TopicBtn := ForumsTab_TopicBtnEdit.Text;
- EngineName := ForumsTab_EngineCBox.Text;
- Tegs := TTegsList.Create;
- Tegs.TegsStr := ForumsTab_TegsCBox.Text;
- end;
- end;
- procedure TMainForm.Load;
- var
- ini: TIniFile;
- J: TRequestListCol;
- const
- p0: string = 'Form';
- p1: string = 'DisplColParam';
- p2: string = 'MessageTab';
- p3: string = 'ForumConfTab';
- p4: string = 'EngineConfTab';
- p5: string = 'Else';
- begin
- FPoster.DBList.LoadFromFile;
- FDisplColParam[rlNumber].Visible:=true;
- FDisplColParam[rlChecked].Visible:=true;
- FDisplColParam[rlBookmarkName].Visible:=DisplGrid_BookmarkNameAction.Checked;
- FDisplColParam[rlBookmarkType].Visible:=DisplGrid_BookmarkTypeAction.Checked;
- FDisplColParam[rlBookmarkURI].Visible:=True;//DisplGrid_BookmarkURIAction.Checked;
- FDisplColParam[rlBookmarkTegs].Visible:=DisplGrid_BookmarkTegsAction.Checked;
- FDisplColParam[rlForumName].Visible:=DisplGrid_ForumNameAction.Checked;
- FDisplColParam[rlForumTegs].Visible:=DisplGrid_ForumTegsAction.Checked;
- FDisplColParam[rlEngineName].Visible:=DisplGrid_EngineNameAction.Checked;
- FDisplColParam[rlEngineTegs].Visible:=DisplGrid_EngineTegsAction.Checked;
- ini := TIniFile.Create(ExtractFilePath(FPath) + SPathItemsSave);
- try
- PostTab_MsgMemo.Lines.LoadFromFile(ExtractFilePath(FPath) +
- SPathMsgSave);
- with ini do
- begin
- width := ReadInteger(p0, 'Width', width);
- Height := ReadInteger(p0, 'Heigth', Height);
- Left := ReadInteger(p0, 'Left', Left);
- Top := ReadInteger(p0, 'Top', Top);
- (*
- if SectionExists(p1+'/Visible') then
- begin
- for J := rlBookmarkName to High(TRequestListCol) do
- FDisplColParam[j].Visible:=ReadBool(p1+'/Visible',RequestColStr[J],false);
- DisplGrid_BookmarkNameAction.Checked:=FDisplColParam[rlBookmarkName].Visible;
- DisplGrid_BookmarkTypeAction.Checked:=FDisplColParam[rlBookmarkType].Visible;
- //DisplGrid_BookmarkURIAction.Checked:=FDisplColParam[rlBookmarkURI].Visible;
- DisplGrid_BookmarkTegsAction.Checked:=FDisplColParam[rlBookmarkTegs].Visible;
- DisplGrid_ForumNameAction.Checked:=FDisplColParam[rlForumName].Visible;
- DisplGrid_ForumTegsAction.Checked:=FDisplColParam[rlForumTegs].Visible;
- DisplGrid_EngineNameAction.Checked:=FDisplColParam[rlEngineName].Visible;
- DisplGrid_EngineTegsAction.Checked:=FDisplColParam[rlEngineTegs].Visible;
- end;
- *)
- for J := rlBookmarkName to High(TRequestListCol) do
- FDisplColParam[j].Width:=ReadInteger(p1+'/Width',RequestColStr[J],ColWidthKoef);
- PostTab_TopicEdit.Text := ReadString(p2, 'Title', '');
- ForumsTab_ListBox.width := ReadInteger(p3, 'ListBoxWidth',
- ForumsTab_ListBox.width);
- with ForumsTab_ListBox do
- ItemIndex := Items.IndexOf(ReadString(p3, 'ActForum', ''));
- EngineTab_ListBox.width := ReadInteger(p4, 'ListBoxWidth',
- EngineTab_ListBox.width);
- with EngineTab_ListBox do
- ItemIndex:= Items.IndexOf(ReadString(p4, 'ActEngine', ''));
- { else }
- StatusBarAction.Checked := ReadBool(p5, 'StatusBar', true);
- StatusBar.Visible := StatusBarAction.Checked;
- ToolBarAction.Checked := ReadBool(p5, 'ToolBar', true);
- MainToolBar.Visible := ToolBarAction.Checked;
- end;
- finally
- ini.Free;
- end;
- end;
- procedure TMainForm.NulEngineConf;
- begin
- EngineTab_NameEdit.Text := '';
- EngineTab_ComentEdit.Text := '';
- EngineTab_LoginEdit.Text := '';
- EngineTab_PassEdit.Text := '';
- EngineTab_MsgTitleEdit.Text := '';
- EngineTab_MsgMsgEdit.Text := '';
- EngineTab_TopicTitleEdit.Text := '';
- EngineTab_TopicMsgEdit.Text := '';
- EngineTab_TegsCBox.Text := '';
- EngineTab_TegsCBox.Items.Clear;
- end;
- procedure TMainForm.NulForumConf;
- begin
- ForumsTab_NameEdit.Text := '';
- ForumsTab_ComentEdit.Text := '';
- ForumsTab_LogEdit.Text := '';
- ForumsTab_PassEdit.Text := '';
- ForumsTab_LogURLEdit.Text := '';
- ForumsTab_LoginBtnEdit.Text := '';
- ForumsTab_MsgBtnEdit.Text := '';
- ForumsTab_TopicBtnEdit.Text := '';
- ForumsTab_TegsCBox.Text := '';
- ForumsTab_TegsCBox.Items.Clear;
- end;
- procedure TMainForm.PostingActionExecute(Sender: TObject);
- var
- I:Integer;
- Prm:TRqtParam;
- Str:string;
- begin
- with SendTab_DisplayBookGrid, FPoster.Request, FPoster.DBList do
- begin
- ClearList;
- for I := 1 to RowCount-1 do
- if Cells[FDisplColParam[rlChecked].Index,i]=#1 then
- begin
- Str:=BookToRqtPrm(Bookmarks.ItemsFromURI[
- Cells[FDisplColParam[rlBookmarkURI].Index,i]], Prm,PostTab_TopicEdit.Text,
- PostTab_MsgMemo.Text);
- if str<>'' then
- WriteToLog(Str);
- if Pos(SErrMsgPrefix,Str)=0 then
- AddToList(Prm);
- end;
- if ListCount=0 then
- MessageBox(0,PChar(SMsgNulBookSelect), 'ForumsPoster: Список пустий...',
- MB_OK or MB_ICONSTOP or MB_TASKMODAL)
- else
- Posting;
- end;
- end;
- procedure TMainForm.PostingBegin(Sender: TObject; Max: integer);
- var
- buff:TRqtStatusConteyner;
- begin
- PageControl.Visible:=false;
- Panel.Visible:=true;
- Proc_AllLabel.Caption:=intToStr(Max);
- Proc_AllPrgsBar.Max:=max;
- PostingCancelAction.Enabled:=true;
- Proc_ContBtn.Enabled:=false;
- Proc_AllPrgsBar.Enabled:=true;
- Proc_StatusLabel.Caption:=SProcWaitFromSendRequest;
- TFPRequest.SetNullStatus(buff);
- SetProgressPosition(buff);
- WriteToLog(Format(SLogSessionBegin,[TimeToStr(Time),DateToStr(Date),FSession]));
- end;
- procedure TMainForm.PostingCancelActionExecute(Sender: TObject);
- begin
- Proc_CancBtn.Enabled := false;
- FPoster.Request.Terminate;
- end;
- procedure TMainForm.PostingEnd(Sender: TObject);
- begin
- PostingCancelAction.Enabled:=false;
- Proc_ContBtn.Enabled:=true;
- Proc_AllPrgsBar.Enabled:=false;
- if TFPRequest(Sender).Terminated then
- Proc_StatusLabel.Caption:=SProcSendRequestTerminated
- else
- Proc_StatusLabel.Caption:=SProcSendRequestDone;
- WriteToLog(Format(SLogSessionEnd,[TimeToStr(Time),DateToStr(Date),FSession]));
- WriteToLog('');
- WriteToLog('');
- inc(FSession);
- end;
- procedure TMainForm.PostingProgress(Sender: TObject; const Status: TRqtStatusConteyner);
- begin
- SetProgressPosition(Status);
- end;
- procedure TMainForm.PostLogStatusActionExecute(Sender: TObject);
- begin
- //
- end;
- procedure TMainForm.Proc_ContBtnClick(Sender: TObject);
- begin
- Panel.Visible := false;
- PageControl.Visible:= true;
- end;
- procedure TMainForm.RqsListUpdTimerTimer(Sender: TObject);
- begin
- RqsListUpdTimer.Enabled:=false;
- disp_UpdRqsList;
- end;
- procedure TMainForm.Save;
- var
- ini: TIniFile;
- I:TRequestListCol;
- const
- p0: string = 'Form';
- p1: string = 'DisplColParam';
- p2: string = 'MessageTab';
- p3: string = 'ForumConfTab';
- p4: string = 'EngineConfTab';
- p5: string = 'Else';
- begin
- if not DirectoryExists(FPath + SPathConf) then
- begin
- CreateDir(FPath + SPathConf);
- end;
- FPoster.DBList.SaveToFile;
- ini := TIniFile.Create(ExtractFilePath(FPath) + SPathItemsSave);
- try
- PostTab_MsgMemo.Lines.SaveToFile(ExtractFilePath(FPath) +
- SPathMsgSave);
- with ini do
- begin
- if WindowState=wsNormal then
- begin
- WriteInteger(p0, 'Width', width);
- WriteInteger(p0, 'Heigth', Height);
- WriteInteger(p0, 'Left', Left);
- WriteInteger(p0, 'Top', Top);
- end;
- disp_GetColWidth;
- for I := TRequestListCol(2) to High(TRequestListCol) do
- begin
- WriteInteger(p1+'/Width',RequestColStr[i],FDisplColParam[i].Width);
- WriteBool(p1+'/Visible',RequestColStr[i],FDisplColParam[i].Visible);
- end;
- WriteString(p2, 'Title', PostTab_TopicEdit.Text);
- WriteInteger(p3, 'ListBoxWidth', ForumsTab_ListBox.width);
- with ForumsTab_ListBox do
- if ItemIndex > -1 then
- WriteString(p3, 'ActForum', Items[ItemIndex])
- else
- WriteString(p3, 'ActForum', '');
- WriteInteger(p4, 'ListBoxWidth', EngineTab_ListBox.width);
- with EngineTab_ListBox do
- if ItemIndex > -1 then
- WriteString(p4, 'ActEngine', Items[ItemIndex])
- else
- WriteString(p4, 'ActEngine', '');
- WriteBool(p5, 'StatusBar', StatusBarAction.Checked);
- WriteBool(p5, 'ToolBar', ToolBarAction.Checked);
- end;
- finally
- ini.Free;
- end;
- end;
- procedure TMainForm.SaveActionExecute(Sender: TObject);
- begin
- FPoster.DBList.SaveToFile;
- end;
- procedure TMainForm.SetEngineConf(const Rec: TEngineConf);
- begin
- with Rec do
- begin
- EngineTab_NameEdit.Text := Name;
- EngineTab_ComentEdit.Text := Coment;
- EngineTab_LoginEdit.Text := LogUser;
- EngineTab_PassEdit.Text := LogPass;
- EngineTab_MsgTitleEdit.Text := MsgTitle;
- EngineTab_MsgMsgEdit.Text := MsgMess;
- EngineTab_TopicTitleEdit.Text := TopicTitle;
- EngineTab_TopicMsgEdit.Text := TopicMsg;
- EngineTab_TegsCBox.Text := Tegs.TegsStr;
- EngineTab_TegsCBox.Items.Text :=
- tegs_GetCBoxItems(Tegs, FPoster.DBList.Engines.GetTegsList);
- end;
- end;
- procedure TMainForm.SendTabShow(Sender: TObject);
- begin
- tegs_AllTegsUpdate;
- disp_UpdRqsList;
- end;
- function TMainForm.tegs_ComboBoxFromIndex(Index: integer): TComboBox;
- begin
- case index of
- 1: result:= SendTab_BookNeedTegsCBox;
- 2: result:= SendTab_ForumNeedTegsCBox;
- 3: result:= SendTab_EngineNeedTegsCBox;
- 4: result:= SendTab_BookExcpTegsCBox;
- 5: result:= SendTab_ForumExcpTegsCBox;
- 6: result:= SendTab_EngineExcpTegsCBox;
- // 7: result:= BooksTab_TegsCBox;
- 8: result:= ForumsTab_TegsCBox;
- 9: result:= EngineTab_TegsCBox;
- else result:= nil;
- end;
- end;
- procedure TMainForm.disp_SetColWidth;
- var
- I:TRequestListCol;
- J:integer;
- begin
- J:=disp_EnbColWidth;
- with SendTab_DisplayBookGrid do
- for I := rlBookmarkName to High(FDisplColParam) do
- if (FDisplColParam[i].Visible)
- and (FDisplColParam[i].Index>1)
- then
- if (FDisplColParam[i].Width>10) then
- ColWidths[FDisplColParam[i].Index]:=FDisplColParam[i].Width *
- (SendTab_DisplayBookGrid.Width-ColWidths[0]-ColWidths[1]-12)
- div j
- else
- ColWidths[FDisplColParam[i].Index]:=10;
- end;
- procedure TMainForm.disp_SetGrid;
- var
- ABoormark, UnMarked:TStrings;
- I:integer;
- begin
- ABoormark:=TStringList.Create;
- UnMarked:=TStringList.Create;
- try
- if FDisplColParam[rlBookmarkURI].Index<>-1 then
- with SendTab_DisplayBookGrid do
- for I := 1 to RowCount-1 do
- if Cells[FDisplColParam[rlBookmarkURI].Index,i]<>'' then
- begin
- ABoormark.Add(Cells[FDisplColParam[rlBookmarkURI].Index,i]);
- if Cells[FDisplColParam[rlChecked].Index,i]<>#1 then
- UnMarked.Add(Cells[FDisplColParam[rlBookmarkURI].Index,i]);
- end;
- disp_SetGrid(ABoormark,UnMarked);
- finally
- ABoormark.Free;
- UnMarked.Free;
- end;
- end;
- procedure TMainForm.disp_SetGrid(ABookmarks, UnMarkedBooks: TStrings);
- procedure SetValue(ACol:TRequestListCol; ARow:integer; const Value:string);
- begin
- if (FDisplColParam[ACol].Index<>-1) and (ARow<>-1)
- and FDisplColParam[ACol].Visible
- then
- SendTab_DisplayBookGrid.Cells[FDisplColParam[ACol].Index,ARow]:=Value;
- end;
- procedure UpdateGridColums;
- var
- i: integer;
- J: TRequestListCol;
- begin
- with SendTab_DisplayBookGrid do
- begin
- FDisplColParam[rlNumber].Index:=0;
- FDisplColParam[rlChecked].Index:=1;
- i:=2;
- disp_GetColWidth;
- for J := rlBookmarkName to High(FDisplColParam) do
- if FDisplColParam[J].Visible then
- begin
- FDisplColParam[J].Index:=i;
- inc(i);
- end;
- SendTab_DisplayBookGrid.ColCount:=i;
- disp_SetColWidth;
- end;
- end;
- const
- BookType: array [boolean] of string = (SBookTypeTopic,SBookTypeMsg);
- var
- I,j:integer;
- I1: TRequestListCol;
- TB:TBookmarkConf;
- TF:TForumConf;
- begin
- UpdateGridColums;
- with SendTab_DisplayBookGrid do
- begin
- if ABookmarks.Count>0 then
- RowCount:=ABookmarks.Count+1
- else
- begin
- RowCount:=2;
- Rows[1].clear;
- end;
- for I1 := Low(TRequestListCol) to High(TRequestListCol) do
- SetValue(I1,0,RequestColCaption[I1]);
- i:=1;
- for J:=0 to ABookmarks.Count-1 do
- begin
- TB:=FPoster.DBList.Bookmarks.ItemsFromURI[ABookmarks.Strings[j]];
- with SendTab_TypeBookCBox, FPoster.DBList do
- if (ItemIndex=2) or (TB.isMsg and (ItemIndex=0))
- or (not TB.isMsg and (ItemIndex=1))
- then
- begin
- SetValue(rlNumber,i,IntToStr(i));
- if UnMarkedBooks.IndexOf(TB.URI)<>-1 then
- SetValue(rlChecked,i,#0)
- else
- SetValue(rlChecked,i,#1);
- SetValue(rlBookmarkName,i,TB.Name);
- SetValue(rlBookmarkURI, i,TB.URI);
- SetValue(rlBookmarkTegs,i,TB.Tegs.TegsStr);
- SetValue(rlBookmarkType,i,BookType[TB.isMsg]);
- if Forums.ContainsFromURI(TB.URI) then
- begin
- TF:=Forums.ItemsFromURI[TB.URI];
- SetValue(rlForumName, i,TF.Name);
- SetValue(rlForumTegs, i,TF.Tegs.TegsStr);
- SetValue(rlEngineName, i,TF.EngineName);
- if Engines.Contains(TF.EngineName) then
- SetValue(rlEngineTegs, i,Engines.ItemsFromName[
- TF.EngineName].Tegs.TegsStr);
- end;
- inc(i);
- end;
- end;
- if i>1 then
- RowCount:=i
- else
- begin
- RowCount:=2;
- Rows[1].clear;
- end;
- end;
- FDisplBooksCount:=ABookmarks.Count;
- end;
- procedure TMainForm.tegs_AllTegsUpdate;
- begin
- tegs_TegsUpdate(SendTab_BookNeedTegsCBox, #0);
- tegs_TegsUpdate(SendTab_ForumNeedTegsCBox, #0);
- tegs_TegsUpdate(SendTab_EngineNeedTegsCBox, #0);
- end;
- procedure TMainForm.tegs_TegsCBoxEnter(Sender: TObject);
- begin
- tegs_TegsUpdate(TComboBox(Sender));
- end;
- procedure TMainForm.tegs_TegsCBoxKeyPress(Sender: TObject;
- var Key: Char);
- begin
- if (CharInSet(Key, [',', #8, #$D])) //#8 - backspase #$D - enter
- and (TComboBox(Sender).SelStart = Length(TComboBox(Sender).Text))
- then
- tegs_TegsUpdate(TComboBox(Sender),Key);
- if key=#$D then
- begin
- with TComboBox(Sender) do
- if SelLength<>0 then
- begin
- SelStart:=Length(Text);
- SelLength:=0;
- end;
- // else
- // case TComboBox(Sender).Tag of
- // 7 : BooksTab_NewBtn.Click;
- // end;
- Key:=#0;
- end;
- end;
- procedure TMainForm.tegs_TegsUpdate(ComboBox: TComboBox; Key: Char=#0);
- var
- AllTegs:TTegsList;
- CBox2:TComboBox;
- begin
- case ComboBox.Tag of
- 1,4,7,10: AllTegs:=FPoster.DBList.Bookmarks.GetTegsList;
- 2,5,8: AllTegs:=FPoster.DBList.Forums.GetTegsList;
- 3,6,9: AllTegs:=FPoster.DBList.Engines.GetTegsList;
- else AllTegs:=nil;
- end;
- if ComboBox.Tag<7 then //4,5,6 - cписок непотрібних тегів
- if ComboBox.Tag>3 then //1-3 бокси йдуть в парі. так і оброб'ляються...
- CBox2:=tegs_ComboBoxFromIndex(ComboBox.Tag-3)
- else
- CBox2:=tegs_ComboBoxFromIndex(ComboBox.Tag+3)
- else
- begin
- CBox2:=NullComboBox; //інші бокси йдуть без пари.
- CBox2.Clear; //а це для функи
- end;
- AllTegs.DeleteTegs(ComboBox.Text);
- AllTegs.DeleteTegs(CBox2.Text);
- ComboBox.Items.Text := tegs_GetCBoxItems(ComboBox.Text, AllTegs,Key);
- ComboBox.SelStart := Length(ComboBox.Text);
- CBox2.Items.Text := tegs_GetCBoxItems(CBox2.Text, AllTegs,Key);
- CBox2.SelStart := Length(CBox2.Text);
- end;
- procedure TMainForm.RunDelayListUpd(Sender: TObject);
- begin
- RqsListUpdTimer.Enabled:=false;
- RqsListUpdTimer.Enabled:=true;
- end;
- procedure TMainForm.tegs_TegsActCBoxClick(Sender: TObject);
- begin
- tegs_ComboBoxFromIndex(TCheckBox(Sender).Tag).Enabled:=
- SendTab_BookTegsActCBox.Checked;
- tegs_ComboBoxFromIndex(TCheckBox(Sender).Tag+3).Enabled:=
- SendTab_BookTegsActCBox.Checked;
- RunDelayListUpd(nil);
- end;
- procedure TMainForm.SendTab_DisplayBookGridDrawCell(Sender: TObject; ACol,
- ARow: Integer; Rect: TRect; State: TGridDrawState);
- begin
- if (ACol=FDisplColParam[rlChecked].Index) and (ARow>0) then
- DrawCheck(ARow);
- end;
- procedure TMainForm.SendTab_DisplayBookGridMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- var
- ACol,ARow:integer;
- begin
- if (Button=mbLeft) then
- with SendTab_DisplayBookGrid do
- begin
- MouseToCell(X,Y,ACol,ARow);
- if (ARow > FDisplBooksCount) or (ARow < 1) then exit;
- if (ACol=FDisplColParam[rlChecked].Index) and (ARow >= 0)
- and (ARow <= RowCount)
- then
- begin
- if Cells[ACol,ARow]=#0 then
- Cells[Col,ARow]:=#1
- else
- Cells[ACol,ARow]:=#0;
- end;
- end;
- end;
- procedure TMainForm.SendTab_TypeBookCBoxChange(Sender: TObject);
- begin
- disp_UpdRqsList;
- end;
- procedure TMainForm.SetEngineConf(const Name: string);
- begin
- if EngineTab_ListBox.Items.IndexOf(Name) <> -1 then
- begin
- EngineTab_ListBox.ItemIndex := EngineTab_ListBox.Items.IndexOf(Name);
- SetEngineConf(FPoster.DBList.Engines.ItemsFromName[Name]);
- end;
- end;
- procedure TMainForm.SetForumConf(const Name: string);
- begin
- if ForumsTab_ListBox.Items.IndexOf(Name) <> -1 then
- begin
- ForumsTab_ListBox.ItemIndex := ForumsTab_ListBox.Items.IndexOf(Name);
- SetForumConf(FPoster.DBList.Forums.ItemsFromName[Name]);
- end
- else
- NulForumConf;
- end;
- procedure TMainForm.SetProgressPosition(const Status: TRqtStatusConteyner);
- begin
- Proc_DoneLabel.Caption:=intToStr(Status.Done);
- Proc_ErrorLabel.Caption:=IntToStr(Status.Error+Status.Terminated);
- Proc_CompitLabel.Caption:=IntToStr(Status.Summ);
- Proc_AllPrgsBar.Position:=Status.Summ;
- end;
- function TMainForm.ShowImportReplaseDialog(DialogType: TImportDialogType;
- out UseFromAll: Boolean; const Str: string; const AFile:string): integer;
- begin
- with DublicateDialogForm do
- case DialogType of
- irEngineName:
- begin
- TitleText.Caption:=Format(SDlgTitleText,[SToEngine, SFromName, str]);
- ReplaseText.Caption:=Format(SDlgReplaseConf,[str, AFile]);
- RenameText.Caption:=Format(SDlgRenameText,[Str, Str+'(2)']);
- end;
- irForumName:
- begin
- TitleText.Caption:=Format(SDlgTitleText,[SToForum, SFromName, str]);
- RenameText.Caption:=Format(SDlgRenameText,[Str, Str+'(2)']);
- end;
- irForumURI:
- begin
- TitleText.Caption:=Format(SDlgTitleText,[SToForum, SToURI, str]);
- RenameText.Caption:=Format(SDlgRenameURIText,[Str, Str+'(2)']);
- end;
- irBookURI:
- begin
- TitleText.Caption:=Format(SDlgTitleText,[SToBookmark, SToURI, str]);
- RenameText.Caption:=Format(SDlgRenameText,[Str, Str+'(2)'])
- end;
- end;
- Result:=DublicateDialogForm.ShowModal;
- UseFromAll:=DublicateDialogForm.FromAllCBox.Checked;
- end;
- procedure TMainForm.SortStringGrid(Grid: TStringGrid; const ACell: Integer;
- UpToDown: Boolean; TopValue: string; InCell: integer);
- var
- I: Integer;
- S: string;
- begin
- SortStringGrid(Grid,ACell,UpToDown);
- with Grid do
- begin
- if Cols[InCell].IndexOf(TopValue)<>-1 then
- for I := Cols[InCell].IndexOf(TopValue) downto 2 do
- begin
- S:=Rows[i].Text;
- Rows[i].Text:=Rows[i-1].Text;
- Rows[i-1].Text:=s;
- end;
- end;
- end;
- procedure TMainForm.SortStringGrid(Grid:TStringGrid;
- const ACell: Integer; UpToDown: Boolean);
- procedure obmin(const i1, i2, CollMax: Integer);
- var
- s: string;
- begin
- with Grid do
- begin
- S:=Rows[i1].Text;
- Rows[i1].Text:=Rows[i2].Text;
- Rows[i2].Text:=s;
- end;
- end;
- var
- I: Integer;
- J: Integer;
- CollMax:integer;
- begin
- with Grid do
- begin
- CollMax:=ColCount-1;
- if UpToDown then
- for I := 1 to RowCount - 1 do
- for J := I + 1 to RowCount - 1 do
- if Cells[ACell, I] < Cells[ACell, J] then
- obmin(I, J, CollMax)
- else
- else
- for I := 1 to RowCount - 1 do
- for J := I + 1 to RowCount - 1 do
- if Cells[ACell, I] > Cells[ACell, J] then
- obmin(I, J, CollMax);
- end;
- end;
- procedure TMainForm.SetForumConf(const Rec: TForumConf);
- begin
- with Rec do
- begin
- ForumsTab_NameEdit.Text := Name;
- ForumsTab_ComentEdit.Text := Coment;
- ForumsTab_LogEdit.Text := LogName;
- ForumsTab_PassEdit.Text := LogPass;
- ForumsTab_LogURLEdit.Text := LogURI;
- ForumsTab_LoginBtnEdit.Text := LogBtn;
- ForumsTab_MsgBtnEdit.Text := MsgBtn;
- ForumsTab_TopicBtnEdit.Text := TopicBtn;
- ForumsTab_EngineCBox.ItemIndex := ForumsTab_EngineCBox.Items.IndexOf
- (EngineName);
- ForumsTab_TegsCBox.Text := Tegs.TegsStr;
- ForumsTab_TegsCBox.Items.Text :=
- tegs_GetCBoxItems(Tegs, FPoster.DBList.Forums.GetTegsList);
- end;
- end;
- procedure TMainForm.StatusBarActionExecute(Sender: TObject);
- begin
- StatusBar.Visible := StatusBarAction.Checked;
- end;
- procedure TMainForm.ThreadLogAdd(Sender: TObject;
- const Item: TRqtThreadLogConteyner; Action: TCollectionNotification);
- var
- str:string;
- begin
- if Action=cnAdded then
- begin
- case Item.ItemType of
- itError: str:='Error';
- itWarning: str:='Warring';
- itDone: str:='Event';
- itTerminated:str:='Terminated';
- itEvent: str:='Event';
- itNone: str:='None';
- end;
- WriteToLog(Format('[%s][ID:%d][%s] %s',[TimeToStr(Item.Time),Item.ThreadId,
- str, Item.Item]));
- end;
- end;
- procedure TMainForm.ToolBarActionExecute(Sender: TObject);
- begin
- MainToolBar.Visible := ToolBarAction.Checked;
- end;
- procedure TMainForm.UpdBookConf();
- var
- I: Integer;
- Tmp:TBookmarkConf;
- const
- DefURI:string='http://';
- begin
- with FPoster.DBList, BooksTab_StringGrid do
- begin
- if not Bookmarks.Contains(DefURI) then
- begin
- Tmp.URI:=DefURI;
- Tmp.Name:='';
- Tmp.isMsg:=false;
- Tmp.Tegs:=nil;
- Bookmarks.Add(Tmp)
- end;
- if Bookmarks.Count > 0 then
- begin
- RowCount := Bookmarks.Count + 1;
- for I := 0 to Bookmarks.Count - 1 do
- begin
- Cells[0,I+1]:=IntToStr(I + 1);
- Cells[blName, I+1] := Bookmarks[I].Name;
- if Bookmarks[i].isMsg then
- Cells[blType, I+1]:=SBookTypeMsg
- else
- Cells[blType, I+1]:=SBookTypeTopic;
- Cells[blURI, I+1] := Bookmarks[I].URI;
- Cells[blTegs, I+1] := Bookmarks[I].Tegs.TegsStr;
- end;
- SortStringGrid(BooksTab_StringGrid, blURI, False, DefURI, blURI);
- end
- else
- begin
- RowCount := 2;
- Rows[1].Text := '';
- end;
- end;
- end;
- procedure TMainForm.UpdEngineConf(const Name: string);
- var
- str: string;
- begin
- if EngineTab_ListBox.ItemIndex > -1 then
- str := EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex];
- EngineTab_ListBox.Items.Text := FPoster.DBList.Engines.ListOfNames;
- ForumsTab_EngineCBox.Items.Text := EngineTab_ListBox.Items.Text;
- // ForumsTab_EngineCBox.Items.Insert(0,'');
- if EngineTab_ListBox.Count <= 0 then
- begin
- EnbEngineConf(false);
- exit;
- end;
- if Name <> '' then
- EngineTab_ListBox.ItemIndex := EngineTab_ListBox.Items.IndexOf(Name)
- else if EngineTab_ListBox.Items.IndexOf(str) <> -1 then
- EngineTab_ListBox.ItemIndex := EngineTab_ListBox.Items.IndexOf(str)
- else if EngineTab_ListBox.Count > 0 then
- EngineTab_ListBox.ItemIndex := 0;
- SetEngineConf(EngineTab_ListBox.Items.Strings[EngineTab_ListBox.ItemIndex]);
- EnbEngineConf(true);
- end;
- procedure TMainForm.UpdForumConf(const Name: string = '');
- var
- str: string;
- begin
- if ForumsTab_ListBox.ItemIndex > -1 then
- str := ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex];
- ForumsTab_ListBox.Items.Text := FPoster.DBList.Forums.ListOfNames;
- if ForumsTab_ListBox.Count = 0 then
- begin
- EnbForumConf(false);
- exit;
- end;
- if Name <> '' then
- ForumsTab_ListBox.ItemIndex := ForumsTab_ListBox.Items.IndexOf(Name)
- else if ForumsTab_ListBox.Items.IndexOf(str) <> -1 then
- ForumsTab_ListBox.ItemIndex := ForumsTab_ListBox.Items.IndexOf(str)
- else if ForumsTab_ListBox.Count > 0 then
- ForumsTab_ListBox.ItemIndex := 0;
- SetForumConf(ForumsTab_ListBox.Items.Strings[ForumsTab_ListBox.ItemIndex]);
- EnbForumConf(true);
- end;
- procedure TMainForm.disp_UpdRqsList;
- var
- SL,CheckMem:TStrings;
- I,J: integer;
- Tegs:TTegsArray;
- begin
- CheckMem:=TStringList.Create;
- try
- with SendTab_DisplayBookGrid do
- for I := 1 to RowCount-1 do
- if Cells[FDisplColParam[rlChecked].Index,i]=#0 then
- CheckMem.Add(Cells[FDisplColParam[rlChecked].Index,i]);
- for I := 0 to 2 do
- for j := 0 to 1 do
- Tegs[i,j]:=TTegsList.Create;
- try
- if SendTab_BookTegsActCBox.Checked then
- begin
- Tegs[0,0].TegsStr:=SendTab_BookNeedTegsCBox.Text;
- Tegs[0,1].TegsStr:=SendTab_BookExcpTegsCBox.Text;
- end;
- if SendTab_ForumTegsActCBox.Checked then
- begin
- Tegs[1,0].TegsStr:=SendTab_ForumNeedTegsCBox.Text;
- Tegs[1,1].TegsStr:=SendTab_ForumExcpTegsCBox.Text;
- end;
- if SendTab_EngineTegsActCBox.Checked then
- begin
- Tegs[2,0].TegsStr:=SendTab_EngineNeedTegsCBox.Text;
- Tegs[2,1].TegsStr:=SendTab_EngineExcpTegsCBox.Text;
- end;
- SL:=FPoster.DBList.TegsFilter(Tegs);
- finally
- for I := 0 to 2 do
- for j := 0 to 1 do
- Tegs[i,j].Free;
- end;
- disp_SetGrid(SL,CheckMem);
- finally
- CheckMem.Free;
- end;
- end;
- procedure TMainForm.WriteToLog(const Msg: string);
- begin
- Proc_LogListBox.Items.Add(Msg);
- if (Proc_LogListBox.ItemIndex = Proc_LogListBox.Items.Count - 2) then
- Proc_LogListBox.ItemIndex := Proc_LogListBox.Items.Count - 1;
- end;
- { TMainForm.TColRec }
- procedure TMainForm.TColRec.SetVisible(const Value: boolean);
- begin
- FVisible := Value;
- if not Value then
- Index:=-1;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment