private:
+#ifdef _DEBUG
+#define __DEBUG
+#endif
//#define FULL_STRING_SEARCH
#define UTF8_IS_FIRST(x) (__extension__({ byte b = x; (!(b) || !((b) & 0x80) || ((b) & 0x40)); }))
{
set
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::table|set");
+#endif
table = value;
}
}
bool OnPostCreate()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::OnPostCreate");
+#endif
if(table)
{
if(!initialized)
{
ResetListFields();
+ if(searchFields)
+ {
+ char name[MAX_FILENAME];
+ sprintf(name, "%s.search", table.name);
+ PrepareWordList(name);
+ }
InitFieldsBoxes(); // IMPORTANT: table must be set *AFTER* all related FieldEditors have been initialized
{
Field fldId = idField, fldName = stringField, fldActive = null;
{
set
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::list|set");
+#endif
list = value;
//ResetListFields();
}
{
set
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::listFields|set");
+#endif
listFields = value;
//ResetListFields();
}
{
set
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::searchFields|set");
+#endif
searchFields = value;
- {
- char name[MAX_FILENAME];
- sprintf(name, "%s.search", table.name);
- PrepareWordList(name);
- }
}
}
Array<StringSearchField> searchFields;
set
{
bool modified = modifiedDocument;
+#ifdef __DEBUG
+ PrintLn("TableEditor::searchString|set");
+#endif
switch(modified ? OnLeavingModifiedDocument() : no)
{
case cancel:
bool internalModifications;
public void NotifyModifiedDocument()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::NotifyModifiedDocument");
+#endif
if(!internalModifications)
OnStateChanged();
}
public virtual DialogResult OnLeavingModifiedDocument()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::OnLeavingModifiedDocument");
+#endif
return MessageBox { master = this, type = yesNoCancel, text = text && text[0] ? text : $"Table Editor",
contents = $"You have modified this entry. Would you like to save it before proceeding?"
}.Modal();
public virtual bool OnRemovalRequest()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::OnRemovalRequest");
+#endif
return MessageBox { master = this, type = yesNo, text = text && text[0] ? text : $"Table Editor",
contents = $"You are about to permanently remove an entry.\n"
"Do you wish to continue?"
public bool NotifyClosing()
{
bool result = true;
+#ifdef __DEBUG
+ PrintLn("TableEditor::NotifyClosing");
+#endif
if(modifiedDocument)
{
switch(OnLeavingModifiedDocument())
//public void List() // this gets called out of nowhere by some constructor thing...
public void Enumerate()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::Enumerate");
+#endif
if(list)
{
DataRow select;
virtual void TableEditor::OnList(Row r, Array<Id> matches)
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::OnList");
+#endif
if(matches)
{
int c;
void CreateRow()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::CreateRow");
+#endif
//list.NotifySelect(this, list, null, 0);
if(!modifiedDocument)
{
void Remove()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::Remove");
+#endif
if(editRow.sysID) //list && list.currentRow)
{
if(OnRemovalRequest())
void Load()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::Load");
+#endif
EditLoad();
}
void Write()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::Write");
+#endif
EditSave();
}
bool ListSelect(DataRow row)
{
bool result = true;
+#ifdef __DEBUG
+ PrintLn("TableEditor::ListSelect");
+#endif
if(/*-row && -*/row != lastRow)
{
uint id;
bool Select(Id id)
{
bool result;
+#ifdef __DEBUG
+ PrintLn("TableEditor::Select");
+#endif
if(idField && editRow.Find(idField, middle, nil, id))
{
//Id test = editRow.sysID;
bool SelectNext()
{
bool result;
+#ifdef __DEBUG
+ PrintLn("TableEditor::SelectNext");
+#endif
// How about confirmation / saving before changing the entry?
if(editRow.Next())
{
bool SelectPrevious()
{
bool result;
+#ifdef __DEBUG
+ PrintLn("TableEditor::SelectPrevious");
+#endif
if(editRow.Previous())
{
//Id test = editRow.sysID;
void SelectListRow(DataRow row)
{
// Time startTime = GetTime();
+#ifdef __DEBUG
+ PrintLn("TableEditor::SelectListRow");
+#endif
if(row)
{
selectedId = row.tag;
~TableEditor()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::~()");
+#endif
fieldsBoxes.Free(); // TOCHECK: do I need to delete each to oppose the increb in AddFieldBox?
delete searchString;
//listFields.Free();
void ResetListFields()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::ResetListFields");
+#endif
if(list && listFields && listFields.count)
{
bool c = list.created;
- if(dataFieldsUsed)
+ //if(dataFieldsUsed)
list.ClearFields();
for(lf : listFields)
list.AddField(lf.dataField);
void AddFieldBox(FieldBox fieldBox)
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::AddFieldBox");
+#endif
if(!fieldsBoxes.Find(fieldBox))
{
fieldsBoxes.Add(fieldBox);
void InitFieldsBoxes()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::InitFieldsBoxes");
+#endif
for(fb : fieldsBoxes)
fb.Init();
//NotifyInitFields(master, this);
void EditNew()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::EditNew");
+#endif
modifiedDocument = false;
}
void EditSave()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::EditSave");
+#endif
internalModifications = true;
for(fb : fieldsBoxes)
fb.Save();
void EditLoad()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::EditLoad");
+#endif
OnLoad();
internalModifications = true;
for(fb : fieldsBoxes)
void EditClear()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::EditClear");
+#endif
internalModifications = true;
for(fb : fieldsBoxes)
fb.Clear();
void SetListRowFields(Row dbRow, DataRow listRow)
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::SetListRowFields");
+#endif
for(lf : listFields)
{
if(lf.dataField && lf.field)
Array<Id> SearchWordList()
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::SearchWordList");
+#endif
#ifdef FULL_STRING_SEARCH
int c;
int numTokens = 0;
void PrepareWordList(char * filePath)
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::PrepareWordList");
+#endif
#ifdef FULL_STRING_SEARCH
Row r { table };
File f = filePath ? FileOpenBuffered(filePath, read) : null;
void AddWord(char * word, int count, bool addAllSubstrings, Id id)
{
+#ifdef __DEBUG
+ PrintLn("TableEditor::AddWord");
+#endif
#ifdef FULL_STRING_SEARCH
int s;
WordEntry mainEntry = null;
WordEntry node;
uint id;
uint count = this.count;
+#ifdef __DEBUG
+ PrintLn("WordEntryBinaryTree::OnSerialize");
+#endif
for(id = 1, node = (WordEntry)root; node;)
{
node.id = id++;
{
WordEntry root, node;
uint count;
+#ifdef __DEBUG
+ PrintLn("WordEntryBinaryTree::OnUnserialize");
+#endif
channel.Unserialize(count);
entries = new WordEntry[count];
btnodes = entries;