Skip to content

Commit

Permalink
Report numb notes found AND error if one happened.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbannon committed Aug 4, 2018
1 parent 9d3aa05 commit 94359ac
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 7 deletions.
8 changes: 8 additions & 0 deletions po/tomboy-ng.po
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,14 @@ msgstr ""
msgid "Label8"
msgstr ""

#: tmainform.labelerror.caption
msgid "X"
msgstr ""

#: tmainform.labelerror.hint
msgid "Launch from commandline to see errors. See website"
msgstr ""

#: tmainform.menuquit.caption
msgctxt "tmainform.menuquit.caption"
msgid "Quit, Close and Go Away."
Expand Down
25 changes: 23 additions & 2 deletions tomboy-ng/mainunit.lfm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
object MainForm: TMainForm
Left = 403
Height = 292
Height = 318
Top = 146
Width = 355
Caption = 'MainForm'
ClientHeight = 290
ClientHeight = 316
ClientWidth = 355
Menu = MainMenu1
OnActivate = FormActivate
Expand Down Expand Up @@ -344,6 +344,27 @@ object MainForm: TMainForm
ParentShowHint = False
ShowHint = True
end
object LabelNotesFound: TLabel
Left = 24
Height = 1
Top = 256
Width = 1
ParentColor = False
end
object LabelError: TLabel
Left = 24
Height = 18
Hint = 'Launch from commandline to see errors. See website'
Top = 277
Width = 11
Caption = 'X'
Font.Height = -16
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
ParentShowHint = False
ShowHint = True
end
object PopupMenuTray: TPopupMenu
left = 272
top = 64
Expand Down
9 changes: 8 additions & 1 deletion tomboy-ng/mainunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
2018/06/19 Got some stuff for singlenotemode() - almost working.
2018/06/22 As above but maybe working now ? DRB
2018/07/04 Display number of notes found and a warning if indexing error occured.
Expand Down Expand Up @@ -60,13 +61,15 @@ TMainForm = class(TForm)
ImageNotesDirTick: TImage;
ImageSyncTick: TImage;
Label1: TLabel;
LabelError: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
LabelNotesFound: TLabel;
MainMenu1: TMainMenu;
MMRecent1: TMenuItem;
MMRecent8: TMenuItem;
Expand Down Expand Up @@ -227,7 +230,11 @@ procedure TMainForm.FormShow(Sender: TObject);
Label7.Caption:='';
Label8.Caption := '';
CheckStatus();
SearchForm.IndexNotes(); // also calls Checkstatus but safe to call anytime
LabelNotesFound.Caption := 'Found ' + inttostr(SearchForm.IndexNotes())
+ ' notes'; // also calls Checkstatus but safe to call anytime
if SearchForm.NoteLister.XMLError then
LabelError.Caption := 'Failed to index one or more notes.'
else LabelError.Caption := '';
if not AllowDismiss then begin
Label7.Caption := 'Sadly, on this OS, I cannot';
Label8.Caption := 'let you dismiss this window';
Expand Down
8 changes: 7 additions & 1 deletion tomboy-ng/note_lister.pas
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
2018/02/15 Can now search case sensitive or not and any combination or exact match
2018/04/28 Set FixedRows to zero after Clean-ing strgrid, seems necessary in Trunk
2018/06/26 Used E.Message in exception generated by bad XML - dah ....
2018/07/04 Added a flag, XMLError, set if we found a note unable to index.
}

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

public
XMLError : Boolean;
{ The directory, with trailing seperator, that the notes are in }
WorkingDir : ANSIString;
SearchIndex : integer;
Expand Down Expand Up @@ -511,7 +513,10 @@ procedure TNoteLister.GetNoteDetails(const Dir, FileName: ANSIString;
// Notebook tag its the StartHere note, otherwise its the Template for
// for the mentioned Notebook.
end;
except on E: EXMLReadError do DebugLn(E.Message);
except on E: EXMLReadError do begin
DebugLn(E.Message);
XMLError := True;
end;
on EAccessViolation do DebugLn('Access Violation ' + FileName);
end;
if NoteP^.IsTemplate then begin // Don't show templates in normal note list
Expand Down Expand Up @@ -606,6 +611,7 @@ function TNoteLister.GetNotes(const Term: ANSIstring): longint;
var
Info : TSearchRec;
begin
XMLError := False;
DebugMode := Application.HasOption('debug-index');
if Term = '' then begin
NoteList.Free;
Expand Down
7 changes: 4 additions & 3 deletions tomboy-ng/searchunit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
2018/05/12 Extensive changes - MainUnit is now just that. Name of this unit changed.
2018/05/20 Alterations to way we startup, wrt mainform status report. Mark
2018/06/04 NoteReadOnly() now checks if NoteLister is valid before calling.
2018/07/04 Pass back some info about how the note indexing went.
}

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

procedure TSearchForm.IndexNotes();
function TSearchForm.IndexNotes() : integer;
// var
// TS1, TS2 : TTimeStamp;
begin
Expand All @@ -393,7 +394,7 @@ procedure TSearchForm.IndexNotes();
NoteLister := TNoteLister.Create;
NoteLister.WorkingDir:=Sett.NoteDirectory;
end;
NoteLister.GetNotes(); { TODO : we should say how many we found }
Result := NoteLister.GetNotes();
// TS1 := DateTimeToTimeStamp(Now);
// Edit1.Text := 'That took (mS) ' + inttostr(TS2.Time - TS1.Time);
UseList();
Expand Down

0 comments on commit 94359ac

Please sign in to comment.