OSDN Git Service

スレタイの[転載禁止]と「©2ch.net」を非表示にする機能を追加
authorzako <zako@users.sourceforge.jp>
Mon, 27 Oct 2014 13:41:01 +0000 (22:41 +0900)
committerzako <zako@users.sourceforge.jp>
Mon, 27 Oct 2014 13:41:01 +0000 (22:41 +0900)
Giko.pas
GikoSystem.pas
ListViewUtils.pas
Option.dfm
Option.pas
Setting.pas

index 08a7f98..401b11d 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -713,6 +713,8 @@ type
         procedure LoadIcon();
         //! \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\93Ç\82Ý\8d\9e\82Ý
         procedure LoadPopupMenu();
+        //! \83X\83\8c\83^\83C\8eæ\93¾
+        function GetThreadTitle(OrgTitle: String): String;
        protected
                procedure CreateParams(var Params: TCreateParams); override;
                procedure WndProc(var Message: TMessage); override;
@@ -847,6 +849,8 @@ type
         procedure StoredTaskTray;
         //! \93¯ID\83\8c\83X\83A\83\93\83J\81[\95\\8e¦
         procedure ShowSameIDAncher(const AID: String);
+        //! \83X\83\8c\83^\83C\95\\8e¦\8dX\90V
+        procedure UpdateThreadTitle;
        published
                property EnabledCloseButton: Boolean read FEnabledCloseButton write SetEnabledCloseButton;
        end;
@@ -3068,7 +3072,7 @@ begin
                if (Thread <> nil) and (ThreadItem <>nil) then begin
                        BrowserBoardNameLabel.Caption := ThreadPTitle;
                        ItemIcon16.GetBitmap(4, ItemBoardImage.Picture.Bitmap);
-                       BrowserNameLabel.Caption := ThreadTitle;
+            BrowserNameLabel.Caption := GetThreadTitle(ThreadTitle);
                        ItemImage.Picture := nil;
                        if ThreadIsLog then
                                if ThreadNewArraical then
@@ -3101,7 +3105,7 @@ begin
                                
                        end;
                end else begin
-                       Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + ThreadTitle + ']';
+                       Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + GetThreadTitle(ThreadTitle) + ']';
                        //\83X\83e\81[\83^\83X\83o\81[\82É\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\82Ì\97e\97Ê\82ð\95\\8e¦
                        StatusBar.Panels[THREADSIZE_PANEL].Text := Format('%6.2f kB', [ThreadItem.Size / 1024]);
                        StatusBar.Panels[THREADSIZE_PANEL].Width :=
@@ -3164,7 +3168,7 @@ begin
                if (FActiveContent <> nil) and (FActiveContent.Thread <> nil)
                        and (FActiveContent.Thread.IsLogFile) then begin
                        try
-                               Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + FActiveContent.Thread.Title + ']'
+                               Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + GetThreadTitle(FActiveContent.Thread.Title) + ']'
                        except
                                on E: Exception do begin
                                        //\83X\83\8c\88ê\97\97DL\8cã\82È\82Ç\82ÉFActiveContent\82Ì\8e\9d\82ÂThread\82ª
@@ -8164,6 +8168,53 @@ begin
             GikoSys.Setting.GetAppDir + ICONTOOL, clPurple);
     end;
 end;
+
+//! \83X\83\8c\83^\83C\95\\8e¦\8dX\90V
+procedure TGikoForm.UpdateThreadTitle;
+var
+       i: Integer;
+    DspTitle: String;
+begin
+    BrowserTab.Tabs.BeginUpdate;
+    for i := 0 to BrowserTab.Tabs.Count - 1 do begin
+        BrowserTab.Tabs.Strings[i] :=
+            GikoSys.GetShortName(TBrowserRecord(BrowserTab.Tabs.Objects[i]).Thread.Title, 20);
+    end;
+    BrowserTab.Tabs.EndUpdate;
+
+    if (FActiveContent <> nil) and (FActiveContent.Thread <> nil) then begin
+        DspTitle := GetThreadTitle(FActiveContent.Thread.Title);
+        BrowserNameLabel.Caption := DspTitle;
+        Self.Caption := GikoDataModule.CAPTION_NAME + ' - [' + DspTitle + ']';
+    end;
+end;
+
+//! \83X\83\8c\83^\83C\8eæ\93¾
+function TGikoForm.GetThreadTitle(OrgTitle: String): String;
+var
+    Idx: Integer;
+    ResTitle: String;
+begin
+    if (GikoSys.Setting.ThreadTitleTrim = False) then begin
+        Result := OrgTitle;
+    end else begin
+        ResTitle := OrgTitle;
+        while (True) do begin
+            Idx := Pos('[\93]\8dÚ\8bÖ\8e~]', ResTitle);
+            if (Idx < 1) then
+                Break;
+            Delete(ResTitle, Idx, 10);
+        end;
+        while (True) do begin
+            Idx := Pos('&copy;2ch.net', ResTitle);
+            if (Idx < 1) then
+                Break;
+            Delete(ResTitle, Idx, 13);
+        end;
+        Result := Trim(ResTitle);
+    end;
+end;
+
 //! \83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\93Ç\82Ý\8d\9e\82Ý
 procedure TGikoForm.LoadPopupMenu();
 begin
