fix merge conflict with feature/deprecated

This commit is contained in:
xiaoyifang 2022-02-03 17:50:47 +08:00
commit 0c94406e2a
31 changed files with 75 additions and 71 deletions

View file

@ -940,8 +940,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
quint16 volumes = qFromBigEndian( dictHeader.totalVolumes );
if( volumes > 1 )
{
QString ss;
ss.sprintf( " (%i/%i)", qFromBigEndian( dictHeader.volume ), volumes );
QString ss=QString( " (%1/%2)").arg( qFromBigEndian( dictHeader.volume ), volumes );
dictName += ss.toLocal8Bit().data();
}

View file

@ -32,7 +32,7 @@ using std::string;
connect( baseReply, SIGNAL( metaDataChanged() ), this, SLOT( applyMetaData() ) );
connect( baseReply, SIGNAL( error( QNetworkReply::NetworkError) ),
connect( baseReply, SIGNAL( errorOccurred( QNetworkReply::NetworkError) ),
this, SLOT( applyError( QNetworkReply::NetworkError ) ) );
connect( baseReply, SIGNAL( readyRead() ), this, SLOT( readDataFromBase() ) );
@ -113,8 +113,8 @@ using std::string;
baseReply->attribute( QNetworkRequest::HttpPipeliningWasUsedAttribute ) );
setAttribute( QNetworkRequest::BackgroundRequestAttribute,
baseReply->attribute( QNetworkRequest::BackgroundRequestAttribute ) );
setAttribute( QNetworkRequest::SpdyWasUsedAttribute,
baseReply->attribute( QNetworkRequest::SpdyWasUsedAttribute ) );
setAttribute( QNetworkRequest::Http2WasUsedAttribute,
baseReply->attribute( QNetworkRequest::Http2WasUsedAttribute ) );
emit metaDataChanged();
}
@ -133,7 +133,7 @@ using std::string;
void AllowFrameReply::applyError( QNetworkReply::NetworkError code )
{
setError( code, baseReply->errorString() );
emit error( code );
emit errorOccurred( code );
}
void AllowFrameReply::readDataFromBase()
@ -283,7 +283,7 @@ QNetworkReply * ArticleNetworkAccessManager::createRequest( Operation op,
QNetworkRequest newReq(req);
if ( hideGoldenDictHeader && req.url().scheme().startsWith("http", Qt::CaseInsensitive))
{
newReq.setRawHeader("User-Agent", req.rawHeader("User-Agent").replace(qApp->applicationName(), ""));
newReq.setRawHeader("User-Agent", req.rawHeader("User-Agent").replace(qApp->applicationName().toUtf8(), ""));
}
QNetworkReply * reply = QNetworkAccessManager::createRequest( op, newReq, outgoingData );
@ -336,8 +336,8 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource(
// See if we have some dictionaries muted
QSet< QString > mutedDicts =
QSet< QString >::fromList( Utils::Url::queryItemValue( url, "muted" ).split( ',' ) );
QStringList mutedDictLists=Utils::Url::queryItemValue( url, "muted" ).split( ',' );
QSet< QString > mutedDicts ( mutedDictLists.begin(),mutedDictLists.end());
// Unpack contexts
@ -525,7 +525,7 @@ void ArticleResourceReply::readyReadSlot()
void ArticleResourceReply::finishedSlot()
{
if (req->dataSize() < 0) {
emit error(ContentNotFoundError);
emit errorOccurred(ContentNotFoundError);
setError(ContentNotFoundError, "content not found");
}

View file

@ -856,15 +856,17 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev )
int delta = result == Gestures::SWIPE_UP ? -120 : 120;
QWidget *widget = static_cast< QWidget * >( obj );
QPoint angleDelta(0, delta);
QPoint pixelDetal;
QWidget *child = widget->childAt( widget->mapFromGlobal( pt ) );
if( child )
{
QWheelEvent whev( child->mapFromGlobal( pt ), pt, delta, Qt::NoButton, Qt::NoModifier );
QWheelEvent whev( child->mapFromGlobal( pt ), pt, pixelDetal,angleDelta, Qt::NoButton, Qt::NoModifier,Qt::NoScrollPhase,false);
qApp->sendEvent( child, &whev );
}
else
{
QWheelEvent whev( widget->mapFromGlobal( pt ), pt, delta, Qt::NoButton, Qt::NoModifier );
QWheelEvent whev( widget->mapFromGlobal( pt ), pt,pixelDetal, angleDelta,Qt::NoButton, Qt::NoModifier,Qt::NoScrollPhase,false );
qApp->sendEvent( widget, &whev );
}
}

View file

@ -98,7 +98,7 @@ bool ArticleWebView::eventFilter(QObject *obj, QEvent *ev) {
void ArticleWebView::mousePressEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::MidButton)
if (event->buttons() & Qt::MiddleButton)
midButtonPressed = true;
}
@ -127,7 +127,7 @@ void ArticleWebView::sendCustomMouseEvent( QEvent::Type type) {
}
void ArticleWebView::mouseReleaseEvent(QMouseEvent *event) {
bool noMidButton = !( event->buttons() & Qt::MidButton );
bool noMidButton = !( event->buttons() & Qt::MiddleButton );
if ( midButtonPressed & noMidButton )
midButtonPressed = false;
@ -169,7 +169,7 @@ void ArticleWebView::wheelEvent( QWheelEvent *ev )
SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &nLines, 0 );
if( nLines == WHEEL_PAGESCROLL )
{
QKeyEvent kev( QEvent::KeyPress, ev->delta() > 0 ? Qt::Key_PageUp : Qt::Key_PageDown,
QKeyEvent kev( QEvent::KeyPress, ev->angleDelta ().y () > 0 ? Qt::Key_PageUp : Qt::Key_PageDown,
Qt::NoModifier );
auto childrens = this->children();
for (auto child : childrens) {

View file

@ -1437,16 +1437,17 @@ void BtreeIndex::getHeadwordsFromOffsets( QList<uint32_t> & offsets,
for( unsigned i = 0; i < result.size(); i++ )
{
QList< uint32_t >::Iterator it = qBinaryFind( begOffsets, endOffsets,
result.at( i ).articleOffset );
uint32_t articleOffset = result.at(i).articleOffset;
QList<uint32_t>::Iterator it = std::lower_bound( begOffsets, endOffsets,
articleOffset );
if( it != offsets.end() )
if( it!=offsets.end())
{
if( isCancelled && Utils::AtomicInt::loadAcquire( *isCancelled ) )
return;
headwords.append( QString::fromUtf8( ( result[ i ].prefix + result[ i ].word ).c_str() ) );
offsets.erase( it );
offsets.erase( it);
begOffsets = offsets.begin();
endOffsets = offsets.end();
}

View file

@ -487,13 +487,13 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles,
ZipFile::SplitZipFile zf( name );
if( !zf.exists() )
return true;
ts = zf.lastModified().toTime_t();
ts = zf.lastModified().toSecsSinceEpoch();
}
else
{
if ( !fileInfo.exists() )
return true;
ts = fileInfo.lastModified().toTime_t();
ts = fileInfo.lastModified().toSecsSinceEpoch();
}
if ( ts > lastModified )
@ -505,7 +505,7 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles,
if ( !fileInfo.exists() )
return true;
return fileInfo.lastModified().toTime_t() < lastModified;
return fileInfo.lastModified().toSecsSinceEpoch() < lastModified;
}
QString generateRandomDictionaryId()

View file

@ -211,7 +211,7 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended )
{
QString command( editDictionaryCommand );
command.replace( "%GDDICT%", "\"" + dictFilename + "\"" );
if( !QProcess::startDetached( command ) )
if( !QProcess::startDetached( command ,QStringList()) )
QApplication::beep();
}

View file

@ -957,9 +957,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
vector< sptr< Dictionary::Class > > dictionaries;
vector< string > dictFiles;
QByteArray catName;
catName += QDir::separator();
catName += "catalogs";
QByteArray catName = QString("%1catalogs").arg(QDir::separator()).toUtf8();
for( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end();
++i )

View file

@ -1732,8 +1732,7 @@ QByteArray EpwingBook::handleReference( EB_Hook_Code code, const unsigned int *
if( refOpenCount > refCloseCount )
return QByteArray();
QString str;
str.sprintf( "<R%i>", refOpenCount );
QString str=QString( "<R%1>").arg( refOpenCount );
refOpenCount += 1;
return str.toUtf8();
}
@ -1747,7 +1746,7 @@ QByteArray EpwingBook::handleReference( EB_Hook_Code code, const unsigned int *
refOffsets.append( argv[ 2 ] );
QString str;
str.sprintf( "</R%i>", refCloseCount );
str.asprintf( "</R%i>", refCloseCount );
refCloseCount += 1;
return str.toUtf8();

View file

@ -110,14 +110,12 @@ void ExtLineEdit::updateButtonPositions()
iconPos = (iconPos == Left ? Right : Left);
if (iconPos == ExtLineEdit::Right) {
int right;
getTextMargins(0, 0, &right, 0);
const int iconoffset = right + 4;
QMargins qm=textMargins();
const int iconoffset = qm.right() + 4;
iconButtons[i]->setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0));
} else {
int left;
getTextMargins(&left, 0, 0, 0);
const int iconoffset = left + 4;
QMargins qm=textMargins();
const int iconoffset = qm.left() + 4;
iconButtons[i]->setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0));
}
}

