本文整理汇总了C++中KWPage::thumbnail方法的典型用法代码示例。如果您正苦于以下问题:C++ KWPage::thumbnail方法的具体用法?C++ KWPage::thumbnail怎么用?C++ KWPage::thumbnail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KWPage
的用法示例。
在下文中一共展示了KWPage::thumbnail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant TextContentsModelImpl::data(int index, Calligra::Components::ContentsModel::Role role) const
{
if(d->entries.count() > 0) {
auto entry = d->entries.at(index);
switch(role) {
case ContentsModel::TitleRole:
return entry.title;
case ContentsModel::LevelRole:
return entry.level;
case ContentsModel::ThumbnailRole: {
if(d->thumbnails.contains(entry.pageNumber)) {
return d->thumbnails.value(entry.pageNumber);
}
if(d->thumbnailSize.isNull()) {
return QImage{};
}
QImage thumb = entry.page->thumbnail(d->thumbnailSize, d->canvas->shapeManager());
d->thumbnails.insert(entry.pageNumber, thumb);
return thumb;
}
case ContentsModel::ContentIndexRole: {
return entry.pageNumber - 1;
}
default:
return QVariant();
}
}
//Fallback behaviour when we don't have a ToC
KWPage page = d->document->pageManager()->page(index + 1);
if(!page.isValid())
return QVariant();
switch(role) {
case ContentsModel::TitleRole:
return QString(i18n("Page %1")).arg(page.pageNumber());
case ContentsModel::LevelRole:
return 0;
case ContentsModel::ThumbnailRole: {
if(d->thumbnails.contains(index)) {
return d->thumbnails.value(index);
}
if(d->thumbnailSize.isNull()) {
return QImage{};
}
QImage thumb = page.thumbnail(d->thumbnailSize, d->canvas->shapeManager());
d->thumbnails.insert(index, thumb);
return thumb;
}
case ContentsModel::ContentIndexRole: {
return index;
}
default:
return QVariant();
}
}
示例2: thumbnail
QImage TextContentsModelImpl::thumbnail(int index, int width) const
{
KWPage page = d->document->pageManager()->page( index + 1 );
return page.thumbnail(QSize{ width, int((page.height() / page.width()) * width)}, d->canvas->shapeManager());
}