index 5cbcdbe..d009d91 100644 (file)
@@ -1445,8 +1445,24 @@ var
        Chr : array [0..255]    of      char;
        S : string;
        i : integer;
+    Idx: Integer;
 begin
        s := Trim(LongName);
+    if (Setting.ThreadTitleTrim = True) then begin
+        while (True) do begin
+            Idx := Pos('[\93]\8dÚ\8bÖ\8e~]', s);
+            if (Idx < 1) then
+                Break;
+            Delete(s, Idx, 10);
+        end;
+        while (True) do begin
+            Idx := Pos('&copy;2ch.net', s);
+            if (Idx < 1) then
+                Break;
+            Delete(s, Idx, 13);
+        end;
+        s := Trim(s);
+    end;
        if (Length(s) <= ALength) then begin
                Result := s;
        end else begin
index 6175d6f..1aa9301 100644 (file)
@@ -553,6 +553,7 @@ var
        BoardCnt: Integer;
        RepStr: String;
        i: Integer;
+    Idx: Integer;
 begin
        //===== \83X\83\8c\83\8a\83X\83g =====
        if GikoSys.Setting.ListIconVisible then
@@ -596,8 +597,23 @@ begin
        RepStr := CustomStringReplace(RepStr, '&amp;', '&' );
        //RepStr := StringReplace(RepStr, '\81\97\81M', ',', [rfReplaceAll]);
 
-    if (ThreadNgList.IsNG(RepStr) = True) then
-        RepStr := '\81\83\82 \82Ú\81`\82ñ\81\84';
+    if (ThreadNgList.IsNG(RepStr) = True) then begin
+        RepStr := '\81\83\82 \82Ú\81`\82ñ\81\84'
+    end else if (GikoSys.Setting.ThreadTitleTrim = True) then begin
+        while (True) do begin
+            Idx := Pos('[\93]\8dÚ\8bÖ\8e~]', RepStr);
+            if (Idx < 1) then
+                Break;
+            Delete(RepStr, Idx, 10);
+        end;
+        while (True) do begin
+            Idx := Pos('&copy;2ch.net', RepStr);
+            if (Idx < 1) then
+                Break;
+            Delete(RepStr, Idx, 13);
+        end;
+        RepStr := Trim(RepStr);
+    end;
 
        if Item.SubItems.Count <> ListView.Columns.Count then begin
                Item.SubItems.Clear;
index 59e33be..0a6e4b0 100644 (file)
@@ -60,7 +60,7 @@ object OptionDialog: TOptionDialog
     Top = 4
     Width = 509
     Height = 389
-    ActivePage = ThreadSheet
+    ActivePage = TabSheet2
     MultiLine = True
     TabOrder = 3
     OnChange = OptionTabChange
@@ -251,7 +251,7 @@ object OptionDialog: TOptionDialog
           Top = 43
           Width = 417
           Height = 20
-          ItemHeight = 0
+          ItemHeight = 12
           TabOrder = 0
           Text = 'BoardURLComboBox'
         end
@@ -1141,12 +1141,12 @@ object OptionDialog: TOptionDialog
         Left = 12
         Top = 8
         Width = 477
-        Height = 121
+        Height = 105
         Caption = #12450#12489#12524#12473#12496#12540
         TabOrder = 0
         object Label3: TLabel
           Left = 12
-          Top = 96
+          Top = 82
           Width = 73
           Height = 12
           Caption = 'URL'#20445#23384#25968'(&S)'
@@ -1154,14 +1154,14 @@ object OptionDialog: TOptionDialog
         end
         object Label11: TLabel
           Left = 152
-          Top = 96
+          Top = 82
           Width = 12
           Height = 12
           Caption = #20491
         end
         object URLDisplayCheckBox: TCheckBox
           Left = 12
-          Top = 20
+          Top = 18
           Width = 389
           Height = 17
           Caption = #12473#12524#12483#12489#12434#38283#12356#12383#12392#12365#12395#12289#12450#12489#12524#12473#12496#12540#12395'URL'#12434#34920#31034#12377#12427'(&D)'
