Adjust code for Qt5

This commit is contained in:
Abs62 2014-05-05 21:31:55 +04:00
parent 273b1b5757
commit 58997960ca
2 changed files with 28 additions and 28 deletions

View file

@ -32,7 +32,7 @@ bool readLine( QTcpSocket & socket, QString & line,
for( ; ; )
{
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
return false;
if( socket.canReadLine() )
@ -60,7 +60,7 @@ bool connectToServer( QTcpSocket & socket, QString const & url,
for( ; ; )
{
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
return false;
socket.connectToHost( serverUrl.host(), port );
@ -71,7 +71,7 @@ bool connectToServer( QTcpSocket & socket, QString const & url,
break;
}
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
return false;
if( !readLine( socket, reply, errorString, isCancelled ) )
@ -87,7 +87,7 @@ bool connectToServer( QTcpSocket & socket, QString const & url,
if( !socket.waitForBytesWritten( 1000 ) )
break;
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
return false;
if( !readLine( socket, reply, errorString, isCancelled ) )
@ -108,13 +108,13 @@ bool connectToServer( QTcpSocket & socket, QString const & url,
socket.write( authCommand.toUtf8() );
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
return false;
if( socket.waitForBytesWritten( 1000 ) )
break;
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
return false;
if( readLine( socket, reply, errorString, isCancelled ) )
@ -130,7 +130,7 @@ bool connectToServer( QTcpSocket & socket, QString const & url,
return true;
}
if( !isCancelled )
if( !Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
errorString = QString( "Server connection fault, socket error %1" )
.arg( QString::number( socket.error() ) );
return false;
@ -302,7 +302,7 @@ void DictServerWordSearchRequestRunnable::run()
void DictServerWordSearchRequest::run()
{
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
{
finish();
return;
@ -332,7 +332,7 @@ void DictServerWordSearchRequest::run()
socket->write( matchReq.toUtf8() );
socket->waitForBytesWritten( 1000 );
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
QString reply;
@ -340,7 +340,7 @@ void DictServerWordSearchRequest::run()
if( !readLine( *socket, reply, errorString, isCancelled ) )
break;
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
if( reply.left( 3 ) == "250" )
@ -349,7 +349,7 @@ void DictServerWordSearchRequest::run()
if( !readLine( *socket, reply, errorString, isCancelled ) )
break;
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
}
@ -379,7 +379,7 @@ void DictServerWordSearchRequest::run()
// Read matches
for( int x = 0; x <= count; x++ )
{
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
if( !readLine( *socket, reply, errorString, isCancelled ) )
@ -403,12 +403,12 @@ void DictServerWordSearchRequest::run()
matchesList.append( word );
}
}
if( isCancelled || !errorString.isEmpty() )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) || !errorString.isEmpty() )
break;
}
}
if( isCancelled || !errorString.isEmpty() )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) || !errorString.isEmpty() )
break;
matchesList.removeDuplicates();
@ -416,7 +416,7 @@ void DictServerWordSearchRequest::run()
break;
}
if( !isCancelled && errorString.isEmpty() )
if( !Qt4x5::AtomicInt::loadAcquire( isCancelled ) && errorString.isEmpty() )
{
matchesList.removeDuplicates();
@ -437,13 +437,13 @@ void DictServerWordSearchRequest::run()
gdWarning( "Prefix find in \"%s\" fault: %s\n", dict.getName().c_str(),
errorString.toUtf8().data() );
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
socket->abort();
else
disconnectFromServer( *socket );
delete socket;
if( !isCancelled )
if( !Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
finish();
}
@ -516,7 +516,7 @@ void DictServerArticleRequestRunnable::run()
void DictServerArticleRequest::run()
{
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
{
finish();
return;
@ -544,13 +544,13 @@ void DictServerArticleRequest::run()
QString reply;
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
if( !readLine( *socket, reply, errorString, isCancelled ) )
break;
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
if( reply.left( 3 ) == "250" )
@ -559,7 +559,7 @@ void DictServerArticleRequest::run()
if( !readLine( *socket, reply, errorString, isCancelled ) )
break;
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
}
@ -591,7 +591,7 @@ void DictServerArticleRequest::run()
// Read articles
for( int x = 0; x < count; x++ )
{
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
break;
if( !readLine( *socket, reply, errorString, isCancelled ) )
@ -671,7 +671,7 @@ void DictServerArticleRequest::run()
articleText += reply;
}
if( isCancelled || !errorString.isEmpty() )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) || !errorString.isEmpty() )
break;
QRegExp phonetic( "\\\\([^\\\\]+)\\\\", Qt::CaseInsensitive ); // phonetics: \stuff\ ...
@ -703,12 +703,12 @@ void DictServerArticleRequest::run()
+ "<br></div>";
}
if( isCancelled || !errorString.isEmpty() )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) || !errorString.isEmpty() )
break;
}
}
}
if( !isCancelled && errorString.isEmpty() && !articleData.empty() )
if( !Qt4x5::AtomicInt::loadAcquire( isCancelled ) && errorString.isEmpty() && !articleData.empty() )
{
Mutex::Lock _( dataMutex );
@ -723,13 +723,13 @@ void DictServerArticleRequest::run()
gdWarning( "Articles request from \"%s\" fault: %s\n", dict.getName().c_str(),
errorString.toUtf8().data() );
if( isCancelled )
if( Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
socket->abort();
else
disconnectFromServer( *socket );
delete socket;
if( !isCancelled )
if( !Qt4x5::AtomicInt::loadAcquire( isCancelled ) )
finish();
}

View file

@ -714,7 +714,7 @@ void DictServersModel::addNewServer()
QModelIndex DictServersModel::index( int row, int column, QModelIndex const & /*parent*/ ) const
{
return createIndex( row, column, 0 );
return createIndex( row, column );
}
QModelIndex DictServersModel::parent( QModelIndex const & /*parent*/ ) const