Пример #1
0
QString UiUtils::formatLastUsedDateRelative(const QDateTime & lastUsed)
{
    QString lastUsedText;
    if (lastUsed.isValid()) {
        const QDateTime now = QDateTime::currentDateTime();
        if (lastUsed.daysTo(now) == 0 ) {
            const int secondsAgo = lastUsed.secsTo(now);
            if (secondsAgo < (60 * 60 )) {
                const int minutesAgo = secondsAgo / 60;
                /*: Label for last used time for a network connection used in the last hour, as the number of minutes since usage */
                lastUsedText = QObject::tr("Last used %n minute(s) ago", "", minutesAgo);
            } else {
                const int hoursAgo = secondsAgo / (60 * 60);
                /*: Label for last used time for a network connection used in the last day, as the number of hours since usage */
                lastUsedText = QObject::tr("Last used %n hour(s) ago", "", hoursAgo);
            }
        } else if (lastUsed.daysTo(now) == 1) {
            /*: Label for last used time for a network connection used the previous day */
            lastUsedText = QObject::tr("Last used yesterday");
        } else {
            lastUsedText = QObject::tr("Last used on %1").arg(QLocale().toString(lastUsed.date(), QLocale::ShortFormat));
        }
    } else {
        /*: Label for last used time for a network connection that has never been used */
        lastUsedText =  QObject::tr("Never used");
    }
    return lastUsedText;
}
Пример #2
0
QString Utility::timeAgoInWords(const QDateTime& dt, const QDateTime& from)
{
    QDateTime now = QDateTime::currentDateTimeUtc();

    if( from.isValid() ) {
        now = from;
    }

    if( dt.daysTo(now)>0 ) {
        int dtn = dt.daysTo(now);
        return QObject::tr("%n day(s) ago", "", dtn);
    } else {
        qint64 secs = dt.secsTo(now);
        if( secs < 0 ) {
            return QObject::tr("in the future");
        }
        if( floor(secs / 3600.0) > 0 ) {
            int hours = floor(secs/3600.0);
            return( QObject::tr("%n hour(s) ago", "", hours) );
        } else {
            int minutes = qRound(secs/60.0);
            if( minutes == 0 ) {
                if(secs < 5) {
                    return QObject::tr("now");
                } else {
                    return QObject::tr("Less than a minute ago");
                }
            }
            return( QObject::tr("%n minute(s) ago", "", minutes) );
        }
    }
    return QObject::tr("Some time ago");
}
Пример #3
0
static double qwtIntervalWidth( const QDateTime &minDate,
    const QDateTime &maxDate, QwtDate::IntervalType intervalType ) 
{
    switch( intervalType )
    {
        case QwtDate::Millisecond:
        {
            const double secsTo = minDate.secsTo( maxDate );
            const double msecs = maxDate.time().msec() -
                minDate.time().msec();

            return secsTo * 1000 + msecs;
        }
        case QwtDate::Second:
        {
            return minDate.secsTo( maxDate );
        }
        case QwtDate::Minute:
        {
            const double secsTo = minDate.secsTo( maxDate );
            return ::floor( secsTo / 60 );
        }
        case QwtDate::Hour:
        {
            const double secsTo = minDate.secsTo( maxDate );
            return ::floor( secsTo / 3600 );
        }
        case QwtDate::Day:
        {
            return minDate.daysTo( maxDate );
        }
        case QwtDate::Week:
        {
            return ::floor( minDate.daysTo( maxDate ) / 7.0 );
        }
        case QwtDate::Month:
        {
            const double years = 
                double( maxDate.date().year() ) - minDate.date().year();

            int months = maxDate.date().month() - minDate.date().month();
            if ( maxDate.date().day() < minDate.date().day() )
                months--;

            return years * 12 + months;
        }
        case QwtDate::Year:
        {
            double years = 
                double( maxDate.date().year() ) - minDate.date().year();

            if ( maxDate.date().month() < minDate.date().month() )
                years -= 1.0;

            return years;
        }
    }

    return 0.0;
}
AppSettings::AppSettings(QObject *parent)
    : QObject(parent)
    , m_lastClosed(QString("") )
    , m_showTutorial(false)
{

    qDebug() << "[AppSettings::AppSettings]";

    // Set the application organization and name, which is used by QSettings
    // when saving values to the persistent store.
    QCoreApplication::setOrganizationName("Will Thrill");
    QCoreApplication::setApplicationName("Wappy");

    // Get the date and time of last time user closed the application
    m_lastClosed = this->getValueFor( AppSettings::APP_LAST_CLOSED, QString(""));

    // Determine if the long-press tutorial image should be displayed
    // rule: always show if it's been more than 1 week since user last used the app
    if( m_lastClosed.length() == 0) {
        m_showTutorial = true;
    }
    else {
        QDateTime lastClosed = QDateTime::fromString(m_lastClosed, AppSettings::APP_DATE_FORMAT);
        QDateTime now = QDateTime::currentDateTime();
        qDebug() << "[AppSettings::AppSettings] days: " << lastClosed.daysTo(now);
        setShowTutorial( lastClosed.daysTo(now) > AppSettings::APP_MAX_DAYS );
    }
}
Пример #5
0
void SelectFlashPage::reload() // TODO: we could do that more efficient :P
{
	fileList.clear();

	QDateTime time_now = QDateTime::currentDateTime();
	int row = 0;
	QList<QFileInfo> allFiles;
	getFileList(&allFiles);

	for(QList<QFileInfo>::const_iterator itr = allFiles.begin(); itr != allFiles.end(); itr++, row++)
	{
		QDateTime lastChanged = itr->lastModified();
		if( lastChanged.daysTo(time_now) == 0 )
			if( lastChanged.secsTo(time_now) <= 3600 ) { // TODO: make 3600 flexible
				int minutesLeft = (int) lastChanged.secsTo(time_now) / 60;
				if( minutesLeft < 1 ) {
					fileList.addItem(
					QString("Still loading: %1")
					.arg(itr->absoluteFilePath())
					);
					puts("a");
					fileList.item(row)->setFlags(fileList.item(row)->flags() ^ Qt::ItemIsEnabled);
					puts("c");
				}
				else
					fileList.addItem(
					QString("%1 Minutes ago: %2")
					.arg(minutesLeft)
					.arg(itr->absoluteFilePath())
					);

		}

	}
}
Пример #6
0
static QString dateString(const QDateTime& dt)
{
    QDateTime current = QDateTime::currentDateTime();
    if (dt.date() == current.date()) {
        //today
        return QString(qApp->translate("Browser", "Today %1")).arg(dt.toString("h:mm:ss ap"));
    } else if (dt.daysTo(current) == 1) {
        //yesterday
        return QString(qApp->translate("Browser", "Yesterday %1")).arg(dt.toString("h:mm:ss ap"));
    } else if (dt.daysTo(current) < 7) {
        //within 7 days
        return dt.toString("dddd h:mm:ss ap");
    } else {
        return dt.toString("dd/MM/yy h:mm:ss ap");
    }
}
Пример #7
0
void HistoryManager::checkForExpired()
{
    if (m_historyLimit < 0 || m_history.isEmpty())
        return;

    QDateTime now = QDateTime::currentDateTime();
    int nextTimeout = 0;

    while (!m_history.isEmpty()) {
        QDateTime checkForExpired = m_history.last().dateTime;
        checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit));
        if (now.daysTo(checkForExpired) > 7) {
            // check at most in a week to prevent int overflows on the timer
            nextTimeout = 7 * 86400;
        } else {
            nextTimeout = now.secsTo(checkForExpired);
        }
        if (nextTimeout > 0)
            break;
        HistoryItem item = m_history.takeLast();
        // remove from saved file also
        m_lastSavedUrl = QString();
        emit entryRemoved(item);
    }

    if (nextTimeout > 0)
        m_expiredTimer.start(nextTimeout * 1000);
}
Пример #8
0
int TidalCurrentPredictor::minutesBetween(QDateTime first, QDateTime second)
{
    int days_passed = first.daysTo(second);
    int hours_passed = second.time().hour() - first.time().hour();
    int minutes_passed = second.time().minute() - first.time().minute();
    return days_passed * 1440 + hours_passed * 60 + minutes_passed;
}
Пример #9
0
/*!
  Finds a free slot in the future which has at least the same size as
  the initial slot.
*/
bool KOEditorFreeBusy::findFreeSlot( QDateTime &dtFrom, QDateTime &dtTo )
{
  if( tryDate( dtFrom, dtTo ) )
    // Current time is acceptable
    return true;

  QDateTime tryFrom = dtFrom;
  QDateTime tryTo = dtTo;

  // Make sure that we never suggest a date in the past, even if the
  // user originally scheduled the meeting to be in the past.
  if( tryFrom < QDateTime::currentDateTime() ) {
    // The slot to look for is at least partially in the past.
    int secs = tryFrom.secsTo( tryTo );
    tryFrom = QDateTime::currentDateTime();
    tryTo = tryFrom.addSecs( secs );
  }

  bool found = false;
  while( !found ) {
    found = tryDate( tryFrom, tryTo );
    // PENDING(kalle) Make the interval configurable
    if( !found && dtFrom.daysTo( tryFrom ) > 365 )
      break; // don't look more than one year in the future
  }

  dtFrom = tryFrom;
  dtTo = tryTo;

  return found;
}
Пример #10
0
QString ConnectionDelegate::displayText(const QVariant &value, const QLocale& locale) const
{
    if (value.type() == QVariant::DateTime) {
        QDateTime lastConnected = QDateTime(value.toDateTime());
        QDateTime currentTime = QDateTime::currentDateTimeUtc();

        int daysAgo = lastConnected.daysTo(currentTime);
        if (daysAgo <= 1 && lastConnected.secsTo(currentTime) < 86400) {
            int minutesAgo = lastConnected.secsTo(currentTime) / 60;
            int hoursAgo = minutesAgo / 60;
            if (hoursAgo < 1) {
                if (minutesAgo < 1)
                    return i18n("Less than a minute ago");
                return i18np("A minute ago", "%1 minutes ago", minutesAgo);
            } else {
                return i18np("An hour ago", "%1 hours ago", hoursAgo);
            }
        } else { // 1 day or more
            if (daysAgo < 30)
                return i18np("Yesterday", "%1 days ago", daysAgo);
            if (daysAgo < 365)
                return i18np("Over a month ago", "%1 months ago", daysAgo / 30);
            return i18np("A year ago", "%1 years ago", daysAgo / 365);
        }

    }
    // These aren't the strings you're looking for, move along.
    return QStyledItemDelegate::displayText(value, locale);
}
Пример #11
0
void HistoryManager::load(void) {
  QString path = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/";
  QDir dir;
  if(!dir.mkpath(path)) {
    return;
  }
  QFile file(path + "history");
  if(!file.open(QIODevice::ReadOnly)) {
    return;
  }
  QByteArray array;
  while(!(array = file.readLine()).isEmpty()) {
    QString title = QString::fromUtf8(array.data()).trimmed();
    array = file.readLine();
    QString urlString = QString::fromUtf8(array.data()).trimmed();
    array = file.readLine();
    QString dateString = QString::fromUtf8(array.data()).trimmed();
    QDateTime date = QDateTime::fromString(dateString, "dd.MM.yyyy hh:mm");
    int days = SettingsManager::settingsManager()->historyExpirationDays();
    if(date.daysTo(QDateTime::currentDateTime()) < days) {
      addItem(QUrl(urlString), title, date);
    }
  }
  file.close();
}
Пример #12
0
StressCalculator::StressCalculator (
    QString cyclist,
	QDateTime startDate,
	QDateTime endDate,
	int shortTermDays = 7,
	int longTermDays = 42) :
	startDate(startDate), endDate(endDate), shortTermDays(shortTermDays),
	longTermDays(longTermDays),
	lastDaysIndex(-1)
{
    // calc SB for today or tomorrow?
    showSBToday = appsettings->cvalue(cyclist, GC_SB_TODAY).toInt();

    days = startDate.daysTo(endDate);

    // make vectors 1 larger in case there is a ride for today.
    // see calculateStress()
    stsvalues.resize(days+2);
    ltsvalues.resize(days+2);
    sbvalues.resize(days+2);
    xdays.resize(days+2);
    list.resize(days+2);
    ltsramp.resize(days+2);
    stsramp.resize(days+2);

    lte = (double)exp(-1.0/longTermDays);
    ste = (double)exp(-1.0/shortTermDays);
}
Пример #13
0
QString CurrentMgr::makeTimeStr(int b)
{
    QDateTime dt;
    dt.setTime_t(b);
    return (dt.daysTo(QDateTime::currentDateTime()) > 31) ? KGlobal::locale()->formatDate(dt.date(), false)
                                                          : KGlobal::locale()->formatDateTime(dt, false);
}
QString GlobalBookmarkManager::makeTimeStr(int b)
{
    QDateTime dt;
    dt.setTime_t(b);
    return (dt.daysTo(QDateTime::currentDateTime()) > 31)
        ? KGlobal::locale()->formatDate(dt.date(), KLocale::LongDate)
        : KGlobal::locale()->formatDateTime(dt, KLocale::LongDate);
}
Пример #15
0
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
QString QfsModDateText (QFileInfo Qi)
{
  QDateTime dt = Qi.lastModified();
  if (!dt.isValid()) return QString("Jan 06, 1965");
  if (dt.daysTo(QDateTime::currentDateTime()) > 300)
       return dt.toString("MMM dd, yyyy");
  else return dt.toString("MMM dd hh:mm");
}
Пример #16
0
QString DocumentListModel::prettyTime(QDateTime theTime)
{
    if( theTime.date().day() == QDateTime::currentDateTime().date().day() )
        return KGlobal::locale()->formatDateTime( theTime, KLocale::FancyShortDate );
    else if( theTime.daysTo( QDateTime::currentDateTime() ) < 7 )
        return KGlobal::locale()->formatDate( theTime.date(), KLocale::FancyShortDate );
    else
        return KGlobal::locale()->formatDate( theTime.date(), KLocale::ShortDate );
}
Пример #17
0
QString FormatDateForChat(time_t time) {
    QDateTime now(QDateTime::currentDateTime());

    QDateTime *dateTime = new QDateTime();
    dateTime->setTime_t(time);

    int daysTo = dateTime->daysTo(now);
    if (daysTo == 0) {
        return "";
    } else {
        return dateTime->toString(" dd/MM");
    }
}
Пример #18
0
QString printDateTime(const QDateTime &datetime)
{
	QString ret;
	QDateTime current_date;
	unsigned int delta;

	current_date.setTime_t(time(NULL));
//	current_date.setTime(QTime(0, 0));

	delta = datetime.daysTo(current_date);
	ret = datetime.toString("hh:mm:ss");

	if (delta != 0)
	{
		if (config_file.readBoolEntry("Look", "NiceDateFormat"))
		{
			if (delta == 1) // 1 day ago
				ret.prepend(qApp->translate("@default", "Yesterday at "));
			else if (delta < 7) // less than week ago
			{
				ret.prepend(datetime.toString(qApp->translate("@default", "dddd at ")));
				ret[0] = ret[0].toUpper(); // looks ugly lowercase ;)
			}
			else if ((delta > 7) && (delta < 14))
			{
				int tmp = delta % 7;
				if (tmp == 0)
					ret.prepend(qApp->translate("@default", "week ago at "));
				else if (tmp == 1)
					ret.prepend(qApp->translate("@default", "week and day ago at "));
				else
					ret.prepend(qApp->translate("@default", "week and %2 days ago at ").arg(delta%7));
			}
			else if (delta < 6*7)
			{
				int tmp = delta % 7;
				if (tmp == 0)
					ret.prepend(qApp->translate("@default", "%1 weeks ago at ").arg(delta/7));
				else if (tmp == 1)
					ret.prepend(qApp->translate("@default", "%1 weeks and day ago at ").arg(delta/7));
				else
					ret.prepend(qApp->translate("@default", "%1 weeks and %2 days ago at ").arg(delta/7).arg(delta%7));
			}
			else
				ret.prepend(datetime.toString(qApp->translate("@default", "d MMMM yyyy at ")));
		}
		else
			ret.append(datetime.toString(" (dd.MM.yyyy)"));
	}
	return ret;
}
Пример #19
0
QString ChatControler::dealTime(qint64 msgtime, int type)
{
    QString strDateTime("");
        QDateTime msgDateTime;
        int distance = 0;
        if (!msgtime)
        {
            return strDateTime;
        }
        msgDateTime.setMSecsSinceEpoch(msgtime);
        distance = msgDateTime.daysTo(QDateTime::currentDateTime());
        //今天
        if (qFabs(distance) <= 0)
        {
            strDateTime = msgDateTime.toString("HH:mm");
        }
        //昨天
        else if (qFabs(distance) <= 1)
        {
            if ( 1 == type)
            {
                strDateTime = "昨天";
            }
            else {
                strDateTime = "昨天" + QString::fromLocal8Bit(" ") + msgDateTime.toString("HH:mm");
            }

        }
        //前天
        else if (qFabs(distance) <= 2)
        {
            if (1 == type)
            {
                strDateTime = "前天";
            }
            else {
                strDateTime = "前天" + QString::fromLocal8Bit(" ") + msgDateTime.toString("HH:mm");
            }
        }
        else
        {
            if (1 == type)
            {
                strDateTime = msgDateTime.toString("MM月dd日");
            }
            else {
                strDateTime = msgDateTime.toString("MM月dd日") +QString::fromLocal8Bit(" ")+msgDateTime.toString("HH:mm");
            }
        }
        return strDateTime;
}
Пример #20
0
void BurnUpChartCreator::buildAllDayTicks()
{
    QDateTime date = efforts.first().date;

    int days = date.daysTo(efforts.last().date);

    int step = getXTickSize(days);

    for(int d=0; d<=days; d += step){
        xTicks.append(date.toTime_t());
        xTickLabels.append(date.toString("yyyy-MM-dd"));
        date = date.addDays(step);
    }
}
Пример #21
0
void Cache::queueObject(QVariant dataurl, QVariant callback)
{
    //qDebug() << "QueueObject callback: " << callback;
    QString namelocal;
    QString url = dataurl.toString();
    if (url.size()) {
        m_cachemap_lock.lockForRead();
        QMap<QString,QString>::iterator it = m_cachemap.find(url);
        if (it!=m_cachemap.end()) {
            //qDebug() << "cache hit" << url;
            namelocal = it.value();
            m_cachemap_lock.unlock();
            makeCallback(callback,true,namelocal);
        } else {
            //qDebug() << "cache miss" << url;
            namelocal = makeCachedURL(url);
            //qDebug() << "Hash:" << name << "Status:" << file.exists() << "URL:" << url;
#ifndef Q_WS_SIMULATOR
            {
                QFileInfo fileinfo(namelocal);
                QDateTime modif = fileinfo.lastModified();
                if (modif.daysTo(QDateTime::currentDateTime()) > CACHE_DAY_DURATION) {
                    QFile(fileinfo.absoluteFilePath()).remove();
                }
            }
#endif
            QFileInfo file(namelocal);
            if (file.exists()) {
                m_cachemap_lock.unlock();
                m_cachemap_lock.lockForWrite();
                m_cachemap.insert(url,namelocal);
                m_cachemap_lock.unlock();
                makeCallback(callback,true,namelocal);
            } else {
                m_cachemap_lock.unlock();
                if (m_cacheonly) {
                    dataurl = QVariant("");
                } else {
                    //add to queue, post and download query
                    if (queueCacheUpdate(dataurl, callback)) {
                        //qDebug() << "download " << url;
                        manager->get(QNetworkRequest(QUrl(url)));
                    }
                }
            }            
        }
    } else {
        makeCallback(callback,false,dataurl);
    }
}
Пример #22
0
void Updates::autoUpdate()
{
    QSettings settings;
    if (!settings.value("auto_update", true).toBool())
        return;
    QDateTime dt = settings.value("last_update_check", QDateTime()).toDateTime();
    QDateTime dtNow = QDateTime::currentDateTimeUtc();
    if (dt.isNull() || dt.daysTo(dtNow) > 0) {
        settings.setValue("last_update_check", dtNow);
        if (!dt.isNull()) {
            QProcess process;
            runUpdateExe(&process, UpdateDetached);
        }
    }
}
Пример #23
0
QString FormatDateForHistoryList(time_t time) {
    QDateTime now(QDateTime::currentDateTime());

    QDateTime *dateTime = new QDateTime();
    dateTime->setTime_t(time);

    int daysTo = dateTime->daysTo(now);
    if (daysTo == 0) {
        return QObject::tr("TODAY");
    } else if (daysTo == 1) {
        return QObject::tr("YESTERDAY");
    } else {
        return dateTime->toString("ddd d MMM");
    }
}
bool CWizDocumentListViewItem::isAvatarNeedUpdate(const QString& strFileName)
{
    if (!QFile::exists(strFileName)) {
        return true;
    }

    QFileInfo info(strFileName);

    QDateTime tCreated = info.created();
    QDateTime tNow = QDateTime::currentDateTime();
    if (tCreated.daysTo(tNow) >= 1) { // download avatar before yesterday
        return true;
    }

    return false;
}
//The paintEvent is connected to the updateslot
void MainWindow::eventTimerSlot(){
    QDateTime curDateTime = QDateTime::currentDateTime();
    int restDays = curDateTime.daysTo(eventDateTime);
    int restHours = eventDateTime.time().hour() - curDateTime.time().hour();
    int restMin = eventDateTime.time().minute() - curDateTime.time().minute();
    if (restMin < 0){
        restHours--;
        restMin+=60;
    }
    if (restHours < 0){
        restDays--;
        restHours+=24;
    }
    QString qStrDays = QString::number(restDays), qStrHour = QString::number(restHours), qStrMinute = QString::number(restMin);
    ui->labelLower->setText("Time until this event happens: " + qStrDays + " days, " + qStrHour + " hours and " + qStrMinute + " minutes.");
}
Пример #26
0
    void MapLogPlacemarkData::addData(const GeoObjectID &id, SinglePointDataPtr data)
    {
        if (!mData.contains(id))
        {
            QVector<SinglePointDataPtr> newHistory;
            newHistory.push_back(data);
            mData.insert(id, newHistory);
            return;
        }

        if (data->isCritical())
        {
            insert(id, data);
        }

        SinglePointDataPtr mostRecent = mData[id].last();

        QDateTime lastTime = mostRecent->time();
        QDateTime recently = lastTime.addMSecs(mostRecent->durationMs());
        QDateTime now = QDateTime::currentDateTime();
        qint64 timespan = recently.daysTo(now) * msecsInDay + recently.time().msecsTo(now.time());

        if (*data == *mostRecent)
        {   //ignore, but advance duration
            //qDebug("Data didn't change");
            mostRecent->advanceDurationMs(timespan);
            return;
        }

        if (timespan > mTimeResolution)
        {
            //qDebug("Data changed and fits in resolution, inserting");
            insert(id, data);
        }
        else
        {
            //qDebug("Data discarded");
            if (mExtraDataBehavior == MapLogPlacemarkData::Ignore)
            { //ignore data completely
                return;
            }
            else
            { //TODO compress data somehow (for now also ignore)
                return;
            }
        }
    }