@@ -1169,7 +1169,7 @@ object OptionDialog: TOptionDialog
         end
         object AddressHistoryCountEdit: TEdit
           Left = 100
-          Top = 92
+          Top = 78
           Width = 45
           Height = 20
           TabOrder = 3
@@ -1177,7 +1177,7 @@ object OptionDialog: TOptionDialog
         end
         object TabStopAddressBarCheckBox: TCheckBox
           Left = 12
-          Top = 44
+          Top = 38
           Width = 389
           Height = 17
           Caption = #12479#12502#12461#12540#12391#12450#12489#12524#12473#12496#12540#12395#31227#21205#12391#12365#12427#12424#12358#12395#12377#12427'(&T)'
@@ -1185,7 +1185,7 @@ object OptionDialog: TOptionDialog
         end
         object LinkAddCheckBox: TCheckBox
           Left = 12
-          Top = 68
+          Top = 58
           Width = 413
           Height = 17
           Caption = #12502#12521#12454#12470#12398#12522#12531#12463#12434#12463#12522#12483#12463#12375#12383#12392#12365#12395' '#12450#12489#12524#12473#12496#12540#23653#27508#12395'URL'#12434#36861#21152#12377#12427'(&L)'
@@ -1194,14 +1194,14 @@ object OptionDialog: TOptionDialog
       end
       object GroupBox15: TGroupBox
         Left = 12
-        Top = 132
+        Top = 116
         Width = 478
-        Height = 79
+        Height = 64
         Caption = #30906#35469#12480#12452#12450#12525#12464
         TabOrder = 1
         object ShowDialogForEndCheckBox: TCheckBox
           Left = 12
-          Top = 21
+          Top = 18
           Width = 204
           Height = 17
           Caption = #32066#20102#26178#12395#30906#35469#12480#12452#12450#12525#12464#12434#34920#31034#12377#12427
@@ -1209,7 +1209,7 @@ object OptionDialog: TOptionDialog
         end
         object AllTabCloseCheckBox: TCheckBox
           Left = 12
-          Top = 48
+          Top = 38
           Width = 344
           Height = 17
           Caption = #20840#12390#12398#12479#12502#12434#38281#12376#12427#12392#12365#12395#30906#35469#12480#12452#12450#12525#12464#12434#34920#31034#12377#12427
@@ -1218,14 +1218,14 @@ object OptionDialog: TOptionDialog
       end
       object SambaGroupBox: TGroupBox
         Left = 12
-        Top = 216
+        Top = 184
         Width = 477
-        Height = 48
+        Height = 44
         Caption = 'Samba24'#23550#31574
         TabOrder = 2
         object UseSambaCheckBox: TCheckBox
           Left = 12
-          Top = 19
+          Top = 18
           Width = 153
           Height = 17
           Caption = 'Samba24'#23550#31574#27231#33021#12434#20351#12358
@@ -1234,13 +1234,13 @@ object OptionDialog: TOptionDialog
       end
       object TabAutoSaveLoad: TGroupBox
         Left = 11
-        Top = 271
+        Top = 236
         Width = 478
-        Height = 50
+        Height = 44
         Caption = 'Tab'#33258#21205#20445#23384#12539#24489#20803
         TabOrder = 3
         object TabLoadSave: TCheckBox
-          Left = 13
+          Left = 12
           Top = 18
           Width = 212
           Height = 17
@@ -1248,6 +1248,22 @@ object OptionDialog: TOptionDialog
           TabOrder = 0
         end
       end
+      object GroupBox27: TGroupBox
+        Left = 11
+        Top = 288
+        Width = 478
+        Height = 44
+        Caption = #12473#12524#12479#12452
+        TabOrder = 4
+        object ThreadTitleTrimCheckBox: TCheckBox
+          Left = 12
+          Top = 18
+          Width = 341
+          Height = 17
+          Caption = #12473#12524#12479#12452#12398'['#36578#36617#31105#27490']'#12392#12300'&&copy;2ch.net'#12301#12434#34920#31034#12375#12394#12356
+          TabOrder = 0
+        end
+      end
     end
     object TabSheet4: TTabSheet
       Caption = #12381#12398#20182#21205#20316#65298
@@ -1732,7 +1748,7 @@ object OptionDialog: TOptionDialog
           Top = 20
           Width = 140
           Height = 20
-          ItemHeight = 0
+          ItemHeight = 12
           TabOrder = 0
           Text = 'BoukenComboBox'
           OnChange = BoukenComboBoxChange
