void TorrentStatistics::loadStats() { // Temp code. Versions v3.1.4 and v3.1.5 saved the data in the qbittorrent.ini file. // This code reads the data from there, writes it to the new file, and removes the keys // from the old file. This code should be removed after some time has passed. // e.g. When we reach v3.3.0 QIniSettings s_old; QIniSettings s("qBittorrent", "qBittorrent-data"); QVariantHash v; // Let's test if the qbittorrent.ini holds the key if (s_old.contains("Stats/AllStats")) { v = s_old.value("Stats/AllStats").toHash(); m_dirty = true; // If the user has used qbt > 3.1.5 and then reinstalled/used // qbt < 3.1.6, there will be stats in qbittorrent-data.ini too // so we need to merge those 2. if (s.contains("Stats/AllStats")) { QVariantHash tmp = s.value("Stats/AllStats").toHash(); v["AlltimeDL"] = v["AlltimeDL"].toULongLong() + tmp["AlltimeDL"].toULongLong(); v["AlltimeUL"] = v["AlltimeUL"].toULongLong() + tmp["AlltimeUL"].toULongLong(); } } else v = s.value("Stats/AllStats").toHash(); m_alltimeDL = v["AlltimeDL"].toULongLong(); m_alltimeUL = v["AlltimeUL"].toULongLong(); if (m_dirty) { saveStats(); s_old.remove("Stats/AllStats"); } }
void FITSHistogramCommand::undo() { FITSView *image = tab->getView(); FITSData *image_data = image->getImageData(); QApplication::setOverrideCursor(Qt::WaitCursor); if (delta != NULL) { double min,max,stddev,average,median,snr; min = image_data->getMin(); max = image_data->getMax(); stddev = image_data->getStdDev(); average = image_data->getMean(); median = image_data->getMedian(); snr = image_data->getSNR(); reverseDelta(); restoreStats(); saveStats(min, max, stddev, average, median, snr); } else { switch (type) { case FITS_ROTATE_CW: image_data->applyFilter(FITS_ROTATE_CCW); break; case FITS_ROTATE_CCW: image_data->applyFilter(FITS_ROTATE_CW); break; case FITS_FLIP_H: case FITS_FLIP_V: image_data->applyFilter(type); break; default: break; } } if (histogram != NULL) { histogram->constructHistogram(); if (tab->getViewer()->isStarsMarked()) image_data->findStars(); } image->popFilter(); image->rescale(ZOOM_KEEP_LEVEL); image->updateFrame(); QApplication::restoreOverrideCursor(); }
void TorrentStatistics::gatherStats() { libtorrent::session_status ss = m_session->getSessionStatus(); if (ss.total_download > m_sessionDL) { m_sessionDL = ss.total_download; m_dirty = true; } if (ss.total_upload > m_sessionUL) { m_sessionUL = ss.total_upload; m_dirty = true; } saveStats(); }
void Channel::readSignal() { signal = pulseIn(channelpin, HIGH, 20000); saveStats(); detectVersus(); }
void FITSHistogramCommand::redo() { FITSView *image = tab->getView(); FITSData *image_data = image->getImageData(); uint8_t *image_buffer = image_data->getImageBuffer(); unsigned int size = image_data->getSize(); int channels = image_data->getNumOfChannels(); int BBP = image_data->getBytesPerPixel(); QApplication::setOverrideCursor(Qt::WaitCursor); if (delta != NULL) { double min,max,stddev,average,median,snr; min = image_data->getMin(); max = image_data->getMax(); stddev = image_data->getStdDev(); average = image_data->getMean(); median = image_data->getMedian(); snr = image_data->getSNR(); reverseDelta(); restoreStats(); saveStats(min, max, stddev, average, median, snr); } else { saveStats(image_data->getMin(), image_data->getMax(), image_data->getStdDev(), image_data->getMean(), image_data->getMedian(), image_data->getSNR()); // If it's rotation of flip, no need to calculate delta if (type >= FITS_ROTATE_CW && type <= FITS_FLIP_V) { image_data->applyFilter(type, image_buffer); } else { uint8_t *buffer = new uint8_t[size * channels * BBP]; if (buffer == NULL) { qWarning() << "Error! not enough memory to create image buffer in redo()" << endl; QApplication::restoreOverrideCursor(); return; } memcpy(buffer, image_buffer, size * channels * BBP); float dataMin = min, dataMax = max; switch (type) { case FITS_AUTO: case FITS_LINEAR: image_data->applyFilter(FITS_LINEAR, NULL, &dataMin, &dataMax); break; case FITS_LOG: image_data->applyFilter(FITS_LOG, NULL, &dataMin, &dataMax); break; case FITS_SQRT: image_data->applyFilter(FITS_SQRT, NULL, &dataMin, &dataMax); break; default: image_data->applyFilter(type); break; } calculateDelta(buffer); delete [] buffer; } } if (histogram != NULL) { histogram->constructHistogram(); if (tab->getViewer()->isStarsMarked()) image_data->findStars(); } image->pushFilter(type); image->rescale(ZOOM_KEEP_LEVEL); image->updateFrame(); QApplication::restoreOverrideCursor(); }
TorrentStatistics::~TorrentStatistics() { if (m_dirty) m_lastWrite = 0; saveStats(); }