Пример #27
0
bool AvatarHostPrivate::isNeedUpdate(const QString& strUserID)
{
    QString strFilePath = Utils::PathResolve::avatarPath() + strUserID + ".png";
    if (!QFile::exists(strFilePath)) {
        return true;
    }

    QPixmap pm(strFilePath);
    QFileInfo info(strFilePath);
    QDateTime tCreated = info.created();
    QDateTime tNow = QDateTime::currentDateTime();
    if (tCreated.daysTo(tNow) >= 1 || pm.isNull()) { // download avatar before yesterday or pixmap is not valid
        return true;
    }

    return false;
}
    bool Manager::fileNotExistingOrOutdated(const QString &fileName)
    {
        // if the file doesn't exist, we need to update
        if (!QFile::exists(fileName)) {
            return true;
        }

        // if the file exists, we need to check if it is old
        QDateTime fileModificationDate = QFileInfo(fileName).lastModified();
        QDateTime today                = QDateTime::currentDateTime();

        // updateInterval hardcoded to 3 days
        if (3 <= fileModificationDate.daysTo(today)) {
            return true;
        }

        return false;
    }
Пример #29
0
unsigned int ColorKeeperModel::isScreenCorrectionHasBeen(
		const unsigned int &osScreenIndex) const {
	std::string path = CORRECTION_PATH;
	path.append(getScreenProfilName(osScreenIndex));
	QFile file(path.c_str());
	if (file.exists()) {
		QFileInfo fileInfo(file);
		QDateTime creationTime = fileInfo.lastModified();
		QDateTime currentTime(QDateTime::currentDateTime());

		unsigned int day = creationTime.daysTo(currentTime);
		if (day > s_ProfilTimeLimit)
			return day - s_ProfilTimeLimit;
		else
			return 0;
	}
	return 0;

}
Пример #30
0
int QuickViewFilterModel::frecencyScore(const QModelIndex &sourceIndex) const
{
    QDateTime loadTime = sourceModel()->data(sourceIndex, HistoryModel::DateTimeRole).toDateTime();
    int days = loadTime.daysTo(m_scaleTime);

    if(days <= 1) {
        return 100;
    } else if(days < 5) {  // within the last 4 days
        return 90;
    } else if(days < 15) {  // within the last two weeks
        return 70;
    } else if(days < 31) {  // within the last month
        return 50;
    } else if(days < 91) {  // within the last 3 months
        return 30;
    }

    return 10;
}