index da1777f..dd70f62 100644 (file)
@@ -229,6 +229,8 @@ type
     UseUnicodeCB: TCheckBox;
     Label27: TLabel;
     DispImageCheckBox: TCheckBox;
+    GroupBox27: TGroupBox;
+    ThreadTitleTrimCheckBox: TCheckBox;
                procedure FormCreate(Sender: TObject);
                procedure FormDestroy(Sender: TObject);
                procedure ApplyButtonClick(Sender: TObject);
@@ -903,6 +905,8 @@ begin
 
     // \83\8c\83X\83G\83f\83B\83^Unicode\93ü\97Í
     UseUnicodeCB.Checked := Gikosys.Setting.UseUnicode;
+    // \83X\83\8c\83^\83C\93Á\92è\95\8e\9a\97ñ\8f\9c\8b\8e
+    ThreadTitleTrimCheckBox.Checked := GikoSys.Setting.ThreadTitleTrim;
 
        //Be2ch\94F\8fØ
        BeUserIDEdit.Text := GikoSys.Setting.BeUserID;
@@ -1222,6 +1226,8 @@ begin
 
     // \83\8c\83X\83G\83f\83B\83^Unicode\93ü\97Í
     Gikosys.Setting.UseUnicode := UseUnicodeCB.Checked;
+    // \83X\83\8c\83^\83C\93Á\92è\95\8e\9a\97ñ\8f\9c\8b\8e
+    GikoSys.Setting.ThreadTitleTrim := ThreadTitleTrimCheckBox.Checked;
 
 end;
 
@@ -1300,6 +1306,9 @@ begin
                end;
                GikoForm.BrowserTab.OnChange(nil);
        end;
+
+    // \83^\83u\82Ì\83X\83\8c\83^\83C\8dX\90V
+    GikoForm.UpdateThreadTitle;
 end;
 
 procedure TOptionDialog.ReadProxyCheckClick(Sender: TObject);
index 7b9a6a4..6c549d5 100644 (file)
@@ -250,6 +250,8 @@ type
                FResPopupHeaderBold: Boolean;
         // BE\83A\83C\83R\83\93\81EEmoticon\89æ\91\9c\95\\8e¦
         FIconImageDisplay: Boolean;
+        // \83X\83\8c\83^\83C\93Á\92è\95\8e\9a\97ñ\8f\9c\8b\8e
+        FThreadTitleTrim: Boolean;
 
                //\83\8d\83O\83t\83H\83\8b\83_
                FLogFolder: string;
@@ -696,6 +698,7 @@ type
                property UnActivePopup: Boolean read FUnActivePopup write FUnActivePopup;
                property ResPopupHeaderBold: Boolean read FResPopupHeaderBold write FResPopupHeaderBold;
         property IconImageDisplay: Boolean read FIconImageDisplay write FIconImageDisplay;
+        property ThreadTitleTrim: Boolean read FThreadTitleTrim write FThreadTitleTrim;
 
                property LogFolder: string read FLogFolder write WriteLogFolder;
         property LogFolderP: string read FLogFolderP;
@@ -1199,6 +1202,8 @@ begin
                FResPopupHeaderBold := ini.ReadBool('Thread', 'ResPopupHeaderBold', True);
         // BE\83A\83C\83R\83\93\81EEmoticon\89æ\91\9c\95\\8e¦
         FIconImageDisplay := ini.ReadBool('Thread', 'IconImageDisplay', True);
+        // \83X\83\8c\83^\83C\93Á\92è\95\8e\9a\97ñ\8f\9c\8b\8e
+        FThreadTitleTrim := ini.ReadBool('Thread', 'ThreadTitleTrim', False);
                //\8dí\8f\9c\8am\94F
                FDeleteMsg := ini.ReadBool('Function', 'LogDeleteMessage', True);
                //\8fI\97¹\8am\94F
@@ -1647,6 +1652,8 @@ begin
                ini.WriteBool('Thread', 'ResPopupHeaderBold', FResPopupHeaderBold);
         // BE\83A\83C\83R\83\93\81EEmoticon\89æ\91\9c\95\\8e¦
         ini.WriteBool('Thread', 'IconImageDisplay', FIconImageDisplay);
+        // \83X\83\8c\83^\83C\93Á\92è\95\8e\9a\97ñ\8f\9c\8b\8e
+        ini.WriteBool('Thread', 'ThreadTitleTrim', FThreadTitleTrim);
                //ini.WriteString('BoardURL', '2ch', FBoardURL2ch);
 
                //\94F\8fØ\97p\83\86\81[\83UID\81E\83p\83X\83\8f\81[\83h