void retranslatePasswordButton()
 {
     if (_cachedCryptedPassword.isEmpty() && _cachedUncryptedPassword.isEmpty())
         ui->changePassword->setText(tkTr(Trans::Constants::SET_PASSWORD));
     else
         ui->changePassword->setText(tkTr(Trans::Constants::CHANGE_PASSWORD));
 }
 void resetModel()
 {
     q->clear();
     QFont bold;
     bold.setBold(true);
     // Create one item for each day of week
     for(int day = Qt::Monday; day <= Qt::Sunday; ++day) {
         QStandardItem *dayItem = new QStandardItem(QDate::longDayName(day));
         dayItem->setFont(bold);
         dayItem->setData(day, WeekDayRole);
         // Add availabilities to items
         const QVector<DayAvailability> &avail = m_UserCalendar->availabilities(day);
         for(int availabilityId = 0; availabilityId < avail.count(); ++availabilityId) {
             for(int timeRangeId = 0; timeRangeId < avail.at(availabilityId).timeRangeCount(); ++timeRangeId) {
                 TimeRange range = avail.at(availabilityId).timeRangeAt(timeRangeId);
                 QStandardItem *time = new QStandardItem(tkTr(Trans::Constants::FROM_1_TO_2).arg(range.from.toString()).arg(range.to.toString()));
                 time->setData(day, WeekDayRole);
                 time->setData(range.from, HourFromRole);
                 time->setData(range.to, HourToRole);
                 time->setData(timeRangeId, TimeRangeIdRole);
                 time->setData(availabilityId, AvailIdRole);
                 time->setToolTip(time->text());
                 dayItem->appendRow(time);
             }
         }
         if (dayItem->rowCount() > 0) {
             dayItem->sortChildren(0);
         }
         q->invisibleRootItem()->appendRow(dayItem);
     }
 }
Esempio n. 3
0
/** \brief Returns a readable age calculated from the date to now */
QString readableAge(const QDate &DOB)
{
    QDate current = QDate::currentDate();
    // Check anniversary
    if (current.month() == DOB.month()
            && current.day() == DOB.day()) {
        int years = current.year() - DOB.year();
        return QString("%1 %2").arg(years).arg(tkTr(YEAR_S, years));
    }
    // Compute average age
    int daysTo = DOB.daysTo(current);
    double age = daysTo / 365.242199;
    QStringList readableAge;
    // years
    int years = (int)age;
    if (years>0) {
        QString tmp = QString::number(years) + " ";
        tmp.append(tkTr(YEAR_S, years));
        readableAge << tmp;
        age -= years;
    }
    // months
    int months = age * 12;
    if (months > 0) {
        QString tmp = QString::number(months) + " ";
        age -= months / 12.0;
        tmp.append(tkTr(MONTH_S, months));
        readableAge << tmp;
    }
    int days = daysTo - (years*365.25) - (months*12);
    if (age > 0) {
        QString tmp = QString::number((int)(age*365.242199)) + " ";
        tmp.append(tkTr(DAYS, days));
        readableAge << tmp;
    }
    return readableAge.join(" ");
}