View file

@ -907,7 +907,9 @@ void FavoritesModel::removeItemsForIndexes( const QModelIndexList & idxList )
for( int i = lowestLevel; i >= 0; i-- )
{
QModelIndexList idxSublist = itemsToDelete[ i ];
std::sort( idxSublist.begin(), idxSublist.end(), qGreater< QModelIndex >() );
//std::greater does not work ,operator < not implemented ,use std:less first ,then std::reverse.
std::sort(idxSublist.begin(), idxSublist.end(), std::less<QModelIndex>());
std::reverse(idxSublist.begin(), idxSublist.end());
it = idxSublist.begin();
for( ; it != idxSublist.end(); ++it )

View file

@ -17,6 +17,7 @@
#include "initializing.hh"
#include <qt_windows.h>
#include <uxtheme.h>
#include <QOperatingSystemVersion>
#endif
@ -248,8 +249,7 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent,
oldBarStyle = 0;
if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA
&& ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based )
if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7
&& !IsThemeActive() )
{
QStyle * barStyle = WindowsStyle::instance().getStyle();
@ -649,7 +649,7 @@ Q_UNUSED( parent );
for( int x = 0; x < hws.length(); x++ )
{
QList< FtsHeadword >::iterator it = qBinaryFind( headwords.begin(), headwords.end(), hws.at( x ) );
QList< FtsHeadword >::iterator it = std::lower_bound( headwords.begin(), headwords.end(), hws.at( x ) );
if( it != headwords.end() )
{
it->dictIDs.push_back( hws.at( x ).dictIDs.front() );

View file

@ -23,7 +23,7 @@ QTextCodec *localeCodec = 0;
QTextCodec::setCodecForLocale( utf8Codec );
}
qWarning( "%s", QString().vsprintf( msg, ap ).toUtf8().data() );
qWarning( "%s", QString().vasprintf( msg, ap ).toUtf8().data() );
if( logFilePtr && logFilePtr->isOpen() )
{
@ -48,7 +48,7 @@ QTextCodec *localeCodec = 0;
QTextCodec::setCodecForLocale( utf8Codec );
}
qDebug( "%s", QString().vsprintf( msg, ap ).toUtf8().data() );
qDebug( "%s", QString().vasprintf( msg, ap ).toUtf8().data() );
if( logFilePtr && logFilePtr->isOpen() )
{

View file

@ -29,6 +29,8 @@ QT += widgets \
printsupport \
help
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00
# QMediaPlayer is not available in Qt4.
!CONFIG( no_qtmultimedia_player ) {
QT += multimedia

View file

@ -744,8 +744,8 @@ void DictGroupsWidget::addAutoGroups()
dictMap[ name ] = vd;
}
QStringList groupList = dictMap.uniqueKeys();
QStringList morphoList = morphoMap.uniqueKeys();
QStringList groupList = dictMap.keys();
QStringList morphoList = morphoMap.keys();
// Insert morphology dictionaries into corresponding lists

View file

@ -11,6 +11,7 @@
#include "helpwindow.hh"
#include "gddebug.hh"
#include <QHelpLink>
namespace Help {
@ -25,9 +26,11 @@ void HelpBrowser::showHelpForKeyword( QString const & id )
{
if ( helpEngine )
{
QMap< QString, QUrl > links = helpEngine->linksForIdentifier( id );
if( !links.isEmpty() )
setSource( links.constBegin().value() );
QList<QHelpLink> links = helpEngine->documentsForIdentifier(id);
if (!links.isEmpty()) {
QHelpLink link=links.constFirst();
setSource(link.url);
}
}
}

View file

@ -87,7 +87,7 @@ void HotKeyEdit::keyPressEvent( QKeyEvent * event )
// Delete current combo
currentKey1 = 0;
currentKey2 = 0;
currentModifiers = 0;
currentModifiers = Qt::NoModifier;
continuingCombo = false;
}
else

View file

@ -8,6 +8,7 @@
#if defined( Q_OS_WIN32 )
#include <qt_windows.h>
#include <uxtheme.h>
#include <QOperatingSystemVersion>
WindowsStyle::WindowsStyle()
{
@ -41,8 +42,7 @@ Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( par
oldBarStyle = 0;
if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA
&& ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based )
if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7
&& !IsThemeActive() )
{
QStyle * barStyle = WindowsStyle::instance().getStyle();

View file

@ -43,7 +43,7 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
bool MainStatusBar::hasImage() const
{
return !picWidget->pixmap()->isNull();
return !picWidget->pixmap().isNull();
}
void MainStatusBar::clearMessage()
@ -92,7 +92,7 @@ void MainStatusBar::refresh()
{
adjustSize();
if ( !picWidget->pixmap()->isNull() )
if ( !picWidget->pixmap().isNull() )
{
picWidget->setFixedSize( textWidget->height(), textWidget->height() );
}

View file

@ -67,7 +67,7 @@ bool MainTabWidget::eventFilter( QObject * obj, QEvent * ev )
if( obj == tabBar() && ev->type() == QEvent::MouseButtonPress )
{
QMouseEvent * mev = static_cast< QMouseEvent *>( ev );
if( mev->button() == Qt::MidButton )
if( mev->button() == Qt::MiddleButton )
{
emit tabCloseRequested( tabBar()->tabAt( mev->pos() ) );
return true;

View file

@ -741,7 +741,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
#ifdef Q_OS_WIN
if( cfg.normalMainWindowGeometry.width() <= 0 )
{
QRect r = QApplication::desktop()->availableGeometry();
QRect r = QGuiApplication::primaryScreen ()->geometry ();
cfg.normalMainWindowGeometry.setRect( r.width() / 4, r.height() / 4, r.width() / 2, r.height() / 2 );
}
if( cfg.maximizedMainWindowGeometry.width() > 0 )
@ -975,7 +975,7 @@ void MainWindow::mousePressEvent( QMouseEvent *event)
return;
}
if (event->button() != Qt::MidButton)
if (event->button() != Qt::MiddleButton)
return QMainWindow::mousePressEvent(event);
// middle clicked
@ -1194,11 +1194,11 @@ void MainWindow::wheelEvent( QWheelEvent *ev )
{
if ( ev->modifiers().testFlag( Qt::ControlModifier ) )
{
if ( ev->delta() > 0 )
if ( ev->angleDelta().y() > 0 )
{
zoomin();
}
else if ( ev->delta() < 0 )
else if ( ev->angleDelta().y() < 0 )
{
zoomout();
}
@ -4363,12 +4363,11 @@ void MainWindow::editDictionary( Dictionary::Class * dict )
QString headword = unescapeTabHeader( ui.tabWidget->tabText( ui.tabWidget->currentIndex() ) );
command.replace( "%GDWORD%", headword );
}
if( !QProcess::startDetached( command ) )
if( !QProcess::startDetached( command,QStringList() ) )
QApplication::beep();
}
}
void MainWindow::openDictionaryFolder( const QString & id )
{
for( unsigned x = 0; x < dictionaries.size(); x++ )

View file

@ -524,7 +524,7 @@ class ArticleSaveProgressDialog : public QProgressDialog
Q_OBJECT
public:
explicit ArticleSaveProgressDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 ):
explicit ArticleSaveProgressDialog( QWidget * parent = 0, Qt::WindowFlags f = Qt::Widget ):
QProgressDialog( parent, f )
{
setAutoReset( false );

View file

@ -357,7 +357,7 @@ bool MdictParser::readHeader( QDataStream & in )
if ( headerAttributes.contains( "StyleSheet" ) )
{
QString styleSheets = headerAttributes.namedItem( "StyleSheet" ).toAttr().value();
QStringList lines = styleSheets.split( QRegularExpression( "[\r\n]" ), QString::KeepEmptyParts );
QStringList lines = styleSheets.split( QRegularExpression( "[\r\n]" ), Qt::KeepEmptyParts );
for ( int i = 0; i < lines.size() - 3; i += 3 )
{

View file

@ -77,7 +77,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
if ( lang == "qt" )
continue; // We skip qt's own localizations
sortedLocs.insertMulti(
sortedLocs.insert(
Language::localizedNameForId( LangCoder::code2toInt( lang.toLatin1().data() ) ),
QPair< QIcon, QString >(
QIcon( QString( ":/flags/%1.png" ).arg( i->mid( 3, 2 ).toLower() ) ),
@ -122,7 +122,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
reg = lang.toUpper();
}
sortedHelps.insertMulti(
sortedHelps.insert(
Language::localizedNameForId( LangCoder::code2toInt( lang.toLatin1().data() ) ),
QPair< QIcon, QString >(
QIcon( QString( ":/flags/%1.png" ).arg( reg.toLower() ) ), lang + "_" + reg ) );

View file

@ -3,6 +3,7 @@
#include "scanflag.hh"
#include "ui_scanflag.h"
#include <QScreen>
static Qt::WindowFlags popupWindowFlags =
@ -53,7 +54,7 @@ void ScanFlag::showScanFlag()
QPoint currentPos = QCursor::pos();
QRect desktop = QApplication::desktop()->screenGeometry();
QRect desktop = QGuiApplication::primaryScreen()->geometry();
QSize windowSize = geometry().size();

View file

@ -625,7 +625,7 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus )
QPoint currentPos = QCursor::pos();
QRect desktop = QApplication::desktop()->screenGeometry();
QRect desktop = QGuiApplication::primaryScreen()->geometry();
QSize windowSize = geometry().size();

View file

@ -902,7 +902,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry )
|| list[ 1 ].endsWith( " tex" ) )
{
QString name;
name.sprintf( "%04X%04X%04X.gif", entry.itemIndex, entry.binIndex, texCount );
name.asprintf( "%04X%04X%04X.gif", entry.itemIndex, entry.binIndex, texCount );
imgName = texCachePath + "/" + name;
if( !QFileInfo( imgName ).exists() )
@ -985,7 +985,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry )
QString command = texCgiPath + " -e " + imgName
+ " \"" + tex + "\"";
QProcess::execute( command );
QProcess::execute( command,QStringList() );
}
QString tag = QString( "<img class=\"imgtex\" src=\"file://" )

View file

@ -74,7 +74,7 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg):
ui.programs->resizeColumnToContents( 0 );
// Make sure this thing will be large enough
ui.programs->setColumnWidth( 1,
QFontMetrics( QFont() ).width(
QFontMetrics( QFont() ).horizontalAdvance(
ProgramTypeEditor::getNameForType( Config::Program::PrefixMatch ) ) + 16 );
ui.programs->resizeColumnToContents( 2 );
ui.programs->resizeColumnToContents( 3 );

View file

@ -107,7 +107,7 @@ TranslateBox::TranslateBox(QWidget *parent) : QWidget(parent),
QHBoxLayout *layout = new QHBoxLayout(this);
setLayout(layout);
layout->setMargin(0);
layout->setContentsMargins(0,0,0,0);
layout->addWidget(translate_line);
QPixmap image(":/icons/system-search.svg");

View file

@ -369,7 +369,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str,
{
codec = QTextCodec::codecForName( QString( "ISO 8859-%1" ).arg( x ).toLatin1() );
if( codec )
urlString.replace( QString( "%25GDISO%1%25" ).arg( x ), codec->fromUnicode( inputWord ).toPercentEncoding() );
urlString.replace( QString( "%25GDISO%1%25" ).arg( x ).toUtf8(), codec->fromUnicode( inputWord ).toPercentEncoding() );
if ( x == 10 )
x = 12; // Skip encodings 11..12, they don't exist

View file

@ -242,11 +242,11 @@ QDateTime SplitZipFile::lastModified() const
unsigned long ts = 0;
for( QVector< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i )
{
unsigned long t = QFileInfo( (*i)->fileName() ).lastModified().toTime_t();
unsigned long t = QFileInfo( (*i)->fileName() ).lastModified().toSecsSinceEpoch();
if( t > ts )
ts = t;
}
return QDateTime::fromTime_t( ts );
return QDateTime::fromSecsSinceEpoch( ts );
}
qint64 SplitZipFile::calcAbsoluteOffset( qint64 offset, quint16 partNo )