Commit e14a9c58 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port some deprecated methods

parent 6ce3dc13
......@@ -26,6 +26,7 @@
#include <QDebug>
#include <QIODevice>
#include <QScopedPointer>
#include <QElapsedTimer>
class K3b::AudioMaxSpeedJob::Private
......@@ -59,7 +60,7 @@ int K3b::AudioMaxSpeedJob::Private::speedTest( K3b::AudioDataSource* source, QIO
}
}
QTime t;
QElapsedTimer t;
qint64 dataRead = 0;
qint64 r = 0;
......
......@@ -180,7 +180,7 @@ void K3b::DataJob::prepareWriting()
if( writingApp() == K3b::WritingAppCdrdao ) {
nextSessionStart += 150;
}
m_isoImager->setMultiSessionInfo( QString().sprintf( "%u,%u",
m_isoImager->setMultiSessionInfo( QString::asprintf( "%u,%u",
d->multiSessionParameterJob->previousSessionStart(),
nextSessionStart ),
d->multiSessionParameterJob->importPreviousSession() ? d->doc->burner() : 0 );
......
......@@ -499,7 +499,7 @@ void K3b::DirItem::addDataItemImpl( DataItem* item )
K3b::RootItem::RootItem( K3b::DataDoc& doc )
: K3b::DirItem( "root", 0 ),
: K3b::DirItem( "root" ),
m_doc( doc )
{
}
......
......@@ -144,7 +144,7 @@ void K3b::MsInfoFetcher::slotMediaDetectionFinished( K3b::Device::DeviceHandler*
nextSession += 15;
nextSession /= 16;
nextSession *= 16;
m_msInfo.sprintf( "16,%llu", nextSession );
m_msInfo = QString::asprintf( "16,%llu", nextSession );
jobFinished( true );
}
......
......@@ -211,9 +211,9 @@ bool K3b::LibDvdCss::crackAllKeys()
// first we get the menu vob
if( title == 0 )
filename.sprintf( "VIDEO_TS/VIDEO_TS.VOB" );
filename = QLatin1String( "VIDEO_TS/VIDEO_TS.VOB" );
else
filename.sprintf( "VIDEO_TS/VTS_%02d_%d.VOB", title, 0 );
filename = QString::asprintf( "VIDEO_TS/VTS_%02d_%d.VOB", title, 0 );
const K3b::Iso9660File* file = dynamic_cast<const K3b::Iso9660File*>( dir->entry( filename ) );
if( file && file->size() > 0 ) {
......@@ -228,7 +228,7 @@ bool K3b::LibDvdCss::crackAllKeys()
QPair<int,int> p;
int vob = 1;
for( ; vob < 100; ++vob ) {
filename.sprintf( "VIDEO_TS/VTS_%02d_%d.VOB", title, vob );
filename = QString::asprintf( "VIDEO_TS/VTS_%02d_%d.VOB", title, vob );
file = dynamic_cast<const K3b::Iso9660File*>( dir->entry( filename ) );
if( file ) {
if( file->size() % 2048 )
......
......@@ -111,7 +111,7 @@ QSize K3b::MsfEdit::sizeHint() const
const QFontMetrics fm(fontMetrics());
int h = lineEdit()->sizeHint().height();
int w = fm.width( lineEdit()->inputMask() );
int w = fm.boundingRect( lineEdit()->inputMask() ).width();
w += 2; // cursor blinking space
QStyleOptionSpinBox opt;
......
......@@ -17,7 +17,7 @@
#include <QDateTime>
#include <QDebug>
#include <QElapsedTimer>
class K3b::ThroughputEstimator::Private
{
......@@ -26,9 +26,9 @@ public:
: started(false) {
}
QTime firstDataTime;
QElapsedTimer firstDataTime;
unsigned long firstData;
QTime lastDataTime;
QElapsedTimer lastDataTime;
unsigned long lastData;
int lastThroughput;
......
......@@ -202,7 +202,7 @@ void K3b::TitleLabel::updatePositioning()
QFontMetrics subTitleFm(f);
d->titleBaseLine = contentsRect().height()/2 + titleFm.height()/2 - titleFm.descent();
d->titleLength = titleFm.width( d->title );
d->titleLength = titleFm.boundingRect( d->title ).width();
d->subTitleBaseLine = d->titleBaseLine;
......
......@@ -40,7 +40,7 @@
****************************************************************************/
//#define QPROCESS_DEBUG
#include <QElapsedTimer>
#if defined QPROCESS_DEBUG
#include <qdebug.h>
#include <QString>
......@@ -1380,7 +1380,7 @@ bool K3bQProcess::waitForBytesWritten(int msecs)
if (d->processState == ::QProcess::NotRunning)
return false;
if (d->processState == ::QProcess::Starting) {
QTime stopWatch;
QElapsedTimer stopWatch;
stopWatch.start();
bool started = waitForStarted(msecs);
if (!started)
......@@ -1416,7 +1416,7 @@ bool K3bQProcess::waitForFinished(int msecs)
if (d->processState == ::QProcess::NotRunning)
return false;
if (d->processState == ::QProcess::Starting) {
QTime stopWatch;
QElapsedTimer stopWatch;
stopWatch.start();
bool started = waitForStarted(msecs);
if (!started)
......
......@@ -41,7 +41,7 @@
//#define QPROCESS_DEBUG
#include "qdebug.h"
#include <QElapsedTimer>
#ifndef QT_NO_PROCESS
#if defined QPROCESS_DEBUG
......@@ -1002,7 +1002,7 @@ bool K3bQProcessPrivate::waitForReadyRead(int msecs)
qDebug("K3bQProcessPrivate::waitForReadyRead(%d)", msecs);
#endif
QTime stopWatch;
QElapsedTimer stopWatch;
stopWatch.start();
forever {
......@@ -1078,7 +1078,7 @@ bool K3bQProcessPrivate::waitForBytesWritten(int msecs)
if (processFlags&K3bQProcess::RawStdin)
return true;
QTime stopWatch;
QElapsedTimer stopWatch;
stopWatch.start();
while (!writeBuffer.isEmpty()) {
......@@ -1145,7 +1145,7 @@ bool K3bQProcessPrivate::waitForFinished(int msecs)
qDebug("K3bQProcessPrivate::waitForFinished(%d)", msecs);
#endif
QTime stopWatch;
QElapsedTimer stopWatch;
stopWatch.start();
forever {
......
......@@ -65,13 +65,13 @@ unsigned int K3b::VideoDVD::Time::totalFrames() const
QString K3b::VideoDVD::Time::toString( bool includeFrames ) const
{
if( includeFrames )
return QString().sprintf( "%02d:%02d:%02d.%02d",
return QString::asprintf( "%02d:%02d:%02d.%02d",
hour(),
minute(),
second(),
frame() );
else
return QString().sprintf( "%02d:%02d:%02d",
return QString::asprintf( "%02d:%02d:%02d",
hour(),
minute(),
second() + ( frame() > 0 ? 1 : 0 ) );
......
......@@ -258,7 +258,7 @@ K3b::Device::Device::Device( const Solid::Device& dev )
else
d->blockDevice = dev.as<Solid::Block>()->device();
#endif
d->writeModes = 0;
d->writeModes = {};
d->maxWriteSpeed = 0;
d->maxReadSpeed = 0;
d->burnfree = false;
......@@ -356,7 +356,7 @@ Solid::StorageAccess* K3b::Device::Device::solidStorage() const
{
QList<Solid::Device> storages = Solid::Device::listFromType( Solid::DeviceInterface::StorageAccess, d->solidDevice.udi() );
if( storages.isEmpty() )
return 0;
return nullptr;
else
return storages.first().as<Solid::StorageAccess>();
}
......@@ -370,8 +370,8 @@ bool K3b::Device::Device::init( bool bCheckWritingModes )
// they all should read CD-ROM.
//
d->readCapabilities = MEDIA_CD_ROM;
d->writeCapabilities = 0;
d->supportedProfiles = 0;
d->writeCapabilities = {};
d->supportedProfiles = {};
if( !open() )
return false;
......@@ -651,7 +651,7 @@ bool K3b::Device::Device::readsDvd() const
K3b::Device::DeviceTypes K3b::Device::Device::type() const
{
DeviceTypes r = 0;
DeviceTypes r = {};
if( readCapabilities() & MEDIA_CD_ROM )
r |= DEVICE_CD_ROM;
if( writeCapabilities() & MEDIA_CD_R )
......@@ -3663,7 +3663,7 @@ QByteArray K3b::Device::Device::mediaId( int mediaType ) const
UByteArray data;
if( readDvdStructure( data, 0x0E ) ) {
if( data[4+16] == 3 && data[4+24] == 4 ) {
id.sprintf( "%6.6s%-6.6s", data.data()+4+17, data.data()+4+25 );
id = QString::asprintf( "%6.6s%-6.6s", data.data()+4+17, data.data()+4+25 );
}
}
}
......@@ -3672,7 +3672,7 @@ QByteArray K3b::Device::Device::mediaId( int mediaType ) const
UByteArray data;
if( readDvdStructure( data, 0x11 ) ||
readDvdStructure( data, 0x0 ) ) {
id.sprintf( "%8.8s/%3.3s", data.data()+23, data.data()+31 );
id = QString::asprintf( "%8.8s/%3.3s", data.data()+23, data.data()+31 );
}
}
......@@ -3680,7 +3680,7 @@ QByteArray K3b::Device::Device::mediaId( int mediaType ) const
UByteArray data;
if( readDiscStructure( data, 1, 0 ) ) {
if( data[4+0] == 'D' && data[4+1] == 'I' )
id.sprintf ("%6.6s/%-3.3s", data.data()+4+100, data.data()+4+106 );
id = QString::asprintf ("%6.6s/%-3.3s", data.data()+4+100, data.data()+4+106 );
}
}
......
......@@ -204,7 +204,7 @@ void K3b::Device::debugBitfield( unsigned char* data, long len )
{
for( int i = 0; i < len; ++i ) {
QString index, bitString;
index.sprintf( "%4i", i );
index = QString::asprintf( "%4i", i );
for( int bp = 7; bp >= 0; --bp )
bitString[7-bp] = ( data[i] & (1<<bp) ? '1' : '0' );
qDebug() << index << " - " << bitString << " - " << (int)data[i];
......
......@@ -235,9 +235,9 @@ QString K3b::Msf::toString( bool showFrames ) const
QString str;
if( showFrames )
str.sprintf( "%.2i:%.2i:%.2i", d->minutes, d->seconds, d->frames );
str = QString::asprintf( "%.2i:%.2i:%.2i", d->minutes, d->seconds, d->frames );
else
str.sprintf( "%.2i:%.2i", d->minutes, d->seconds );
str = QString::asprintf( "%.2i:%.2i", d->minutes, d->seconds );
return str;
}
......
......@@ -475,7 +475,7 @@ void K3b::MediaCopyDialog::toggleAll()
// selection of the writing mode
//
if( burnDev == readDev ) {
K3b::WritingModes modes = 0;
K3b::WritingModes modes = WritingModeAuto;
if ( sourceMedium.diskInfo().mediaType() & K3b::Device::MEDIA_CD_ALL ) {
modes = K3b::WritingModeTao|K3b::WritingModeSao|K3b::WritingModeRaw;
}
......
......@@ -166,7 +166,7 @@ void K3b::MediaFormattingDialog::slotStartClicked()
void K3b::MediaFormattingDialog::toggleAll()
{
K3b::Medium medium = k3bappcore->mediaCache()->medium( m_writerSelectionWidget->writerDevice() );
K3b::WritingModes modes = 0;
K3b::WritingModes modes = WritingModeAuto;
if ( medium.diskInfo().mediaType() & (K3b::Device::MEDIA_DVD_RW|K3b::Device::MEDIA_DVD_RW_SEQ|K3b::Device::MEDIA_DVD_RW_OVWR) ) {
modes |= K3b::WritingModeIncrementalSequential|K3b::WritingModeRestrictedOverwrite;
}
......
......@@ -215,7 +215,7 @@ void K3b::FillStatusDisplayWidget::paintEvent( QPaintEvent* )
// if there is not enough space we just align it left
// ====================================================================================
int docSizeTextPos = 0;
int docSizeTextLength = fontMetrics().width(docSizeText);
int docSizeTextLength = fontMetrics().boundingRect(docSizeText).width();
if( docSizeTextLength + 5 > crect.width() ) {
docSizeTextPos = crect.left() + 5; // a little margin
}
......@@ -234,7 +234,7 @@ void K3b::FillStatusDisplayWidget::paintEvent( QPaintEvent* )
overSizeFont.setBold(false);
QRect overSizeTextRect( barRect );
int overSizeTextLength = QFontMetrics(overSizeFont).width(overSizeText);
int overSizeTextLength = QFontMetrics(overSizeFont).boundingRect(overSizeText).width();
if( overSizeTextLength + 5 > overSizeTextRect.width() - (int)(one*cdSize.totalFrames()) ) {
// we don't have enough space on the right, so we paint to the left of the line
overSizeTextRect.setLeft( (int)(one*cdSize.totalFrames()) - overSizeTextLength - 5 );
......
......@@ -38,7 +38,7 @@ public:
void VolumeNameWidget::Private::fontChanged( const QFontMetrics& fontMetrics )
{
volumeNameEdit->setMaximumWidth( fontMetrics.width('A')*50 );
volumeNameEdit->setMaximumWidth( fontMetrics.boundingRect('A').width()*50 );
}
......
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