当前位置: 首页>>代码示例>>C++>>正文


C++ QContent::lastUpdated方法代码示例

本文整理汇总了C++中QContent::lastUpdated方法的典型用法代码示例。如果您正苦于以下问题:C++ QContent::lastUpdated方法的具体用法?C++ QContent::lastUpdated怎么用?C++ QContent::lastUpdated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QContent的用法示例。


在下文中一共展示了QContent::lastUpdated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: thumbnail

/*!
    Loads a thumbnail representation of \a content.  The thumbnail will be scaled to \a size
    according to the given aspect ratio mode.
*/
QImage QContentStore::thumbnail(const QContent &content, const QSize &size, Qt::AspectRatioMode mode)
{
    QImage thumbnail;

    QString thumbPath = thumbnailPath(content.fileName());

    QFileInfo thumbInfo(thumbPath);

    if (thumbInfo.exists()) {
        if (thumbInfo.lastModified() > content.lastUpdated())
            thumbnail = readThumbnail(thumbPath, size, mode);
    } else {
        thumbnail = QContentFactory::thumbnail(content, size, mode);
    }

    if (thumbnail.isNull()) {
        if (QIODevice *device = content.open()) {
            QImageReader reader(device);

            if (reader.canRead()) {
                QSize scaledSize = reader.size();

                reader.setQuality(25);
                if (scaledSize.width() > 128 || scaledSize.height() > 128) {
                    scaledSize.scale(QSize(128, 128), Qt::KeepAspectRatio);

                    reader.setQuality( 49 ); // Otherwise Qt smooth scales
                    reader.setScaledSize(scaledSize);
                    reader.read(&thumbnail);

                    if (!thumbnail.isNull()) {
                        QImageWriter writer(thumbPath, QByteArray::fromRawData("PNG", 3));
                        writer.setQuality(25);
                        writer.write(thumbnail);

                        if (size.isValid())
                            thumbnail = thumbnail.scaled(size, mode);
                    }
                } else {
                    if (size.isValid()) {
                        scaledSize.scale(size, mode);
                        reader.setQuality( 49 ); // Otherwise Qt smooth scales
                        reader.setScaledSize(scaledSize);
                    }
                    reader.read(&thumbnail);
                }
            }

            delete device;
        }
    }

    if (thumbnail.isNull() && content.type().startsWith(m_audioPrefix)) {
        QDir dir = QFileInfo(content.fileName()).absoluteDir();

        foreach (const QString &fileName, m_folderThumbnails) {
            if (dir.exists(fileName)) {
                thumbnail = readThumbnail(dir.absoluteFilePath(fileName), size, mode);
                break;
            }
        }
    }
开发者ID:Camelek,项目名称:qtmoko,代码行数:66,代码来源:qcontentstore.cpp

示例2: paint

void ThumbnailDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    Q_ASSERT(index.isValid());
    const QContentSetModel *model = qobject_cast< const QContentSetModel * >( index.model() );
    Q_ASSERT(model);

    QStyleOptionViewItem opt = option;

    // set text alignment
    opt.displayAlignment = Qt::AlignCenter;

    // do layout
    QContent content = model->content( index );
    QPixmap pixmap;

    if( content.fileKnown() ) {
        pixmap = repository_->thumbnail( ThumbnailRequest( index, content.file(), option.decorationSize, content.lastUpdated() ) );
    }
    if( pixmap.isNull() ) {
        QIcon icon = qvariant_cast<QIcon>(model->data(index, Qt::DecorationRole));
        pixmap = icon.pixmap( option.decorationSize );
    }
    QRect pixmapRect = QRect(0, 0, option.decorationSize.width(),
                           option.decorationSize.height());

    QFontMetrics fontMetrics(opt.font);
    QString text = model->data(index, Qt::DisplayRole).toString();
    QRect textRect(0, 0, option.decorationSize.width(), fontMetrics.lineSpacing());

    QVariant value = model->data(index, Qt::CheckStateRole);
    QRect checkRect = check(opt, opt.rect, value);
    Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt());

    doLayout(opt, &checkRect, &pixmapRect, &textRect, false);

    // draw the background color
    if (option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
        QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                                  ? QPalette::Normal : QPalette::Disabled;
        painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
    } else {
        value = model->data(index, Qt::BackgroundColorRole);
        if (value.isValid() && qvariant_cast<QColor>(value).isValid())
            painter->fillRect(option.rect, qvariant_cast<QColor>(value));
    }

    // draw the item
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, pixmapRect, pixmap);
    drawDisplay(painter, opt, textRect, text);
    drawFocus(painter, opt, textRect);
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:52,代码来源:thumbnailview_p.cpp

示例3: loadThumbs

void CameraMainWindow::loadThumbs( bool resized )
{
    int i = 0;
    showWaitScreen();
    for (; i < nthumb && i < m_photoModel->rowCount(); ++i)
    {
        QContent content = m_photoModel->content(i);
        if (resized || picturefile[i].id() != content.id() || picturefile[i].lastUpdated() != content.lastUpdated()) {
            picturefile[i] = content;

            thumb[i]->setIcon(QThumbnail(picturefile[i].fileName()).pixmap(QSize(thumbw, thumbh)));
            thumb[i]->setEnabled(true);
        }
    }

    for (; i < nthumb; ++i) {
        picturefile[i] = QContent();
        thumb[i]->setIcon(QIcon());
        thumb[i]->setEnabled(false);
    }

    if ( cur_thumb >= 0 )
        selectThumb(cur_thumb);

    if ( !camera->videocaptureview->available() ) {
        if(settings)
            a_timer->setVisible(false);
        camera->photo->setEnabled(false);
        camera->video->setEnabled(false);
        if (m_photoModel->rowCount() == 0) {
            thumb[0]->setEnabled(false);
        } else {
            thumb[0]->setFocus();
            thumb[0]->setEnabled(true);
        }
    }

    if(settings)
        updateActions();
    hideWaitScreen();
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:41,代码来源:mainwindow.cpp


注:本文中的QContent::lastUpdated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。