-
Notifications
You must be signed in to change notification settings - Fork 5
/
LogList.cpp
1018 lines (981 loc) · 28.9 KB
/
LogList.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
//Copyright+LGPL
//-----------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2000-2013 Makoto Mori, Nobuyuki Oba
//-----------------------------------------------------------------------------------------------------------------------------------------------
// This file is part of MMVARI.
// MMVARI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// MMVARI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License along with MMTTY. If not, see
// <http://www.gnu.org/licenses/>.
//-----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "LogList.h"
#include "QsoDlg.h"
#include "LogConv.h"
#include "LogSet.h"
#include "country.h"
#include "Main.h"
#include "InputWin.h"
#include "Hamlog5.h"
#include "TH5Len.h"
//---------------------------------------------------------------------
#pragma resource "*.dfm"
//TLogListDlg *LogListDlg;
//---------------------------------------------------------------------
__fastcall TLogListDlg::TLogListDlg(TComponent* AOwner)
: TForm(AOwner)
{
FormStyle = ((TForm *)AOwner)->FormStyle;
Font->Name = ((TForm *)AOwner)->Font->Name;
Font->Charset = ((TForm *)AOwner)->Font->Charset;
if( sys.m_MsgEng ){
Grid->Font->Name = ((TForm *)AOwner)->Font->Name;
Grid->Font->Charset = ((TForm *)AOwner)->Font->Charset;
KFile->Caption = "File(&F)";
KEdit->Caption = "Edit(&E)";
KFind->Caption = "Find(&S)";
KOpt->Caption = "Option(&O)";
KOpen->Caption = "Open LogData File(&O)...";
KFlush->Caption = "Save data now(&M)";
KReIndex->Caption = "Make Index";
KMTextRead->Caption = "Load MMLOG TextFile(&R)...";
KMTextWrite->Caption = "Save selected range to MMLOG TextFile(&W)...";
KImport->Caption = "Import";
KImportLog200->Caption = "Log200 File...";
KImportHamlog->Caption = "Hamlog File...";
KImportADIF->Caption = "ADIF File...";
KExport->Caption = "Export selected range";
KExportADIF->Caption = "ADIF File...";
KExportLog200->Caption = "Log200 File...";
KExportHamlog->Caption = "Hamlog File...";
KExportCabrillo->Caption = "Cabrillo file...";
KExit->Caption = "Return to MMVARI(&X)";
KDelCur->Caption = "Cut";
KInsCur->Caption = "Insert";
KSelAll->Caption = "Select All";
KDelSel->Caption = "Delete selected range";
KSortDate->Caption = "Sort(Date/Time)";
KTop->Caption = "Move Top";
KBottom->Caption = "Move Last";
KFindTop->Caption = "Search forward...";
KFindBottom->Caption = "Search backward...";
KFindConT->Caption = "Search forward again";
KFindConB->Caption = "Search backward again";
KLogOpt->Caption = "Setup Logging...";
}
int CX = ::GetSystemMetrics(SM_CXFULLSCREEN);
int CY = ::GetSystemMetrics(SM_CYFULLSCREEN);
if( (CX < Width)||(CY < Height) ){
Top = 0;
Left = 0;
Width = CX;
Height = CY;
}
m_DateWidth = Grid->ColWidths[0];
FormCenter(this, CX, CY);
if( Owner != NULL ){
WindowState = ((TForm *)Owner)->WindowState;
}
SetTimeZone();
KExportCabrillo->Visible = FALSE; // Delete this function by JE3HHT on Sep.2010
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::SetTimeZone(void)
{
switch(Log.m_LogSet.m_TimeZone){
case 'I':
if( sys.m_LCID == 0x0412 ){
m_TimeZone = "KST";
}
else {
m_TimeZone = "JST";
}
break;
default:
m_TimeZone = "UTC";
break;
}
if(Log.m_LogSet.m_DateType & 1){
Grid->ColWidths[0] = (m_DateWidth * 10) / 8;
}
else {
Grid->ColWidths[0] = m_DateWidth;
}
}
//---------------------------------------------------------------------------
// アイドル処理
void __fastcall TLogListDlg::OnIdle(TObject *Sender, bool &Done)
{
UpdateMenu();
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::UpdateLogCount(int sw)
{
Grid->RowCount = Log.GetCount() + 2;
if( sw ){
Grid->Row = Log.GetCount() + 1;
AdjustTopRow();
char bf[256];
if( Log.IsOpen() ){
sprintf(bf, sys.m_MsgEng ? "%s - [%u QSO data(s)]" : "%s - [%u件のデータがあります]", Log.m_FileName.c_str(), Log.GetCount());
}
else {
sprintf(bf, "%s is not opened.", Log.m_FileName.c_str());
}
Caption = bf;
}
Grid->Col = 0;
Grid->Invalidate();
}
void __fastcall TLogListDlg::AdjustTopRow(void)
{
int GridLine = Grid->GridHeight/Grid->RowHeights[1] - 1;
int Top = Grid->Row - GridLine + 1;
if( Top < 1 ) Top = 1;
Grid->TopRow = Top;
Grid->Invalidate();
}
void __fastcall TLogListDlg::Execute(void)
{
if( !Log.IsOpen() ){
Log.Open(NULL, TRUE);
}
Application->OnIdle = OnIdle;
UpdateLogCount(1);
ShowModal();
Application->OnIdle = NULL;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::GridDrawCell(TObject *Sender, int Col,
int Row, TRect &Rect, TGridDrawState State)
{
char bf[256];
SDMMLOG sd;
Grid->Canvas->FillRect(Rect);
int X = Rect.Left + 4;
int Y = Rect.Top + 2;
if( Row ){
Row--;
bf[0] = 0;
if( Row < Log.GetCount() ){
Log.GetData(&sd, Row);
}
else {
memset(&sd, 0, sizeof(SDMMLOG));
}
if( Log.m_LogSet.m_TimeZone != 'I' ){
JSTtoUTC(&sd);
}
switch(Col){
case 0: // Date
OnWave();
strcpy(bf, Log.GetDateString(&sd));
break;
case 1: // Time
strcpy(bf, Log.GetTimeString(sd.btime));
break;
case 2: // Call
strcpy(bf, sd.call);
break;
case 3: // M
bf[0] = sd.cq;
bf[1] = 0;
break;
case 4: // HisRST
strcpy(bf, sd.ur);
break;
case 5: // MyRST
strcpy(bf, sd.my);
break;
case 6: // Band
strcpy(bf, Log.GetFreqString(sd.band, sd.fq));
break;
case 7: // Mode
strcpy(bf, Log.GetModeString(sd.mode));
break;
case 8: // Pow
strcpy(bf, sd.pow);
break;
case 9: // Name
strcpy(bf, sd.name);
break;
case 10: // QTH
strcpy(bf, sd.qth);
break;
case 11: // S
bf[0] = sd.send;
bf[1] = 0;
break;
case 12: // R
bf[0] = sd.recv;
bf[1] = 0;
break;
case 13: // REM
strcpy(bf, sd.rem);
break;
case 14: // QSL
strcpy(bf, sd.qsl);
break;
case 15: // etime;
strcpy(bf, Log.GetTimeString(sd.etime));
break;
case 16: // Env
if( sd.env ) sprintf(bf, "%u", sd.env);
break;
case 17: // Opt1
strcpy(bf, sd.opt1);
break;
case 18: // Opt2
strcpy(bf, sd.opt2);
break;
case 19: // Usr1
strcpy(bf, Log.GetOptStr(2, &sd));
break;
case 20: // Usr2
strcpy(bf, Log.GetOptStr(3, &sd));
break;
}
Grid->Canvas->TextRect(Rect, X, Y, bf);
}
else { // タイトル
LPCSTR _tt[]={
"Date","JST","Call","M", "His","My","Band","Mode","Pow","Name","QTH","S","R",
"Note","QSL", "End", "Env", "Opt1", "Opt2", "Usr1", "Usr2",
};
if( Col == 1 ){
Grid->Canvas->TextRect(Rect, X, Y, m_TimeZone.c_str());
}
else {
Grid->Canvas->TextRect(Rect, X, Y, _tt[Col]);
}
}
}
//---------------------------------------------------------------------------
// リターンキーの処理
void __fastcall TLogListDlg::GridKeyPress(TObject *Sender, char &Key)
{
if( Key == 0x0d ){
GridDblClick(NULL);
Key = 0;
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::UpdateMenu(void)
{
int f = Log.IsOpen();
KFlush->Enabled = f && Log.IsEdit();
KDelCur->Enabled = f && (Grid->Row <= Log.GetCount()) && (Grid->Row >= 1);
KInsCur->Enabled = f && (Grid->Row <= Log.GetCount()) && (Grid->Row >= 1);
KDelSel->Enabled = f && (Grid->Selection.Top < Grid->Selection.Bottom);
KTop->Enabled = f && Log.GetCount();
KBottom->Enabled = f && Log.GetCount();
KFindTop->Enabled = f && Log.GetCount();
KFindBottom->Enabled = f && Log.GetCount();
KFindConT->Enabled = f && Log.GetCount();
KFindConB->Enabled = f && Log.GetCount();
KSortDate->Enabled = f && Log.GetCount() && (Grid->Selection.Top < Grid->Selection.Bottom);
KSelAll->Enabled = f && Log.GetCount();
KMTextRead->Enabled = f;
KMTextWrite->Enabled = f && Log.GetCount() && (Grid->Selection.Top <= Log.GetCount());
KExport->Enabled = f && Log.GetCount() && (Grid->Selection.Top <= Log.GetCount());
KReIndex->Enabled = f;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KOpenClick(TObject *Sender)
{
#if 1
MainVARI->KFLOClick(NULL);
UpdateLogCount(1);
#else
OpenDialog->Options >> ofCreatePrompt;
OpenDialog->Options >> ofFileMustExist;
if(MsgEng){
OpenDialog->Title = "Open LogData File";
OpenDialog->Filter = "MMLOG Data File(*.mdt)|*.mdt|";
}
else {
OpenDialog->Title = "ログファイルのオープン";
OpenDialog->Filter = "MMLOG Data File(*.mdt)|*.mdt|";
}
OpenDialog->FileName = "";
OpenDialog->DefaultExt = "mdt";
OpenDialog->InitialDir = MMLogDir;
NormalWindow(this);
if( OpenDialog->Execute() == TRUE ){
Log.Close();
Log.MakeName(OpenDialog->FileName.c_str());
Log.Open(NULL, TRUE);
UpdateLogCount(1);
}
TopWindow(this);
#endif
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KFlushClick(TObject *Sender)
{
Log.Close();
Log.Open(NULL, TRUE);
UpdateLogCount(0);
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KDelCurClick(TObject *Sender)
{
int n = Grid->Row - 1;
SDMMLOG sd;
Log.GetData(&sd, n);
memcpy(&Log.m_bak, &sd, sizeof(SDMMLOG));
Log.Delete(n, n);
UpdateLogCount(0);
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KInsCurClick(TObject *Sender)
{
int n = Grid->Row - 1;
Log.Insert(n, &Log.m_bak);
UpdateLogCount(0);
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KDelSelClick(TObject *Sender)
{
if( YesNoMB( sys.m_MsgEng ? "Delete Selection.(will not be able to restore) Are you sure?":"現在選択されている範囲を削除します.削除した内容は復元できません\r\n\r\nよろしおまっか?") == IDYES ){
int top = Grid->Selection.Top - 1;
int end = Grid->Selection.Bottom - 1;
Log.Delete(top, end);
UpdateLogCount(0);
Grid->Row = top + 1;
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KExitClick(TObject *Sender)
{
ModalResult = mrOk;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KFindTopClick(TObject *Sender)
{
if( m_FindCall.IsEmpty() || (Sender == KFindTop) ){
AnsiString as = m_FindCall;
if( InputMB(NULL, sys.m_MsgEng ? "Callsign":"検索するコールサイン", as) == FALSE ) return;
jstrupr(as.c_str());
m_FindCall = as;
}
int n = Log.Find(m_FindCall.c_str(), Grid->Row, 0);
if( n >= 0 ){
Grid->Row = n + 1;
}
else {
WarningMB(sys.m_MsgEng ? "'%s' was not found" : "'%s'は見つかりませんでした.", m_FindCall.c_str());
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KFindBottomClick(TObject *Sender)
{
if( m_FindCall.IsEmpty() || (Sender == KFindBottom) ){
AnsiString as = m_FindCall;
if( InputMB(NULL, sys.m_MsgEng ? "Callsign":"検索するコールサイン", as) == FALSE ) return;
jstrupr(as.c_str());
m_FindCall = as;
}
int n = Log.Find(m_FindCall.c_str(), Grid->Row - 2, 1);
if( n >= 0 ){
Grid->Row = n + 1;
}
else {
WarningMB(sys.m_MsgEng ? "'%s' was not found" : "'%s'は見つかりませんでした.", m_FindCall.c_str());
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KTopClick(TObject *Sender)
{
Grid->Row = 1;
Grid->TopRow = 1;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KBottomClick(TObject *Sender)
{
Grid->Row = Log.GetCount() + 1;
AdjustTopRow();
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KSortDateClick(TObject *Sender)
{
if( YesNoMB( sys.m_MsgEng ? "It may take substantial time. Are you sure?":"この処理はメチャンコ時間がかかるかも知れません.\r\n\r\nよろしおまっか?" ) == IDYES ){
int top = Grid->Selection.Top - 1;
int end = Grid->Selection.Bottom - 1;
if( top == end ){
top = 0;
end = Log.GetCount() - 1;
}
Log.SortDate(top, end);
Grid->Invalidate();
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::GridDblClick(TObject *Sender)
{
int n = Grid->Row - 1;
if( (n >= 0) && (n < Log.GetCount()) ){
TQSODlgBox *pBox = new TQSODlgBox(this);
SDMMLOG sd;
Log.GetData(&sd, n);
CLogFind Find;
Log.FindSet(&Find, sd.call);
pBox->Execute(&Find, &sd, n);
Grid->Invalidate();
delete pBox;
}
}
//---------------------------------------------------------------------------
// MMLOGテキストファイルのロード
void __fastcall TLogListDlg::KMTextReadClick(TObject *Sender)
{
OpenDialog->Options >> ofCreatePrompt;
OpenDialog->Options << ofFileMustExist;
if( sys.m_MsgEng ){
OpenDialog->Title = "Load MMLOG Text file";
OpenDialog->Filter = "MMLOG Text Files(*.log)|*.log|";
}
else {
OpenDialog->Title = "MMLOGテキストファイルのロード";
OpenDialog->Filter = "MMLOGテキストファイル(*.log)|*.log|";
}
OpenDialog->FileName = "";
OpenDialog->DefaultExt = "log";
OpenDialog->InitialDir = sys.m_LogDir;
if( OpenDialog->Execute() == TRUE ){
LoadMmlogText(AnsiString(OpenDialog->FileName).c_str()); //JA7UDE 0428
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KMTextWriteClick(TObject *Sender)
{
SaveDialog->Options << ofOverwritePrompt;
if( sys.m_MsgEng ){
SaveDialog->Title = "Save MMLOG Text File";
SaveDialog->Filter = "MMLOG Text Files(*.log)|*.log|";
}
else {
SaveDialog->Title = "MMLOGテキストファイルの作成";
SaveDialog->Filter = "MMLOGテキストファイル(*.log)|*.log|";
}
char bf[256];
strcpy(bf, Log.GetName());
SetEXT(bf, ".log");
SaveDialog->FileName = bf;
SaveDialog->DefaultExt = "log";
SaveDialog->InitialDir = sys.m_LogDir;
if( SaveDialog->Execute() == TRUE ){
SaveMmlogText(AnsiString(SaveDialog->FileName).c_str()); //JA7UDE 0428
}
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::SureRead(void)
{
int r;
if( sys.m_MsgEng ){
r = YesNoCancelMB("MMVARI has QSO data(s) already. Add QSO data from file?\r\n\r\n<Yes>\tAdded to the end\r\n<No>\tOverwrite\r\n\t(All the current data are deleted, and replaced by the read data)\r\n<Cancel>\tAbort this function");
}
else {
r = YesNoCancelMB("現在MMVARIにログデータが存在します. 追加読みこみしますか?\r\n\r\n<はい>\t現在のログデータの最後に読み込んだデータが追加される.\r\n<いいえ>\t現在のログデータは全て削除され読み込んだデータに置き換わる.\r\n<キャンセル>\t処理中止");
}
switch(r){
case IDCANCEL:
return 0;
case IDNO:
if( sys.m_MsgEng ){
r = OkCancelMB("Delete All QSO data(s)...(will not be able to restore) Are you sure?");
}
else {
r = OkCancelMB("現在MMVARIが保持しているログデータを全て失います.\r\n\r\nほんまにええでっか?");
}
switch(r){
case IDOK:
Log.DeleteAll();
break;
case IDCANCEL:
return 0;
}
break;
default:
break;
}
return 1;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::LoadMmlogText(LPCSTR pName)
{
char bf[1024];
if( Log.GetCount() ){
if( !SureRead() ) return;
}
FILE *fp = fopen(pName, "rt");
if( fp != NULL ){
int r = IDNO;
if( sys.m_MsgEng ){
r = YesNoMB("This function exists for compatibility with old software which handle JST.\r\n\r\nAre recorded data UTC?");
}
CWaitCursor w;
SDMMLOG sd;
while(!feof(fp)){
if( fgets(bf, 1023, fp) != NULL ){
ClipLF(bf);
if( bf[0] ){
if( Log.ReadAscii(&sd, bf) == TRUE ){
if( r == IDYES ) UTCtoJST(&sd);
Log.PutData(&sd, Log.GetCount());
}
}
}
}
fclose(fp);
}
else {
ErrorMB(sys.m_MsgEng ? "Can't open '%s'" : "'%s'が見つかりません.", pName);
}
UpdateLogCount(1);
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::SaveMmlogText(LPCSTR pName)
{
FILE *fp = fopen(pName, "wt");
if( fp != NULL ){
int r = IDNO;
if( sys.m_MsgEng ){
r = YesNoMB("This function exists for compatibility with old software which handle JST.\r\n\r\nDo you want UTC?");
}
SDMMLOG sd;
int b = Grid->Selection.Top - 1;
int e = Grid->Selection.Bottom - 1;
if( e >= Log.GetCount() ) e--;
int i;
CWaitCursor w;
for( i = b; i <= e; i++ ){
Log.GetData(&sd, i);
if( r == IDYES ) JSTtoUTC(&sd);
fprintf(fp, "\042%s\042,\042%s.%02u\042,\042%s\042,\042%s\042,\042%s\042,\042%s\042,",
Log.GetDateString(&sd, 0),
Log.GetTimeString(sd.btime), (sd.btime % 30 * 2),
sd.call, sd.ur, sd.my,
Log.GetFreqString(sd.band, sd.fq)
);
fprintf(fp, "\042%s\042,\042%s\042,\042%s\042,\042%s\042,\042%s\042,\042%s\042,",
Log.GetModeString(sd.mode),
sd.pow, sd.name, sd.qth, sd.rem, sd.qsl
);
fprintf(fp, "\042%s\042,\042%.1s\042,\042%.1s\042,\042%.1s\042,\042%u\042,",
Log.GetTimeString(sd.etime),
&sd.send, &sd.recv, &sd.cq, sd.env
);
fprintf(fp, "\042%s\042,\042%s\042,", sd.opt1, sd.opt2 );
fprintf(fp, "\042%s\042,", Log.GetOptStr(2, &sd));
fprintf(fp, "\042%s\042\n", Log.GetOptStr(3, &sd));
if( ferror(fp) ) break;
}
if( fclose(fp) ){
ErrorMB( sys.m_MsgEng ? "Can't save to '%s'" : "'%s'が正しく作成できませんでした.", pName);
}
}
else {
ErrorMB(sys.m_MsgEng ? "Can't save to '%s'" : "'%s'が作成できません.", pName);
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KSelAllClick(TObject *Sender)
{
TGridRect gRect;
gRect.Top = 1;
gRect.Bottom = Grid->RowCount - 1;
gRect.Left = 0;
gRect.Right = 20;
Grid->Selection = gRect;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KReIndexClick(TObject *Sender)
{
Log.MakeIndex();
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::LoadLog200(LPCSTR pName)
{
if( Log.GetCount() ){
if( !SureRead() ) return FALSE;
}
CLog200 log200;
if( log200.Open(pName) ){
SDMMLOG sd;
CWaitCursor w;
while(log200.Read(&sd)==TRUE){
Log.PutData(&sd, Log.GetCount());
}
log200.Close();
}
else {
UpdateLogCount(1);
return FALSE;
}
UpdateLogCount(1);
return TRUE;
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::SaveLog200(LPCSTR pName)
{
int b = Grid->Selection.Top - 1;
int e = Grid->Selection.Bottom - 1;
if( e >= Log.GetCount() ) e--;
CLog200 log200;
if( log200.Create(pName) ){
SDMMLOG sd;
int i;
CWaitCursor w;
for( i = b; i <= e; i++ ){
Log.GetData(&sd, i);
if( log200.Write(&sd) == FALSE ) break;
}
log200.Close();
}
return TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KExportLog200Click(TObject *Sender)
{
SaveDialog->Options << ofOverwritePrompt;
if( sys.m_MsgEng ){
SaveDialog->Title = "Save LOG200 Data file";
SaveDialog->Filter = "LOG200 Data File(*.l2)|*.l2|";
}
else {
SaveDialog->Title = "LOG200データファイルの作成";
SaveDialog->Filter = "LOG200データファイル(*.l2)|*.l2|";
}
char bf[256];
strcpy(bf, Log.GetName());
SetEXT(bf, ".l2");
SaveDialog->FileName = bf;
SaveDialog->DefaultExt = "l2";
SaveDialog->InitialDir = sys.m_ExtLogDir;
if( SaveDialog->Execute() == TRUE ){
SaveLog200(AnsiString(SaveDialog->FileName).c_str()); //JA7UDE 0428
SetDirName(sys.m_ExtLogDir, AnsiString(SaveDialog->FileName).c_str()); //JA7UDE 0428
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KImportLog200Click(TObject *Sender)
{
OpenDialog->Options >> ofCreatePrompt;
OpenDialog->Options >> ofFileMustExist;
if( sys.m_MsgEng ){
OpenDialog->Title = "Load LOG200 Data File";
OpenDialog->Filter = "LOG200 Data File(*.l2)|*.l2|";
}
else {
OpenDialog->Title = "LOG200データファイルのロード";
OpenDialog->Filter = "LOG200データファイル(*.l2)|*.l2|";
}
OpenDialog->FileName = "";
OpenDialog->DefaultExt = "l2";
OpenDialog->InitialDir = sys.m_ExtLogDir;
if( OpenDialog->Execute() == TRUE ){
LoadLog200(AnsiString(OpenDialog->FileName).c_str()); //JA7UDE 0428
SetDirName(sys.m_ExtLogDir, AnsiString(OpenDialog->FileName).c_str()); //JA7UDE 0428
}
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::LoadHamLog(LPCSTR pName)
{
if( Log.GetCount() ){
if( !SureRead() ) return FALSE;
}
CHamLog HamLog;
if( HamLog.Open(pName) ){
SDMMLOG sd;
CWaitCursor w;
while(HamLog.Read(&sd)==TRUE){
Log.PutData(&sd, Log.GetCount());
}
HamLog.Close();
}
else {
UpdateLogCount(1);
return FALSE;
}
UpdateLogCount(1);
return TRUE;
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::LoadHamLog5(LPCSTR pName)
{
if( Log.GetCount() ){
if( !SureRead() ) return FALSE;
}
CHamlog5 HamLog;
if( HamLog.Open(pName, TRUE) ){
SDMMLOG sd;
CWaitCursor w;
DWORD Pos;
for( Pos = 0; Pos < HamLog.GetRCount(); Pos++ ){
if( HamLog.Seek(Pos) ){
HamLog.DecodeData(&sd);
Log.PutData(&sd, Log.GetCount());
}
}
HamLog.Close();
}
else {
UpdateLogCount(1);
return FALSE;
}
UpdateLogCount(1);
return TRUE;
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::SaveHamLog(LPCSTR pName)
{
int b = Grid->Selection.Top - 1;
int e = Grid->Selection.Bottom - 1;
if( e >= Log.GetCount() ) e--;
CHamLog HamLog;
if( HamLog.Create(pName) ){
SDMMLOG sd;
int i;
CWaitCursor w;
for( i = b; i <= e; i++ ){
Log.GetData(&sd, i);
if( HamLog.Write(&sd) == FALSE ) break;
}
HamLog.Close();
}
return TRUE;
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::SaveHamLog5(LPCSTR pName)
{
int b = Grid->Selection.Top - 1;
int e = Grid->Selection.Bottom - 1;
if( e >= Log.GetCount() ) e--;
char master[256];
SetDirName(master, pName);
strcat(master, "HAMLOG.HDB");
CHamlog5 HamLog;
if( HamLog.Open(master, FALSE) ){ // フィールド情報を読み込む
HamLog.Close();
}
else { // フィールド情報を問い合わせ
TTH5LenDlg *pBox = new TTH5LenDlg(this);
if( !pBox->Execute() ){
return FALSE;
}
}
if( HamLog.Create(pName) ){
SDMMLOG sd;
int i;
int n = 0;
CWaitCursor w;
for( i = b; i <= e; i++, n++ ){
Log.GetData(&sd, i);
HamLog.Seek(n);
HamLog.EncodeData(&sd);
if( HamLog.Update() == FALSE ) break;
}
HamLog.Close();
}
return TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KImportHamlogClick(TObject *Sender)
{
OpenDialog->Options >> ofCreatePrompt;
OpenDialog->Options >> ofFileMustExist;
if( sys.m_MsgEng ){
OpenDialog->Title = "Load HamLog Data File";
OpenDialog->Filter = "HamLog Data File(*.hdb;*.dbs)|*.hdb;*.dbs|";
}
else {
OpenDialog->Title = "HamLogデータファイルのロード";
OpenDialog->Filter = "HamLogデータファイル(*.hdb;*.dbs)|*.hdb;*.dbs|";
}
OpenDialog->FileName = "";
OpenDialog->DefaultExt = "hdb";
OpenDialog->InitialDir = sys.m_ExtLogDir;
if( OpenDialog->Execute() == TRUE ){
LPCSTR pName = AnsiString(OpenDialog->FileName).c_str(); //JA7UDE 0428
if( !strcmpi(GetEXT(pName), "HDB") ){
LoadHamLog5(pName);
}
else {
LoadHamLog(pName);
}
SetDirName(sys.m_ExtLogDir, pName);
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KExportHamlogClick(TObject *Sender)
{
SaveDialog->Options << ofOverwritePrompt;
if( sys.m_MsgEng ){
SaveDialog->Title = "Save HAMLOG Data File";
SaveDialog->Filter = "HAMLOG (Ver5) Data File(*.hdb)|*.hdb|HAMLOG Data File(*.dbs)|*.dbs|";
}
else {
SaveDialog->Title = "HAMLOGデータファイルの作成";
SaveDialog->Filter = "HAMLOG (Ver5) データファイル(*.hdb)|*.hdb|HAMLOGデータファイル(*.dbs)|*.dbs|";
}
char bf[256];
strcpy(bf, Log.GetName());
SetEXT(bf, ".hdb");
SaveDialog->FileName = bf;
SaveDialog->DefaultExt = "hdb";
SaveDialog->InitialDir = sys.m_ExtLogDir;
if( SaveDialog->Execute() == TRUE ){
LPCSTR pName = AnsiString(SaveDialog->FileName).c_str(); //JA7UDE 0428
if( !strcmpi(GetEXT(pName), "HDB") ){
SaveHamLog5(pName);
}
else {
SaveHamLog(pName);
}
SetDirName(sys.m_ExtLogDir, pName);
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KLogOptClick(TObject *Sender)
{
TLogSetDlg *pBox = new TLogSetDlg(this);
pBox->Execute();
delete pBox;
SetTimeZone();
Grid->Invalidate();
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::SaveADIF(LPCSTR pName)
{
int b = Grid->Selection.Top - 1;
int e = Grid->Selection.Bottom - 1;
if( e >= Log.GetCount() ) e--;
CLogADIF logADIF;
if( logADIF.Create(pName) ){
SDMMLOG sd;
int i;
CWaitCursor w;
for( i = b; i <= e; i++ ){
Log.GetData(&sd, i);
if( logADIF.Write(&sd) == FALSE ) break;
}
logADIF.Close();
}
return TRUE;
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::LoadADIF(LPCSTR pName)
{
if( Log.GetCount() ){
if( !SureRead() ) return FALSE;
}
CLogADIF logADIF;
if( logADIF.Open(pName) ){
SDMMLOG sd;
memset(&sd, 0, sizeof(sd));
CWaitCursor w;
while(logADIF.Read(&sd)==TRUE){
Log.PutData(&sd, Log.GetCount());
memset(&sd, 0, sizeof(sd));
}
logADIF.Close();
}
else {
UpdateLogCount(1);
return FALSE;
}
UpdateLogCount(1);
return TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KExportADIFClick(TObject *Sender)
{
SaveDialog->Options << ofOverwritePrompt;
if( sys.m_MsgEng ){
SaveDialog->Title = "Save ADIF File";
SaveDialog->Filter = "ADIF Files(*.adi)|*.adi|";
}
else {
SaveDialog->Title = "ADIF ファイルの作成";
SaveDialog->Filter = "ADIF ファイル(*.adi)|*.adi|";
}
char bf[256];
strcpy(bf, Log.GetName());
SetEXT(bf, ".adi");
SaveDialog->FileName = bf;
SaveDialog->DefaultExt = "adi";
SaveDialog->InitialDir = sys.m_ExtLogDir;
if( SaveDialog->Execute() == TRUE ){
SaveADIF(AnsiString(SaveDialog->FileName).c_str()); //JA7UDE 0428
SetDirName(sys.m_ExtLogDir, AnsiString(SaveDialog->FileName).c_str()); //JA7UDE 0428
}
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KImportADIFClick(TObject *Sender)
{
OpenDialog->Options >> ofCreatePrompt;
OpenDialog->Options >> ofFileMustExist;
if( sys.m_MsgEng ){
OpenDialog->Title = "Load ADIF File";
OpenDialog->Filter = "ADIF Files(*.adi;*.txt)|*.adi;*.txt|";
}
else {
OpenDialog->Title = "ADIF ファイルのロード";
OpenDialog->Filter = "ADIF ファイル(*.adi;*.txt)|*.adi;*.txt|";
}
OpenDialog->FileName = "";
OpenDialog->DefaultExt = "adi";
OpenDialog->InitialDir = sys.m_ExtLogDir;
if( OpenDialog->Execute() == TRUE ){
LoadADIF(AnsiString(OpenDialog->FileName).c_str()); //JA7UDE 0428
SetDirName(sys.m_ExtLogDir, AnsiString(OpenDialog->FileName).c_str()); //JA7UDE 0428
}
}
//---------------------------------------------------------------------------
int __fastcall TLogListDlg::SaveCabrillo(LPCSTR pName)
{
int b = Grid->Selection.Top - 1;
int e = Grid->Selection.Bottom - 1;
if( e >= Log.GetCount() ) e--;
CLogCabrillo logCabrillo;
if( logCabrillo.Create(pName) ){
SDMMLOG sd;
int i;
CWaitCursor w;
for( i = b; i <= e; i++ ){
Log.GetData(&sd, i);
if( logCabrillo.Write(&sd) == FALSE ) break;
}
logCabrillo.Close();
}
return TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TLogListDlg::KExportCabrilloClick(TObject *Sender)
{
SaveDialog->Options << ofOverwritePrompt;
if( sys.m_MsgEng ){
SaveDialog->Title = "Save Cabrillo File";
SaveDialog->Filter = "Cabrillo Files(*.txt)|*.txt|";
}