Commit 2a1d6521 authored by Michael Reeves's avatar Michael Reeves

fix formating

parent cfdc97a3
......@@ -77,7 +77,7 @@ FileAccess::~FileAccess()
/*
Needed only during directory listing right now.
*/
void FileAccess::setFile(FileAccess* pParent, const QFileInfo &fi)
void FileAccess::setFile(FileAccess* pParent, const QFileInfo& fi)
{
reset();
......@@ -109,7 +109,7 @@ void FileAccess::setFile(const QUrl& url, bool bWantToWrite)
if(!m_url.scheme().isEmpty())
m_url.setScheme(QLatin1Literal("file"));
if(m_url.isLocalFile() || !m_url.isValid() ) // Treat invalid urls as local files.
if(m_url.isLocalFile() || !m_url.isValid()) // Treat invalid urls as local files.
{
m_fileInfo = QFileInfo(m_url.toLocalFile());
m_pParent = nullptr;
......@@ -126,8 +126,8 @@ void FileAccess::setFile(const QUrl& url, bool bWantToWrite)
jh.stat(2 /*all details*/, bWantToWrite); // returns bSuccess, ignored
m_bValidData = true; // After running stat() the variables are initialised
// and valid even if the file doesn't exist and the stat
// query failed.
// and valid even if the file doesn't exist and the stat
// query failed.
}
}
......@@ -161,7 +161,7 @@ void FileAccess::loadData()
m_linkTarget = m_fileInfo.readLink();
#ifndef Q_OS_WIN
// Unfortunately Qt5 symLinkTarget/readLink always returns an absolute path, even if the link is relative
char *s = (char*)malloc(PATH_MAX + 1);
char* s = (char*)malloc(PATH_MAX + 1);
ssize_t len = readlink(QFile::encodeName(absoluteFilePath()).constData(), s, PATH_MAX);
if(len > 0)
{
......@@ -187,7 +187,7 @@ void FileAccess::addPath(const QString& txt)
else
{
QString slash = (txt.isEmpty() || txt[0] == '/') ? QLatin1String("") : QLatin1String("/");
setFile(absoluteFilePath() + slash + txt);
setFile(absoluteFilePath() + slash + txt);
}
}
......@@ -230,50 +230,50 @@ void FileAccess::setUdsEntry(const KIO::UDSEntry& e)
uint f = *ei;
switch(f)
{
case KIO::UDSEntry::UDS_SIZE:
m_size = e.numberValue(f);
break;
case KIO::UDSEntry::UDS_NAME:
filePath = e.stringValue(f);
break; // During listDir the relative path is given here.
case KIO::UDSEntry::UDS_MODIFICATION_TIME:
m_modificationTime = QDateTime::fromMSecsSinceEpoch(e.numberValue(f));
break;
case KIO::UDSEntry::UDS_LINK_DEST:
m_linkTarget = e.stringValue(f);
break;
case KIO::UDSEntry::UDS_ACCESS:
{
#ifndef Q_OS_WIN
acc = e.numberValue(f);
m_bReadable = (acc & S_IRUSR) != 0;
m_bWritable = (acc & S_IWUSR) != 0;
m_bExecutable = (acc & S_IXUSR) != 0;
#endif
break;
}
case KIO::UDSEntry::UDS_FILE_TYPE:
{
fileType = e.numberValue(f);
m_bDir = (fileType & QT_STAT_MASK) == QT_STAT_DIR;
m_bFile = (fileType & QT_STAT_MASK) == QT_STAT_REG;
m_bSymLink = (fileType & QT_STAT_MASK) == QT_STAT_LNK;
m_bExists = fileType != 0;
//m_fileType = fileType;
break;
}
case KIO::UDSEntry::UDS_SIZE:
m_size = e.numberValue(f);
break;
case KIO::UDSEntry::UDS_NAME:
filePath = e.stringValue(f);
break; // During listDir the relative path is given here.
case KIO::UDSEntry::UDS_MODIFICATION_TIME:
m_modificationTime = QDateTime::fromMSecsSinceEpoch(e.numberValue(f));
break;
case KIO::UDSEntry::UDS_LINK_DEST:
m_linkTarget = e.stringValue(f);
break;
case KIO::UDSEntry::UDS_ACCESS:
{
#ifndef Q_OS_WIN
acc = e.numberValue(f);
m_bReadable = (acc & S_IRUSR) != 0;
m_bWritable = (acc & S_IWUSR) != 0;
m_bExecutable = (acc & S_IXUSR) != 0;
#endif
break;
}
case KIO::UDSEntry::UDS_FILE_TYPE:
{
fileType = e.numberValue(f);
m_bDir = (fileType & QT_STAT_MASK) == QT_STAT_DIR;
m_bFile = (fileType & QT_STAT_MASK) == QT_STAT_REG;
m_bSymLink = (fileType & QT_STAT_MASK) == QT_STAT_LNK;
m_bExists = fileType != 0;
//m_fileType = fileType;
break;
}
case KIO::UDSEntry::UDS_URL:
m_url = QUrl( e.stringValue(f) );
break;
case KIO::UDSEntry::UDS_MIME_TYPE:
break;
case KIO::UDSEntry::UDS_GUESSED_MIME_TYPE:
break;
case KIO::UDSEntry::UDS_XML_PROPERTIES:
break;
default:
break;
case KIO::UDSEntry::UDS_URL:
m_url = QUrl(e.stringValue(f));
break;
case KIO::UDSEntry::UDS_MIME_TYPE:
break;
case KIO::UDSEntry::UDS_GUESSED_MIME_TYPE:
break;
case KIO::UDSEntry::UDS_XML_PROPERTIES:
break;
default:
break;
}
}
......@@ -295,8 +295,6 @@ void FileAccess::setUdsEntry(const KIO::UDSEntry& e)
m_bValidData = true;
m_bSymLink = !m_linkTarget.isEmpty();
#ifndef Q_OS_WIN
m_bHidden = m_name[0] == '.';
#endif
......@@ -466,7 +464,7 @@ bool FileAccess::interruptableReadFile(void* pDestBuffer, qint64 maxLength)
}
i += reallyRead;
pp.setCurrent( qFloor(double(i) / maxLength * 100));
pp.setCurrent(qFloor(double(i) / maxLength * 100));
if(pp.wasCancelled())
return false;
}
......@@ -482,7 +480,7 @@ bool FileAccess::readFile(void* pDestBuffer, qint64 maxLength)
if(isLocal() || !m_localCopy.isEmpty())
{
if(open(QIODevice::ReadOnly))//krazy:exclude=syscalls
return interruptableReadFile( pDestBuffer, maxLength); // maxLength == f.read( (char*)pDestBuffer, maxLength );
return interruptableReadFile(pDestBuffer, maxLength); // maxLength == f.read( (char*)pDestBuffer, maxLength );
}
else
{
......@@ -584,7 +582,8 @@ bool FileAccess::open(const QFile::OpenMode flags)
{
bool result;
result = createLocalCopy();
if(!result){
if(!result)
{
setStatusText(i18n("Creating temp copy of %1 failed.", absoluteFilePath()));
return result;
}
......@@ -602,10 +601,10 @@ bool FileAccess::open(const QFile::OpenMode flags)
return r;
}
qint64 FileAccess::read(char *data, const qint64 maxlen)
qint64 FileAccess::read(char* data, const qint64 maxlen)
{
if(!isNormal()){
if(!isNormal())
{
//This is not an error special files should be skipped
setStatusText(QString());
return 0;
......@@ -617,7 +616,7 @@ qint64 FileAccess::read(char *data, const qint64 maxlen)
len = realFile->read(data, maxlen);
}
else
len = tmpFile->read(data, maxlen);
len = tmpFile->read(data, maxlen);
if(len != maxlen)
{
......@@ -636,11 +635,10 @@ void FileAccess::close()
tmpFile->close();
}
bool FileAccess::createLocalCopy()
{
if(isLocal() || !m_localCopy.isEmpty())
return true;
return true;
tmpFile->setAutoRemove(true);
tmpFile->setFileTemplate(QStringLiteral("XXXXXX-kdiff3tmp"));
......@@ -750,7 +748,7 @@ bool FileAccess::createBackup(const QString& bakExtension)
return false;
}
}
bool bSuccess = rename(bakFile);// krazy:exclude=syscalls
bool bSuccess = rename(bakFile); // krazy:exclude=syscalls
if(!bSuccess)
{
setStatusText(i18n("While trying to make a backup, renaming failed.\nFilenames: %1 -> %2",
......@@ -766,9 +764,9 @@ void FileAccess::doError()
m_bExists = false;
}
void FileAccess::filterList(t_DirectoryList *pDirList, const QString& filePattern,
const QString& fileAntiPattern, const QString& dirAntiPattern,
const bool bUseCvsIgnore)
void FileAccess::filterList(t_DirectoryList* pDirList, const QString& filePattern,
const QString& fileAntiPattern, const QString& dirAntiPattern,
const bool bUseCvsIgnore)
{
CvsIgnoreList cvsIgnoreList;
if(bUseCvsIgnore)
......@@ -790,7 +788,7 @@ void FileAccess::filterList(t_DirectoryList *pDirList, const QString& filePatter
++i2;
QString fileName = i->fileName();
if( (i->isFile() &&
if((i->isFile() &&
(!Utils::wildcardMultiMatch(filePattern, fileName, bCaseSensitive) ||
Utils::wildcardMultiMatch(fileAntiPattern, fileName, bCaseSensitive))) ||
(i->isDir() && Utils::wildcardMultiMatch(dirAntiPattern, fileName, bCaseSensitive)) ||
......
This diff is collapsed.
......@@ -160,7 +160,8 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
else
errors = m_sd1.readAndPreprocess(m_pOptions->m_pEncodingA, m_pOptions->m_bAutoDetectUnicodeA);
if(!errors.isEmpty()){
if(!errors.isEmpty())
{
KMessageBox::errorList(m_pOptionDialog, i18n("Errors occurred during pre-processing of file A."), errors);
}
......@@ -214,7 +215,6 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
pp.step();
pp.step();
}
}
else
{
......@@ -222,9 +222,9 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
{
pp.setInformation(i18n("Loading C"));
if(bUseCurrentEncoding)
errors=m_sd3.readAndPreprocess(m_sd3.getEncoding(), false);
errors = m_sd3.readAndPreprocess(m_sd3.getEncoding(), false);
else
errors=m_sd3.readAndPreprocess(m_pOptions->m_pEncodingC, m_pOptions->m_bAutoDetectUnicodeC);
errors = m_sd3.readAndPreprocess(m_pOptions->m_pEncodingC, m_pOptions->m_bAutoDetectUnicodeC);
if(!errors.isEmpty())
KMessageBox::errorList(m_pOptionDialog, i18n("Errors occurred during pre-processing of file C."), errors);
......@@ -300,11 +300,13 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, bool bLoadFiles, boo
if(m_sd1.hasData() && m_sd3.hasData() && m_sd1.isText() && m_sd3.isText())
pTotalDiffStatus->bTextAEqC = m_diff3LineList.fineDiff(C, m_sd3.getLineDataForDisplay(), m_sd1.getLineDataForDisplay());
pp.step();
if(m_sd1.getSizeBytes() == 0) {
if(m_sd1.getSizeBytes() == 0)
{
pTotalDiffStatus->bTextAEqB = false;
pTotalDiffStatus->bTextAEqC = false;
}
if(m_sd2.getSizeBytes() == 0) {
if(m_sd2.getSizeBytes() == 0)
{
pTotalDiffStatus->bTextAEqB = false;
pTotalDiffStatus->bTextBEqC = false;
}
......@@ -914,7 +916,7 @@ void KDiff3App::wheelEvent(QWheelEvent* pWheelEvent)
scrollDiffTextWindow(deltaX, deltaY);
}
void KDiff3App::keyPressEvent(QKeyEvent *keyEvent)
void KDiff3App::keyPressEvent(QKeyEvent* keyEvent)
{
if(keyEvent->key() == Qt::Key_Escape && m_pKDiff3Shell && m_pOptions->m_bEscapeKeyQuits)
{
......@@ -968,7 +970,7 @@ void KDiff3App::keyPressEvent(QKeyEvent *keyEvent)
}
bool KDiff3App::eventFilter(QObject* o, QEvent* e)
{//TODO: Move this into DiffTextWindow::DropEvent
{ //TODO: Move this into DiffTextWindow::DropEvent
if(e->type() == QEvent::Drop)
{
QDropEvent* pDropEvent = static_cast<QDropEvent*>(e);
......@@ -1113,7 +1115,7 @@ void KDiff3App::slotFileOpen()
slotStatusMsg(i18n("Ready."));
}
void KDiff3App::slotFileOpen2(const QString& fn1, const QString& fn2, const QString& fn3, const QString& ofn,
void KDiff3App::slotFileOpen2(const QString& fn1, const QString& fn2, const QString& fn3, const QString& ofn,
const QString& an1, const QString& an2, const QString& an3, TotalDiffStatus* pTotalDiffStatus)
{
if(!canContinue()) return;
......@@ -1188,15 +1190,18 @@ void KDiff3App::slotFileNameChanged(const QString& fileName, e_SrcSelector winId
QString an2 = m_sd2.getAliasName();
QString fn3 = m_sd3.getFilename();
QString an3 = m_sd3.getAliasName();
if(winIdx == A) {
if(winIdx == A)
{
fn1 = fileName;
an1 = "";
}
if(winIdx == B) {
if(winIdx == B)
{
fn2 = fileName;
an2 = "";
}
if(winIdx == C) {
if(winIdx == C)
{
fn3 = fileName;
an3 = "";
}
......@@ -1288,7 +1293,8 @@ void KDiff3App::slotEditSelectAll()
{
LineRef l = 0;
int p = 0; // needed as dummy return values
if(m_pMergeResultWindow && m_pMergeResultWindow->hasFocus()) {
if(m_pMergeResultWindow && m_pMergeResultWindow->hasFocus())
{
m_pMergeResultWindow->setSelection(0, 0, m_pMergeResultWindow->getNofLines(), 0);
}
else if(m_pDiffTextWindow1 && m_pDiffTextWindow1->hasFocus())
......@@ -1372,9 +1378,18 @@ void KDiff3App::choose(e_SrcSelector choice)
}
}
void KDiff3App::slotChooseA() { choose(A); }
void KDiff3App::slotChooseB() { choose(B); }
void KDiff3App::slotChooseC() { choose(C); }
void KDiff3App::slotChooseA()
{
choose(A);
}
void KDiff3App::slotChooseB()
{
choose(B);
}
void KDiff3App::slotChooseC()
{
choose(C);
}
void KDiff3App::slotAutoSolve()
{
......@@ -1416,15 +1431,18 @@ void KDiff3App::slotSplitDiff()
LineRef firstLine = -1;
LineRef lastLine = -1;
DiffTextWindow* pDTW = nullptr;
if(m_pDiffTextWindow1) {
if(m_pDiffTextWindow1)
{
pDTW = m_pDiffTextWindow1;
pDTW->getSelectionRange(&firstLine, &lastLine, eD3LLineCoords);
}
if(firstLine < 0 && m_pDiffTextWindow2) {
if(firstLine < 0 && m_pDiffTextWindow2)
{
pDTW = m_pDiffTextWindow2;
pDTW->getSelectionRange(&firstLine, &lastLine, eD3LLineCoords);
}
if(firstLine < 0 && m_pDiffTextWindow3) {
if(firstLine < 0 && m_pDiffTextWindow3)
{
pDTW = m_pDiffTextWindow3;
pDTW->getSelectionRange(&firstLine, &lastLine, eD3LLineCoords);
}
......@@ -1441,15 +1459,18 @@ void KDiff3App::slotJoinDiffs()
LineRef firstLine = -1;
LineRef lastLine = -1;
DiffTextWindow* pDTW = nullptr;
if(m_pDiffTextWindow1) {
if(m_pDiffTextWindow1)
{
pDTW = m_pDiffTextWindow1;
pDTW->getSelectionRange(&firstLine, &lastLine, eD3LLineCoords);
}
if(firstLine < 0 && m_pDiffTextWindow2) {
if(firstLine < 0 && m_pDiffTextWindow2)
{
pDTW = m_pDiffTextWindow2;
pDTW->getSelectionRange(&firstLine, &lastLine, eD3LLineCoords);
}
if(firstLine < 0 && m_pDiffTextWindow3) {
if(firstLine < 0 && m_pDiffTextWindow3)
{
pDTW = m_pDiffTextWindow3;
pDTW->getSelectionRange(&firstLine, &lastLine, eD3LLineCoords);
}
......@@ -1553,8 +1574,8 @@ void KDiff3App::slotSelectionEnd()
void KDiff3App::slotClipboardChanged()
{
const QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();
const QClipboard* clipboard = QApplication::clipboard();
const QMimeData* mimeData = clipboard->mimeData();
if(mimeData->hasText())
{
QString s = clipboard->text();
......@@ -2346,15 +2367,18 @@ void KDiff3App::slotAddManualDiffHelp()
LineRef firstLine = -1;
LineRef lastLine = -1;
e_SrcSelector winIdx = Invalid;
if(m_pDiffTextWindow1) {
if(m_pDiffTextWindow1)
{
m_pDiffTextWindow1->getSelectionRange(&firstLine, &lastLine, eFileCoords);
winIdx = A;
}
if(firstLine < 0 && m_pDiffTextWindow2) {
if(firstLine < 0 && m_pDiffTextWindow2)
{
m_pDiffTextWindow2->getSelectionRange(&firstLine, &lastLine, eFileCoords);
winIdx = B;
}
if(firstLine < 0 && m_pDiffTextWindow3) {
if(firstLine < 0 && m_pDiffTextWindow3)
{
m_pDiffTextWindow3->getSelectionRange(&firstLine, &lastLine, eFileCoords);
winIdx = C;
}
......@@ -2463,8 +2487,8 @@ void KDiff3App::slotUpdateAvailabilities()
goCurrent->setEnabled(bDiffWindowVisible);
goPrevUnsolvedConflict->setEnabled(bMergeEditorVisible && m_pMergeResultWindow->isUnsolvedConflictAboveCurrent());
goNextUnsolvedConflict->setEnabled(bMergeEditorVisible && m_pMergeResultWindow->isUnsolvedConflictBelowCurrent());
goPrevConflict->setEnabled(bDiffWindowVisible && bMergeEditorVisible &&m_pMergeResultWindow->isConflictAboveCurrent());
goNextConflict->setEnabled(bDiffWindowVisible && bMergeEditorVisible &&m_pMergeResultWindow->isConflictBelowCurrent());
goPrevConflict->setEnabled(bDiffWindowVisible && bMergeEditorVisible && m_pMergeResultWindow->isConflictAboveCurrent());
goNextConflict->setEnabled(bDiffWindowVisible && bMergeEditorVisible && m_pMergeResultWindow->isConflictBelowCurrent());
goPrevDelta->setEnabled(bDiffWindowVisible && bMergeEditorVisible && m_pMergeResultWindow->isDeltaAboveCurrent());
goNextDelta->setEnabled(bDiffWindowVisible && bMergeEditorVisible && m_pMergeResultWindow->isDeltaBelowCurrent());
......
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