From c53c22bc90eef136f242f85723b5d31f26b3cf25 Mon Sep 17 00:00:00 2001 From: LoudSnorer Date: Mon, 25 Mar 2024 19:48:54 -0400 Subject: [PATCH] Add Daily Search Item; searh for any Journal item. notes,bookmarks,weight,feelings --- oscar/dailySearchTab.cpp | 49 ++++++++++++++++++++++++++++++++++++++++ oscar/dailySearchTab.h | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/oscar/dailySearchTab.cpp b/oscar/dailySearchTab.cpp index 0a4b362e..41051915 100644 --- a/oscar/dailySearchTab.cpp +++ b/oscar/dailySearchTab.cpp @@ -30,6 +30,7 @@ #include "dailySearchTab.h" #include "SleepLib/day.h" #include "SleepLib/profiles.h" +#include "SleepLib/journal.h" #include "daily.h" #include "SleepLib/machine_common.h" @@ -468,6 +469,7 @@ void DailySearchTab::populateControl() { // Now add events commandList->clear(); + addCommandItem(tr("Journal"),ST_JOURNAL); addCommandItem(tr("Notes"),ST_NOTES); addCommandItem(tr("Notes containing"),ST_NOTES_STRING); addCommandItem(tr("Bookmarks"),ST_BOOKMARKS); @@ -505,6 +507,7 @@ void DailySearchTab::populateControl() { void DailySearchTab::setState(STATE newState) { STATE prev=state; state = newState; + //enum STATE { reset , waitForSearchTopic , matching , multpileMatches , waitForStart , autoStart , searching , endOfSeaching , waitForContinue , noDataFound}; switch (state) { case multpileMatches : break; @@ -826,6 +829,47 @@ bool DailySearchTab::matchFind(Match* myMatch ,Day* day, QDate& date, Qt::Alignm myMatch->updateMinMaxValues(numDisabled); } break; + case ST_JOURNAL : + { + Session* journal=daily->GetJournalSession(date,false); + if (journal) { + myMatch->foundString = journal->settings[LastUpdated].toDateTime().toString(); + myMatch->foundString.append(" "); + bool empty =true; + if ( journal->settings.contains(Bookmark_Start) ) { + if (journal->settings[Bookmark_Start].toList().size()>0) { + empty = false; + myMatch->foundString.append("B"); + /* Not reuired. + if ( journal->settings.contains(Bookmark_Notes) ) { + if (journal->settings[Bookmark_Start].toList().size()>0) { + myMatch->foundString.append("n"); + } + } + */ + } + } + if ( journal->settings.contains(Journal_Notes) ) { + myMatch->foundString.append("N"); + empty = false; + } + if ( journal->settings.contains(Journal_Weight) ) { + myMatch->foundString.append("W"); + empty = false; + } + if ( journal->settings.contains(Journal_ZombieMeter) ) { + myMatch->foundString.append("F"); + empty = false; + } + if (empty) { + break; + myMatch->foundString.append(tr("Empty")); + } + found=true; + alignment=Qt::AlignLeft; + } + } + break; case ST_NOTES : { Session* journal=daily->GetJournalSession(date,false); @@ -1164,6 +1208,11 @@ void DailySearchTab::process_match_info(QString text, int topic) { selectInteger->setValue(0); setoperation(OP_NO_PARMS,displayWhole); break; + case ST_JOURNAL : + setResult(DS_ROW_HEADER,1,QDate(),tr("JUmps\nJumps to Date's Notes")); + match->nextTab = TW_NOTES ; + setoperation( OP_NO_PARMS ,displayString); + break; case ST_NOTES : setResult(DS_ROW_HEADER,1,QDate(),tr("Note\nJumps to Date's Notes")); match->nextTab = TW_NOTES ; diff --git a/oscar/dailySearchTab.h b/oscar/dailySearchTab.h index cea2e846..cc780e19 100644 --- a/oscar/dailySearchTab.h +++ b/oscar/dailySearchTab.h @@ -47,7 +47,7 @@ class Daily; //forward declaration. enum ValueMode { invalidValueMode , notUsed , minutesToMs , hoursToMs , hundredths , opWhole , displayWhole , opString , displayString, secondsDisplayString}; -enum SearchTopic { ST_NONE , ST_DAYS_SKIPPED , ST_DISABLED_SESSIONS , ST_NOTES , ST_NOTES_STRING , ST_BOOKMARKS , ST_BOOKMARKS_STRING , ST_AHI , ST_SESSION_LENGTH , ST_SESSIONS_QTY , ST_DAILY_USAGE , ST_APNEA_LENGTH , ST_APNEA_ALL , ST_CLEAR , ST_EVENT }; +enum SearchTopic { ST_NONE , ST_DAYS_SKIPPED , ST_DISABLED_SESSIONS , ST_JOURNAL , ST_NOTES , ST_NOTES_STRING , ST_BOOKMARKS , ST_BOOKMARKS_STRING , ST_AHI , ST_SESSION_LENGTH , ST_SESSIONS_QTY , ST_DAILY_USAGE , ST_APNEA_LENGTH , ST_APNEA_ALL , ST_CLEAR , ST_EVENT }; enum OpCode { //DO NOT CHANGE NUMERIC OP CODES because THESE VALUES impact compare operations.