[Fix Daily Search] add search at first imstall

This commit is contained in:
LoudSnorer 2024-03-25 19:30:50 -04:00
parent d18826266b
commit 37097ee3ce
2 changed files with 10 additions and 45 deletions

View File

@ -381,25 +381,6 @@ void DailySearchTab::addCommandItem(QString str,int topic) {
commandList->setItemWidget(item, topicButton); commandList->setItemWidget(item, topicButton);
} }
void DailySearchTab::debugStates() {
#ifdef TEST_MACROS_ENABLED
return;
qDebug() ;
for (int ind = 0; ind <commandList->count() ; ++ind) {
QListWidgetItem *item = commandList->item(ind);
QAbstractButton* topicButton = dynamic_cast<QAbstractButton*>(commandList->itemWidget(item));
if (!topicButton) continue;
int topic = buttonGroup->id(topicButton);
DEBUGFC
QQ("checkable",topicButton->isCheckable())
QQ("check",topicButton->isChecked())
O(topicButton->text())
O(topic)
;
}
#endif
}
void DailySearchTab::showOnlyAhiChannels(bool ahiOnly) { void DailySearchTab::showOnlyAhiChannels(bool ahiOnly) {
for (int ind = 0; ind <commandList->count() ; ++ind) { for (int ind = 0; ind <commandList->count() ; ++ind) {
QListWidgetItem *item = commandList->item(ind); QListWidgetItem *item = commandList->item(ind);
@ -423,7 +404,6 @@ void DailySearchTab::showOnlyAhiChannels(bool ahiOnly) {
lastButton = nullptr; lastButton = nullptr;
lastTopic = ST_NONE ; lastTopic = ST_NONE ;
}; };
debugStates();
}; };
void DailySearchTab::on_matchGroupButton_toggled(QAbstractButton* topicButton ) { void DailySearchTab::on_matchGroupButton_toggled(QAbstractButton* topicButton ) {
@ -487,11 +467,6 @@ void DailySearchTab::populateControl() {
operationCombo->addItem(opCodeStr(OP_NE)); operationCombo->addItem(opCodeStr(OP_NE));
// Now add events // Now add events
QDate date = p_profile->LastDay(MT_CPAP);
if ( !date.isValid()) return;
Day* day = p_profile->GetDay(date);
if (!day) return;
commandList->clear(); commandList->clear();
addCommandItem(tr("Notes"),ST_NOTES); addCommandItem(tr("Notes"),ST_NOTES);
addCommandItem(tr("Notes containing"),ST_NOTES_STRING); addCommandItem(tr("Notes containing"),ST_NOTES_STRING);
@ -508,6 +483,10 @@ void DailySearchTab::populateControl() {
} }
addCommandItem(tr("Number of Sessions"),ST_SESSIONS_QTY); addCommandItem(tr("Number of Sessions"),ST_SESSIONS_QTY);
QDate date = p_profile->LastDay(MT_CPAP);
if ( !date.isValid()) return;
Day* day = p_profile->GetDay(date);
if (!day) return;
if (p_profile->general->showUnknownFlags()) chans |= schema::UNKNOWN; if (p_profile->general->showUnknownFlags()) chans |= schema::UNKNOWN;
QList<ChannelID> available; QList<ChannelID> available;
@ -526,8 +505,6 @@ void DailySearchTab::populateControl() {
void DailySearchTab::setState(STATE newState) { void DailySearchTab::setState(STATE newState) {
STATE prev=state; STATE prev=state;
state = newState; state = newState;
//enum STATE { reset , waitForSearchTopic , matching , multpileMatches , waitForStart , autoStart , searching , endOfSeaching , waitForContinue , noDataFound};
//DEBUGFC O(prev) O("==>") O(state) Q( matches.size()) QQ("name",match->matchName) O(match->opCodeStr) O(match->compareString) O(match->units);
switch (state) { switch (state) {
case multpileMatches : case multpileMatches :
break; break;
@ -598,7 +575,6 @@ void DailySearchTab::setState(STATE newState) {
hideResults(true); hideResults(true);
break; break;
}; };
//DEBUGFC O(prev) O("==>") O(state) Q(matchButton->isVisible()) Q(addMatchButton->isVisible()) Q( matches.size());
}; };
QRegExp Match::searchPatterToRegex (QString searchPattern) { QRegExp Match::searchPatterToRegex (QString searchPattern) {
@ -852,9 +828,9 @@ bool DailySearchTab::matchFind(Match* myMatch ,Day* day, QDate& date, Qt::Alignm
break; break;
case ST_NOTES : case ST_NOTES :
{ {
Session* journal=daily->GetJournalSession(date); Session* journal=daily->GetJournalSession(date,false);
if (journal && journal->settings.contains(Journal_Notes)) { if (journal && journal->settings.contains(Journal_Notes)) {
QString jcontents = convertRichText2Plain(journal->settings[Journal_Notes].toString()); QString jcontents = Daily::convertHtmlToPlainText(journal->settings[Journal_Notes].toString());
myMatch->foundString = jcontents.simplified().left(stringDisplayLen).simplified(); myMatch->foundString = jcontents.simplified().left(stringDisplayLen).simplified();
found=true; found=true;
alignment=Qt::AlignLeft; alignment=Qt::AlignLeft;
@ -863,7 +839,7 @@ bool DailySearchTab::matchFind(Match* myMatch ,Day* day, QDate& date, Qt::Alignm
break; break;
case ST_BOOKMARKS : case ST_BOOKMARKS :
{ {
Session* journal=daily->GetJournalSession(date); Session* journal=daily->GetJournalSession(date,false);
if (journal && journal->settings.contains(Bookmark_Notes)) { if (journal && journal->settings.contains(Bookmark_Notes)) {
found=true; found=true;
QStringList notes = journal->settings[Bookmark_Notes].toStringList(); QStringList notes = journal->settings[Bookmark_Notes].toStringList();
@ -877,7 +853,7 @@ bool DailySearchTab::matchFind(Match* myMatch ,Day* day, QDate& date, Qt::Alignm
break; break;
case ST_BOOKMARKS_STRING : case ST_BOOKMARKS_STRING :
{ {
Session* journal=daily->GetJournalSession(date); Session* journal=daily->GetJournalSession(date,false);
if (journal && journal->settings.contains(Bookmark_Notes)) { if (journal && journal->settings.contains(Bookmark_Notes)) {
QStringList notes = journal->settings[Bookmark_Notes].toStringList(); QStringList notes = journal->settings[Bookmark_Notes].toStringList();
QString findStr = selectString->text(); QString findStr = selectString->text();
@ -895,9 +871,9 @@ bool DailySearchTab::matchFind(Match* myMatch ,Day* day, QDate& date, Qt::Alignm
break; break;
case ST_NOTES_STRING : case ST_NOTES_STRING :
{ {
Session* journal=daily->GetJournalSession(date); Session* journal=daily->GetJournalSession(date,false);
if (journal && journal->settings.contains(Journal_Notes)) { if (journal && journal->settings.contains(Journal_Notes)) {
QString jcontents = convertRichText2Plain(journal->settings[Journal_Notes].toString()); QString jcontents = Daily::convertHtmlToPlainText(journal->settings[Journal_Notes].toString());
QString findStr = selectString->text(); QString findStr = selectString->text();
if (jcontents.contains(findStr,Qt::CaseInsensitive) ) { if (jcontents.contains(findStr,Qt::CaseInsensitive) ) {
found=true; found=true;
@ -1147,7 +1123,6 @@ void DailySearchTab::process_match_info(QString text, int topic) {
// here to select new search criteria // here to select new search criteria
// must reset all variables and label, button, etc // must reset all variables and label, button, etc
clearMatch() ; clearMatch() ;
//DEBUGFC QQ("name",match->matchName) O(match->opCodeStr) O(match->compareString) O(match->units) O(selectUnits->text());
commandWidget->show(); commandWidget->show();
match->matchName = text; match->matchName = text;
// get item selected // get item selected
@ -1733,12 +1708,6 @@ QString Match::formatTime (qint32 ms) {
return QString("%1:%2:%3").arg(hours).arg(minutes,2,10,QLatin1Char('0')).arg(seconds,2,10,QLatin1Char('0')); return QString("%1:%2:%3").arg(hours).arg(minutes,2,10,QLatin1Char('0')).arg(seconds,2,10,QLatin1Char('0'));
} }
QString DailySearchTab::convertRichText2Plain (QString rich) {
richText.setHtml(rich);
QString line=richText.toPlainText().simplified();
return line.replace(QRegExp("[\\s\\r\\n]+")," ").simplified();
}
QString DailySearchTab::opCodeStr(OpCode opCode) { QString DailySearchTab::opCodeStr(OpCode opCode) {
switch (opCode) { switch (opCode) {
case OP_LT : return "< "; case OP_LT : return "< ";

View File

@ -224,7 +224,6 @@ private:
bool helpMode=false; bool helpMode=false;
QString helpString = helpStr(); QString helpString = helpStr();
void clearMatch(); void clearMatch();
void debugStates();
void setState(STATE); void setState(STATE);
void createUi(); void createUi();
void populateControl(); void populateControl();
@ -257,7 +256,6 @@ private:
QString helpStr(); QString helpStr();
QString centerLine(QString line); QString centerLine(QString line);
QString convertRichText2Plain (QString rich);
QRegExp searchPatterToRegex (QString wildcard); QRegExp searchPatterToRegex (QString wildcard);
void addCommandItem(QString str,int topic); void addCommandItem(QString str,int topic);
float commandListItemMaxWidth = 0; float commandListItemMaxWidth = 0;
@ -283,8 +281,6 @@ private:
int DaysWithFileErrors; int DaysWithFileErrors;
void setoperation(OpCode opCode,ValueMode mode) ; void setoperation(OpCode opCode,ValueMode mode) ;
QTextDocument richText;
void process_match_info(QString text, int topic); void process_match_info(QString text, int topic);