/** * Update the local favorites file and add thumb if necessary. */ void favoriteWindow::save() { Favorite oldFav = m_favorite; // Update monitors int interval = ui->spinMonitoringInterval->value() * 60; Site *site = m_profile->getSites().value(ui->comboMonitoringSource->currentText()); QList<Monitor> monitors = oldFav.getMonitors(); if (interval == 0) { monitors.clear(); } else if (monitors.isEmpty()) { monitors.append(Monitor(site, interval, QDateTime::currentDateTimeUtc())); } else { Monitor rep(site, interval, monitors[0].lastCheck()); monitors[0] = rep; } m_favorite = Favorite(ui->tagLineEdit->text(), ui->noteSpinBox->value(), ui->lastViewedDateTimeEdit->dateTime(), monitors); m_favorite.setImagePath(savePath("thumbs/" + m_favorite.getName(true) + ".png")); if (oldFav.getName() != m_favorite.getName()) { if (QFile::exists(savePath("thumbs/" + oldFav.getName(true) + ".png"))) { QFile::rename(savePath("thumbs/" + oldFav.getName(true) + ".png"), m_favorite.getImagePath()); } m_profile->removeFavorite(oldFav); } if (QFile::exists(ui->imageLineEdit->text())) { QPixmap img(ui->imageLineEdit->text()); if (!img.isNull()) { m_favorite.setImage(img); } } m_profile->addFavorite(m_favorite); }