[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/qt Makefile.am qtcommon.h qtcommon.cpp
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot/qt Makefile.am qtcommon.h qtcommon.cpp |
Date: |
Sat, 23 Jan 2010 23:34:49 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 10/01/23 23:34:48
Modified files:
qt : Makefile.am qtcommon.h
Added files:
qt : qtcommon.cpp
Log message:
Fixed encoding bugs for good, this time.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/Makefile.am?cvsroot=eliot&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/qtcommon.h?cvsroot=eliot&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/qtcommon.cpp?cvsroot=eliot&rev=1.1
Patches:
Index: Makefile.am
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/Makefile.am,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- Makefile.am 6 Dec 2009 00:10:29 -0000 1.13
+++ Makefile.am 23 Jan 2010 23:34:48 -0000 1.14
@@ -63,7 +63,7 @@
resources.cpp
eliot_SOURCES = \
- qtcommon.h \
+ qtcommon.h qtcommon.cpp \
coord_model.h coord_model.cpp \
bag_widget.cpp bag_widget.h \
dic_tools_widget.cpp dic_tools_widget.h \
Index: qtcommon.h
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/qtcommon.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- qtcommon.h 4 Jan 2010 20:19:34 -0000 1.8
+++ qtcommon.h 23 Jan 2010 23:34:48 -0000 1.9
@@ -1,7 +1,7 @@
/*****************************************************************************
* Eliot
- * Copyright (C) 2008 Olivier Teulière
- * Authors: Olivier Teulière <ipkiss @@ gmail.com>
+ * Copyright (C) 2010 Olivier Teulière
+ * Authors: Olivier Teulière <ipkiss @@ gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,9 @@
#define QT_COMMON_H_
#include "config.h"
+#include <string>
#include <QtCore/QString>
+#include "encoding.h"
#if ENABLE_NLS
# include <libintl.h>
@@ -34,21 +36,15 @@
# define _(String) String
#endif
+// Convert to/from std::wstring
+std::wstring qtw(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))
// Convert to/from utf-8 char*
#define qfu(s) QString::fromUtf8(s)
#define qtu(s) (s).toUtf8().data()
-// Convert to/from local encoding
-#define qfl(s) QString::fromLocal8Bit(s)
-#define qtl(s) (s).toLocal8Bit().data()
-// Convert to/from std::wstring
-#ifdef QT_NO_STL
-# include "encoding.h"
-# define qfw(s) QString::fromWCharArray(wstring(s).c_str())
-# define qtw(s) convertToWc(qtl(s))
-#else
-# define qfw(s) QString::fromStdWString(s)
-# define qtw(s) (s).toStdWString().data()
-#endif
// Translation macro to use gettext
#define _q(s) qfl(_(s))
Index: qtcommon.cpp
===================================================================
RCS file: qtcommon.cpp
diff -N qtcommon.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ qtcommon.cpp 23 Jan 2010 23:34:48 -0000 1.1
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Eliot
+ * Copyright (C) 2010 Olivier Teulière
+ * Authors: Olivier Teulière <ipkiss @@ gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *****************************************************************************/
+
+#include "qtcommon.h"
+
+using namespace std;
+
+
+wstring qtw(const QString &q)
+{
+#ifdef QT_NO_STL
+ wchar_t *array = new wchar_t[q.size()];
+ int size = q.toWCharArray(array);
+ wstring ws(array, size);
+ delete[] array;
+ return ws;
+#else
+ return q.toStdWString();
+#endif
+}
+
+
+QString qfw(const wstring &wstr)
+{
+#ifdef QT_NO_STL
+ return QString::fromWCharArray(wstr.c_str());
+#else
+ return QString::fromStdWString(wstr);
+#endif
+}
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/qt Makefile.am qtcommon.h qtcommon.cpp,
Olivier Teulière <=