Skip to content

Commit 94359ac

Browse files
committed
Report numb notes found AND error if one happened.
1 parent 9d3aa05 commit 94359ac

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

po/tomboy-ng.po

+8
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,14 @@ msgstr ""
315315
msgid "Label8"
316316
msgstr ""
317317

318+
#: tmainform.labelerror.caption
319+
msgid "X"
320+
msgstr ""
321+
322+
#: tmainform.labelerror.hint
323+
msgid "Launch from commandline to see errors. See website"
324+
msgstr ""
325+
318326
#: tmainform.menuquit.caption
319327
msgctxt "tmainform.menuquit.caption"
320328
msgid "Quit, Close and Go Away."

tomboy-ng/mainunit.lfm

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
object MainForm: TMainForm
22
Left = 403
3-
Height = 292
3+
Height = 318
44
Top = 146
55
Width = 355
66
Caption = 'MainForm'
7-
ClientHeight = 290
7+
ClientHeight = 316
88
ClientWidth = 355
99
Menu = MainMenu1
1010
OnActivate = FormActivate
@@ -344,6 +344,27 @@ object MainForm: TMainForm
344344
ParentShowHint = False
345345
ShowHint = True
346346
end
347+
object LabelNotesFound: TLabel
348+
Left = 24
349+
Height = 1
350+
Top = 256
351+
Width = 1
352+
ParentColor = False
353+
end
354+
object LabelError: TLabel
355+
Left = 24
356+
Height = 18
357+
Hint = 'Launch from commandline to see errors. See website'
358+
Top = 277
359+
Width = 11
360+
Caption = 'X'
361+
Font.Height = -16
362+
Font.Style = [fsBold]
363+
ParentColor = False
364+
ParentFont = False
365+
ParentShowHint = False
366+
ShowHint = True
367+
end
347368
object PopupMenuTray: TPopupMenu
348369
left = 272
349370
top = 64

tomboy-ng/mainunit.pas

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
1515
2018/06/19 Got some stuff for singlenotemode() - almost working.
1616
2018/06/22 As above but maybe working now ? DRB
17+
2018/07/04 Display number of notes found and a warning if indexing error occured.
1718
1819
1920
@@ -60,13 +61,15 @@ TMainForm = class(TForm)
6061
ImageNotesDirTick: TImage;
6162
ImageSyncTick: TImage;
6263
Label1: TLabel;
64+
LabelError: TLabel;
6365
Label2: TLabel;
6466
Label3: TLabel;
6567
Label4: TLabel;
6668
Label5: TLabel;
6769
Label6: TLabel;
6870
Label7: TLabel;
6971
Label8: TLabel;
72+
LabelNotesFound: TLabel;
7073
MainMenu1: TMainMenu;
7174
MMRecent1: TMenuItem;
7275
MMRecent8: TMenuItem;
@@ -227,7 +230,11 @@ procedure TMainForm.FormShow(Sender: TObject);
227230
Label7.Caption:='';
228231
Label8.Caption := '';
229232
CheckStatus();
230-
SearchForm.IndexNotes(); // also calls Checkstatus but safe to call anytime
233+
LabelNotesFound.Caption := 'Found ' + inttostr(SearchForm.IndexNotes())
234+
+ ' notes'; // also calls Checkstatus but safe to call anytime
235+
if SearchForm.NoteLister.XMLError then
236+
LabelError.Caption := 'Failed to index one or more notes.'
237+
else LabelError.Caption := '';
231238
if not AllowDismiss then begin
232239
Label7.Caption := 'Sadly, on this OS, I cannot';
233240
Label8.Caption := 'let you dismiss this window';

tomboy-ng/note_lister.pas

+7-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
2018/02/15 Can now search case sensitive or not and any combination or exact match
4747
2018/04/28 Set FixedRows to zero after Clean-ing strgrid, seems necessary in Trunk
4848
2018/06/26 Used E.Message in exception generated by bad XML - dah ....
49+
2018/07/04 Added a flag, XMLError, set if we found a note unable to index.
4950
}
5051

5152
{$mode objfpc}
@@ -140,6 +141,7 @@ TNoteLister = class
140141
function RemoveXml(const St: AnsiString): AnsiString;
141142

142143
public
144+
XMLError : Boolean;
143145
{ The directory, with trailing seperator, that the notes are in }
144146
WorkingDir : ANSIString;
145147
SearchIndex : integer;
@@ -511,7 +513,10 @@ procedure TNoteLister.GetNoteDetails(const Dir, FileName: ANSIString;
511513
// Notebook tag its the StartHere note, otherwise its the Template for
512514
// for the mentioned Notebook.
513515
end;
514-
except on E: EXMLReadError do DebugLn(E.Message);
516+
except on E: EXMLReadError do begin
517+
DebugLn(E.Message);
518+
XMLError := True;
519+
end;
515520
on EAccessViolation do DebugLn('Access Violation ' + FileName);
516521
end;
517522
if NoteP^.IsTemplate then begin // Don't show templates in normal note list
@@ -606,6 +611,7 @@ function TNoteLister.GetNotes(const Term: ANSIstring): longint;
606611
var
607612
Info : TSearchRec;
608613
begin
614+
XMLError := False;
609615
DebugMode := Application.HasOption('debug-index');
610616
if Term = '' then begin
611617
NoteList.Free;

tomboy-ng/searchunit.pas

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
2018/05/12 Extensive changes - MainUnit is now just that. Name of this unit changed.
8080
2018/05/20 Alterations to way we startup, wrt mainform status report. Mark
8181
2018/06/04 NoteReadOnly() now checks if NoteLister is valid before calling.
82+
2018/07/04 Pass back some info about how the note indexing went.
8283
}
8384

8485
{$mode objfpc}{$H+}
@@ -150,7 +151,7 @@ TSearchForm = class(TForm)
150151
{ Reads header in each note in notes directory, updating Search List and
151152
the recently used list under the TrayIcon. Downside is time it takes
152153
to index. use UpdateList() if you just have updates. }
153-
procedure IndexNotes();
154+
function IndexNotes() : integer;
154155
{ Returns true when passed string is the title of an existing note }
155156
function IsThisaTitle(const Term: ANSIString): boolean;
156157
{ Gets called with a title and filename (clicking grid), with just a title
@@ -383,7 +384,7 @@ procedure TSearchForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
383384
if not AllowClose then hide(); }
384385
end;
385386

386-
procedure TSearchForm.IndexNotes();
387+
function TSearchForm.IndexNotes() : integer;
387388
// var
388389
// TS1, TS2 : TTimeStamp;
389390
begin
@@ -393,7 +394,7 @@ procedure TSearchForm.IndexNotes();
393394
NoteLister := TNoteLister.Create;
394395
NoteLister.WorkingDir:=Sett.NoteDirectory;
395396
end;
396-
NoteLister.GetNotes(); { TODO : we should say how many we found }
397+
Result := NoteLister.GetNotes();
397398
// TS1 := DateTimeToTimeStamp(Now);
398399
// Edit1.Text := 'That took (mS) ' + inttostr(TS2.Time - TS1.Time);
399400
UseList();

0 commit comments

Comments
 (0)