Commit 8beef33c authored by Laurent Montel's avatar Laurent Montel

Port some deprecated methods

parent db0f4771
......@@ -84,15 +84,15 @@ EditAnnotToolDialog::EditAnnotToolDialog( QWidget *parent, const QDomElement &in
widgetLayout->addWidget( m_appearanceBox, 2, 0, 1, 3 );
// Populate combobox with annotation types
m_type->addItem( i18n("Pop-up Note"), qVariantFromValue( ToolNoteLinked ) );
m_type->addItem( i18n("Inline Note"), qVariantFromValue( ToolNoteInline ) );
m_type->addItem( i18n("Freehand Line"), qVariantFromValue( ToolInk ) );
m_type->addItem( i18n("Straight Line"), qVariantFromValue( ToolStraightLine ) );
m_type->addItem( i18n("Polygon"), qVariantFromValue( ToolPolygon ) );
m_type->addItem( i18n("Text markup"), qVariantFromValue( ToolTextMarkup ) );
m_type->addItem( i18n("Geometrical shape"), qVariantFromValue( ToolGeometricalShape ) );
m_type->addItem( i18n("Stamp"), qVariantFromValue( ToolStamp ) );
m_type->addItem( i18n("Typewriter"), qVariantFromValue( ToolTypewriter ) );
m_type->addItem( i18n("Pop-up Note"), QVariant::fromValue( ToolNoteLinked ) );
m_type->addItem( i18n("Inline Note"), QVariant::fromValue( ToolNoteInline ) );
m_type->addItem( i18n("Freehand Line"), QVariant::fromValue( ToolInk ) );
m_type->addItem( i18n("Straight Line"), QVariant::fromValue( ToolStraightLine ) );
m_type->addItem( i18n("Polygon"), QVariant::fromValue( ToolPolygon ) );
m_type->addItem( i18n("Text markup"), QVariant::fromValue( ToolTextMarkup ) );
m_type->addItem( i18n("Geometrical shape"), QVariant::fromValue( ToolGeometricalShape ) );
m_type->addItem( i18n("Stamp"), QVariant::fromValue( ToolStamp ) );
m_type->addItem( i18n("Typewriter"), QVariant::fromValue( ToolTypewriter ) );
createStubAnnotation();
......
......@@ -102,7 +102,7 @@ void WidgetAnnotTools::setTools(const QStringList& items)
if ( itemText.isEmpty() )
itemText = PageViewAnnotator::defaultToolName( toolElement );
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
listEntry->setData( ToolXmlRole, qVariantFromValue(toolXml) );
listEntry->setData( ToolXmlRole, QVariant::fromValue(toolXml) );
listEntry->setIcon( PageViewAnnotator::makeToolPixmap( toolElement ) );
}
}
......@@ -136,7 +136,7 @@ void WidgetAnnotTools::slotEdit()
// Edit list entry and attach XML string as data
listEntry->setText( itemText );
listEntry->setData( ToolXmlRole, qVariantFromValue( doc.toString(-1) ) );
listEntry->setData( ToolXmlRole, QVariant::fromValue( doc.toString(-1) ) );
listEntry->setIcon( PageViewAnnotator::makeToolPixmap( toolElement ) );
// Select and scroll
......@@ -166,7 +166,7 @@ void WidgetAnnotTools::slotAdd()
// Create list entry and attach XML string as data
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
listEntry->setData( ToolXmlRole, qVariantFromValue( rootDoc.toString(-1) ) );
listEntry->setData( ToolXmlRole, QVariant::fromValue( rootDoc.toString(-1) ) );
listEntry->setIcon( PageViewAnnotator::makeToolPixmap( toolElement ) );
// Select and scroll
......
......@@ -95,7 +95,7 @@ void WidgetDrawingTools::setTools( const QStringList &items )
itemText = name;
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
listEntry->setData( ToolXmlRole, QVariant::fromValue( toolXml ) );
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
}
}
......@@ -157,7 +157,7 @@ void WidgetDrawingTools::slotAdd()
// Create list entry and attach XML string as data
const QString toolXml = rootDoc.toString( -1 );
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
listEntry->setData( ToolXmlRole, QVariant::fromValue( toolXml ) );
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
// Select and scroll
......@@ -201,7 +201,7 @@ void WidgetDrawingTools::slotEdit()
// Edit list entry and attach XML string as data
const QString toolXml = doc.toString( -1 );
listEntry->setText( itemText );
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
listEntry->setData( ToolXmlRole, QVariant::fromValue( toolXml ) );
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
// Select and scroll
......
......@@ -138,7 +138,7 @@ class Okular::FormFieldButtonPrivate : public Okular::FormFieldPrivate
QString value() const override
{
Q_Q( const FormFieldButton );
return qVariantFromValue<bool>( q->state() ).toString();
return QVariant::fromValue<bool>( q->state() ).toString();
}
};
......
......@@ -371,7 +371,7 @@ void CHMGenerator::additionalRequestData()
new Okular::ObjectRect ( Okular::NormalizedRect(r,xScale,yScale),
false,
Okular::ObjectRect::Action,
new Okular::GotoAction ( QString::null, viewport))); //krazy:exclude=nullstrassign for old broken gcc
new Okular::GotoAction ( QString(), viewport)));
}
}
}
......
......@@ -188,7 +188,7 @@ class EBook
/*!
* \brief Gets the Title of the page referenced by url.
* \param url An URL in ebook file to get title from. Must be absolute.
* \return The title, or QString::null if the URL cannot be found or not a HTML page.
* \return The title, or QString() if the URL cannot be found or not a HTML page.
*
* \ingroup dataretrieve
*/
......
......@@ -44,7 +44,7 @@ EBook_CHM::EBook_CHM()
{
m_envOptions = getenv("KCHMVIEWEROPTS");
m_chmFile = NULL;
m_filename = m_font = QString::null;
m_filename = m_font = QString();
m_textCodec = 0;
m_textCodecForSpecialFiles = 0;
......@@ -66,7 +66,7 @@ void EBook_CHM::close()
chm_close( m_chmFile );
m_chmFile = NULL;
m_filename = m_font = QString::null;
m_filename = m_font = QString();
m_home.clear();
m_topicsFile.clear();
......@@ -334,7 +334,7 @@ int EBook_CHM::findStringInQuotes (const QString& tag, int offset, QString& valu
// If we do not need to decode HTML entities, just return.
if ( decodeentities )
{
QString htmlentity = QString::null;
QString htmlentity = QString();
bool fill_entity = false;
value.reserve (qend - qbegin); // to avoid multiple memory allocations
......@@ -359,7 +359,7 @@ int EBook_CHM::findStringInQuotes (const QString& tag, int offset, QString& valu
break;
value.append ( decode );
htmlentity = QString::null;
htmlentity = QString();
fill_entity = false;
}
else
......@@ -472,7 +472,7 @@ bool EBook_CHM::parseFileAndFillArray( const QString& file, QList< ParsedEntry >
data.push_back( entry );
}
entry.name = QString::null;
entry.name = QString();
entry.urls.clear();
entry.iconid = defaultimagenum;
entry.seealso.clear();
......@@ -787,7 +787,7 @@ QString EBook_CHM::getTopicByUrl( const QUrl& url )
QMap< QUrl, QString >::const_iterator it = m_url2topics.constFind( url );
if ( it == m_url2topics.constEnd() )
return QString::null;
return QString();
return it.value();
}
......
......@@ -151,7 +151,7 @@ class EBook_CHM : public EBook
/*!
* \brief Gets the Title of the page referenced by url.
* \param url An URL in ebook file to get title from. Must be absolute.
* \return The title, or QString::null if the URL cannot be found or not a HTML page.
* \return The title, or QString() if the URL cannot be found or not a HTML page.
*
* \ingroup dataretrieve
*/
......
......@@ -139,7 +139,7 @@ class EBook_EPUB : public EBook
/*!
* \brief Gets the Title of the page referenced by url.
* \param url An URL in ebook file to get title from. Must be absolute.
* \return The title, or QString::null if the URL cannot be found or not a HTML page.
* \return The title, or QString() if the URL cannot be found or not a HTML page.
*
* \ingroup dataretrieve
*/
......
......@@ -203,7 +203,7 @@ bool EBookSearch::searchQuery(const QString & query, QList< QUrl > * results, EB
// Just add the word; it is most likely a space or terminated by tokenizer.
keeper.addTerm( term );
term = QString::null;
term = QString();
}
keeper.addTerm( term );
......
......@@ -212,7 +212,7 @@ QString HelperEntityDecoder::decode( const QString &entity ) const
if ( !valid )
{
qWarning ( "HelperEntityDecoder::decode: could not decode HTML entity '%s'", qPrintable( entity ) );
return QString::null;
return QString();
}
return (QString) (QChar( ascode ));
......
......@@ -260,7 +260,7 @@ bool Index::parseDocumentToStringlist(EBook *chmFile, const QUrl& filename, QStr
if ( ch == '&' )
{
state = STATE_IN_HTML_ENTITY;
parseentity = QString::null;
parseentity = QString();
continue;
}
......@@ -283,7 +283,7 @@ bool Index::parseDocumentToStringlist(EBook *chmFile, const QUrl& filename, QStr
tokenlist.push_back( parsedbuf.toLower() );
tokenlist.push_back( ch.toLower() );
parsedbuf = QString::null;
parsedbuf = QString();
continue;
}
......@@ -292,7 +292,7 @@ tokenize_buf:
if ( !parsedbuf.isEmpty() )
{
tokenlist.push_back( parsedbuf.toLower() );
parsedbuf = QString::null;
parsedbuf = QString();
}
}
......
......@@ -95,7 +95,7 @@ void ghostscript_interface::setBackgroundColor(const PageNumber& page, const QCo
#endif
if (pageList.value(page) == 0) {
pageInfo *info = new pageInfo(QString::null); //krazy:exclude=nullstrassign for old broken gcc
pageInfo *info = new pageInfo(QString());
info->background = background_color;
if (permanent)
info->permanentBackground = background_color;
......
......@@ -134,7 +134,7 @@ bool QUnpluck::open( const QString &fileName )
mInfo.insert( QStringLiteral("name"), QString::fromLocal8Bit(plkr_GetName( mDocument ) ));
mInfo.insert( QStringLiteral("title"), QString::fromLocal8Bit(plkr_GetTitle( mDocument ) ));
mInfo.insert( QStringLiteral("author"), QString::fromLocal8Bit(plkr_GetAuthor( mDocument ) ));
mInfo.insert( QStringLiteral("time"), QDateTime::fromTime_t( plkr_GetPublicationTime( mDocument ) ).toString() );
mInfo.insert( QStringLiteral("time"), QDateTime::fromSecsSinceEpoch( plkr_GetPublicationTime( mDocument ) ).toString() );
AddRecord( plkr_GetHomeRecordID( mDocument ) );
......
......@@ -130,7 +130,7 @@ void PopplerAnnotationProxy::notifyAddition( Okular::Annotation *okl_ann, int pa
delete ppl_page;
// Set pointer to poppler annotation as native Id
okl_ann->setNativeId( qVariantFromValue( ppl_ann ) );
okl_ann->setNativeId( QVariant::fromValue( ppl_ann ) );
okl_ann->setDisposeDataFunction( disposeAnnotation );
qCDebug(OkularPdfDebug) << okl_ann->uniqueName();
......@@ -265,7 +265,7 @@ void PopplerAnnotationProxy::notifyRemoval( Okular::Annotation *okl_ann, int pag
ppl_page->removeAnnotation( ppl_ann ); // Also destroys ppl_ann
delete ppl_page;
okl_ann->setNativeId( qVariantFromValue(0) ); // So that we don't double-free in disposeAnnotation
okl_ann->setNativeId( QVariant::fromValue(0) ); // So that we don't double-free in disposeAnnotation
qCDebug(OkularPdfDebug) << okl_ann->uniqueName();
}
......@@ -423,7 +423,7 @@ Okular::Annotation* createAnnotationFromPopplerAnnotation( Poppler::Annotation *
// TODO clone revisions
if ( tieToOkularAnn )
{
annotation->setNativeId( qVariantFromValue( ann ) );
annotation->setNativeId( QVariant::fromValue( ann ) );
annotation->setDisposeDataFunction( disposeAnnotation );
}
}
......
......@@ -252,7 +252,7 @@ QString PopplerSignatureInfo::reason() const
QDateTime PopplerSignatureInfo::signingTime() const
{
return QDateTime::fromTime_t( m_info.signingTime() );
return QDateTime::fromSecsSinceEpoch( m_info.signingTime() );
}
QByteArray PopplerSignatureInfo::signature() const
......
......@@ -986,7 +986,7 @@ void XpsHandler::processImageBrush( XpsRenderNode &node )
brush = QBrush( image );
brush.setTransform( viewboxMatrix.inverted() * viewportMatrix );
node.data = qVariantFromValue( brush );
node.data = QVariant::fromValue( brush );
}
void XpsHandler::processPath( XpsRenderNode &node )
......@@ -1173,7 +1173,7 @@ void XpsHandler::processPathGeometry( XpsRenderNode &node )
}
if ( !geom->paths.isEmpty() ) {
node.data = qVariantFromValue( geom );
node.data = QVariant::fromValue( geom );
} else {
delete geom;
}
......@@ -1262,7 +1262,7 @@ void XpsHandler::processPathFigure( XpsRenderNode &node )
}
if ( !path.isEmpty() ) {
node.data = qVariantFromValue( new XpsPathFigure( path, isFilled ) );
node.data = QVariant::fromValue( new XpsPathFigure( path, isFilled ) );
}
}
......@@ -1296,7 +1296,7 @@ void XpsHandler::processEndElement( XpsRenderNode &node )
processPath( node );
} else if (node.name == QLatin1String("MatrixTransform")) {
//TODO Ignoring x:key
node.data = qVariantFromValue( QTransform( attsToMatrix( node.attributes.value( QStringLiteral("Matrix") ) ) ) );
node.data = QVariant::fromValue( QTransform( attsToMatrix( node.attributes.value( QStringLiteral("Matrix") ) ) ) );
} else if ((node.name == QLatin1String("Canvas.RenderTransform")) || (node.name == QLatin1String("Glyphs.RenderTransform")) || (node.name == QLatin1String("Path.RenderTransform"))) {
QVariant data = node.getRequiredChildData( QStringLiteral("MatrixTransform") );
if (data.canConvert<QTransform>()) {
......@@ -1310,7 +1310,7 @@ void XpsHandler::processEndElement( XpsRenderNode &node )
processStroke( node );
} else if (node.name == QLatin1String("SolidColorBrush")) {
//TODO Ignoring opacity, x:key
node.data = qVariantFromValue( QBrush( QColor( hexToRgba( node.attributes.value( QStringLiteral("Color") ).toLatin1() ) ) ) );
node.data = QVariant::fromValue( QBrush( QColor( hexToRgba( node.attributes.value( QStringLiteral("Color") ).toLatin1() ) ) ) );
} else if (node.name == QLatin1String("ImageBrush")) {
processImageBrush( node );
} else if (node.name == QLatin1String("ImageBrush.Transform")) {
......@@ -1324,7 +1324,7 @@ void XpsHandler::processEndElement( XpsRenderNode &node )
qgrad->setStart( start );
qgrad->setFinalStop( end );
applySpreadStyleToQGradient( node.attributes.value( QStringLiteral("SpreadMethod") ), qgrad );
node.data = qVariantFromValue( QBrush( *qgrad ) );
node.data = QVariant::fromValue( QBrush( *qgrad ) );
delete qgrad;
}
} else if (node.name == QLatin1String("RadialGradientBrush")) {
......@@ -1340,7 +1340,7 @@ void XpsHandler::processEndElement( XpsRenderNode &node )
// TODO what in case of different radii?
qgrad->setRadius( qMin( radiusX, radiusY ) );
applySpreadStyleToQGradient( node.attributes.value( QStringLiteral("SpreadMethod") ), qgrad );
node.data = qVariantFromValue( QBrush( *qgrad ) );
node.data = QVariant::fromValue( QBrush( *qgrad ) );
delete qgrad;
}
} else if (node.name == QLatin1String("LinearGradientBrush.GradientStops")) {
......@@ -1354,7 +1354,7 @@ void XpsHandler::processEndElement( XpsRenderNode &node )
if ( !gradients.isEmpty() ) {
QLinearGradient * qgrad = new QLinearGradient();
addXpsGradientsToQGradient( gradients, qgrad );
node.data = qVariantFromValue< QGradient * >( qgrad );
node.data = QVariant::fromValue< QGradient * >( qgrad );
}
} else if (node.name == QLatin1String("RadialGradientBrush.GradientStops")) {
QList<XpsGradient> gradients;
......@@ -1367,7 +1367,7 @@ void XpsHandler::processEndElement( XpsRenderNode &node )
if ( !gradients.isEmpty() ) {
QRadialGradient * qgrad = new QRadialGradient();
addXpsGradientsToQGradient( gradients, qgrad );
node.data = qVariantFromValue< QGradient * >( qgrad );
node.data = QVariant::fromValue< QGradient * >( qgrad );
}
} else if (node.name == QLatin1String("PathFigure")) {
processPathFigure( node );
......
......@@ -98,7 +98,7 @@ class FileItem : public QTreeWidgetItem
setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable );
const QString fileString = document->bookmarkManager()->titleForUrl( url );
setText( 0, fileString );
setData( 0, UrlRole, qVariantFromValue( url ) );
setData( 0, UrlRole, QVariant::fromValue( url ) );
}
QVariant data( int column, int role ) const override
......
......@@ -92,7 +92,7 @@ EmbeddedFilesDialog::EmbeddedFilesDialog(QWidget *parent, const Okular::Document
twi->setText(2, ef->size() <= 0 ? i18nc("Not available size", "N/A") : KFormat().formatByteSize(ef->size()));
twi->setText(3, dateToString( ef->creationDate() ) );
twi->setText(4, dateToString( ef->modificationDate() ) );
twi->setData( 0, EmbeddedFileRole, qVariantFromValue( ef ) );
twi->setData( 0, EmbeddedFileRole, QVariant::fromValue( ef ) );
m_tw->addTopLevelItem(twi);
}
// Having filled the columns, it is nice to resize them to be able to read the contents
......
......@@ -377,7 +377,7 @@ void ProgressWidget::mousePressEvent( QMouseEvent * e )
void ProgressWidget::wheelEvent( QWheelEvent * e )
{
if ( e->delta() > 0 )
if ( e->angleDelta().y() > 0 )
emit nextPage();
else
emit prevPage();
......@@ -575,7 +575,7 @@ void PagesEdit::mousePressEvent( QMouseEvent * e )
void PagesEdit::wheelEvent( QWheelEvent * e )
{
if ( e->delta() > 0 )
if ( e->angleDelta().y() > 0 )
m_miniBar->slotEmitNextPage();
else
m_miniBar->slotEmitPrevPage();
......
......@@ -542,14 +542,14 @@ void PageView::setupViewerActions( KActionCollection * ac )
d->aTrimMargins = new KToggleAction(QIcon::fromTheme( QStringLiteral("trim-margins") ), i18n( "&Trim Margins" ), d->aTrimMode->menu() );
d->aTrimMode->addAction( d->aTrimMargins );
ac->addAction( QStringLiteral("view_trim_margins"), d->aTrimMargins );
d->aTrimMargins->setData( qVariantFromValue( (int)Okular::Settings::EnumTrimMode::Margins ) );
d->aTrimMargins->setData( QVariant::fromValue( (int)Okular::Settings::EnumTrimMode::Margins ) );
connect( d->aTrimMargins, &QAction::toggled, this, &PageView::slotTrimMarginsToggled );
d->aTrimMargins->setChecked( Okular::Settings::trimMargins() );
d->aTrimToSelection = new KToggleAction(QIcon::fromTheme( QStringLiteral("trim-to-selection") ), i18n( "Trim To &Selection" ), d->aTrimMode->menu() );
d->aTrimMode->addAction( d->aTrimToSelection);
ac->addAction( QStringLiteral("view_trim_selection"), d->aTrimToSelection);
d->aTrimToSelection->setData( qVariantFromValue( (int)Okular::Settings::EnumTrimMode::Selection ) );
d->aTrimToSelection->setData( QVariant::fromValue( (int)Okular::Settings::EnumTrimMode::Selection ) );
connect( d->aTrimToSelection, &QAction::toggled, this, &PageView::slotTrimToSelectionToggled );
d->aZoomFitWidth = new KToggleAction(QIcon::fromTheme( QStringLiteral("zoom-fit-width") ), i18n("Fit &Width"), this);
......@@ -577,7 +577,7 @@ void PageView::setupViewerActions( KActionCollection * ac )
do { \
QAction *vm = new QAction( text, this ); \
vm->setCheckable( true ); \
vm->setData( qVariantFromValue( id ) ); \
vm->setData( QVariant::fromValue( id ) ); \
d->aViewMode->addAction( vm ); \
ac->addAction( QStringLiteral(name), vm ); \
vmGroup->addAction( vm ); \
......@@ -3333,7 +3333,7 @@ void PageView::wheelEvent( QWheelEvent *e )
return;
}
int delta = e->delta(),
int delta = e->angleDelta().y(),
vScroll = verticalScrollBar()->value();
e->accept();
if ( (e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier ) {
......
......@@ -227,7 +227,7 @@ PresentationWidget::PresentationWidget( QWidget * parent, Okular::Document * doc
for ( int i = 0; i < screenCount; ++i )
{
QAction *act = m_screenSelect->addAction( i18nc( "%1 is the screen number (0, 1, ...)", "Screen %1", i ) );
act->setData( qVariantFromValue( i ) );
act->setData( QVariant::fromValue( i ) );
}
}
QWidget *spacer = new QWidget( m_topBar );
......@@ -654,7 +654,7 @@ void PresentationWidget::wheelEvent( QWheelEvent * e )
return;
// performance note: don't remove the clipping
int div = e->delta() / 120;
int div = e->angleDelta().y() / 120;
if ( div > 0 )
{
if ( div > 3 )
......
......@@ -776,7 +776,7 @@ void Sidebar::listContextMenu( const QPoint &pos )
const int itssize = static_cast< int >( _itssize ); \
QAction *sizeAct = menu.addAction( text ); \
sizeAct->setCheckable( true ); \
sizeAct->setData( qVariantFromValue( itssize ) ); \
sizeAct->setData( QVariant::fromValue( itssize ) ); \
sizeAct->setChecked( itssize == curSize ); \
sizeGroup->addAction( sizeAct ); \
}
......
......@@ -892,7 +892,7 @@ void ThumbnailListPrivate::wheelEvent( QWheelEvent * e )
if ( r.contains( e->pos() - QPoint( margin / 2, margin / 2 ) ) && e->orientation() == Qt::Vertical && e->modifiers() == Qt::ControlModifier )
{
m_document->setZoom( e->delta() );
m_document->setZoom( e->angleDelta().y() );
}
else
{
......
......@@ -403,7 +403,7 @@ bool VideoWidget::eventFilter( QObject * object, QEvent * event )
QWheelEvent * we = static_cast< QWheelEvent * >( event );
// forward wheel events to parent widget
QWheelEvent *copy = new QWheelEvent( we->pos(), we->globalPos(), we->delta(), we->buttons(), we->modifiers(), we->orientation() );
QWheelEvent *copy = new QWheelEvent( we->pos(), we->globalPos(), we->angleDelta().y(), we->buttons(), we->modifiers(), we->orientation() );
QCoreApplication::postEvent( parentWidget(), copy );
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment