Esempio n. 1
0
/**
 * @brief Accesses items data
 * @param index Index of item
 * @param role Role
 * @return data
 */
QVariant ConcertModel::data(const QModelIndex &index, int role) const
{
    if (index.row() < 0 || index.row() > m_concerts.count())
        return QVariant();

    if (role == Qt::UserRole)
        return index.row();

    Concert *concert = m_concerts[index.row()];
    if (index.column() == 0 && role == Qt::DisplayRole) {
        return concert->name();
    } else if (index.column() == 0 && role == Qt::ToolTipRole) {
        if (concert->files().size() == 0)
            return QVariant();
        return concert->files().at(0);
    } else if (index.column() == 1 && role == Qt::DisplayRole) {
        return concert->folderName();
    } else if (role == Qt::UserRole+1) {
        return concert->infoLoaded();
    } else if (role == Qt::UserRole+2) {
        return concert->hasChanged();
    } else if (role == Qt::ForegroundRole) {
        if (concert->hasChanged())
            return QColor(255, 0, 0);
    } else if (role == Qt::FontRole) {
        if (concert->hasChanged()) {
            QFont font;
            font.setItalic(true);
            return font;
        }
    }
    return QVariant();
}
Esempio n. 2
0
/**
 * @brief Accesses items data
 * @param index Index of item
 * @param role Role
 * @return data
 */
QVariant ConcertModel::data(const QModelIndex &index, int role) const
{
    if (index.row() < 0 || index.row() > m_concerts.count())
        return QVariant();

    if (role == Qt::UserRole)
        return index.row();

    Concert *concert = m_concerts[index.row()];
    if (index.column() == 0 && role == Qt::DisplayRole) {
        return Helper::appendArticle(concert->name());
    } else if (index.column() == 0 && role == Qt::ToolTipRole) {
        if (concert->files().size() == 0)
            return QVariant();
        return concert->files().at(0);
    } else if (index.column() == 1 && role == Qt::DisplayRole) {
        return concert->folderName();
    } else if (role == Qt::UserRole+1) {
        return concert->controller()->infoLoaded();
    } else if (role == Qt::UserRole+2) {
        return concert->hasChanged();
    } else if (role == Qt::UserRole+3) {
        return concert->syncNeeded();
    /*
    } else if (role == Qt::ForegroundRole) {
        if (concert->hasChanged())
            return QColor(255, 0, 0);
    */
    } else if (role == Qt::FontRole) {
        if (concert->hasChanged()) {
            QFont font;
            font.setItalic(true);
            return font;
        }
    } else if (role == Qt::DecorationRole) {
        if (!concert->controller()->infoLoaded())
            return m_newIcon;
        else if (concert->syncNeeded())
            return m_syncIcon;
    }
    return QVariant();
}