Commit 37455577 authored by Thomas Fischer's avatar Thomas Fischer Committed by Michael Reeves

Applying various clazy recommendations

Applying various changes suggested by clazy, including:
- const references in foreach loops
- 'midRef' instead of 'mid'
- Removing/disabling unused variables
parent 2c91e943
......@@ -332,7 +332,6 @@ int DiffTextWindow::getMaxTextWidth()
else if ( getAtomic( d->m_maxTextWidth ) < 0 )
{
d->m_maxTextWidth = 0;
QFontMetrics fm( fontMetrics() );
QTextLayout textLayout(QString(), font(), this);
for( int i = 0; i< d->m_size; ++i )
{
......@@ -1559,13 +1558,14 @@ int s_maxNofRunnables = 0;
class RecalcWordWrapRunnable : public QRunnable
{
DiffTextWindow* m_pDTW;
DiffTextWindowData* m_pDTWData;
// DiffTextWindowData* m_pDTWData; // TODO unused?
int m_visibleTextWidth;
int m_cacheIdx;
public:
RecalcWordWrapRunnable( DiffTextWindow* p, DiffTextWindowData* pData, int visibleTextWidth, int cacheIdx )
: m_pDTW(p), m_pDTWData(pData), m_visibleTextWidth(visibleTextWidth), m_cacheIdx(cacheIdx)
: m_pDTW(p), /* m_pDTWData(pData),*/ m_visibleTextWidth(visibleTextWidth), m_cacheIdx(cacheIdx)
{
Q_UNUSED(pData) // TODO really unused?
setAutoDelete(true);
//++s_runnableCount; // in Qt>=5.3 only
s_runnableCount.fetchAndAddOrdered(1);
......@@ -1790,7 +1790,6 @@ void DiffTextWindow::recalcWordWrapHelper( int wrapLineVectorSize, int visibleTe
int endIdx = qMin(firstD3LineIdx + s_linesPerRunnable, size);
int maxTextWidth = getAtomic( d->m_maxTextWidth ); // current value
QFontMetrics fm(fontMetrics());
QTextLayout textLayout(QString(), font(), this);
for (int i = firstD3LineIdx; i< endIdx; ++i)
{
......@@ -2085,7 +2084,7 @@ void EncodingLabel::mousePressEvent(QMouseEvent *)
if (m_pOptions!=0)
{
QStringList& recentEncodings = m_pOptions->m_recentEncodings;
foreach(QString s, recentEncodings)
foreach(const QString &s, recentEncodings)
{
insertCodec("", QTextCodec::codecForName(s.toLatin1()), codecEnumList, m_pContextEncodingMenu, currentTextCodecEnum);
}
......
......@@ -2251,7 +2251,6 @@ void DirectoryMergeWindow::Data::setMergeOperation( const QModelIndex& mi, e_Mer
}
mfi.m_eMergeOperation = eMOp;
QString s;
if ( bRecursive )
{
e_MergeOperation eChildrenMergeOp = mfi.m_eMergeOperation;
......
......@@ -500,7 +500,7 @@ bool FileAccess::exists() const
if ( parent() || d())
return m_bExists;
else
return QFileInfo( absoluteFilePath() ).exists();
return QFileInfo::exists(absoluteFilePath());
}
qint64 FileAccess::size() const
......@@ -1584,7 +1584,7 @@ bool FileAccessJobHandler::listDir( t_DirectoryList* pDirList, bool bRecursive,
}
else
{
foreach ( QFileInfo fi, fiList ) // for each file...
foreach ( const QFileInfo &fi, fiList ) // for each file...
{
if ( fi.fileName() == "." || fi.fileName()==".." )
continue;
......
......@@ -586,7 +586,7 @@ int MergeResultWindow::getNofLines()
int MergeResultWindow::getVisibleTextAreaWidth()
{
QFontMetrics fm = fontMetrics();
// QFontMetrics fm = fontMetrics(); // FIXME used?
return width() - getTextXOffset();
}
......@@ -2289,7 +2289,7 @@ void MergeResultWindow::keyPressEvent( QKeyEvent* e )
else
{
QString s = str.left(x);
s += str.mid( x+1 );
s += str.midRef( x+1 );
melIt->setString( s );
setModified();
}
......@@ -2326,7 +2326,7 @@ void MergeResultWindow::keyPressEvent( QKeyEvent* e )
else
{
QString s = str.left( x-1 );
s += str.mid( x );
s += str.midRef( x );
--x;
melIt->setString( s );
setModified();
......@@ -2729,7 +2729,7 @@ void MergeResultWindow::deleteSelection()
{
// This is the last line in the selection
int pos = convertToPosInText( lineString, lastPosInLine, m_pOptions->m_tabSize );
firstLineString += lineString.mid( pos ); // rest of line
firstLineString += lineString.midRef( pos ); // rest of line
melItFirst->setString( firstLineString );
}
......
......@@ -171,7 +171,7 @@ void KDiff3App::mainInit( TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, bo
errors = m_sd1.readAndPreprocess(m_sd1.getEncoding(), false);
else
errors = m_sd1.readAndPreprocess(m_pOptions->m_pEncodingA, m_pOptions->m_bAutoDetectUnicodeA);
foreach(QString error, errors)
foreach(const QString &error, errors)
{
KMessageBox::error( m_pOptionDialog, error );
}
......@@ -182,7 +182,7 @@ void KDiff3App::mainInit( TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, bo
errors = m_sd2.readAndPreprocess(m_sd2.getEncoding(), false);
else
errors = m_sd2.readAndPreprocess(m_pOptions->m_pEncodingB, m_pOptions->m_bAutoDetectUnicodeB);
foreach(QString error, errors)
foreach(const QString &error, errors)
{
KMessageBox::error( m_pOptionDialog, error );
}
......@@ -976,7 +976,7 @@ bool KDiff3App::eventFilter( QObject* o, QEvent* e )
if ( o == m_pDiffTextWindow1 ) errors = m_sd1.setData(text);
else if ( o == m_pDiffTextWindow2 ) errors = m_sd2.setData(text);
else if ( o == m_pDiffTextWindow3 ) errors = m_sd3.setData(text);
foreach(QString error, errors)
foreach(const QString &error, errors)
{
KMessageBox::error( m_pOptionDialog, error );
}
......@@ -1240,7 +1240,7 @@ void KDiff3App::slotEditPaste()
do_init = true;
}
foreach(QString error, errors)
foreach(const QString &error, errors)
{
KMessageBox::error( m_pOptionDialog, error );
}
......
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