Revision: 6249
Author: nogu.dev
Date: Sat Mar 13 04:38:05 2010
Log: * qt4/immodule/plugin.cpp
* qt4/immodule/qhelpermanager.cpp
* qt4/immodule/qtextutil.cpp
* qt4/immodule/quiminputcontext.cpp
* qt4/immodule/quiminputcontext_compose.cpp
* qt4/pref/customwidgets.cpp
* qt4/qtgettext.h
* qt4/switcher/qt4.cpp
- Don't use QByteArray::operator const char *() const.
Use QByteArray::data(). This commit also removes many C style casts,
which should be avoided in C++.
http://code.google.com/p/uim/source/detail?r=6249
Modified:
/trunk/qt4/immodule/plugin.cpp
/trunk/qt4/immodule/qhelpermanager.cpp
/trunk/qt4/immodule/qtextutil.cpp
/trunk/qt4/immodule/quiminputcontext.cpp
/trunk/qt4/immodule/quiminputcontext_compose.cpp
/trunk/qt4/pref/customwidgets.cpp
/trunk/qt4/qtgettext.h
/trunk/qt4/switcher/qt4.cpp
=======================================
--- /trunk/qt4/immodule/plugin.cpp Sun Feb 28 15:00:48 2010
+++ /trunk/qt4/immodule/plugin.cpp Sat Mar 13 04:38:05 2010
@@ -81,8 +81,8 @@
imname = uim_get_default_im_name( setlocale( LC_ALL, 0 ) );
QStringList langs = createLanguageList( key );
- QUimInputContext *uic = new QUimInputContext( imname.toUtf8(),
- langs[ 0 ].toUtf8() );
+ QUimInputContext *uic = new QUimInputContext( imname.toUtf8().data(),
+ langs[ 0
].toUtf8().data() );
return uic;
}
@@ -153,7 +153,7 @@
qs = "uim-" + qs;
lst << qs;
- qDebug( "name = %s", ( const char* ) qs.toUtf8() );
+ qDebug( "name = %s", qs.toUtf8().data() );
}
}
uim_release_context( tmp_uc );
=======================================
--- /trunk/qt4/immodule/qhelpermanager.cpp Tue Mar 2 14:25:16 2010
+++ /trunk/qt4/immodule/qhelpermanager.cpp Sat Mar 13 04:38:05 2010
@@ -103,7 +103,7 @@
{
QStringList list = str.split( '\n' );
uim_prop_activate( focusedInputContext->uimContext(),
- list[ 1 ].toUtf8() );
+ list[ 1 ].toUtf8().data() );
}
else if ( str.startsWith( QLatin1String( "im_list_get" ) ) )
{
@@ -158,8 +158,8 @@
for ( it = contextList.begin(); it != contextList.end(); ++it )
{
uim_prop_update_custom( ( *it )->uimContext(),
- list[ 1 ].toUtf8(),
- list[ 2 ].toUtf8() );
+ list[ 1 ].toUtf8().data(),
+ list[ 2 ].toUtf8().data() );
break; /* all custom variables are global */
}
}
@@ -185,7 +185,7 @@
if ( focusedInputContext )
{
uim_switch_im( focusedInputContext->uimContext(),
- im_name.toUtf8() );
+ im_name.toUtf8().data() );
uim_prop_list_update( focusedInputContext->uimContext() );
focusedInputContext->readIMConf();
}
@@ -195,11 +195,11 @@
QList<QUimInputContext *>::iterator it;
for ( it = contextList.begin(); it != contextList.end(); ++it )
{
- uim_switch_im( ( *it )->uimContext(), im_name.toUtf8() );
+ uim_switch_im( ( *it )->uimContext(), im_name.toUtf8().data()
);
( *it )->readIMConf();
uim_prop_update_custom( ( *it )->uimContext(),
"custom-preserved-default-im-name",
- im_name_sym.toUtf8() );
+ im_name_sym.toUtf8().data() );
}
}
else if ( str.startsWith( QLatin1String(
@@ -210,11 +210,11 @@
QList<QUimInputContext *>::iterator it;
for ( it = contextList.begin(); it != contextList.end(); ++it )
{
- uim_switch_im( ( *it )->uimContext(), im_name.toUtf8() );
+ uim_switch_im( ( *it )->uimContext(),
im_name.toUtf8().data() );
( *it )->readIMConf();
uim_prop_update_custom( ( *it )->uimContext(),
"custom-preserved-default-im-name",
- im_name_sym.toUtf8() );
+ im_name_sym.toUtf8().data() );
}
}
}
@@ -236,9 +236,9 @@
{
QString leafstr;
leafstr.sprintf( "%s\t%s\t%s\t",
- ( const char * )( *it ).name.toUtf8(),
- uim_get_language_name_from_locale( ( *it
).lang.toUtf8() ),
- ( const char * )( *it).short_desc.toUtf8() );
+ ( *it ).name.toUtf8().data(),
+ uim_get_language_name_from_locale( ( *it
).lang.toUtf8().data() ),
+ ( *it).short_desc.toUtf8().data() );
if ( QString::compare( ( *it ).name, current_im_name ) == 0 )
leafstr.append( "selected" );
@@ -248,7 +248,7 @@
msg += leafstr;
}
- uim_helper_send_message( im_uim_fd, ( const char* ) msg.toUtf8() );
+ uim_helper_send_message( im_uim_fd, msg.toUtf8().data() );
}
void QUimHelperManager::send_im_change_whole_desktop( const char *name )
@@ -256,7 +256,7 @@
QString msg;
msg.sprintf("im_change_whole_desktop\n%s\n", name);
- uim_helper_send_message( im_uim_fd, ( const char* ) msg.toUtf8() );
+ uim_helper_send_message( im_uim_fd, msg.toUtf8().data() );
}
void QUimHelperManager::helper_disconnect_cb()
@@ -280,7 +280,7 @@
QString msg = "prop_list_update\ncharset=UTF-8\n";
msg += QString::fromUtf8( str );
- uim_helper_send_message( im_uim_fd, ( const char* ) msg.toUtf8() );
+ uim_helper_send_message( im_uim_fd, msg.toUtf8().data() );
}
void QUimHelperManager::update_prop_label_cb( void *ptr, const char *str )
@@ -292,5 +292,5 @@
QString msg = "prop_label_update\ncharset=UTF-8\n";
msg += QString::fromUtf8( str );
- uim_helper_send_message( im_uim_fd, ( const char* ) msg.toUtf8() );
-}
+ uim_helper_send_message( im_uim_fd, msg.toUtf8().data() );
+}
=======================================
--- /trunk/qt4/immodule/qtextutil.cpp Thu Mar 11 04:29:19 2010
+++ /trunk/qt4/immodule/qtextutil.cpp Sat Mar 13 04:38:05 2010
@@ -171,8 +171,8 @@
if (! ( ~former_req_len & ( ~UTextExtent_Line |
~UTextExtent_Full ) ) )
return -1;
}
- *former
- = strdup( text.mid( offset, precedence_len - offset ).toUtf8()
);
+ *former = strdup(
+ text.mid( offset, precedence_len - offset ).toUtf8().data() );
offset = 0;
if ( latter_req_len >= 0 ) {
@@ -185,7 +185,7 @@
}
}
*latter = strdup( text.mid( precedence_len + preedit_len,
- following_len - offset ).toUtf8() );
+ following_len - offset ).toUtf8().data() );
break;
case UTextOrigin_Beginning:
@@ -209,7 +209,7 @@
latter_text = text.mid( precedence_len + preedit_len,
following_len );
text = former_text + latter_text;
}
- *latter = strdup( text.toUtf8() );
+ *latter = strdup( text.toUtf8().data() );
break;
case UTextOrigin_End:
@@ -232,7 +232,7 @@
latter_text = text.right( following_len );
text = former_text + latter_text;
}
- *former = strdup( text.toUtf8() );
+ *former = strdup( text.toUtf8().data() );
*latter = 0;
break;
@@ -295,7 +295,7 @@
}
}
edit->setSelection( start_para, start_index, para, index -
preedit_cursor_pos, 0 );
- *former = strdup( edit->selectedText().toUtf8() );
+ *former = strdup( edit->selectedText().toUtf8().data() );
if ( latter_req_len >= 0 ) {
for ( int i = 0; i < latter_req_len; i++ )
@@ -313,7 +313,7 @@
}
edit->setSelection( para, index - preedit_cursor_pos + preedit_len,
end_para, end_index, 0 );
- *latter = strdup( edit->selectedText().toUtf8() );
+ *latter = strdup( edit->selectedText().toUtf8().data() );
break;
case UTextOrigin_Beginning:
@@ -347,7 +347,7 @@
edit->setSelection( para, index - preedit_cursor_pos +
preedit_len, end_para, end_index, 0 );
text += edit->selectedText();
}
- *latter = strdup( text.toUtf8() );
+ *latter = strdup( text.toUtf8().data() );
break;
case UTextOrigin_End:
@@ -382,7 +382,7 @@
edit->setSelection( para, index - preedit_cursor_pos +
preedit_len, end_para, end_index, 0 );
text += edit->selectedText();
}
- *former = strdup( text.toUtf8() );
+ *former = strdup( text.toUtf8().data() );
*latter = 0;
break;
@@ -466,7 +466,7 @@
if (! ( ~latter_req_len & ( ~UTextExtent_Line |
~UTextExtent_Full ) ) )
return -1;
}
- *latter = strdup( text.left( len - offset ).toUtf8() );
+ *latter = strdup( text.left( len - offset ).toUtf8().data() );
} else if ( origin == UTextOrigin_End ||
( origin == UTextOrigin_Cursor && !cursor_at_beginning ) )
{
offset = 0;
@@ -477,7 +477,7 @@
if (! ( ~former_req_len & ( ~UTextExtent_Line |
~UTextExtent_Full ) ) )
return -1;
}
- *former = strdup( text.mid( offset, len - offset ).toUtf8() );
+ *former = strdup( text.mid( offset, len - offset ).toUtf8().data()
);
*latter = 0;
} else {
return -1;
@@ -532,7 +532,7 @@
if ( latter_req_len == UTextExtent_Line && ( ( newline =
text.find( '\n' ) ) != -1 ) )
offset = len - newline;
}
- *latter = strdup( text.left( len - offset ).toUtf8() );
+ *latter = strdup( text.left( len - offset ).toUtf8().data() );
} else if ( origin == UTextOrigin_End ||
( origin == UTextOrigin_Cursor && !cursor_at_beginning ) )
{
offset = 0;
@@ -548,7 +548,7 @@
if ( former_req_len == UTextExtent_Line && ( ( newline =
text.findRev( '\n' ) ) != -1 ) )
offset = newline + 1;
}
- *former = strdup( text.mid( offset, len - offset ).toUtf8() );
+ *former = strdup( text.mid( offset, len - offset ).toUtf8().data()
);
*latter = 0;
} else {
edit->setTextFormat( format );
@@ -590,7 +590,7 @@
&& ( ( newline = text.lastIndexOf( '\n' ) ) != -1 ) )
offset = newline + 1;
}
- *former = strdup( text.mid( offset, len - offset ).toUtf8() );
+ *former = strdup( text.mid( offset, len - offset ).toUtf8().data()
);
*latter = 0;
break;
@@ -608,7 +608,7 @@
&& ( ( newline = text.indexOf( '\n' ) ) != -1 ) )
offset = len - newline;
}
- *latter = strdup( text.left( len - offset ).toUtf8() );
+ *latter = strdup( text.left( len - offset ).toUtf8().data() );
break;
case UTextOrigin_Unspecified:
=======================================
--- /trunk/qt4/immodule/quiminputcontext.cpp Thu Mar 11 04:30:09 2010
+++ /trunk/qt4/immodule/quiminputcontext.cpp Sat Mar 13 04:38:05 2010
@@ -419,7 +419,7 @@
for ( it = contextList.begin(); it != contextList.end(); ++it )
{
( *it )->m_uc
- = ( *it )->createUimContext( ( *it )->m_imname.toAscii() );
+ = ( *it )->createUimContext( ( *it
)->m_imname.toAscii().data() );
}
}
@@ -488,7 +488,7 @@
void QUimInputContext::commit_cb( void *ptr, const char *str )
{
QString qs = QString::fromUtf8( str );
- qDebug( "commit_cb : str = |%s|", ( const char* ) qs.toLocal8Bit() );
+ qDebug( "commit_cb : str = |%s|", qs.toLocal8Bit().data() );
QUimInputContext *ic = ( QUimInputContext * ) ptr;
ic->commitString( qs );
@@ -505,7 +505,7 @@
void QUimInputContext::pushback_cb( void *ptr, int attr, const char *str )
{
QString qs = QString::fromUtf8( str );
- qDebug( "pushback_cb : str = |%s|", ( const char* ) qs.toLocal8Bit()
);
+ qDebug( "pushback_cb : str = |%s|", qs.toLocal8Bit().data() );
if ( !str )
return ;
@@ -924,7 +924,7 @@
( *it )->readIMConf();
}
}
-
uim_prop_update_custom(this->uimContext(), "custom-preserved-default-im-name",
( const char* ) im_name_sym.toUtf8() );
+
uim_prop_update_custom(this->uimContext(), "custom-preserved-default-im-name",
im_name_sym.toUtf8().data() );
}
void QUimInputContext::switch_system_global_im( const char *name )
=======================================
--- /trunk/qt4/immodule/quiminputcontext_compose.cpp Thu Mar 11 04:29:39
2010
+++ /trunk/qt4/immodule/quiminputcontext_compose.cpp Sat Mar 13 04:38:05
2010
@@ -621,7 +621,7 @@
ucs = KeySymToUcs4(ks);
QString qs = QString(QChar(ks));
- mb = (const char *)qs.toLocal8Bit();
+ mb = qs.toLocal8Bit().data();
if (!mb)
return 0;
len = strlen(mb);
@@ -796,7 +796,7 @@
}
qs = codec->toUnicode(rhs_string_mb);
- rhs_string_utf8 = strdup((const char *)qs.toUtf8());
+ rhs_string_utf8 = strdup(qs.toUtf8().data());
for (int i = 0; i < n; i++) {
for (p = *top; p; p = p->next) {
=======================================
--- /trunk/qt4/pref/customwidgets.cpp Tue Mar 2 14:25:16 2010
+++ /trunk/qt4/pref/customwidgets.cpp Sat Mar 13 04:38:05 2010
@@ -167,7 +167,7 @@
Q_ASSERT( m_custom->type == UCustom_Str );
free( m_custom->value->as_str );
- m_custom->value->as_str = strdup( (const char*)text.toUtf8() );
+ m_custom->value->as_str = strdup( text.toUtf8().data() );
setCustom( m_custom );
}
@@ -259,7 +259,7 @@
Q_ASSERT( m_custom->type == UCustom_Pathname );
free( m_custom->value->as_pathname->str );
- m_custom->value->as_pathname->str = strdup( (const char*)text.toUtf8()
);
+ m_custom->value->as_pathname->str = strdup( text.toUtf8().data() );
setCustom( m_custom );
}
@@ -763,7 +763,7 @@
for( int i = 0; i < num; i++ )
{
- const char *keystr = (const char *)keyStrList[i].toAscii();
+ const char *keystr = keyStrList[i].toAscii().data();
struct uim_custom_key *item = (struct uim_custom_key
*)malloc(sizeof(struct uim_custom_key));
item->type = UCustomKey_Regular;
=======================================
--- /trunk/qt4/qtgettext.h Fri Sep 25 08:52:02 2009
+++ /trunk/qt4/qtgettext.h Sat Mar 13 04:38:05 2010
@@ -59,7 +59,7 @@
#else /* ENABLE_NLS */
-#define mygettext(String) QString::fromLocal8Bit( (const char *)(String) )
+#define mygettext(String) QString::fromLocal8Bit( (String) )
#endif /* ENABLE_NLS */
#endif /* Not def: UIM_QT4_QTGETTEXT_H */
=======================================
--- /trunk/qt4/switcher/qt4.cpp Tue Mar 2 14:25:16 2010
+++ /trunk/qt4/switcher/qt4.cpp Sat Mar 13 04:38:05 2010
@@ -198,7 +198,7 @@
msg.append( imName );
msg.append( "\n" );
- uim_helper_send_message( uim_fd, ( const char* ) msg.toUtf8() );
+ uim_helper_send_message( uim_fd, msg.toUtf8().data() );
}
QString UimImSwitcher::selectedImName() const
@@ -271,8 +271,10 @@
if (iminfoList[1].isEmpty())
lang = QString("-");
else
- lang = QString::fromUtf8(gettext(iminfoList[1].toUtf8()));
- short_desc =
QString::fromUtf8(gettext(iminfoList[2].toUtf8()));
+ lang = QString::fromUtf8(
+ gettext(iminfoList[1].toUtf8().data()));
+ short_desc = QString::fromUtf8(
+ gettext(iminfoList[2].toUtf8().data()));
// add new item to listview
int row = listview->rowCount();