forked from JDimproved/JDim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bbslistviewbase.cpp
3214 lines (2485 loc) · 90.4 KB
/
bbslistviewbase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ライセンス: GPL2
//#define _DEBUG
//#define _DEBUG_XML
#include "jddebug.h"
#include "gtkmmversion.h"
#include "bbslistviewbase.h"
#include "bbslistadmin.h"
#include "selectdialog.h"
#include "editlistwin.h"
#include "addetcdialog.h"
#include "skeleton/msgdiag.h"
#include "jdlib/miscutil.h"
#include "jdlib/miscgtk.h"
#include "jdlib/jdregex.h"
#include "dbtree/interface.h"
#include "dbimg/imginterface.h"
#include "icons/iconmanager.h"
#include "xml/tools.h"
#include "config/globalconf.h"
#include "control/controlutil.h"
#include "control/controlid.h"
#include "cache.h"
#include "command.h"
#include "global.h"
#include "httpcode.h"
#include "sharedbuffer.h"
#include "viewfactory.h"
#include "prefdiagfactory.h"
#include "colorid.h"
#include "fontid.h"
#include "updatemanager.h"
#include "session.h"
#include "compmanager.h"
#include "dndmanager.h"
#include "sign.h"
enum
{
REPLACE_NEXT_NO = 0,
REPLACE_NEXT_YES,
REPLACE_NEXT_ADD
};
// row -> path
#define GET_PATH( row ) m_treestore->get_path( row )
// ポップアップメニュー表示
#define SHOW_POPUPMENU(slot) do{\
std::string url = path2url( m_path_selected ); \
if( ! m_path_selected.empty() && url.empty() ) url = "dummy_url"; \
show_popupmenu( url, slot ); \
}while(0)
#define POPUPMENU_BOARD1 \
"<menuitem action='OpenTab'/>" \
"<menuitem action='OpenBrowser'/>" \
"<separator/>" \
"<menuitem action='CopyURL'/>" \
"<menuitem action='CopyTitleURL'/>" \
"<separator/>" \
"<menuitem action='AppendFavorite'/>" \
"<separator/>"
#define POPUPMENU_BOARD2 \
"<menuitem action='SearchCacheBoard'/>" \
"<separator/>" \
"<menuitem action='ImportDat'/>" \
"<separator/>" \
"<menuitem action='PreferenceBoard'/>" \
"</popup>" \
#define POPUPMENU_ARRANGE_BASE \
"<menuitem action='Arrange_Type'/>" \
"<menuitem action='Arrange_Name'/>" \
"</menu>" \
"<separator/>"
#define POPUPMENU_ARRANGE \
"<menu action='Arrange_Menu'>" \
POPUPMENU_ARRANGE_BASE
#define POPUPMENU_ARRANGEDIR \
"<menu action='ArrangeDir_Menu'>" \
POPUPMENU_ARRANGE_BASE
#define POPUPMENU_DELETE \
"<menu action='Delete_Menu'>" \
"<menuitem action='Delete'/>" \
"</menu>"
#define POPUPMENU_SELECT \
"<menuitem action='CopyURL'/>" \
"<menuitem action='CopyTitleURL'/>" \
"<separator/>" \
"<menuitem action='Rename'/>" \
"<menuitem action='NewDir'/>" \
"<menuitem action='NewCom'/>" \
"<separator/>" \
POPUPMENU_ARRANGE \
"<separator/>" \
POPUPMENU_DELETE \
"<separator/>" \
"<menuitem action='SearchCacheBoard'/>" \
"<separator/>" \
"<menuitem action='ImportDat'/>" \
"<separator/>" \
"<menuitem action='PreferenceArticle'/>" \
"<menuitem action='PreferenceBoard'/>" \
"<menuitem action='PreferenceImage'/>"
using namespace BBSLIST;
BBSListViewBase::BBSListViewBase( const std::string& url,const std::string& arg1, const std::string& arg2 )
: SKELETON::View( url ),
m_treeview( url, DNDTARGET_FAVORITE, m_columns, true, CONFIG::get_fontname( FONT_BBS ), COLOR_CHAR_BBS, COLOR_BACK_BBS, COLOR_BACK_BBS_EVEN ),
m_ready_tree( false ),
m_clicked( false ),
m_jump_y( -1 ),
m_search_invert( false ),
m_open_only_onedir( false ),
m_cancel_expand( false ),
m_expanding( 0 ),
m_editlistwin( NULL ),
m_set_bookmark( false )
{
m_scrwin.add( m_treeview );
m_scrwin.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
pack_start( m_scrwin );
show_all_children();
m_treestore = Gtk::TreeStore::create( m_columns );
#if !GTKMM_CHECK_VERSION(2,7,0)
// gtkmm26以下にはunset_model()が無いのでここでset_model()しておく
// それ以上は m_treeview.xml2tree() でセットする
m_treeview.set_treestore( m_treestore );
#endif
// Gtk::TreeStoreでset_fixed_height_mode()を使うとexpandしたときに
// スクロールバーが誤動作するので使わないこと
/*
#if GTK_CHECK_VERSION(2,6,0)
// セルを固定の高さにする
// append_column する前に columnに対して set_sizing( Gtk::TREE_VIEW_COLUMN_FIXED ) すること
m_treeview.set_fixed_height_mode( true );
#ifdef _DEBUG
std::cout << "BBSListViewBase::BBSListViewBase : m_treeview.set_fixed_height_mode\n";
#endif
#endif
*/
// 共有UNDOバッファをセット
m_treeview.set_undo_buffer( BBSLIST::get_undo_buffer_favorite() );
// 列の登録
m_treeview.create_column( CONFIG::get_tree_ypad() );
m_treeview.set_column_for_height( 0 );
#if GTKMM_CHECK_VERSION(2,12,0)
// エクスパンダ表示とレベルインデント
m_treeview.set_show_expanders( CONFIG::get_tree_show_expanders() );
m_treeview.set_level_indentation( CONFIG::get_tree_level_indent() );
#endif
// treeviewのシグナルにコネクト
m_treeview.signal_row_expanded().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_row_exp ) );
m_treeview.signal_row_collapsed().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_row_col ) );
m_treeview.sig_button_press().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_button_press ) );
m_treeview.sig_button_release().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_button_release ) );
m_treeview.sig_motion_notify().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_motion_notify ) );
m_treeview.sig_key_press().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_key_press ) );
m_treeview.sig_key_release().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_key_release ) );
m_treeview.sig_scroll_event().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_scroll_event ) );
m_treeview.sig_dropped_from_other().connect( sigc::mem_fun(*this, &BBSListViewBase::slot_dropped_from_other ) );
///////////////////
// ポップアップメニューの設定
// アクショングループを作ってUIマネージャに登録
action_group() = Gtk::ActionGroup::create();
action_group()->add( Gtk::Action::create( "OpenTab", "タブで開く(_T)"), sigc::mem_fun( *this, &BBSListViewBase::slot_open_tab ) );
action_group()->add( Gtk::Action::create( "OpenBrowser", ITEM_NAME_OPEN_BROWSER "(_W)" ),
sigc::mem_fun( *this, &BBSListViewBase::slot_open_browser ) );
action_group()->add( Gtk::Action::create( "OpenCacheBrowser", ITEM_NAME_OPEN_CACHE_BROWSER "(_X)" ),
sigc::mem_fun( *this, &BBSListViewBase::slot_open_cache_browser ) );
action_group()->add( Gtk::Action::create( "AppendFavorite", "AppendFavorite"), sigc::mem_fun( *this, &BBSListViewBase::slot_append_favorite ) );
action_group()->add( Gtk::Action::create( "NewDir", "新規ディレクトリ(_N)"), sigc::mem_fun( *this, &BBSListViewBase::slot_newdir ) );
action_group()->add( Gtk::Action::create( "NewCom", "コメント挿入(_I)"), sigc::mem_fun( *this, &BBSListViewBase::slot_newcomment ) );
action_group()->add( Gtk::Action::create( "NewEtc", "外部板追加(_E)..."), sigc::mem_fun( *this, &BBSListViewBase::slot_newetcboard ) );
action_group()->add( Gtk::Action::create( "MoveEtc", "編集(_E)..."), sigc::mem_fun( *this, &BBSListViewBase::slot_moveetcboard ) );
action_group()->add( Gtk::Action::create( "Rename", "名前変更(_R)"), sigc::mem_fun( *this, &BBSListViewBase::slot_rename ) );
action_group()->add( Gtk::Action::create( "Delete_Menu", "Delete" ) );
action_group()->add( Gtk::Action::create( "Delete", "お気に入りから削除する(_D)"), sigc::mem_fun( *this, &BBSListViewBase::delete_view_impl ) );
action_group()->add( Gtk::Action::create( "Delete_etc", "外部板を削除する(_D)"), sigc::mem_fun( *this, &BBSListViewBase::delete_view_impl ) );
action_group()->add( Gtk::Action::create( "Delete_hist", "履歴から削除する(_D)"), sigc::mem_fun( *this, &BBSListViewBase::delete_view_impl ) );
action_group()->add( Gtk::Action::create( "OpenRows", "選択した行を開く(_O)"), sigc::mem_fun( *this, &BBSListViewBase::open_selected_rows ) );
action_group()->add( Gtk::Action::create( "CheckUpdateRows", "更新チェックのみ(_H)"), sigc::mem_fun( *this, &BBSListViewBase::slot_checkupdate_selected_rows ) );
action_group()->add( Gtk::Action::create( "CheckUpdateOpenRows", "更新された行をタブで開く(_E)"),
sigc::mem_fun( *this, &BBSListViewBase::slot_checkupdate_open_selected_rows ) );
action_group()->add( Gtk::Action::create( "CopyURL", ITEM_NAME_COPY_URL "(_U)"), sigc::mem_fun( *this, &BBSListViewBase::slot_copy_url ) );
action_group()->add( Gtk::Action::create( "CopyTitleURL", ITEM_NAME_COPY_TITLE_URL "(_L)" ),
sigc::mem_fun( *this, &BBSListViewBase::slot_copy_title_url ) );
action_group()->add( Gtk::Action::create( "SelectDir", "全て選択(_A)"), sigc::mem_fun( *this, &BBSListViewBase::slot_select_all_dir ) );
action_group()->add( Gtk::Action::create( "CheckUpdate_Menu", "更新チェック(_M)" ) );
action_group()->add( Gtk::Action::create( "CheckUpdateDir", "更新チェックのみ(_R)"), sigc::mem_fun( *this, &BBSListViewBase::slot_check_update_dir ) );
action_group()->add( Gtk::Action::create( "CheckUpdateOpenDir", "更新された行をタブで開く(_A)"),
sigc::mem_fun( *this, &BBSListViewBase::slot_check_update_open_dir ) );
action_group()->add( Gtk::Action::create( "CancelCheckUpdate", "キャンセル(_C)" ),
sigc::mem_fun( *this, &BBSListViewBase::stop ) );
action_group()->add( Gtk::Action::create( "Arrange_Menu", "並び替え(_G)" ) );
action_group()->add( Gtk::Action::create( "ArrangeDir_Menu", "ディレクトリ内の並び替え(_G)" ) );
action_group()->add( Gtk::Action::create( "Arrange_Type", "種類順(_T)"),
sigc::bind< int >( sigc::mem_fun( *this, &BBSListViewBase::slot_sort ), SKELETON::SORT_BY_TYPE ) );
action_group()->add( Gtk::Action::create( "Arrange_Name", "名前順(_N)"),
sigc::bind< int >( sigc::mem_fun( *this, &BBSListViewBase::slot_sort ), SKELETON::SORT_BY_NAME ) );
action_group()->add( Gtk::Action::create( "OpenAsBoard", "ディレクトリをスレ一覧に表示(_B)"), sigc::mem_fun( *this, &BBSListViewBase::slot_opendir_as_board ) );
action_group()->add( Gtk::Action::create( "CreateVBoard", "仮想板作成(_V)"), sigc::mem_fun( *this, &BBSListViewBase::slot_create_vboard ) );
action_group()->add( Gtk::Action::create( "SearchCacheBoard", "キャッシュ内ログ検索(_S)"), sigc::mem_fun( *this, &BBSListViewBase::slot_search_cache_board ) );
action_group()->add( Gtk::Action::create( "ImportDat", "datのインポート(_I)"), sigc::mem_fun( *this, &BBSListViewBase::slot_import_dat ) );
action_group()->add( Gtk::Action::create( "PreferenceArticle", ITEM_NAME_PREF_THREAD "(_P)..." ), sigc::mem_fun( *this, &BBSListViewBase::slot_preferences_article ) );
action_group()->add( Gtk::Action::create( "PreferenceBoard", ITEM_NAME_PREF_BOARD "(_O)..." ), sigc::mem_fun( *this, &BBSListViewBase::slot_preferences_board ) );
action_group()->add( Gtk::Action::create( "PreferenceImage", ITEM_NAME_PREF_IMAGE "(_M)..." ), sigc::mem_fun( *this, &BBSListViewBase::slot_preferences_image ) );
ui_manager() = Gtk::UIManager::create();
ui_manager()->insert_action_group( action_group() );
// ポップアップメニューのレイアウト
Glib::ustring str_ui =
"<ui>"
// 板一覧 + 板
"<popup name='popup_menu'>"
POPUPMENU_BOARD1
POPUPMENU_BOARD2
// 板一覧 + 外部板
"<popup name='popup_menu_etc'>"
POPUPMENU_BOARD1
"<menuitem action='MoveEtc'/>"
"<separator/>"
"<menu action='Delete_Menu'>"
"<menuitem action='Delete_etc'/>"
"</menu>"
"<separator/>"
POPUPMENU_BOARD2
// 板一覧 + 複数選択
"<popup name='popup_menu_mul'>"
"<menuitem action='OpenRows'/>"
"<separator/>"
"<menuitem action='AppendFavorite'/>"
"</popup>"
// 板一覧 + 複数選択 + 外部板含む
"<popup name='popup_menu_mul_etc'>"
"<menuitem action='OpenRows'/>"
"<separator/>"
"<menuitem action='AppendFavorite'/>"
"<separator/>"
"<menu action='Delete_Menu'>"
"<menuitem action='Delete_etc'/>"
"</menu>"
"</popup>"
// 板一覧 + ディレクトリ
"<popup name='popup_menu_dir'>"
"<menuitem action='SelectDir'/>"
"</popup>"
// 板一覧 + 外部板ディレクトリ
"<popup name='popup_menu_etcdir'>"
"<menuitem action='SelectDir'/>"
"<separator/>"
"<menuitem action='NewEtc'/>"
"</popup>"
/////////////////////////////////////////
// お気に入り
"<popup name='popup_menu_favorite'>"
"<menuitem action='OpenTab'/>"
"<menuitem action='OpenBrowser'/>"
"<menuitem action='OpenCacheBrowser'/>"
"<separator/>"
POPUPMENU_SELECT
"</popup>"
// お気に入り + 複数選択
"<popup name='popup_menu_favorite_mul'>"
"<menuitem action='OpenRows'/>"
"<separator/>"
"<menu action='CheckUpdate_Menu'>"
"<menuitem action='CheckUpdateRows'/>"
"<menuitem action='CheckUpdateOpenRows'/>"
"<separator/>"
"<menuitem action='CancelCheckUpdate'/>"
"</menu>"
"<separator/>"
POPUPMENU_DELETE
"</popup>"
// お気に入り + 何もないところをクリック
"<popup name='popup_menu_favorite_space'>"
"<menuitem action='NewDir'/>"
"<menuitem action='NewCom'/>"
"</popup>"
// お気に入り + ディレクトリ
"<popup name='popup_menu_favorite_dir'>"
"<menu action='CheckUpdate_Menu'>"
"<menuitem action='CheckUpdateDir'/>"
"<menuitem action='CheckUpdateOpenDir'/>"
"<separator/>"
"<menuitem action='CancelCheckUpdate'/>"
"</menu>"
"<separator/>"
"<menuitem action='SelectDir'/>"
"<separator/>"
"<menuitem action='Rename'/>"
"<menuitem action='NewDir'/>"
"<menuitem action='NewCom'/>"
"<separator/>"
"<menuitem action='OpenAsBoard'/>"
"<menuitem action='CreateVBoard'/>"
"<separator/>"
POPUPMENU_ARRANGEDIR
"<separator/>"
POPUPMENU_DELETE
"</popup>"
// お気に入り + コメント
"<popup name='popup_menu_favorite_com'>"
"<menuitem action='Rename'/>"
"<menuitem action='NewDir'/>"
"<menuitem action='NewCom'/>"
"<separator/>"
POPUPMENU_ARRANGE
"<separator/>"
POPUPMENU_DELETE
"</popup>"
// お気に入り + 仮想板
"<popup name='popup_menu_favorite_vboard'>"
"<menuitem action='OpenTab'/>"
"<separator/>"
"<menuitem action='Rename'/>"
"<menuitem action='NewDir'/>"
"<menuitem action='NewCom'/>"
"<separator/>"
POPUPMENU_ARRANGE
"<separator/>"
POPUPMENU_DELETE
"</popup>"
//////////////////////////////////////
// 選択(selectlistview)
"<popup name='popup_menu_select'>"
POPUPMENU_SELECT
"</popup>"
/////////////////////////////////////////
// 履歴
"<popup name='popup_menu_history'>"
"<menuitem action='OpenTab'/>"
"<menuitem action='OpenBrowser'/>"
"<separator/>"
"<menuitem action='CopyURL'/>" \
"<menuitem action='CopyTitleURL'/>" \
"<separator/>"
"<menuitem action='AppendFavorite'/>"
"<separator/>" \
"<menu action='Delete_Menu'>" \
"<menuitem action='Delete_hist'/>" \
"</menu>" \
"<separator/>" \
"<menuitem action='SearchCacheBoard'/>" \
"<separator/>" \
"<menuitem action='ImportDat'/>" \
"<separator/>" \
"<menuitem action='PreferenceArticle'/>" \
"<menuitem action='PreferenceBoard'/>" \
"<menuitem action='PreferenceImage'/>" \
"</popup>"
// 履歴 + 複数選択
"<popup name='popup_menu_history_mul'>"
"<menuitem action='OpenRows'/>"
"<separator/>"
"<menuitem action='AppendFavorite'/>"
"<separator/>"
"<menu action='CheckUpdate_Menu'>"
"<menuitem action='CheckUpdateRows'/>"
"<menuitem action='CheckUpdateOpenRows'/>"
"<separator/>"
"<menuitem action='CancelCheckUpdate'/>"
"</menu>"
"<separator/>"
"<menu action='Delete_Menu'>"
"<menuitem action='Delete_hist'/>"
"</menu>"
"</popup>"
// 履歴 + 仮想板
"<popup name='popup_menu_history_vboard'>"
"<menuitem action='OpenTab'/>"
"<separator/>"
"<menu action='Delete_Menu'>"
"<menuitem action='Delete_hist'/>"
"</menu>"
"</popup>"
"</ui>";
ui_manager()->add_ui_from_string( str_ui );
// ポップアップメニューにキーアクセレータを表示
Gtk::Menu* popupmenu = id2popupmenu( "/popup_menu" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_etc" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_mul" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_mul_etc" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_dir" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_favorite" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_favorite_mul" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_favorite_space" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_favorite_dir" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_favorite_com" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_favorite_vboard" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_history" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_history_mul" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_history_vboard" );
CONTROL::set_menu_motion( popupmenu );
popupmenu = id2popupmenu( "/popup_menu_select" );
CONTROL::set_menu_motion( popupmenu );
// マウスジェスチャ可
set_enable_mg( true );
// コントロールモード設定
get_control().add_mode( CONTROL::MODE_BBSLIST );
}
BBSListViewBase::~BBSListViewBase()
{
#ifdef _DEBUG
std::cout << "BBSListViewBase::~BBSListViewBase : " << get_url() << std::endl;
#endif
if( m_editlistwin ) delete m_editlistwin;
m_editlistwin = NULL;
}
void BBSListViewBase::save_session()
{
save_xml();
}
SKELETON::Admin* BBSListViewBase::get_admin()
{
return BBSLIST::get_admin();
}
//
// treeviewのD&Dによる編集を可能にする
//
void BBSListViewBase::set_editable( const bool editable )
{
get_treeview().set_editable_view( editable );
}
//
// 親ウィンドウをセット
//
void BBSListViewBase::set_parent_win( Gtk::Window* parent_win )
{
SKELETON::View::set_parent_win( parent_win );
get_treeview().set_parent_win( parent_win );
}
//
// コマンド
//
bool BBSListViewBase::set_command( const std::string& command, const std::string& arg1, const std::string& arg2 )
{
if( command == "append_item" ) append_item();
else if( command == "append_history" ) append_history();
else if( command == "remove_item" ) remove_item( arg1 );
else if( command == "remove_headitem" ) remove_headitem();
else if( command == "remove_allitems" ) remove_allitems();
else if( command == "edit_tree" ) edit_tree();
else if( command == "save_xml" ) save_xml();
else if( command == "toggle_articleicon" ) toggle_articleicon( arg1 );
else if( command == "toggle_boardicon" ) toggle_boardicon( arg1 );
else if( command == "replace_thread" ) replace_thread( arg1, arg2 );
else if( command == "hide_popup" ) m_treeview.hide_popup();
else if( command == "check_update_root" ) check_update_dir( true, false );
else if( command == "check_update_open_root" ) check_update_dir( true, true );
else if( command == "cancel_check_update" ) stop();
else if( command == "select_item" ) select_item( arg1 );
return true;
}
//
// クロック入力
//
void BBSListViewBase::clock_in()
{
View::clock_in();
m_treeview.clock_in();
if( m_editlistwin ) m_editlistwin->clock_in();
// スクロールバー移動
// 初期化直後など、まだスクロールバーが表示されてない時があるので表示されるまでジャンプしない
if( m_jump_y != -1 ){
auto adjust = m_treeview.get_vadjustment();
if( adjust && adjust->get_upper() > m_jump_y ){
#ifdef _DEBUG
std::cout << "BBSListViewBase::clock_in jump to = " << m_jump_y << " upper = " << (int)adjust->get_upper() << std::endl;
#endif
// 何故か先頭にジャンプ出来ないので 1 にジャンプする
if( m_jump_y == 0 ) m_jump_y = 1;
adjust->set_value( m_jump_y );
m_jump_y = -1;
}
}
}
//
// コメント色変更( 再帰用 )
//
void BBSListViewBase::set_fgcolor_of_comment( const Gtk::TreeModel::Children& children )
{
Gtk::TreeModel::iterator it = children.begin();
for( ; it != children.end(); ++it ){
Gtk::TreeModel::Row row = *it;
const int type = row2type( row );
if( type == TYPE_COMMENT ) row[ m_columns.m_fgcolor ] = Gdk::Color( CONFIG::get_color( COLOR_CHAR_BBS_COMMENT ) );
else if( type == TYPE_DIR ) set_fgcolor_of_comment( row.children() );
}
}
//
// 再描画
//
void BBSListViewBase::redraw_view()
{
// 起動中とシャットダウン中は処理しない
if( SESSION::is_booting() ) return;
if( SESSION::is_quitting() ) return;
#ifdef _DEBUG
std::cout << "BBSListViewBase::ViewBase::redraw_view " << get_url() << std::endl;
#endif
m_treeview.redraw_view();
}
//
// 色やフォントなどの変更
//
void BBSListViewBase::relayout()
{
m_treeview.init_color( COLOR_CHAR_BBS, COLOR_BACK_BBS, COLOR_BACK_BBS_EVEN );
m_treeview.init_font( CONFIG::get_fontname( FONT_BBS ) );
set_fgcolor_of_comment( m_treestore->children() );
}
//
// フォーカス
//
void BBSListViewBase::focus_view()
{
// 行の名前を編集中なら何もしない
if( m_treeview.is_renaming_row() ) return;
#ifdef _DEBUG
std::cout << "BBSListViewBase::focus_view url = " << get_url() << std::endl;
#endif
m_treeview.grab_focus();
}
//
// フォーカスアウト
//
void BBSListViewBase::focus_out()
{
SKELETON::View::focus_out();
m_treeview.hide_tooltip();
m_treeview.hide_popup();
}
//
// 閉じる
//
void BBSListViewBase::close_view()
{
#ifdef _DEBUG
std::cout << "BBSListViewBase::close_view\n";
#endif
CORE::core_set_command( "toggle_sidebar" );
}
//
// 削除
//
// BBSListViewBaseの場合は選択行の削除
//
void BBSListViewBase::delete_view()
{
SKELETON::MsgDiag mdiag( get_parent_win(), "削除しますか?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO );
if( mdiag.run() != Gtk::RESPONSE_YES ) return;
delete_view_impl();
}
// BBSListViewBaseの場合は選択行の削除
void BBSListViewBase::delete_view_impl()
{
const bool force = true;
m_treeview.delete_selected_rows( force );
}
//
// ツリー内の全ての項目をURLを新しいアドレスに変更 ( id は未使用 )
//
void BBSListViewBase::update_item( const std::string& url, const std::string& id )
{
#ifdef _DEBUG
std::cout << "BBSListViewBase::update_item " << url << " / " << get_url() << std::endl;
#endif
if( url == get_url() ) update_urls();
}
//
// viewの操作
//
bool BBSListViewBase::operate_view( const int control )
{
if( CONTROL::operate_common( control, get_url(), BBSLIST::get_admin() ) ) return true;
Gtk::TreePath path = m_treeview.get_current_path();
bool open_tab = false;
#ifdef _DEBUG
std::cout << "BBSListViewBase::operate_view = " << control << std::endl;
#endif
switch( control ){
case CONTROL::Down:
row_down();
break;
case CONTROL::Up:
row_up();
break;
case CONTROL::PageUp:
page_up();
break;
case CONTROL::PageDown:
page_down();
break;
case CONTROL::PrevDir:
prev_dir();
break;
case CONTROL::NextDir:
next_dir();
break;
case CONTROL::Home:
goto_top();
break;
case CONTROL::End:
goto_bottom();
break;
// 全て選択
case CONTROL::SelectAll:
slot_select_all();
break;
// 開く
case CONTROL::OpenBoardTabButton:
if( ! m_path_selected.empty() ){
open_tab = true;
// pathがディレクトリでタブで開くボタンを入れ替えている時はディレクトリ開閉にする
if( path2type( path ) == TYPE_DIR && CONTROL::is_toggled_tab_button() ) open_tab = false;
open_row( path, open_tab );
}
break;
case CONTROL::OpenBoardButton:
if( ! m_path_selected.empty() ){
open_tab = false;
// pathがディレクトリでタブで開くボタンを入れ替えている時は更新チェックにする
if( path2type( path ) == TYPE_DIR && CONTROL::is_toggled_tab_button() ) open_tab = true;
open_row( path, open_tab );
}
break;
case CONTROL::OpenBoardTab:
open_tab = true;
// pathがディレクトリでタブで開くキーを入れ替えている時はディレクトリ開閉にする
if( path2type( path ) == TYPE_DIR && CONTROL::is_toggled_tab_key() ) open_tab = false;
open_row( path, open_tab );
break;
case CONTROL::OpenBoard:
open_tab = false;
// pathがディレクトリでタブで開くキーを入れ替えている時は更新チェックにする
if( path2type( path ) == TYPE_DIR && CONTROL::is_toggled_tab_key() ) open_tab = true;
open_row( path, open_tab );
break;
case CONTROL::Right:
if( m_treeview.get_row( path ) ){
if( ! m_treeview.expand_row( path, false ) ) switch_rightview();
}
break;
case CONTROL::Left:
if( const Gtk::TreeModel::Row row = m_treeview.get_row( path ) ) {
if( ( path2type( path ) != TYPE_DIR || ! m_treeview.row_expanded( path ) ) && row.parent() ){
path = GET_PATH( row.parent() );
m_treeview.set_cursor( path );
}
m_treeview.collapse_row( path );
}
break;
case CONTROL::ToggleArticle:
CORE::core_set_command( "toggle_article" );
break;
// 終了
case CONTROL::Quit:
close_view();
break;
case CONTROL::Reload:
reload();
break;
case CONTROL::Delete:
delete_view();
break;
// ポップアップメニュー表示
case CONTROL::ShowPopupMenu:
{
if( m_treeview.get_selection()->get_selected_rows().size() >= 1 ){
m_path_selected = * (m_treeview.get_selection()->get_selected_rows().begin() );
}
SHOW_POPUPMENU(true);
break;
}
// 検索
case CONTROL::Search:
set_search_invert( false );
BBSLIST::get_admin()->set_command( "focus_toolbar_search" );
break;
case CONTROL::SearchInvert:
set_search_invert( true );
BBSLIST::get_admin()->set_command( "focus_toolbar_search" );
break;
case CONTROL::SearchNext:
down_search();
break;
case CONTROL::SearchPrev:
up_search();
break;
case CONTROL::StopLoading:
CORE::core_set_command( "cancel_check_update" );
break;
case CONTROL::Undo:
undo();
break;
case CONTROL::Redo:
redo();
break;
default:
return false;
}
return true;
}
//
// ポップアップメニューを表示する前にメニューのアクティブ状態を切り替える
//
// SKELETON::View::show_popupmenu() を参照すること
//
void BBSListViewBase::activate_act_before_popupmenu( const std::string& url )
{
Glib::RefPtr< Gtk::Action > act_search, act_import, act_board, act_article, act_image, act_opencache, act_opentab;
act_search = action_group()->get_action( "SearchCacheBoard" );
act_import = action_group()->get_action( "ImportDat" );
act_board = action_group()->get_action( "PreferenceBoard" );
act_article = action_group()->get_action( "PreferenceArticle" );
act_image = action_group()->get_action( "PreferenceImage" );
act_opencache = action_group()->get_action( "OpenCacheBrowser" );
act_opentab = action_group()->get_action( "OpenTab" );
if( act_search ) act_search->set_sensitive( false );
if( act_import ) act_import->set_sensitive( false );
if( act_board ) act_board->set_sensitive( false );
if( act_article ) act_article->set_sensitive( false );
if( act_image ) act_image->set_sensitive( false );
if( act_opencache ) act_opencache->set_sensitive( false );
if( act_opentab ) act_opentab->set_sensitive( true );
int type = path2type( m_path_selected );
switch( type ){
case TYPE_BOARD:
case TYPE_BOARD_UPDATE:
if( act_search ) act_search->set_sensitive( true );
if( act_import ) act_import->set_sensitive( true );
if( act_board ) act_board->set_sensitive( true );
break;
case TYPE_THREAD:
case TYPE_THREAD_UPDATE:
case TYPE_THREAD_OLD:
if( act_article ) act_article->set_sensitive( true );
break;
case TYPE_IMAGE:
if( act_image && ! DBIMG::get_abone( url ) ) act_image->set_sensitive( true );
if( act_opencache && DBIMG::is_cached( url ) ) act_opencache->set_sensitive( true );
break;
case TYPE_DIR:
break;
case TYPE_LINK:
if( act_opentab ) act_opentab->set_sensitive( false );
break;
}
}
// idからポップアップメニュー取得
Gtk::Menu* BBSListViewBase::id2popupmenu( const std::string& id )
{
return dynamic_cast< Gtk::Menu* >( ui_manager()->get_widget( id ) );
}
//
// 先頭に戻る
//
void BBSListViewBase::goto_top()
{
m_treeview.goto_top();
show_status();
}
//
// 一番最後へ
//
void BBSListViewBase::goto_bottom()
{
m_treeview.goto_bottom();
show_status();
}
//
// 上へ移動
//
void BBSListViewBase::row_up()
{
m_treeview.row_up();
show_status();
}
//
// 下へ移動
//
void BBSListViewBase::row_down()