[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/qt dic_tools_widget.cpp dic_wizard.cpp ma...
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot/qt dic_tools_widget.cpp dic_wizard.cpp ma... |
Date: |
Sat, 30 Jul 2011 19:45:19 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 11/07/30 19:45:19
Modified files:
qt : dic_tools_widget.cpp dic_wizard.cpp
main_window.cpp new_game.cpp
play_word_mediator.cpp player_widget.cpp
qtcommon.cpp qtcommon.h training_widget.cpp
Log message:
Renamed the string conversion macros, to make chaining more natural.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/dic_tools_widget.cpp?cvsroot=eliot&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/dic_wizard.cpp?cvsroot=eliot&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/main_window.cpp?cvsroot=eliot&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/new_game.cpp?cvsroot=eliot&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/play_word_mediator.cpp?cvsroot=eliot&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/player_widget.cpp?cvsroot=eliot&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/qtcommon.cpp?cvsroot=eliot&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/qtcommon.h?cvsroot=eliot&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/training_widget.cpp?cvsroot=eliot&r1=1.24&r2=1.25
Patches:
Index: dic_tools_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/dic_tools_widget.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- dic_tools_widget.cpp 28 Jul 2011 20:55:49 -0000 1.16
+++ dic_tools_widget.cpp 30 Jul 2011 19:45:18 -0000 1.17
@@ -177,7 +177,7 @@
return;
}
- wstring input = m_dic->convertFromInput(qtw(rack->text()));
+ wstring input = m_dic->convertFromInput(wfq(rack->text()));
bool res = m_dic->searchWord(input);
// Convert the input to uppercase
std::transform(input.begin(), input.end(), input.begin(), towupper);
@@ -211,7 +211,7 @@
return;
}
- const wstring &input =
m_dic->convertFromInput(qtw(rack->text().toUpper()));
+ const wstring &input =
m_dic->convertFromInput(wfq(rack->text().toUpper()));
const wdstring &disp = m_dic->convertToDisplay(input);
model->setHeaderData(0, Qt::Horizontal,
_q("Rack: %1").arg(qfw(disp)),
@@ -264,7 +264,7 @@
return;
}
- const wstring &input =
m_dic->convertFromInput(qtw(rack->text().toUpper()));
+ const wstring &input =
m_dic->convertFromInput(wfq(rack->text().toUpper()));
const wdstring &disp = m_dic->convertToDisplay(input);
model->setHeaderData(0, Qt::Horizontal,
_q("Regular expression: %1").arg(qfw(disp)),
@@ -373,7 +373,7 @@
{
try
{
- ofstream file(qtl(fileName).c_str());
+ ofstream file(lfq(fileName).c_str());
ListDic::printWords(file, *m_dic);
QMessageBox::information(this, _q("Export words list"),
_q("File '%1' successfully
saved").arg(fileName));
@@ -433,7 +433,7 @@
return Intermediate;
// The string is invalid if it contains invalid input characters
- const wistring &winput = qtw(input);
+ const wistring &winput = wfq(input);
if (!m_dic->validateInputChars(winput))
return Invalid;
@@ -473,7 +473,7 @@
wstring authorizedChars = L".[]()*+?:^";
// The string is invalid if it contains invalid input characters
- const wistring &winput = qtw(input);
+ const wistring &winput = wfq(input);
if (!m_dic->validateInputChars(winput, authorizedChars))
return Invalid;
Index: dic_wizard.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/dic_wizard.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- dic_wizard.cpp 29 Jan 2011 23:47:21 -0000 1.6
+++ dic_wizard.cpp 30 Jul 2011 19:45:18 -0000 1.7
@@ -327,17 +327,17 @@
bool isVowel = model->data(model->index(i, 3)).toBool();
bool isConsonant = model->data(model->index(i, 4)).toBool();
- wstring wstr = qtw(letter);
+ wstring wstr = wfq(letter);
if (wstr.size() != 1)
- throw DicException("Invalid letter '" + qtl(letter) + "'");
+ throw DicException("Invalid letter '" + lfq(letter) + "'");
builder.addLetter(wstr[0], points, frequency,
isVowel, isConsonant, vector<wstring>());
}
// Build the dictionary
- builder.generateDawg(qtl(field("wordList").toString()),
- qtl(field("genDic").toString()),
- qtl(field("dicName").toString()));
+ builder.generateDawg(lfq(field("wordList").toString()),
+ lfq(field("genDic").toString()),
+ lfq(field("dicName").toString()));
}
catch (std::exception &e)
{
Index: main_window.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/main_window.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- main_window.cpp 28 Jul 2011 20:55:49 -0000 1.42
+++ main_window.cpp 30 Jul 2011 19:45:19 -0000 1.43
@@ -168,10 +168,10 @@
QString dicPath = qs.value(PrefsDialog::kINTF_DIC_PATH, "").toString();
if (dicPath != "")
{
- LOG_INFO("Using dictionary " << qtl(dicPath));
+ LOG_INFO("Using dictionary " << lfq(dicPath));
try
{
- m_dic = new Dictionary(qtl(dicPath));
+ m_dic = new Dictionary(lfq(dicPath));
}
catch (DicException &e)
{
@@ -308,7 +308,7 @@
void MainWindow::displayErrorMsg(QString iMsg, QString iContext)
{
- LOG_ERROR("Displayed error: " << qtl(iMsg));
+ LOG_ERROR("Displayed error: " << lfq(iMsg));
if (iContext == "")
iContext = _q("Eliot - Error");
@@ -318,7 +318,7 @@
void MainWindow::displayInfoMsg(QString iMsg)
{
- LOG_INFO("Displayed message: " << qtl(iMsg));
+ LOG_INFO("Displayed message: " << lfq(iMsg));
statusBar()->showMessage(iMsg);
}
@@ -340,7 +340,7 @@
bool res = QDesktopServices::openUrl(QUrl(url));
if (!res)
{
- LOG_ERROR("Could not open URL: " << qtl(url));
+ LOG_ERROR("Could not open URL: " << lfq(url));
}
}
@@ -401,13 +401,13 @@
return;
}
- LOG_INFO("Loading new dictionary file: " << qtl(iFileName));
+ LOG_INFO("Loading new dictionary file: " << lfq(iFileName));
destroyCurrentGame();
try
{
- Dictionary *dic = new Dictionary(qtl(iFileName));
+ Dictionary *dic = new Dictionary(lfq(iFileName));
delete m_dic;
m_dic = dic;
emit dicChanged(m_dic);
@@ -600,7 +600,7 @@
{
try
{
- PublicGame *tmpGame = PublicGame::load(qtl(fileName), *m_dic);
+ PublicGame *tmpGame = PublicGame::load(lfq(fileName), *m_dic);
destroyCurrentGame();
m_game = tmpGame;
}
@@ -628,7 +628,7 @@
{
try
{
- m_game->save(qtl(fileName));
+ m_game->save(lfq(fileName));
displayInfoMsg(_q("Game saved"));
}
catch (std::exception &e)
Index: new_game.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/new_game.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- new_game.cpp 29 Nov 2009 16:01:33 -0000 1.8
+++ new_game.cpp 30 Jul 2011 19:45:19 -0000 1.9
@@ -133,7 +133,7 @@
double level = m_model->data(m_model->index(num, 2)).toInt();
player = new AIPercent(level / 100.);
}
- player->setName(qtw(name));
+ player->setName(wfq(name));
game->addPlayer(player);
}
}
Index: play_word_mediator.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/play_word_mediator.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- play_word_mediator.cpp 16 Jul 2011 23:31:18 -0000 1.6
+++ play_word_mediator.cpp 30 Jul 2011 19:45:19 -0000 1.7
@@ -108,7 +108,7 @@
{
// Compute the points of the word
const wstring &word = getWord();
- const wstring &coords = qtw(m_lineEditCoord.text());
+ const wstring &coords = wfq(m_lineEditCoord.text());
int points = m_game->computePoints(word, coords);
if (points >= 0)
m_lineEditPoints.setText(QString("%1").arg(points));
@@ -126,7 +126,7 @@
const wstring &word = getWord(true);
QString coords = m_lineEditCoord.text();
- int res = m_game->play(word, qtw(coords));
+ int res = m_game->play(word, wfq(coords));
if (res == 0)
{
emit gameUpdated();
@@ -186,7 +186,7 @@
wstring PlayWordMediator::getWord(bool emitSignal)
{
// Convert the jokers to lowercase
- const wistring &inputWord = qtw(m_lineEditPlay.text().toUpper());
+ const wistring &inputWord = wfq(m_lineEditPlay.text().toUpper());
// Convert to internal representation, then back to QString
QString word = qfw(m_game->getDic().convertFromInput(inputWord));
@@ -194,7 +194,7 @@
while ((pos = word.indexOf('(')) != -1)
{
if (word.size() < pos + 3 || word[pos + 2] != ')' ||
- !m_game->getDic().validateLetters(qtw(QString(word[pos + 1]))))
+ !m_game->getDic().validateLetters(wfq(QString(word[pos + 1]))))
{
// Bug in validate()!
// This should never happen
@@ -215,7 +215,7 @@
// Convert the input string into an internal one
const wstring intWord =
- m_game->getDic().convertFromInput(qtw(word));
+ m_game->getDic().convertFromInput(wfq(word));
return intWord;
}
@@ -223,9 +223,9 @@
void PlayWordMediator::lineEditCoord_textChanged(const QString &iText)
{
- Coord c(qtw(iText));
+ Coord c(wfq(iText));
if (!(m_coordModel.getCoord() == c))
- m_coordModel.setCoord(Coord(qtw(iText)));
+ m_coordModel.setCoord(Coord(wfq(iText)));
lineEditPlay_textChanged();
}
@@ -254,7 +254,7 @@
if (input == "")
return Intermediate;
- const wistring &winput = qtw(input);
+ const wistring &winput = wfq(input);
// The string is invalid if it contains invalid input characters
if (!m_dic.validateInputChars(winput, L"()") || input.contains('?'))
return Invalid;
@@ -272,7 +272,7 @@
while ((pos = qintInput.indexOf('(')) != -1)
{
if (qintInput.size() < pos + 3 || qintInput[pos + 2] != ')' ||
- !m_dic.validateLetters(qtw(QString(qintInput[pos + 1]))))
+ !m_dic.validateLetters(wfq(QString(qintInput[pos + 1]))))
{
return Intermediate;
}
@@ -298,13 +298,13 @@
QValidator::State CoordsValidator::validate(QString &input, int &) const
{
// Only authorize characters part of a valid coordinate
- wstring copy = qtw(input.toUpper());
+ wstring copy = wfq(input.toUpper());
wstring authorized = L"ABCDEFGHIJKLMNO1234567890";
if (copy.find_first_not_of(authorized) != wstring::npos)
return Invalid;
// Check coordinates
- Coord c(qtw(input));
+ Coord c(wfq(input));
if (!c.isValid())
return Intermediate;
Index: player_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/player_widget.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- player_widget.cpp 28 Jul 2011 20:55:49 -0000 1.23
+++ player_widget.cpp 30 Jul 2011 19:45:19 -0000 1.24
@@ -168,7 +168,7 @@
{
// Convert the input string into an internal one
const wstring &letters =
- m_game->getDic().convertFromInput(qtw(inputLetters));
+ m_game->getDic().convertFromInput(wfq(inputLetters));
// Pass the turn (and possibly change letters)
int res = m_game->freeGamePass(letters);
@@ -208,7 +208,7 @@
QValidator::State ChangeValidator::validate(QString &input, int &) const
{
// The string is invalid if it contains invalid input characters
- const wistring &winput = qtw(input);
+ const wistring &winput = wfq(input);
if (!m_dic.validateInputChars(winput))
return Invalid;
@@ -219,7 +219,7 @@
if (!m_dic.validateLetters(intInput))
return Intermediate;
- const wstring &rack = m_dic.convertFromInput(qtw(m_lineEdit.text()));
+ const wstring &rack = m_dic.convertFromInput(wfq(m_lineEdit.text()));
if (intInput.size() > rack.size())
return Intermediate;
// The letters to change must be in the rack
Index: qtcommon.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/qtcommon.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- qtcommon.cpp 23 Jan 2010 23:34:48 -0000 1.1
+++ qtcommon.cpp 30 Jul 2011 19:45:19 -0000 1.2
@@ -23,7 +23,7 @@
using namespace std;
-wstring qtw(const QString &q)
+wstring wfq(const QString &q)
{
#ifdef QT_NO_STL
wchar_t *array = new wchar_t[q.size()];
Index: qtcommon.h
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/qtcommon.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- qtcommon.h 12 Feb 2010 18:16:57 -0000 1.11
+++ qtcommon.h 30 Jul 2011 19:45:19 -0000 1.12
@@ -37,14 +37,14 @@
#endif
// Convert to/from std::wstring
-std::wstring qtw(const QString &q);
+std::wstring wfq(const QString &q);
QString qfw(const wstring &wstr);
// Convert to/from local encoding
#define qfl(s) qfw(convertToWc(s))
-#define qtl(s) convertToMb(qtw(s))
+#define lfq(s) convertToMb(wfq(s))
// Convert to/from utf-8 char*
#define qfu(s) QString::fromUtf8(s)
-#define qtu(s) (s).toUtf8().data()
+#define ufq(s) (s).toUtf8().data()
// Translation macro to use gettext
#ifdef __APPLE__
// On MacOSX, we force the encoding to UTF-8, because we have trouble
Index: training_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/training_widget.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- training_widget.cpp 30 Jul 2011 13:15:52 -0000 1.24
+++ training_widget.cpp 30 Jul 2011 19:45:19 -0000 1.25
@@ -284,7 +284,7 @@
try
{
lineEditRack->setPalette(blackPalette);
- const wstring &input = m_game->getDic().convertFromInput(qtw(iText));
+ const wstring &input = m_game->getDic().convertFromInput(wfq(iText));
m_game->trainingSetRackManual(false, input);
pushButtonSearch->setEnabled(m_model->rowCount() == 0 &&
lineEditRack->text() != "");
@@ -387,7 +387,7 @@
const Dictionary &dic = m_bag->getDic();
// The string is invalid if it contains invalid input characters
- const wistring &winput = qtw(input);
+ const wistring &winput = wfq(input);
if (!dic.validateInputChars(winput))
return Invalid;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/qt dic_tools_widget.cpp dic_wizard.cpp ma...,
Olivier Teulière <=