2004-12-05 22:47:32 +00:00
|
|
|
/***************************************************************************
|
2013-03-14 22:09:07 +00:00
|
|
|
* Copyright (C) 2004 by Albert Astals Cid <aacid@kde.org> *
|
2004-12-05 22:47:32 +00:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2007-04-19 18:30:20 +00:00
|
|
|
#include "propertiesdialog.h"
|
|
|
|
|
2005-01-02 14:37:49 +00:00
|
|
|
// qt/kde includes
|
2016-07-21 19:53:54 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileDialog>
|
2014-10-06 06:31:17 +00:00
|
|
|
#include <QIcon>
|
2016-07-21 19:53:54 +00:00
|
|
|
#include <QLayout>
|
|
|
|
#include <QLatin1Char>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QProgressBar>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
#include <QTreeView>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
#include <KIconLoader>
|
2014-10-12 15:20:07 +00:00
|
|
|
#include <KLocalizedString>
|
2016-07-21 19:53:54 +00:00
|
|
|
#include <KMessageBox>
|
|
|
|
#include <KSqueezedTextLabel>
|
2014-10-08 11:48:01 +00:00
|
|
|
#include <QMimeDatabase>
|
2004-12-05 22:47:32 +00:00
|
|
|
|
2005-01-02 14:37:49 +00:00
|
|
|
// local includes
|
|
|
|
#include "core/document.h"
|
2007-07-07 20:35:01 +00:00
|
|
|
#include "core/fontinfo.h"
|
2004-12-05 22:47:32 +00:00
|
|
|
|
2008-08-01 20:26:22 +00:00
|
|
|
static const int IsExtractableRole = Qt::UserRole;
|
|
|
|
static const int FontInfoRole = Qt::UserRole + 1;
|
|
|
|
|
2006-09-21 08:45:36 +00:00
|
|
|
PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
|
2017-09-05 21:27:18 +00:00
|
|
|
: KPageDialog( parent ), m_document( doc ), m_fontPage( nullptr ),
|
|
|
|
m_fontModel( nullptr ), m_fontInfo( nullptr ), m_fontProgressBar( nullptr ),
|
2007-07-09 12:34:08 +00:00
|
|
|
m_fontScanStarted( false )
|
2004-12-05 22:47:32 +00:00
|
|
|
{
|
2014-05-11 09:17:49 +00:00
|
|
|
setFaceType( Tabbed );
|
2014-08-14 11:35:43 +00:00
|
|
|
setWindowTitle( i18n( "Unknown File" ) );
|
|
|
|
setStandardButtons( QDialogButtonBox::Ok );
|
2014-05-11 09:17:49 +00:00
|
|
|
|
|
|
|
// PROPERTIES
|
|
|
|
QFrame *page = new QFrame();
|
|
|
|
KPageWidgetItem *item = addPage( page, i18n( "&Properties" ) );
|
2015-10-29 12:37:11 +00:00
|
|
|
item->setIcon( QIcon::fromTheme( QStringLiteral("document-properties") ) );
|
2014-05-11 09:17:49 +00:00
|
|
|
|
|
|
|
// get document info
|
|
|
|
const Okular::DocumentInfo info = doc->documentInfo();
|
|
|
|
QFormLayout *layout = new QFormLayout( page );
|
|
|
|
|
|
|
|
// mime name based on mimetype id
|
2016-07-11 20:05:18 +00:00
|
|
|
QString mimeName = info.get( Okular::DocumentInfo::MimeType ).section( QLatin1Char('/'), -1 ).toUpper();
|
2014-08-14 11:35:43 +00:00
|
|
|
setWindowTitle( i18n( "%1 Properties", mimeName ) );
|
2014-05-11 09:17:49 +00:00
|
|
|
|
|
|
|
/* obtains the properties list, conveniently ordered */
|
|
|
|
QStringList orderedProperties;
|
|
|
|
orderedProperties << Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::FilePath )
|
|
|
|
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::PagesSize )
|
|
|
|
<< Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::DocumentSize );
|
|
|
|
for (Okular::DocumentInfo::Key ks = Okular::DocumentInfo::Title;
|
|
|
|
ks <= Okular::DocumentInfo::Keywords;
|
|
|
|
ks = Okular::DocumentInfo::Key( ks+1 ) )
|
|
|
|
{
|
|
|
|
orderedProperties << Okular::DocumentInfo::getKeyString( ks );
|
2012-07-02 10:03:45 +00:00
|
|
|
}
|
2014-05-11 09:17:49 +00:00
|
|
|
foreach( const QString &ks, info.keys()) {
|
|
|
|
if ( !orderedProperties.contains( ks ) ) {
|
|
|
|
orderedProperties << ks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for ( QStringList::Iterator it = orderedProperties.begin();
|
|
|
|
it != orderedProperties.end();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
const QString key = *it;
|
|
|
|
const QString titleString = info.getKeyTitle( key );
|
|
|
|
const QString valueString = info.get( key );
|
|
|
|
if ( titleString.isNull() || valueString.isNull() )
|
2009-11-16 00:46:33 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// create labels and layout them
|
2017-09-05 21:27:18 +00:00
|
|
|
QWidget *value = nullptr;
|
2014-05-11 09:17:49 +00:00
|
|
|
if ( key == Okular::DocumentInfo::getKeyString( Okular::DocumentInfo::MimeType ) ) {
|
2013-01-01 15:56:13 +00:00
|
|
|
/// for mime type fields, show icon as well
|
|
|
|
value = new QWidget( page );
|
|
|
|
/// place icon left of mime type's name
|
|
|
|
QHBoxLayout *hboxLayout = new QHBoxLayout( value );
|
|
|
|
hboxLayout->setMargin( 0 );
|
|
|
|
/// retrieve icon and place it in a QLabel
|
2014-09-11 13:18:05 +00:00
|
|
|
QMimeDatabase db;
|
|
|
|
QMimeType mimeType = db.mimeTypeForName( valueString );
|
2013-01-01 15:56:13 +00:00
|
|
|
KSqueezedTextLabel *squeezed;
|
2014-09-11 13:18:05 +00:00
|
|
|
if (mimeType.isValid()) {
|
2013-01-01 15:56:13 +00:00
|
|
|
/// retrieve icon and place it in a QLabel
|
|
|
|
QLabel *pixmapLabel = new QLabel( value );
|
|
|
|
hboxLayout->addWidget( pixmapLabel, 0 );
|
2014-09-11 13:18:05 +00:00
|
|
|
pixmapLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType.iconName(), KIconLoader::Small ) );
|
2013-01-01 15:56:13 +00:00
|
|
|
/// mime type's name and label
|
2014-09-11 13:18:05 +00:00
|
|
|
squeezed = new KSqueezedTextLabel( i18nc( "mimetype information, example: \"PDF Document (application/pdf)\"", "%1 (%2)", mimeType.comment(), valueString ), value );
|
2013-01-01 15:56:13 +00:00
|
|
|
} else {
|
|
|
|
/// only mime type name
|
|
|
|
squeezed = new KSqueezedTextLabel( valueString, value );
|
|
|
|
}
|
|
|
|
squeezed->setTextInteractionFlags( Qt::TextSelectableByMouse );
|
|
|
|
hboxLayout->addWidget( squeezed, 1 );
|
|
|
|
} else {
|
|
|
|
/// default for any other document information
|
|
|
|
KSqueezedTextLabel *label = new KSqueezedTextLabel( valueString, page );
|
|
|
|
label->setTextInteractionFlags( Qt::TextSelectableByMouse );
|
|
|
|
value = label;
|
|
|
|
}
|
|
|
|
layout->addRow( new QLabel( i18n( "%1:", titleString ) ), value);
|
2009-11-16 00:46:33 +00:00
|
|
|
}
|
2014-05-11 09:17:49 +00:00
|
|
|
|
|
|
|
// FONTS
|
|
|
|
if ( doc->canProvideFontInformation() ) {
|
|
|
|
// create fonts tab and layout it
|
|
|
|
QFrame *page2 = new QFrame();
|
|
|
|
m_fontPage = addPage(page2, i18n("&Fonts"));
|
2015-10-29 12:37:11 +00:00
|
|
|
m_fontPage->setIcon( QIcon::fromTheme( QStringLiteral("preferences-desktop-font") ) );
|
2016-07-24 17:59:30 +00:00
|
|
|
QVBoxLayout *page2Layout = new QVBoxLayout(page2);
|
2014-05-11 09:17:49 +00:00
|
|
|
// add a tree view
|
|
|
|
QTreeView *view = new QTreeView(page2);
|
|
|
|
view->setContextMenuPolicy(Qt::CustomContextMenu);
|
2014-10-01 17:40:48 +00:00
|
|
|
connect(view, &QTreeView::customContextMenuRequested, this, &PropertiesDialog::showFontsMenu);
|
2014-05-11 09:17:49 +00:00
|
|
|
page2Layout->addWidget(view);
|
|
|
|
view->setRootIsDecorated(false);
|
|
|
|
view->setAlternatingRowColors(true);
|
|
|
|
view->setSortingEnabled( true );
|
|
|
|
// creating a proxy model so we can sort the data
|
|
|
|
QSortFilterProxyModel *proxymodel = new QSortFilterProxyModel(view);
|
|
|
|
proxymodel->setDynamicSortFilter( true );
|
|
|
|
proxymodel->setSortCaseSensitivity( Qt::CaseInsensitive );
|
|
|
|
m_fontModel = new FontsListModel(view);
|
|
|
|
proxymodel->setSourceModel(m_fontModel);
|
|
|
|
view->setModel(proxymodel);
|
|
|
|
view->sortByColumn( 0, Qt::AscendingOrder );
|
|
|
|
m_fontInfo = new QLabel( this );
|
|
|
|
page2Layout->addWidget( m_fontInfo );
|
|
|
|
m_fontInfo->setText( i18n( "Reading font information..." ) );
|
|
|
|
m_fontInfo->hide();
|
|
|
|
m_fontProgressBar = new QProgressBar( this );
|
|
|
|
page2Layout->addWidget( m_fontProgressBar );
|
|
|
|
m_fontProgressBar->setRange( 0, 100 );
|
|
|
|
m_fontProgressBar->setValue( 0 );
|
|
|
|
m_fontProgressBar->hide();
|
|
|
|
}
|
|
|
|
|
2016-07-24 17:59:30 +00:00
|
|
|
// KPageDialog is a bit buggy, it doesn't fix its own sizeHint, so we have to manually resize
|
|
|
|
resize(layout->sizeHint());
|
2007-07-07 20:35:01 +00:00
|
|
|
|
2011-07-31 19:22:04 +00:00
|
|
|
connect( pageWidget(), SIGNAL(currentPageChanged(KPageWidgetItem*,KPageWidgetItem*)),
|
|
|
|
this, SLOT(pageChanged(KPageWidgetItem*,KPageWidgetItem*)) );
|
2007-07-07 20:35:01 +00:00
|
|
|
}
|
|
|
|
|
2007-07-08 21:22:37 +00:00
|
|
|
PropertiesDialog::~PropertiesDialog()
|
|
|
|
{
|
|
|
|
m_document->stopFontReading();
|
|
|
|
}
|
|
|
|
|
2007-07-07 20:35:01 +00:00
|
|
|
void PropertiesDialog::pageChanged( KPageWidgetItem *current, KPageWidgetItem * )
|
|
|
|
{
|
|
|
|
if ( current == m_fontPage && !m_fontScanStarted )
|
|
|
|
{
|
2014-10-01 17:40:48 +00:00
|
|
|
connect(m_document, &Okular::Document::gotFont, m_fontModel, &FontsListModel::addFont);
|
|
|
|
connect(m_document, &Okular::Document::fontReadingProgress, this, &PropertiesDialog::slotFontReadingProgress);
|
|
|
|
connect(m_document, &Okular::Document::fontReadingEnded, this, &PropertiesDialog::slotFontReadingEnded);
|
2015-10-29 12:37:11 +00:00
|
|
|
QTimer::singleShot( 0, this, &PropertiesDialog::reallyStartFontReading );
|
2007-07-07 20:35:01 +00:00
|
|
|
|
|
|
|
m_fontScanStarted = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::slotFontReadingProgress( int page )
|
|
|
|
{
|
2007-12-28 17:14:10 +00:00
|
|
|
m_fontProgressBar->setValue( m_fontProgressBar->maximum() * ( page + 1 ) / m_document->pages() );
|
2007-07-07 20:35:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::slotFontReadingEnded()
|
|
|
|
{
|
|
|
|
m_fontInfo->hide();
|
|
|
|
m_fontProgressBar->hide();
|
2004-12-05 22:47:32 +00:00
|
|
|
}
|
2006-03-30 23:15:30 +00:00
|
|
|
|
2007-07-07 20:35:01 +00:00
|
|
|
void PropertiesDialog::reallyStartFontReading()
|
2006-03-30 23:15:30 +00:00
|
|
|
{
|
2007-07-07 20:35:01 +00:00
|
|
|
m_fontInfo->show();
|
|
|
|
m_fontProgressBar->show();
|
|
|
|
m_document->startFontReading();
|
|
|
|
}
|
2006-03-30 23:15:30 +00:00
|
|
|
|
2008-08-01 20:26:22 +00:00
|
|
|
void PropertiesDialog::showFontsMenu(const QPoint &pos)
|
|
|
|
{
|
|
|
|
QTreeView *view = static_cast<QTreeView*>(sender());
|
|
|
|
QModelIndex index = view->indexAt(pos);
|
|
|
|
if (index.data(IsExtractableRole).toBool())
|
|
|
|
{
|
|
|
|
QMenu *menu = new QMenu(this);
|
|
|
|
menu->addAction( i18nc("@action:inmenu", "&Extract Font") );
|
|
|
|
QAction *result = menu->exec(view->viewport()->mapToGlobal(pos));
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
Okular::FontInfo fi = index.data(FontInfoRole).value<Okular::FontInfo>();
|
|
|
|
const QString caption = i18n( "Where do you want to save %1?", fi.name() );
|
2016-07-21 19:53:54 +00:00
|
|
|
const QString path = QFileDialog::getSaveFileName( this, caption, fi.name() );
|
2008-08-01 20:26:22 +00:00
|
|
|
if ( path.isEmpty() )
|
|
|
|
return;
|
2016-07-21 19:53:54 +00:00
|
|
|
|
2008-08-01 20:26:22 +00:00
|
|
|
QFile f( path );
|
2009-12-26 20:47:58 +00:00
|
|
|
if ( f.open( QIODevice::WriteOnly ) )
|
2008-08-01 20:26:22 +00:00
|
|
|
{
|
2009-12-26 20:47:58 +00:00
|
|
|
f.write( m_document->fontData(fi) );
|
|
|
|
f.close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
KMessageBox::error( this, i18n( "Could not open \"%1\" for writing. File was not saved.", path ) );
|
2008-08-01 20:26:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-30 23:15:30 +00:00
|
|
|
FontsListModel::FontsListModel( QObject * parent )
|
|
|
|
: QAbstractTableModel( parent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FontsListModel::~FontsListModel()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-07-07 20:35:01 +00:00
|
|
|
void FontsListModel::addFont( const Okular::FontInfo &fi )
|
2006-03-30 23:15:30 +00:00
|
|
|
{
|
2006-09-28 12:21:04 +00:00
|
|
|
beginInsertRows( QModelIndex(), m_fonts.size(), m_fonts.size() );
|
2006-03-30 23:15:30 +00:00
|
|
|
|
2007-07-07 20:35:01 +00:00
|
|
|
m_fonts << fi;
|
2006-03-30 23:15:30 +00:00
|
|
|
|
|
|
|
endInsertRows();
|
|
|
|
}
|
|
|
|
|
2007-07-08 18:40:37 +00:00
|
|
|
int FontsListModel::columnCount( const QModelIndex &parent ) const
|
2006-03-30 23:15:30 +00:00
|
|
|
{
|
2008-02-26 20:08:36 +00:00
|
|
|
return parent.isValid() ? 0 : 3;
|
2006-03-30 23:15:30 +00:00
|
|
|
}
|
|
|
|
|
2007-07-07 20:35:01 +00:00
|
|
|
static QString descriptionForFontType( Okular::FontInfo::FontType type )
|
|
|
|
{
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case Okular::FontInfo::Type1:
|
|
|
|
return i18n("Type 1");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::Type1C:
|
|
|
|
return i18n("Type 1C");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::Type1COT:
|
|
|
|
return i18nc("OT means OpenType", "Type 1C (OT)");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::Type3:
|
|
|
|
return i18n("Type 3");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::TrueType:
|
|
|
|
return i18n("TrueType");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::TrueTypeOT:
|
|
|
|
return i18nc("OT means OpenType", "TrueType (OT)");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::CIDType0:
|
|
|
|
return i18n("CID Type 0");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::CIDType0C:
|
|
|
|
return i18n("CID Type 0C");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::CIDType0COT:
|
|
|
|
return i18nc("OT means OpenType", "CID Type 0C (OT)");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::CIDTrueType:
|
|
|
|
return i18n("CID TrueType");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::CIDTrueTypeOT:
|
|
|
|
return i18nc("OT means OpenType", "CID TrueType (OT)");
|
|
|
|
break;
|
2009-11-21 00:50:13 +00:00
|
|
|
case Okular::FontInfo::TeXPK:
|
|
|
|
return i18n("TeX PK");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::TeXVirtual:
|
|
|
|
return i18n("TeX virtual");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::TeXFontMetric:
|
|
|
|
return i18n("TeX Font Metric");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::TeXFreeTypeHandled:
|
|
|
|
return i18n("TeX FreeType-handled");
|
|
|
|
break;
|
2007-07-07 20:35:01 +00:00
|
|
|
case Okular::FontInfo::Unknown:
|
|
|
|
return i18nc("Unknown font type", "Unknown");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2008-02-26 20:08:36 +00:00
|
|
|
static QString pathOrDescription( const Okular::FontInfo &font )
|
2007-07-08 16:07:37 +00:00
|
|
|
{
|
2008-02-26 20:08:36 +00:00
|
|
|
switch ( font.embedType() )
|
2007-07-08 16:07:37 +00:00
|
|
|
{
|
|
|
|
case Okular::FontInfo::NotEmbedded:
|
2008-02-26 20:08:36 +00:00
|
|
|
return font.file();
|
2007-07-08 16:07:37 +00:00
|
|
|
break;
|
2007-07-08 16:23:07 +00:00
|
|
|
case Okular::FontInfo::EmbeddedSubset:
|
2008-02-26 20:08:36 +00:00
|
|
|
return i18n("Embedded (subset)");
|
2007-07-08 16:07:37 +00:00
|
|
|
break;
|
2007-07-08 16:23:07 +00:00
|
|
|
case Okular::FontInfo::FullyEmbedded:
|
2008-02-26 20:08:36 +00:00
|
|
|
return i18n("Fully embedded");
|
2007-07-08 16:07:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2008-02-26 20:16:25 +00:00
|
|
|
static QString descriptionForEmbedType( Okular::FontInfo::EmbedType type )
|
|
|
|
{
|
|
|
|
switch ( type )
|
|
|
|
{
|
|
|
|
case Okular::FontInfo::NotEmbedded:
|
|
|
|
return i18n("No");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::EmbeddedSubset:
|
|
|
|
return i18n("Yes (subset)");
|
|
|
|
break;
|
|
|
|
case Okular::FontInfo::FullyEmbedded:
|
|
|
|
return i18n("Yes");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2006-03-30 23:15:30 +00:00
|
|
|
QVariant FontsListModel::data( const QModelIndex &index, int role ) const
|
|
|
|
{
|
2008-02-26 20:03:22 +00:00
|
|
|
if ( !index.isValid() || index.row() < 0 || index.row() >= m_fonts.count() )
|
|
|
|
return QVariant();
|
2006-03-30 23:15:30 +00:00
|
|
|
|
2008-02-26 20:03:22 +00:00
|
|
|
switch ( role )
|
|
|
|
{
|
|
|
|
case Qt::DisplayRole:
|
|
|
|
switch ( index.column() )
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
QString fontname = m_fonts.at( index.row() ).name();
|
2008-02-26 20:08:36 +00:00
|
|
|
return fontname.isEmpty() ? i18nc( "font name not available (empty)", "[n/a]" ) : fontname;
|
2008-02-26 20:03:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
return descriptionForFontType( m_fonts.at( index.row() ).type() );
|
|
|
|
break;
|
|
|
|
case 2:
|
2008-02-26 20:08:36 +00:00
|
|
|
return pathOrDescription( m_fonts.at( index.row() ) );
|
2008-02-26 20:03:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-24 23:31:52 +00:00
|
|
|
break;
|
2008-02-26 20:16:25 +00:00
|
|
|
case Qt::ToolTipRole:
|
|
|
|
{
|
|
|
|
QString fontname = m_fonts.at( index.row() ).name();
|
|
|
|
if ( fontname.isEmpty() )
|
|
|
|
fontname = i18n( "Unknown font" );
|
2015-10-29 12:37:11 +00:00
|
|
|
QString tooltip = QLatin1String( "<html><b>" ) + fontname + QLatin1String( "</b>" );
|
2008-02-26 20:16:25 +00:00
|
|
|
if ( m_fonts.at( index.row() ).embedType() == Okular::FontInfo::NotEmbedded )
|
2016-10-29 14:32:24 +00:00
|
|
|
tooltip += QStringLiteral( " (<span style=\"font-family: '%1'\">%2</span>)" ).arg( fontname, fontname );
|
2015-10-29 12:37:11 +00:00
|
|
|
tooltip += QLatin1String( "<br />" ) + i18n( "Embedded: %1", descriptionForEmbedType( m_fonts.at( index.row() ).embedType() ) );
|
|
|
|
tooltip += QLatin1String( "</html>" );
|
2008-02-26 20:16:25 +00:00
|
|
|
return tooltip;
|
|
|
|
break;
|
|
|
|
}
|
2008-08-01 20:26:22 +00:00
|
|
|
case IsExtractableRole:
|
|
|
|
{
|
|
|
|
return m_fonts.at( index.row() ).canBeExtracted();
|
|
|
|
}
|
|
|
|
case FontInfoRole:
|
|
|
|
{
|
|
|
|
QVariant v;
|
|
|
|
v.setValue( m_fonts.at( index.row() ) );
|
|
|
|
return v;
|
|
|
|
}
|
2008-02-26 20:03:22 +00:00
|
|
|
}
|
|
|
|
|
2007-12-24 23:31:52 +00:00
|
|
|
return QVariant();
|
2006-03-30 23:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QVariant FontsListModel::headerData( int section, Qt::Orientation orientation, int role ) const
|
|
|
|
{
|
|
|
|
if ( orientation != Qt::Horizontal )
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
if ( role == Qt::TextAlignmentRole )
|
|
|
|
return QVariant( Qt::AlignLeft );
|
|
|
|
|
|
|
|
if ( role != Qt::DisplayRole )
|
|
|
|
return QVariant();
|
|
|
|
|
|
|
|
switch ( section )
|
|
|
|
{
|
|
|
|
case 0: return i18n( "Name" ); break;
|
|
|
|
case 1: return i18n( "Type" ); break;
|
2008-02-26 20:08:36 +00:00
|
|
|
case 2: return i18n( "File" ); break;
|
2006-03-30 23:15:30 +00:00
|
|
|
default:
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-08 18:40:37 +00:00
|
|
|
int FontsListModel::rowCount( const QModelIndex &parent ) const
|
2006-03-30 23:15:30 +00:00
|
|
|
{
|
2007-07-08 18:40:37 +00:00
|
|
|
return parent.isValid() ? 0 : m_fonts.size();
|
2006-03-30 23:15:30 +00:00
|
|
|
}
|
|
|
|
|
2014-08-08 22:00:07 +00:00
|
|
|
#include "moc_propertiesdialog.cpp"
|
2008-08-01 20:26:22 +00:00
|
|
|
|
|
|
|
/* kate: replace-tabs on; indent-width 4; */
|