Populate Favourites with days containing bookmarks, fix Daily->LoadDate() double firing

This commit is contained in:
Mark Watkins 2011-12-26 14:41:28 +10:00
parent 3d8ef6cc89
commit ebc363b4c6
4 changed files with 48 additions and 3 deletions

View File

@ -2614,8 +2614,6 @@ void gGraphView::paintGL()
redrawtimer->setInterval(20);
redrawtimer->setSingleShot(true);
redrawtimer->start();
} else {
int i=5;
}
}
}

View File

@ -533,7 +533,7 @@ void Daily::UpdateCalendarDay(QDate date)
void Daily::LoadDate(QDate date)
{
ui->calendar->setSelectedDate(date);
on_calendar_selectionChanged();
// on_calendar_selectionChanged();
}
void Daily::on_calendar_selectionChanged()
@ -1429,6 +1429,7 @@ void Daily::on_addBookmarkButton_clicked()
ui->bookmarkTable->blockSignals(false);
update_Bookmarks();
mainwin->updateFavourites();
//ui->bookmarkTable->setItem(row,2,new QTableWidgetItem(QString::number(st)));
//ui->bookmarkTable->setItem(row,3,new QTableWidgetItem(QString::number(et)));
@ -1456,6 +1457,7 @@ void Daily::update_Bookmarks()
journal->settings[Bookmark_Notes]=notes;
journal->SetChanged(true);
BookmarksChanged=true;
mainwin->updateFavourites();
}
void Daily::on_removeBookmarkButton_clicked()
@ -1467,6 +1469,7 @@ void Daily::on_removeBookmarkButton_clicked()
ui->bookmarkTable->blockSignals(false);
update_Bookmarks();
}
mainwin->updateFavourites();
}
void Daily::on_ZombieMeter_valueChanged(int action)
{

View File

@ -750,6 +750,7 @@ void MainWindow::on_summaryButton_clicked()
lastchanged=false;
if (day) {
EventDataType hours=day->hours();
if (hours>PROFILE.cpap->complianceHours()) {
@ -1012,12 +1013,40 @@ void MainWindow::on_summaryButton_clicked()
html+="</table>";
html+="</div>";
}
updateFavourites();
html+=htmlFooter();
ui->summaryView->setHtml(html);
// QString file="qrc:/docs/index.html";
// QUrl url(file);
// ui->webView->setUrl(url);
}
void MainWindow::updateFavourites()
{
ui->favouritesList->clear();
QDate date=PROFILE.LastDay();
do {
Day * journal=PROFILE.GetDay(date,MT_JOURNAL);
if (journal) {
if (journal->size()>0) {
Session *sess=(*journal)[0];
if (sess->settings.contains(Bookmark_Start)) {
QVariantList start=sess->settings[Bookmark_Start].toList();
QVariantList end=sess->settings[Bookmark_End].toList();
QStringList notes=sess->settings[Bookmark_Notes].toStringList();
if (notes.size()>0) {
QListWidgetItem *item=new QListWidgetItem(date.toString());
item->setData(Qt::UserRole,date);
ui->favouritesList->addItem(item);
}
}
}
}
date=date.addDays(-1);
} while (date>=PROFILE.FirstDay());
}
void MainWindow::on_backButton_clicked()
{
@ -2042,3 +2071,14 @@ void MainWindow::on_webView_linkClicked(const QUrl &url)
ui->webView->setUrl(url);
}
}
void MainWindow::on_favouritesList_itemSelectionChanged()
{
QListWidgetItem *item=ui->favouritesList->currentItem();
if (!item) return;
QDate date=item->data(Qt::UserRole).toDate();
if (date.isValid()) {
daily->LoadDate(date);
ui->tabWidget->setCurrentWidget(daily);
}
}

View File

@ -76,6 +76,8 @@ public:
//! \brief Log message s to Application Debug log
void Log(QString s);
//! \brief Update the list of Favourites (Bookmarks) in the right sidebar.
void updateFavourites();
//! \brief Create a new menu object in the main menubar.
QMenu * CreateMenu(QString title);
@ -253,6 +255,8 @@ private slots:
void on_webView_linkClicked(const QUrl &arg1);
void on_favouritesList_itemSelectionChanged();
private:
Ui::MainWindow *ui;