Commit e9f80e6b authored by Bernd Gehrmann's avatar Bernd Gehrmann
Browse files

Interpret all output from cvs in the user's locale

svn path=/trunk/kdesdk/cervisia/; revision=160293
parent d1f0a6ce
2002-06-11 Bernd Gehrmann <bernd@mail.berlios.de>
* Interpret all output from cvs in the user's locale
2002-04-28 Bernd Gehrmann <bernd@mail.berlios.de>
* Little layout fix in log dialog by Christian Loose
......
......@@ -134,7 +134,7 @@ bool AnnotateDialog::parseCvsAnnotate(const QString &sandbox, const QString &rep
//
state = Begin;
QCString line;
QString line;
while (l.getOneLine(&line))
{
switch (state)
......
......@@ -1175,7 +1175,7 @@ void CervisiaPart::slotMakePatch()
return;
}
QTextStream t(&f);
QCString line;
QString line;
while (l.getOneLine(&line))
t << line << '\n';
......
/*
* Copyright (C) 1999-2001 Bernd Gehrmann
* Copyright (C) 1999-2002 Bernd Gehrmann
* bernd@physik.hu-berlin.de
*
* This program may be distributed under the terms of the Q Public
......@@ -333,7 +333,7 @@ void CheckoutDialog::moduleButtonClicked()
return;
module_combo->clear();
QCString str;
QString str;
while (l.getOneLine(&str))
{
if (str.left(12) == "Unknown host")
......
/*
* Copyright (C) 1999-2001 Bernd Gehrmann
* Copyright (C) 1999-2002 Bernd Gehrmann
* bernd@physik.hu-berlin.de
*
* This program may be distributed under the terms of the Q Public
......
......@@ -165,13 +165,13 @@ void CvsProgressDialog::timeoutOccured()
bool CvsProgressDialog::getOneLine(QCString *str)
bool CvsProgressDialog::getOneLine(QString *str)
{
if (output.isEmpty())
return false;
*str = output.first();
output.removeFirst();
output.remove(output.begin());
return true;
}
......@@ -194,7 +194,7 @@ bool CvsProgressDialog::processOutput()
else if (item.left(11) == "cvs server:")
resultbox->insertItem(item);
else
output.append(item.latin1());
output.append(item);
buf = buf.right(buf.length()-pos-1);
}
......@@ -204,7 +204,7 @@ bool CvsProgressDialog::processOutput()
void CvsProgressDialog::receivedOutputNongui(KProcess *, char *buffer, int buflen)
{
buf += QCString(buffer, buflen+1);
buf += QString::fromLocal8Bit(buffer, buflen+1);
if (processOutput())
{
stopNonguiPart();
......@@ -215,7 +215,7 @@ void CvsProgressDialog::receivedOutputNongui(KProcess *, char *buffer, int bufle
void CvsProgressDialog::receivedOutput(KProcess *, char *buffer, int buflen)
{
buf += QCString(buffer, buflen+1);
buf += QString::fromLocal8Bit(buffer, buflen+1);
(void) processOutput();
}
......
......@@ -37,7 +37,7 @@ public:
bool execCommand(const QString &sandbox, const QString &repository,
const QString &cmdline, const QString &errindicator);
bool getOneLine(QCString *str);
bool getOneLine(QString *str);
protected:
virtual void closeEvent(QCloseEvent *e);
......@@ -63,7 +63,7 @@ private:
QPushButton *cancelbutton;
QTimer *timer;
QString buf;
QStrList output;
QStringList output;
KAnimWidget *gear;
};
......
......@@ -259,7 +259,7 @@ public:
bool DiffDialog::parseCvsDiff(const QString &sandbox, const QString &repository,
const QString &filename, const QString &revA, const QString &revB)
{
QStrList linesA, linesB;
QStringList linesA, linesB;
int linenoA, linenoB;
enum { Normal, VersionA, VersionB } state;
......@@ -358,7 +358,7 @@ bool DiffDialog::parseCvsDiff(const QString &sandbox, const QString &repository,
if (!l.execCommand(sandbox, repository, cmdline, "diff"))
return false;
QCString line;
QString line;
while ( l.getOneLine(&line) && line.left(3) != "+++")
;
......@@ -375,7 +375,7 @@ bool DiffDialog::parseCvsDiff(const QString &sandbox, const QString &repository,
}
if (line.length() < 1)
continue;
char marker = line[0];
QChar marker = line[0];
line.remove(0, 1);
if (marker == '-')
......@@ -402,16 +402,16 @@ bool DiffDialog::parseCvsDiff(const QString &sandbox, const QString &repository,
linenoB+1, linesB.count());
itemscombo->insertItem(str);
}
QStrListIterator itA(linesA);
QStrListIterator itB(linesB);
for (; itA.current() || itB.current(); ++itA, ++itB)
QStringList::ConstIterator itA = linesA.begin();
QStringList::ConstIterator itB = linesB.begin();
for (; itA != linesA.end() || itB != linesB.end(); ++itA, ++itB)
{
if (itA.current())
if (itA != linesA.end())
{
diff1->addLine(itA.current(), DiffView::Neutral,
diff1->addLine(*itA, DiffView::Neutral,
++linenoA);
if (itB.current())
diff2->addLine(itB.current(), DiffView::Change,
if (itB != linesB.end())
diff2->addLine(*itB, DiffView::Change,
++linenoB);
else
diff2->addLine("", DiffView::Delete);
......@@ -419,7 +419,7 @@ bool DiffDialog::parseCvsDiff(const QString &sandbox, const QString &repository,
else
{
diff1->addLine("", DiffView::Neutral);
diff2->addLine(itB.current(), DiffView::Insert,
diff2->addLine(*itB, DiffView::Insert,
++linenoB);
}
}
......@@ -445,16 +445,16 @@ bool DiffDialog::parseCvsDiff(const QString &sandbox, const QString &repository,
linenoB+1, linesB.count());
itemscombo->insertItem(str);
}
QStrListIterator itA(linesA);
QStrListIterator itB(linesB);
for (; itA.current() || itB.current(); ++itA, ++itB)
QStringList::ConstIterator itA = linesA.begin();
QStringList::ConstIterator itB = linesB.begin();
for (; itA != linesA.end() || itB != linesB.end(); ++itA, ++itB)
{
if (itA.current())
if (itA != linesA.end())
{
diff1->addLine(itA.current(), DiffView::Neutral,
diff1->addLine(*itA, DiffView::Neutral,
++linenoA);
if (itB.current())
diff2->addLine(itB.current(), DiffView::Change,
if (itB != linesB.end())
diff2->addLine(*itB, DiffView::Change,
++linenoB);
else
diff2->addLine("", DiffView::Delete);
......@@ -462,7 +462,7 @@ bool DiffDialog::parseCvsDiff(const QString &sandbox, const QString &repository,
else
{
diff1->addLine("", DiffView::Neutral);
diff2->addLine(itB.current(), DiffView::Insert,
diff2->addLine(*itB, DiffView::Insert,
++linenoB);
}
}
......
......@@ -324,7 +324,7 @@ bool HistoryDialog::parseHistory(const QString &sandbox, const QString &reposito
if (!l.execCommand(sandbox, repository, cmdline, "history"))
return false;
QCString line;
QString line;
int index = 0;
while (l.getOneLine(&line) )
{
......
......@@ -227,7 +227,7 @@ bool LogDialog::parseCvsLog(const QString &sbox, const QString &repo, const QStr
repository = repo;
filename = fname;
setCaption(i18n("CVS Log: ") + filename);
setCaption(i18n("CVS Log: %1").arg(filename));
QString cmdline = cvsClient(repository) + " -f log ";
cmdline += KShellProcess::quote(filename);
......@@ -238,9 +238,10 @@ bool LogDialog::parseCvsLog(const QString &sbox, const QString &repo, const QStr
return false;
state = Begin;
QCString line;
QString line;
while ( l.getOneLine(&line) )
{
kdDebug() << "Line:#" << line << "#" << endl;
switch (state)
{
case Begin:
......@@ -300,7 +301,7 @@ bool LogDialog::parseCvsLog(const QString &sbox, const QString &repo, const QStr
state = Branches;
break;
case Branches:
if (qstrncmp(line, "branches:", 9) != 0)
if (!line.startsWith("branches:"))
{
comment = line;
state = Comment;
......
......@@ -130,7 +130,7 @@ void MergeDialog::buttonClicked(bool branch)
QString searchedtype = QString::fromLatin1(branch? "branch" : "revision");
QStrList tags(true);
QCString str;
QString str;
while (l.getOneLine(&str))
{
int pos1, pos2, pos3;
......
......@@ -12,12 +12,13 @@
*/
#include "config.h"
#include <ctype.h>
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <qfile.h>
#include <qregexp.h>
#include <ctype.h>
#include <qtextcodec.h>
#include <kapplication.h>
#include <kconfig.h>
#include <kprocess.h>
......@@ -157,14 +158,7 @@ void cleanupTempFiles()
{
QStringList::Iterator it;
for (it = tempFiles->begin(); it != tempFiles->end(); ++it)
#if 0
QFile::remove(*it);
#else
{
QFile f(*it);
f.remove();
}
#endif
delete tempFiles;
}
}
......@@ -180,6 +174,14 @@ QString tempFileName(const QString &suffix)
return f.name();
}
QTextCodec *detectCodec(const QString &fileName)
{
QFile f(fileName);
// TODO
return QTextCodec::codecForLocale();
}
// Local Variables:
// c-basic-offset: 4
// End:
......@@ -26,6 +26,7 @@ QString colorAsString(const QColor &color);
QString userName();
QString tempFileName(const QString &suffix);
void cleanupTempFiles();
QTextCodec *detectCodec(const QString &fileName);
bool isValidTag(const QString &str);
QString cvsClient(QString sRepository);
......
......@@ -12,11 +12,12 @@
*/
#include <qpushbutton.h>
#include <qlayout.h>
#include <qfile.h>
#include <qkeycode.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qtextcodec.h>
#include <qtextstream.h>
#include <qfile.h>
#include <kbuttonbox.h>
#include <kapplication.h>
#include <kdebug.h>
......@@ -183,23 +184,25 @@ bool ResolveDialog::parseFile(const QString &name)
{
int lineno1, lineno2;
int advanced1, advanced2;
char buf[512];
enum { Normal, VersionA, VersionB } state;
setCaption(i18n("CVS Resolve: ") + name);
setCaption(i18n("CVS Resolve: %1").arg(name));
fname = name;
FILE *f = fopen(name.latin1(), "r");
if (!f)
return false;
QFile f(name);
if (!f.open(IO_ReadOnly))
return false;
QTextStream stream(&f);
QTextCodec *fcodec = detectCodec(name);
stream.setCodec(fcodec);
state = Normal;
lineno1 = lineno2 = 0;
advanced1 = advanced2 = 0;
while (fgets(buf, sizeof buf, f))
while (!stream.atEnd())
{
QString line = buf;
QString line = stream.readLine();
if (line.left(7) == "<<<<<<<")
{
state = VersionA;
......@@ -249,7 +252,7 @@ bool ResolveDialog::parseFile(const QString &name)
diff2->addLine(line, DiffView::Unchanged, lineno2);
}
}
fclose(f);
f.close();
updateNofN();
return true; // succesful
......@@ -266,11 +269,13 @@ void ResolveDialog::saveFile(const QString &name)
"Cervisia");
return;
}
QTextStream t(&f);
QTextStream stream(&f);
QTextCodec *fcodec = detectCodec(name);
stream.setCodec(fcodec);
int count = merge->count();
for (int i = 0; i < count; ++i)
t << merge->stringAtOffset(i);
stream << merge->stringAtOffset(i);
f.close();
}
......
......@@ -15,13 +15,15 @@
#ifndef _RESOLVEDLG_H_
#define _RESOLVEDLG_H_
#include <qcheckbox.h>
#include <qdialog.h>
#include <qlabel.h>
#include <qmultilinedit.h>
#include <qcheckbox.h>
#include <qptrlist.h>
#include "diffview.h"
class QTextCodec;
class ResolveItem;
class ResolveDialog : public QDialog
......@@ -72,6 +74,7 @@ private:
QPtrList<ResolveItem> items;
QString fname;
QTextCodec *fcodec;
int markeditem;
};
......
......@@ -142,7 +142,7 @@ void TagDialog::tagButtonClicked()
return;
QStrList tags(true);
QCString str;
QString str;
while (l.getOneLine(&str))
{
int pos1, pos2, pos3;
......
......@@ -130,7 +130,7 @@ void UpdateDialog::buttonClicked(bool branch)
QString searchedtype = QString::fromLatin1(branch? "branch" : "revision");
QStrList tags(true);
QCString str;
QString str;
while (l.getOneLine(&str))
{
int pos1, pos2, pos3;
......
......@@ -1125,7 +1125,7 @@ void UpdateView::updateItem(const QString &name, Status status, bool isdir)
kdDebug() << "longest match: " << longestmatch->dirPath() << endl;
kdDebug() << "leaves: " << dirpath.mid(longestmatch->dirPath().length()) << endl;
QStringList leaves = QStringList::split('/', dirpath.mid(longestmatch->dirPath().length()));
for (int i=0; i < leaves.count(); ++i)
for (int i=0; i < (int)leaves.count(); ++i)
{
QString newFileName = longestmatch->dirPath();
for (int j=0; j < i; ++j)
......
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