本文整理汇总了C++中QContent::file方法的典型用法代码示例。如果您正苦于以下问题:C++ QContent::file方法的具体用法?C++ QContent::file怎么用?C++ QContent::file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QContent
的用法示例。
在下文中一共展示了QContent::file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getInformation
/*
* Find information about an Application, including what other installed applications
* there are which have binaries bigger or smaller than this one.
* Pre-requisite - the appContent is valid, ie has a backing file.
*/
QString AppViewer::getInformation( const QContent &appContent )
{
QFileInfo fi( appContent.file() );
QString info = tr( "Binary is: <b>%1</b><br>" ).arg( fi.fileName() );
qint64 chosenAppSize = fi.size();
info += tr( "Size is: <b>%1 bytes</b><br>" ).arg( chosenAppSize );
enum Count { SMALL, LARGE };
int qtopiaCounts[2] = { 0, 0 };
int packageCounts[2] = { 0, 0 };
int *currentCount;
QStringList paths = Qtopia::installPaths();
foreach ( QString p, paths )
{
QDir qDir( p + "bin" );
qDebug( "Checking %s\n", qPrintable( qDir.path() ));
if ( qDir.exists() )
{
QFileInfoList binaries = qDir.entryInfoList( QDir::Executable );
currentCount = ( p == Qtopia::packagePath() ) ? packageCounts : qtopiaCounts;
foreach ( QFileInfo f, binaries )
if ( f.size() > chosenAppSize )
++currentCount[LARGE];
else
++currentCount[SMALL];
}
示例2: documentSelected
void TextViewer::documentSelected(const QContent & docContent)
{
// make use of the document selected by the QDocumentSelector widget
docSelector->hide();
if (docContent.isValid()){
QFile f(docContent.file());
if (f.open(QIODevice::ReadOnly)){
QTextStream fstream(&f);
textArea->setHtml(fstream.readAll());
}else{
qWarning() << "Unable to read content from file" << docContent.file();
}
}else{
qWarning()<< "Document " << docContent.file() << " is invalid";
}
}
示例3: 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);
}
示例4: documentSelected
/*
* Respond to the documentSelected signal from the appSelector, by displaying
* information about the selected application.
*/
void AppViewer::documentSelected( const QContent &appContent )
{
appSelector->hide();
if ( appContent.isValid() )
{
textArea->setHtml( getInformation( appContent ));
}
else
{
textArea->setHtml(
tr( "<font color=\"#CC0000\">Could not find information about %1</font>" )
.arg( appContent.name() ));
qWarning() << "Application " << appContent.file() << " not found";
}
}
示例5: load
ImageIO::Status ImageIO::load( const QContent& lnk, int levels )
{
static const int maxSize = 2097152;
static const int maxArea = 1920000;
_lnk = lnk;
QImageReader reader( lnk.fileName() );
_format = reader.format();
QImage image;
if( reader.supportsOption( QImageIOHandler::Size ) )
{
QSize size = reader.size();
if( size.width() * size.height() > maxArea )
{
_status = SIZE_ERROR;
return _status;
}
}
else if( QFileInfo( lnk.file() ).size() > maxSize )
{
_status = SIZE_ERROR;
return _status;
}
if( reader.read( &image ) )
_status = load( image, levels );
else
_status = LOAD_ERROR;
return _status;
}