Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 80dead6d authored by Michael Reeves's avatar Michael Reeves

Compile with QT_RESTRICTED_CAST_FROM_ASCII

parent 21ac4a02
......@@ -25,7 +25,6 @@ include(FeatureSummary)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(ECMSetupVersion)
# include(GenerateExportHeader)
ecm_setup_version(1.7.90 VARIABLE_PREFIX KDIFF3 VERSION_HEADER ${CMAKE_BINARY_DIR}/src/version.h)
......@@ -55,8 +54,8 @@ find_package(
set(KDiff3_LIBRARIES ${Qt5PrintSupport_LIBRARIES} KF5::I18n KF5::CoreAddons KF5::Crash KF5::IconThemes )
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# I don't need warnings about wired things in comments.
set(CLANG_WARNING_FLAGS "-Wno-comment -Wshorten-64-to-32 -Wstring-conversion -Wc++11-narrowing")
#Adjust clang specfic warnings
set(CLANG_WARNING_FLAGS "-Wno-invalid-pp-token -Wno-comment -Wshorten-64-to-32 -Wstring-conversion -Wc++11-narrowing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_WARNING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CLANG_WARNING_FLAGS}")
endif()
......@@ -71,11 +70,8 @@ set(
add_definitions(
-DQT_DEPRECATED_WARNINGS #Get warnings from QT about deprecated functions.
-DQT_NO_URL_CAST_FROM_STRING #implict casting from string to url does not always behave as you might think
-DQT_RESTRICTED_CAST_FROM_ASCII #casting from char*/QByteArray to QString can produce unexpected results for non-latin characters.
)
#remove unnneeded errors
remove_definitions(
-DQT_NO_CAST_FROM_ASCII #While a good idea in gerneral this triggers for many simple non-translatable strings
)
add_subdirectory(src)
add_subdirectory(doc)
......
......@@ -197,22 +197,22 @@ static int num(QString& s, int idx)
void ValueMap::writeEntry(const QString& k, const QFont& v)
{
m_map[k] = v.family() + "," + QString::number(v.pointSize()) + "," + (v.bold() ? "bold" : "normal");
m_map[k] = v.family() + QLatin1String(",") + QString::number(v.pointSize()) + QLatin1String(",") + (v.bold() ? QLatin1String("bold") : QLatin1String("normal"));
}
void ValueMap::writeEntry(const QString& k, const QColor& v)
{
m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue());
m_map[k] = numStr(v.red()) + QLatin1String(",") + numStr(v.green()) + QLatin1String(",") + numStr(v.blue());
}
void ValueMap::writeEntry(const QString& k, const QSize& v)
{
m_map[k] = numStr(v.width()) + "," + numStr(v.height());
m_map[k] = numStr(v.width()) + QLatin1String(",") + numStr(v.height());
}
void ValueMap::writeEntry(const QString& k, const QPoint& v)
{
m_map[k] = numStr(v.x()) + "," + numStr(v.y());
m_map[k] = numStr(v.x()) + QLatin1String(",") + numStr(v.y());
}
void ValueMap::writeEntry(const QString& k, int v)
......@@ -232,7 +232,7 @@ void ValueMap::writeEntry(const QString& k, const QString& v)
void ValueMap::writeEntry(const QString& k, const char* v)
{
m_map[k] = v;
m_map[k] = QLatin1String(v);
}
void ValueMap::writeEntry(const QString& k, const QStringList& v)
......
......@@ -179,7 +179,7 @@ DiffTextWindow::DiffTextWindow(
setAcceptDrops(true);
d->m_pOptions = pOptions;
init(nullptr, nullptr, d->m_eLineEndStyle, nullptr, 0, nullptr, nullptr, false);
init(QString(""), nullptr, d->m_eLineEndStyle, nullptr, 0, nullptr, nullptr, false);
setMinimumSize(QSize(20, 20));
......@@ -1855,9 +1855,9 @@ void DiffTextWindowFrame::init()
{
QString s = QDir::toNativeSeparators(pDTW->d->m_filename);
d->m_pFileSelection->setText(s);
QString winId = pDTW->d->m_winIdx == 1 ? (pDTW->d->m_bTriple ? "A (Base)" : "A") : (pDTW->d->m_winIdx == 2 ? "B" : "C");
QString winId = pDTW->d->m_winIdx == 1 ? (pDTW->d->m_bTriple ? i18n("A (Base)") : i18n("A")) : (pDTW->d->m_winIdx == 2 ? i18n("B") : i18n("C"));
d->m_pLabel->setText(winId + ":");
d->m_pEncoding->setText(i18n("Encoding: %1", pDTW->d->m_pTextCodec != nullptr ? pDTW->d->m_pTextCodec->name() : QString()));
d->m_pEncoding->setText(i18n("Encoding: %1", pDTW->d->m_pTextCodec != nullptr ? QLatin1String(pDTW->d->m_pTextCodec->name()) : QString()));
d->m_pLineEndStyle->setText(i18n("Line end style: %1", pDTW->d->m_eLineEndStyle == eLineEndStyleDos ? i18n("DOS") : i18n("Unix")));
}
}
......@@ -2048,7 +2048,8 @@ void EncodingLabel::insertCodec(const QString& visibleCodecName, QTextCodec* pCo
if(pCodec != nullptr && !codecEnumList.contains(CodecMIBEnum))
{
QAction* pAction = new QAction(pMenu); // menu takes ownership, so deleting the menu deletes the action too.
pAction->setText(visibleCodecName.isEmpty() ? QString(pCodec->name()) : visibleCodecName + " (" + pCodec->name() + ")");
QLatin1String codecName(pCodec->name());
pAction->setText(visibleCodecName.isEmpty() ? codecName : visibleCodecName + QLatin1String(" (") + codecName + QLatin1String(")"));
pAction->setData(CodecMIBEnum);
pAction->setCheckable(true);
if(currentTextCodecEnum == CodecMIBEnum)
......@@ -2067,7 +2068,7 @@ void EncodingLabel::slotEncodingChanged()
QTextCodec* pCodec = QTextCodec::codecForMib(pAction->data().toInt());
if(pCodec != nullptr)
{
QString s(pCodec->name());
QString s(QLatin1String(pCodec->name()));
QStringList& recentEncodings = m_pOptions->m_recentEncodings;
if(!recentEncodings.contains(s) && s != "UTF-8" && s != "System")
{
......
......@@ -512,11 +512,11 @@ QVariant DirectoryMergeWindow::Data::data(const QModelIndex& index, int role) co
case s_NameCol:
return QFileInfo(pMFI->subPath()).fileName();
case s_ACol:
return "A";
return i18n("A");
case s_BCol:
return "B";
return i18n("B");
case s_CCol:
return "C";
return i18n("C");
//case s_OpCol: return i18n("Operation");
//case s_OpStatusCol: return i18n("Status");
case s_UnsolvedCol:
......@@ -563,13 +563,13 @@ QVariant DirectoryMergeWindow::Data::data(const QModelIndex& index, int role) co
return i18n("Merge to A & B");
break;
case eCopyAToDest:
return "A";
return i18n("A");
break;
case eCopyBToDest:
return "B";
return i18n("B");
break;
case eCopyCToDest:
return "C";
return i18n("C");
break;
case eDeleteFromDest:
return i18n("Delete (if exists)");
......@@ -654,11 +654,11 @@ QVariant DirectoryMergeWindow::Data::headerData(int section, Qt::Orientation ori
case s_NameCol:
return i18n("Name");
case s_ACol:
return "A";
return i18n("A");
case s_BCol:
return "B";
return i18n("B");
case s_CCol:
return "C";
return i18n("C");
case s_OpCol:
return i18n("Operation");
case s_OpStatusCol:
......@@ -3295,19 +3295,19 @@ DirectoryMergeInfo::DirectoryMergeInfo(QWidget* pParent)
int line = 0;
m_pA = new QLabel("A", this);
m_pA = new QLabel(i18n("A"), this);
grid->addWidget(m_pA, line, 0);
m_pInfoA = new QLabel(this);
grid->addWidget(m_pInfoA, line, 1);
++line;
m_pB = new QLabel("B", this);
m_pB = new QLabel(i18n("B"), this);
grid->addWidget(m_pB, line, 0);
m_pInfoB = new QLabel(this);
grid->addWidget(m_pInfoB, line, 1);
++line;
m_pC = new QLabel("C", this);
m_pC = new QLabel(i18n("C"), this);
grid->addWidget(m_pC, line, 0);
m_pInfoC = new QLabel(this);
grid->addWidget(m_pInfoC, line, 1);
......@@ -3348,15 +3348,15 @@ static void addListViewItem(QTreeWidget* pListView, const QString& dir,
if(fi != nullptr && fi->exists())
{
QString dateString = fi->lastModified().toString("yyyy-MM-dd hh:mm:ss");
//TODO: Move logic to FileAccess
new QTreeWidgetItem(
pListView,
QStringList() << dir << QString(fi->isDir() ? i18n("Dir") : i18n("File")) + (fi->isSymLink() ? "-Link" : "") << QString::number(fi->size()) << QString(fi->isReadable() ? "r" : " ") + (fi->isWritable() ? "w" : " ")
QStringList() << dir << QString(fi->isDir() ? i18n("Dir") : i18n("File")) + (fi->isSymLink() ? i18n("-Link") : "") << QString::number(fi->size()) << QLatin1String(fi->isReadable() ? "r" : " ") + QLatin1String(fi->isWritable() ? "w" : " ")
#ifdef Q_OS_WIN
/*Future: Use GetFileAttributes()*/
<<
#else
+ (fi->isExecutable() ? "x" : " ")
+ QLatin1String((fi->isExecutable() ? "x" : " "))
<<
#endif
dateString << QString(fi->isSymLink() ? (" -> " + fi->readLink()) : QString("")));
......@@ -3433,9 +3433,9 @@ void DirectoryMergeInfo::setInfo(
}
m_pInfoList->clear();
addListViewItem(m_pInfoList, "A", dirA.prettyAbsPath(), mfi.m_pFileInfoA);
addListViewItem(m_pInfoList, "B", dirB.prettyAbsPath(), mfi.m_pFileInfoB);
addListViewItem(m_pInfoList, "C", dirC.prettyAbsPath(), mfi.m_pFileInfoC);
addListViewItem(m_pInfoList, i18n("A"), dirA.prettyAbsPath(), mfi.m_pFileInfoA);
addListViewItem(m_pInfoList, i18n("B"), dirB.prettyAbsPath(), mfi.m_pFileInfoB);
addListViewItem(m_pInfoList, i18n("C"), dirC.prettyAbsPath(), mfi.m_pFileInfoC);
if(!bHideDest)
{
FileAccess fiDest(dirDest.prettyAbsPath() + "/" + mfi.subPath(), true);
......@@ -3491,7 +3491,7 @@ void DirectoryMergeWindow::slotSaveMergeState()
//slotStatusMsg(i18n("Saving Directory Merge State ..."));
//QString s = KFileDialog::getSaveUrl( QDir::currentPath(), 0, this, i18n("Save As...") ).url();
QString s = QFileDialog::getSaveFileName(this, i18n("Save Directory Merge State As..."), QDir::currentPath(), nullptr);
QString s = QFileDialog::getSaveFileName(this, i18n("Save Directory Merge State As..."), QDir::currentPath());
if(!s.isEmpty())
{
d->m_dirMergeStateFilename = s;
......
......@@ -336,8 +336,8 @@ void FileAccess::addPath(const QString& txt)
}
else
{
QString slash = (txt.isEmpty() || txt[0] == '/') ? "" : "/";
setFile(absoluteFilePath() + slash + txt);
QString slash = (txt.isEmpty() || txt[0] == '/') ? QLatin1String("") : QLatin1String("/");
setFile(absoluteFilePath() + slash + txt);
}
}
......@@ -1437,12 +1437,12 @@ void CvsIgnoreList::addEntry(const QString& pattern)
}
else
{
m_generalPatterns.append(pattern.toLocal8Bit());
m_generalPatterns.append(pattern);
}
}
else
{
m_generalPatterns.append(pattern.toLocal8Bit());
m_generalPatterns.append(pattern);
}
}
else
......
......@@ -26,7 +26,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName);
const QString &actionName);
template <>
inline QAction * createAction<QAction>(
......@@ -34,7 +34,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName) {
const QString &actionName) {
Q_ASSERT( ac != nullptr );
QAction * theAction = ac->addAction( actionName );
theAction->setText( text );
......@@ -47,7 +47,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName) {
const QString &actionName) {
Q_ASSERT( ac != nullptr );
KToggleAction* theAction = new KToggleAction(ac);
ac->addAction( actionName, theAction );
......@@ -63,7 +63,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
const QString &actionName)
{
T* theAction = createAction<T>( text, receiver, slot, ac, actionName );
ac->setDefaultShortcut(theAction, shortcut);
......@@ -76,7 +76,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
const QString &actionName)
{
T* theAction = createAction<T>( text, receiver, slot, ac, actionName );
theAction->setIcon( icon );
......@@ -90,7 +90,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
const QString &actionName)
{
T* theAction = createAction<T>( text, receiver, slot, ac, actionName );
theAction->setIcon( icon );
......@@ -105,7 +105,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
const QString &actionName)
{
T* theAction = createAction<T>( text, shortcut, receiver, slot, ac, actionName );
theAction->setIcon( icon );
......@@ -120,7 +120,7 @@ namespace KDiff3 {
const QObject* receiver,
const char* slot,
KActionCollection* ac,
const char* actionName)
const QString &actionName)
{
T* theAction = createAction<T>( text, shortcut, receiver, slot, ac, actionName );
theAction->setIcon( icon );
......
......@@ -63,7 +63,7 @@
#include "smalldialogs.h"
#define ID_STATUS_MSG 1
#define MAIN_TOOLBAR_NAME "mainToolBar"
#define MAIN_TOOLBAR_NAME QLatin1String("mainToolBar")
KActionCollection* KDiff3App::actionCollection()
{
......@@ -81,13 +81,12 @@ QStatusBar* KDiff3App::statusBar()
return m_pKDiff3Shell->statusBar();
}
KToolBar* KDiff3App::toolBar(const char* toolBarId)
KToolBar* KDiff3App::toolBar(const QLatin1String toolBarId)
{
if(m_pKDiff3Shell == nullptr)
return nullptr;
else
return m_pKDiff3Shell->toolBar(toolBarId);
//return m_pKDiff3Shell->toolBar();
}
bool KDiff3App::isPart()
......@@ -360,8 +359,7 @@ KDiff3App::KDiff3App(QWidget* pParent, const QString /*name*/, KDiff3Part* pKDif
m_pDirectoryMergeWindow->initDirectoryMergeActions(this, actionCollection());
delete KDiff3Shell::getParser();
//if( args != 0 ) args->clear(); // Free up some memory.
if(m_pKDiff3Shell == nullptr) {
completeInit();
}
......@@ -524,7 +522,7 @@ void KDiff3App::initActions(KActionCollection* ac)
fileOpen = KStandardAction::open(this, SLOT(slotFileOpen()), ac);
fileOpen->setStatusTip(i18n("Opens documents for comparison..."));
fileReload = KDiff3::createAction<QAction>(i18n("Reload"), QKeySequence(QKeySequence::Refresh), this, SLOT(slotReload()), ac, "file_reload");
fileReload = KDiff3::createAction<QAction>(i18n("Reload"), QKeySequence(QKeySequence::Refresh), this, SLOT(slotReload()), ac, QLatin1String("file_reload"));
fileSave = KStandardAction::save(this, SLOT(slotFileSave()), ac);
fileSave->setStatusTip(i18n("Saves the merge result. All conflicts must be solved!"));
......@@ -755,7 +753,7 @@ void KDiff3App::slotFileSaveAs()
{
slotStatusMsg(i18n("Saving file with a new filename..."));
QString s = QFileDialog::getSaveFileUrl(this, i18n("Save As..."), QUrl::fromLocalFile(QDir::currentPath()), nullptr).url(QUrl::PreferLocalFile);
QString s = QFileDialog::getSaveFileUrl(this, i18n("Save As..."), QUrl::fromLocalFile(QDir::currentPath())).url(QUrl::PreferLocalFile);
if(!s.isEmpty()) {
m_outputFilename = s;
m_pMergeResultWindowTitle->setFileName(m_outputFilename);
......
......@@ -333,7 +333,7 @@ class KDiff3App : public QSplitter
KActionCollection* actionCollection();
QStatusBar* statusBar();
KToolBar* toolBar(const char*);
KToolBar* toolBar(QLatin1String);
KDiff3Part* m_pKDiff3Part;
KParts::MainWindow* m_pKDiff3Shell;
bool m_bAutoFlag;
......
......@@ -37,17 +37,17 @@
static KAboutData createAboutData()
{
QByteArray appVersion = QByteArray(KDIFF3_VERSION_STRING);
QString appVersion = QString(KDIFF3_VERSION_STRING);
if(sizeof(void*) == 8)
appVersion += " (64 bit)";
else if(sizeof(void*) == 4)
appVersion += " (32 bit)";
KAboutData aboutData("kdiff3part", i18n("KDiff3 Part"),
KAboutData aboutData(QLatin1String("kdiff3part"), i18n("KDiff3 Part"),
appVersion, i18n("A KPart to display SVG images"),
KAboutLicense::GPL_V2,
i18n("Copyright 2007, Aurélien Gâteau <aurelien.gateau@free.fr>"));
aboutData.addAuthor(i18n("Joachim Eibl"), QString(), QByteArray("joachim.eibl at gmx.de"));
aboutData.addAuthor(i18n("Joachim Eibl"), QString(), QString("joachim.eibl at gmx.de"));
return aboutData;
}
......@@ -59,7 +59,7 @@ KDiff3Part::KDiff3Part(QWidget* parentWidget, QObject* parent, const QVariantLis
{
//set AboutData
setComponentData(createAboutData());
const QString widgetName = args[0].toString().toUtf8();
const QString widgetName = args[0].toString();
// this should be your custom internal widget
m_widget = new KDiff3App(parentWidget, widgetName, this);
......
......@@ -75,11 +75,11 @@ void initialiseCmdLineArgs(QCommandLineParser* cmdLineParser)
if(!(*i).isEmpty())
{
if(i->length() == 1) {
cmdLineParser->addOption(QCommandLineOption(QStringList() << i->toLatin1() << QLatin1String("ignore"), i18n("Ignored. (User defined.)")));
cmdLineParser->addOption(QCommandLineOption(QStringList() << *i << QLatin1String("ignore"), i18n("Ignored. (User defined.)")));
}
else
{
cmdLineParser->addOption(QCommandLineOption(QStringList() << i->toLatin1(), i18n("Ignored. (User defined.)")));
cmdLineParser->addOption(QCommandLineOption(QStringList() << *i, i18n("Ignored. (User defined.)")));
}
}
}
......@@ -103,22 +103,24 @@ static bool isOptionUsed(const QString& s, int argc, char* argv[])
int main(int argc, char* argv[])
{
const QLatin1String appName("kdiff3");
QApplication app(argc, argv); // KAboutData and QCommandLineParser depend on this being setup.
KLocalizedString::setApplicationDomain("kdiff3");
KLocalizedString::setApplicationDomain(appName.data());
KCrash::initialize();
const QByteArray& appName = QByteArray::fromRawData("kdiff3", 6);
const QString i18nName = i18n("KDiff3");
QByteArray appVersion = QByteArray::fromRawData(KDIFF3_VERSION_STRING, sizeof(KDIFF3_VERSION_STRING));
QString appVersion(KDIFF3_VERSION_STRING);
if(sizeof(void*) == 8)
appVersion += " (64 bit)";
appVersion += i18n(" (64 bit)");
else if(sizeof(void*) == 4)
appVersion += " (32 bit)";
appVersion += i18n(" (32 bit)");
const QString description = i18n("Tool for Comparison and Merge of Files and Directories");
const QString copyright = i18n("(c) 2002-2014 Joachim Eibl, (c) 2017 Michael Reeves KF5/Qt5 port");
const QString& homePage = QStringLiteral("");
const QString& bugsAddress = QStringLiteral("reeves.87""@""gmail.com");
const QString homePage = QStringLiteral("");
const QString bugsAddress = QStringLiteral("reeves.87""@""gmail.com");
KAboutData aboutData(appName, i18nName,
appVersion, description, KAboutLicense::GPL_V2, copyright, description,
......@@ -177,7 +179,7 @@ int main(int argc, char* argv[])
QMessageBox::information(nullptr, aboutData.displayName(),
aboutData.displayName() + ' ' + aboutData.version());
#if !defined(Q_OS_WIN)
printf("%s %s\n", appName.constData(), appVersion.constData());
printf("%s %s\n", appName.data(), appVersion.toLocal8Bit().constData());
#endif
exit(0);
}
......
......@@ -906,17 +906,17 @@ void MergeResultWindow::showNrOfConflicts()
else
{
if(m_pTotalDiffStatus->bBinaryAEqB)
totalInfo += i18n("Files %1 and %2 are binary equal.\n", QString("A"), QString("B"));
totalInfo += i18n("Files %1 and %2 are binary equal.\n", i18n("A"), i18n("B"));
else if(m_pTotalDiffStatus->bTextAEqB)
totalInfo += i18n("Files %1 and %2 have equal text.\n", QString("A"), QString("B"));
totalInfo += i18n("Files %1 and %2 have equal text.\n", i18n("A"), i18n("B"));
if(m_pTotalDiffStatus->bBinaryAEqC)
totalInfo += i18n("Files %1 and %2 are binary equal.\n", QString("A"), QString("C"));
totalInfo += i18n("Files %1 and %2 are binary equal.\n", i18n("A"), i18n("C"));
else if(m_pTotalDiffStatus->bTextAEqC)
totalInfo += i18n("Files %1 and %2 have equal text.\n", QString("A"), QString("C"));
totalInfo += i18n("Files %1 and %2 have equal text.\n", i18n("A"), i18n("C"));
if(m_pTotalDiffStatus->bBinaryBEqC)
totalInfo += i18n("Files %1 and %2 are binary equal.\n", QString("B"), QString("C"));
totalInfo += i18n("Files %1 and %2 are binary equal.\n", i18n("B"), i18n("C"));
else if(m_pTotalDiffStatus->bTextBEqC)
totalInfo += i18n("Files %1 and %2 have equal text.\n", QString("B"), QString("C"));
totalInfo += i18n("Files %1 and %2 have equal text.\n", i18n("B"), i18n("C"));
}
int nrOfUnsolvedConflicts = getNrOfUnsolvedConflicts();
......@@ -1215,7 +1215,7 @@ void MergeResultWindow::collectHistoryInformation(
int src, Diff3LineList::const_iterator iHistoryBegin, Diff3LineList::const_iterator iHistoryEnd,
HistoryMap& historyMap,
std::list<HistoryMap::iterator>& hitList // list of iterators
)
)
{
std::list<HistoryMap::iterator>::iterator itHitListFront = hitList.begin();
Diff3LineList::const_iterator id3l = iHistoryBegin;
......@@ -1626,14 +1626,16 @@ void MergeResultWindow::timerEvent(QTimerEvent*)
QString MergeResultWindow::MergeEditLine::getString(const MergeResultWindow* mrw)
{
if(isRemoved()) {
if(isRemoved())
{
return QString();
}
if(!isModified())
{
int src = m_src;
if(src == 0) {
if(src == 0)
{
return QString();
}
const Diff3Line& d3l = *m_id3l;
......@@ -1658,7 +1660,7 @@ QString MergeResultWindow::MergeEditLine::getString(const MergeResultWindow* mrw
{
return m_str;
}
return nullptr;
return QString();
}
/// Converts the cursor-posOnScreen into a text index, considering tabulators.
......@@ -1705,7 +1707,7 @@ QVector<QTextLayout::FormatRange> MergeResultWindow::getTextLayoutForLine(int li
{
// tabs
QTextOption textOption;
#if QT_VERSION < QT_VERSION_CHECK(5,10,0)
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
textOption.setTabStop(QFontMetricsF(font()).width(' ') * m_pOptions->m_tabSize);
#else
textOption.setTabStopDistance(QFontMetricsF(font()).width(' ') * m_pOptions->m_tabSize);
......@@ -1776,11 +1778,11 @@ void MergeResultWindow::writeLine(
if(bUserModified)
srcName = "m";
else if(srcSelect == A && mergeDetails != eNoChange)
srcName = "A";
srcName = i18n("A");
else if(srcSelect == B)
srcName = "B";
srcName = i18n("B");
else if(srcSelect == C)
srcName = "C";
srcName = i18n("C");
if(rangeMark & 4)
{
......@@ -2277,7 +2279,8 @@ void MergeResultWindow::keyPressEvent(QKeyEvent* e)
bool bShift = (e->QInputEvent::modifiers() & Qt::ShiftModifier) != 0;
#ifdef Q_OS_WIN
bool bAlt = (e->QInputEvent::modifiers() & Qt::AltModifier) != 0;
if(bCtrl && bAlt) {
if(bCtrl && bAlt)
{
bCtrl = false;
bAlt = false;
} // AltGr-Key pressed.
......@@ -2375,14 +2378,18 @@ void MergeResultWindow::keyPressEvent(QKeyEvent* e)
{ // calc last indentation
MergeLineList::iterator mlIt1 = mlIt;
MergeEditLineList::iterator melIt1 = melIt;
for(;;) {
for(;;)
{
const QString s = melIt1->getString(this);
if(!s.isEmpty()) {
if(!s.isEmpty())
{
int i;
for(i = 0; i < s.length(); ++i) {
for(i = 0; i < s.length(); ++i)
{
if(s[i] != ' ' && s[i] != '\t') break;
}
if(i < s.length()) {
if(i < s.length())
{
indentation = s.left(i);
break;
}
......@@ -2426,13 +2433,15 @@ void MergeResultWindow::keyPressEvent(QKeyEvent* e)
break;
case Qt::Key_Home:
x = 0;
if(bCtrl) {
if(bCtrl)
{
y = 0;
}
break; // cursor movement
case Qt::Key_End:
x = INT_MAX;
if(bCtrl) {
if(bCtrl)
{
y = INT_MAX;
}
break;
......@@ -2444,7 +2453,8 @@ void MergeResultWindow::keyPressEvent(QKeyEvent* e)
if(!bCtrl)
{
int newX = textLayoutOrig.previousCursorPosition(x);
if(newX == x && y > 0) {
if(newX == x && y > 0)
{
--y;
x = INT_MAX;
}
......@@ -2474,7 +2484,8 @@ void MergeResultWindow::keyPressEvent(QKeyEvent* e)
if(!bCtrl)
{
int newX = textLayoutOrig.nextCursorPosition(x);
if(newX == x && y < m_totalSize - 1) {
if(newX == x && y < m_totalSize - 1)
{
++y;
x = 0;
}
......@@ -2502,25 +2513,29 @@ void MergeResultWindow::keyPressEvent(QKeyEvent* e)
break;
case Qt::Key_Up:
if(!bCtrl) {
if(!bCtrl)
{
--y;
bYMoveKey = true;
}
break;
case Qt::Key_Down:
if(!bCtrl) {
if(!bCtrl)
{
++y;
bYMoveKey = true;
}
break;
case Qt::Key_PageUp:
if(!bCtrl) {
if(!bCtrl)
{
y -= getNofVisibleLines();
bYMoveKey = true;
}
break;
case Qt::Key_PageDown:
if(!bCtrl) {
if(!bCtrl)
{
y += getNofVisibleLines();
bYMoveKey = true;
}
......@@ -2747,7 +2762,7 @@ void MergeResultWindow::deleteSelection()
return;
}
Q_ASSERT(m_selection.isValidFirstLine());
setModified();
int line = 0;
......@@ -3057,7 +3072,7 @@ Overview::Overview(Options* pOptions)
m_bPaintingAllowed = false;
m_firstLine = 0;
m_pageHeight = 0;
setFixedWidth(20);
}
......@@ -3406,21 +3421,21 @@ void WindowTitleWidget::setLineEndStyles(e_LineEndStyle eLineEndStyleA, e_LineEn
m_pLineEndStyleSelector->clear();
QString dosUsers;
if(eLineEndStyleA == eLineEndStyleDos)
dosUsers += "A";
dosUsers += i18n("A");
if(eLineEndStyleB == eLineEndStyleDos)
dosUsers += (