[uim-commit] r531 - trunk/qt

kzk at freedesktop.org kzk at freedesktop.org
Fri Feb 4 21:41:14 PST 2005


Author: kzk
Date: 2005-02-04 21:41:11 -0800 (Fri, 04 Feb 2005)
New Revision: 531

Added:
   trunk/qt/chardict-bushuviewwidget.cpp
   trunk/qt/chardict-bushuviewwidget.h
   trunk/qt/chardict-chargridview.cpp
   trunk/qt/chardict-chargridview.h
   trunk/qt/chardict-kseparator.cpp
   trunk/qt/chardict-kseparator.h
   trunk/qt/chardict-qt.cpp
   trunk/qt/chardict-qt.h
   trunk/qt/chardict-unicodeviewwidget.cpp
   trunk/qt/chardict-unicodeviewwidget.h
Modified:
   trunk/qt/Makefile.am
Log:
* Merge uim-chardict-qt from uim-kdehelper.

* qt/chardict-kseparator.h
* qt/chardict-chargridview.h
* qt/chardict-qt.cpp
* qt/chardict-bushuviewwidget.cpp
* qt/chardict-unicodeviewwidget.cpp
* qt/chardict-kseparator.cpp
* qt/chardict-chargridview.cpp
* qt/chardict-qt.h
* qt/chardict-bushuviewwidget.h
* qt/chardict-unicodeviewwidget.h
  - new files

* qt/Makefile.am
  - add uim-chardict-qt


Modified: trunk/qt/Makefile.am
===================================================================
--- trunk/qt/Makefile.am	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/Makefile.am	2005-02-05 05:41:11 UTC (rev 531)
@@ -1,6 +1,6 @@
 if QT
 
-INCLUDES        = -I$(top_srcdir) -I$(top_builddir)
+INCLUDES    = -I$(top_srcdir) -I$(top_builddir)
 
 QT_CXXFLAGS = $(UIM_QT_CXXFLAGS)
 QT_LDFLAGS  = $(UIM_QT_LDFLAGS)
@@ -17,7 +17,12 @@
 	switcher-qt.h \
 	pref-customwidgets.h \
 	pref-kseparator.h \
-	pref-qt.h
+	pref-qt.h \
+	chardict-bushuviewwidget.h \
+	chardict-unicodeviewwidget.h \
+	chardict-chargridview.h \
+	chardict-kseparator.h \
+	chardict-qt.h
 MOC_FILES = \
 	toolbar-common-quimhelpertoolbar.moc \
 	toolbar-common-uimstateindicator.moc \
@@ -26,7 +31,12 @@
 	switcher-qt.moc \
 	pref-customwidgets.moc \
 	pref-kseparator.moc \
-	pref-qt.moc
+	pref-qt.moc \
+	chardict-bushuviewwidget.moc \
+	chardict-unicodeviewwidget.moc \
+	chardict-chargridview.moc \
+	chardict-kseparator.moc \
+	chardict-qt.moc
 UI_TMP_FILES = \
 	pref-olisteditformbase.cpp \
 	pref-olisteditformbase.h \
@@ -44,7 +54,8 @@
 	uim-toolbar-qt \
 	uim-candwin-qt \
 	uim-im-switcher-qt \
-	uim-pref-qt
+	uim-pref-qt \
+	uim-chardict-qt
 
 # Immodule
 if QT_IMMODULE
@@ -171,8 +182,38 @@
 	echo '#include "pref-keygrabformbase.moc"' >> pref-keygrabformbase.cpp.tmp
 	mv pref-keygrabformbase.cpp.tmp pref-keygrabformbase.cpp
 
-endif
+uim_chardict_qt_SOURCES = \
+	chardict-qt.cpp \
+	chardict-bushuviewwidget.cpp \
+	chardict-chargridview.cpp \
+	chardict-kseparator.cpp \
+	chardict-unicodeviewwidget.cpp
+uim_chardict_qt_CXXFLAGS = $(QT_CXXFLAGS) -DBUSHUDICT=\"$(datadir)/uim/helperdata/bushu.t\"
+uim_chardict_qt_LDFLAGS  = $(QT_LDFLAGS)
+uim_chardict_qt_LDADD    = $(top_builddir)/uim/libuim.la
+chardict-qt.cpp: chardict-qt.moc
+chardict-qt.moc: chardict-qt.h
+	$(MOC) chardict-qt.h -o chardict-qt.moc
+chardict-bushuviewwidget.cpp: chardict-bushuviewwidget.moc
+chardict-bushuviewwidget.moc: chardict-bushuviewwidget.h
+	$(MOC) chardict-bushuviewwidget.h -o chardict-bushuviewwidget.moc
+chardict-unicodeviewwidget.cpp: chardict-unicodeviewwidget.moc
+chardict-unicodeviewwidget.moc: chardict-unicodeviewwidget.h
+	$(MOC) chardict-unicodeviewwidget.h -o chardict-unicodeviewwidget.moc
+chardict-chargridview.cpp: chardict-chargridview.moc
+chardict-chargridview.moc: chardict-chargridview.h
+	$(MOC) chardict-chargridview.h -o chardict-chargridview.moc
+chardict-kseparator.cpp: chardict-kseparator.moc
+chardict-kseparator.moc: chardict-kseparator.h
+	$(MOC) chardict-kseparator.h -o chardict-kseparator.moc
+EXTRA_DIST = $(helperdata_DATA)
+helperdatadir = $(datadir)/uim/helperdata
+helperdata_DATA = bushu.t
 
 CLEANFILES = \
 	$(MOC_FILES) \
 	$(UI_TMP_FILES)
+
+
+endif
+

Added: trunk/qt/chardict-bushuviewwidget.cpp
===================================================================
--- trunk/qt/chardict-bushuviewwidget.cpp	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-bushuviewwidget.cpp	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,183 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#include "chardict-bushuviewwidget.h"
+#include "chardict-chargridview.h"
+
+#include <qlayout.h>
+#include <qvbox.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qsettings.h>
+#include <qheader.h>
+#include <qpainter.h>
+#include <qdrawutil.h>
+#include <qtextcodec.h>
+
+#include "qtgettext.h"
+
+#define _FROM_EUCJP(String) QTextCodec::codecForName( "EUC-JP" )->toUnicode(String)
+
+BushuViewWidget::BushuViewWidget( QWidget *parent, const char *name )
+        : CharDictViewBase( parent, name )
+{
+    setupWidgets();
+    readDict();
+
+    readConfig();
+}
+
+BushuViewWidget::~BushuViewWidget()
+{
+    writeConfig();
+}
+
+void BushuViewWidget::setupWidgets()
+{
+    m_mainSplitter = new QSplitter( this );
+
+    QVBox *leftVBox = new QVBox( m_mainSplitter );
+    QLabel *bushuLabel = new QLabel( leftVBox );
+    bushuLabel->setText( _( "Bushu List" ) );
+    bushuLabel->setAlignment( Qt::AlignHCenter );
+    m_bushuListView = new QListView( leftVBox );
+    m_bushuListView->setSorting( -1 );
+    m_bushuListView->setSelectionMode( QListView::Single );
+    m_bushuListView->addColumn( "0" );
+    m_bushuListView->header() ->setStretchEnabled( true, 0 );
+    m_bushuListView->header() ->hide();
+    m_bushuListView->setColumnWidthMode( 1, QListView::Maximum );
+    m_bushuListView->setHScrollBarMode( QScrollView::AlwaysOff );
+    m_bushuListView->setAllColumnsShowFocus( true );
+    QObject::connect( m_bushuListView, SIGNAL( selectionChanged( QListViewItem * ) ),
+                      this, SLOT( slotBushuSelected( QListViewItem * ) ) );
+
+    m_charGridView = new CharGridView( 10, 0, m_mainSplitter );
+    QObject::connect( m_charGridView, SIGNAL( charSelected( const QString & ) ),
+                      this, SIGNAL( charSelected( const QString & ) ) );
+
+    // main layout
+    QHBoxLayout* layout = new QHBoxLayout( this );
+    layout->addWidget( m_mainSplitter );
+}
+
+void BushuViewWidget::readDict()
+{
+    QFile file( BUSHUDICT );
+    if ( file.open( IO_ReadOnly ) )
+    {
+        QTextStream stream( &file );
+        QString line;
+        while ( !stream.atEnd() )
+        {
+            QString bushuName = QStringList::split( " ", _FROM_EUCJP( stream.readLine() ) ) [ 0 ];
+
+            // insert last
+            QListViewItem *lastItem = m_bushuListView->lastItem();
+            if( lastItem )
+            {
+                new QListViewItem( m_bushuListView, lastItem, bushuName );
+            }
+            else
+            {
+                new QListViewItem( m_bushuListView, bushuName );
+            }
+                
+        }
+        file.close();
+    }
+}
+
+void BushuViewWidget::slotBushuSelected( QListViewItem *item )
+{
+    if ( !item )
+        return ;
+
+    QString selectedBushuName = item->text( 0 );
+    if ( selectedBushuName.isEmpty() )
+        return ;
+
+    QFile file( BUSHUDICT );
+    if ( file.open( IO_ReadOnly ) )
+    {
+        QTextStream stream( &file );
+        QString line;
+
+        // search selected bushu line by line
+        while ( !stream.atEnd() )
+        {
+            QStringList chars = QStringList::split( " ", _FROM_EUCJP( stream.readLine() ) );
+            QString bushuName = chars[ 0 ];
+            if ( selectedBushuName == bushuName )
+            {
+                // Display Characters
+                chars.remove( bushuName );
+                m_charGridView->setCharacters( chars );
+            }
+        }
+        file.close();
+    }
+}
+
+void BushuViewWidget::writeConfig()
+{
+    QSettings settings;
+
+    // splitter
+    QString str;
+    QTextOStream out( &str );
+    out << *m_mainSplitter;
+    settings.writeEntry( "/uim-kdehelper/chardict/bushuview/splitter", str );
+}
+
+void BushuViewWidget::readConfig()
+{
+    QSettings settings;
+    QString str;
+
+    // splitter
+    str = settings.readEntry( "/uim-kdehelper/chardict/bushuview/splitter" );
+    if ( !str.isEmpty() )
+    {
+        QTextIStream in( &str );
+        in >> *m_mainSplitter;
+    }
+}
+
+void BushuViewWidget::setFont( const QFont &font )
+{
+    m_charGridView->setFont( font );
+}
+
+#include "chardict-bushuviewwidget.moc"

Added: trunk/qt/chardict-bushuviewwidget.h
===================================================================
--- trunk/qt/chardict-bushuviewwidget.h	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-bushuviewwidget.h	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,71 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#ifndef _BUSHU_VIEW_WIDGET_H_
+#define _BUSHU_VIEW_WIDGET_H_
+
+#include "chardict-qt.h"
+
+#include <qwidget.h>
+#include <qfont.h>
+#include <qlistview.h>
+#include <qsplitter.h>
+
+class CharGridView;
+
+class BushuViewWidget : public CharDictViewBase
+{
+    Q_OBJECT
+
+public:
+    BushuViewWidget( QWidget *parent = 0, const char *name = 0 );
+    ~BushuViewWidget();
+
+    void setFont( const QFont &font );
+
+protected:
+    void setupWidgets();
+    void readDict();
+
+    void writeConfig();
+    void readConfig();
+
+protected slots:
+    void slotBushuSelected( QListViewItem * );
+
+protected:
+    QSplitter *m_mainSplitter;
+    QListView *m_bushuListView;
+    CharGridView *m_charGridView;
+};
+
+#endif /* Not def: _BUSHU_VIEW_WIDGET_H_ */

Added: trunk/qt/chardict-chargridview.cpp
===================================================================
--- trunk/qt/chardict-chargridview.cpp	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-chargridview.cpp	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,204 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#include "chardict-chargridview.h"
+
+#include <qpainter.h>
+#include <qpoint.h>
+#include <qbrush.h>
+#include <qdrawutil.h>
+
+static const int COLS = 10;
+
+CharGridView::CharGridView( int x, int y, QWidget *parent, const char *name )
+        : QGridView( parent, name )
+{
+    setNumCols( x );
+    setNumRows( y );
+    setCellWidth( 30 );
+    setCellHeight( 30 );
+
+    setHScrollBarMode( QScrollView::AlwaysOff );
+
+    m_activeCell.setX( -1 );
+    m_activeCell.setY( -1 );
+
+    m_font = font();
+
+    setFrameStyle( QFrame::NoFrame );
+    show();
+}
+CharGridView::~CharGridView()
+{}
+void CharGridView::paintCell( QPainter * painter, int y, int x )
+{
+    // set font
+    if ( m_font != font() )
+        painter->setFont( m_font );
+
+    bool isActiveCell = ( ( m_activeCell.x() == x ) && ( m_activeCell.y() == y ) );
+    if ( isActiveCell )
+    {
+        // save the painter's state to the stack and swap back/fore ground colors
+        painter->save();
+        QColor tmp( painter->pen().color() );
+        painter->setPen( painter->backgroundColor() );
+        painter->setBackgroundColor( tmp );
+    }
+
+    QBrush bBrush( colorGroup().base() );
+    QBrush tBrush( colorGroup().text() );
+    if ( isActiveCell )
+        qDrawShadePanel( painter, 0, 0, cellWidth(), cellHeight(), colorGroup(), false, 2, &tBrush ); //&(painter->brush()));
+    else
+        qDrawPlainRect( painter, 0, 0, cellWidth(), cellHeight(), colorGroup().foreground(), 1, &bBrush ); //&(painter->brush()));
+
+    QString c = coordsToChar( x, y );
+    if ( !c.isEmpty() )
+        painter->drawText( 0, 0, cellWidth(), cellHeight(), AlignCenter, c );
+
+    // restore state
+    if ( isActiveCell )
+        painter->restore();
+}
+
+void CharGridView::contentsMousePressEvent( QMouseEvent * e )
+{
+    if ( e->button() != LeftButton )
+        return ;
+
+    int y = e->pos().y();
+    int x = e->pos().x();
+
+    int row = rowAt( y );
+    int col = columnAt( x );
+
+    if ( ( m_activeCell.y() != row ) || ( m_activeCell.x() != col ) )
+    {
+        int oldactivecelly = m_activeCell.y();
+        int oldactivecellx = m_activeCell.x();
+        m_activeCell.setY( row );
+        m_activeCell.setX( col );
+        updateCell( oldactivecelly, oldactivecellx );
+        updateCell( m_activeCell.y(), m_activeCell.x() );
+    }
+}
+
+void CharGridView::contentsMouseReleaseEvent( QMouseEvent * e )
+{
+    if ( e->button() != LeftButton )
+        return ;
+
+    emit charSelected( coordsToChar( m_activeCell.x(), m_activeCell.y() ) );
+}
+QString CharGridView::coordsToChar( int x, int y )
+{
+    if ( x < 0 || x > numCols() || y < 0 || y > numRows() )
+        debug( "coordsToIndex: invalid coords(%d, %d)\n", x, y );
+
+    unsigned int index = y * numCols() + x;
+    if ( index < m_charList.count() )
+        return m_charList[ index ];
+    else
+        return QString::null;
+}
+
+QSize CharGridView::sizeHint( void ) const
+{
+    return QSize( numCols() * cellWidth(), numRows() * cellHeight() );
+}
+
+void CharGridView::resizeEvent( QResizeEvent * e )
+{
+    updateCharGridView();
+}
+
+void CharGridView::setCharacters( const QStringList &charList )
+{
+    // default position
+    m_activeCell.setX( -1 );
+    m_activeCell.setY( -1 );
+
+    m_charList.clear();
+    m_charList = charList;
+
+    int total = m_charList.count();
+
+    int cols = COLS;
+    int rows = total / COLS;
+    if ( total % COLS > 0 )
+    {
+        rows++;
+    }
+
+    setNumCols( cols );
+    setNumRows( rows );
+
+    updateCharGridView();
+
+    // repaint all cells
+    for ( int i = 0; i < numRows(); i++ )
+        for ( int j = 0; j < numCols(); j++ )
+            repaintCell( i, j, true );
+}
+void CharGridView::updateCharGridView()
+{
+    int cellsize = 0;
+    QScrollBar *vScrollBar = verticalScrollBar();
+    /**
+     * 2004-12-06 Kazuki Ohta <mover at hct.zaq.ne.jp>
+     * FIXME:
+     * The timing vScrollBar is shown is tricky.
+     * So this code doesn't work properly.
+     * hmm..
+     */
+    /*
+    if( vScrollBar->isShown() )
+    {
+        qDebug("vScrollBar->isShown() = true");
+        cellsize = (width() - vScrollBar->minimumWidth())/numCols();
+    }
+    else
+    {
+        qDebug("vScrollBar->isShown() = false");
+        cellsize = width()/numCols();
+    }
+    */ 
+    // adhoc code
+    // but minimumWidth() is always 0 ?
+    cellsize = ( width() - vScrollBar->minimumWidth() ) / numCols();
+
+    setCellWidth( cellsize );
+    setCellHeight( cellsize );
+}
+
+#include "chardict-chargridview.moc"

Added: trunk/qt/chardict-chargridview.h
===================================================================
--- trunk/qt/chardict-chargridview.h	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-chargridview.h	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,74 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#ifndef _CHAR_GRID_VIEW_H_
+#define _CHAR_GRID_VIEW_H_
+
+#include <qgridview.h>
+#include <qstringlist.h>
+#include <qfont.h>
+#include <qpoint.h>
+
+class CharGridView : public QGridView
+{
+    Q_OBJECT
+
+public:
+    CharGridView( int x, int y, QWidget *parent = 0, const char *name = 0 );
+    ~CharGridView();
+
+    void setCharacters( const QStringList &charList );
+    virtual QSize sizeHint( void ) const;
+
+    void setFont( const QFont &font ) { m_font = font; }
+
+protected:
+    virtual void paintCell( QPainter * painter, int y, int x );
+    virtual void resizeEvent( QResizeEvent * e );
+    virtual void contentsMousePressEvent( QMouseEvent * e );
+    virtual void contentsMouseReleaseEvent( QMouseEvent * e );
+
+    void updateCharGridView();
+
+protected slots:
+    QString coordsToChar( int x, int y );
+
+signals:
+    void charSelected( const QString & );
+
+protected:
+    QPoint m_activeCell;
+    QStringList m_charList;
+    QFont m_font;
+};
+
+#endif /* Not def: _CHAR_GRID_VIEW_H_ */

Added: trunk/qt/chardict-kseparator.cpp
===================================================================
--- trunk/qt/chardict-kseparator.cpp	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-kseparator.cpp	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,114 @@
+/*
+*   Copyright (C) 1997  Michael Roth <mroth at wirlweb.de>
+*
+*   This program is free software; you can redistribute it and/or modify
+*   it under the terms of the GNU Library 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 Library General Public License for more details.
+*
+*   You should have received a copy of the GNU Library General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+#include "chardict-kseparator.h"
+
+#include <qstyle.h>
+
+KSeparator::KSeparator( QWidget* parent, const char* name, WFlags f )
+        : QFrame( parent, name, f )
+{
+    setLineWidth( 1 );
+    setMidLineWidth( 0 );
+    setOrientation( HLine );
+}
+
+
+
+KSeparator::KSeparator( int orientation, QWidget* parent, const char* name, WFlags f )
+        : QFrame( parent, name, f )
+{
+    setLineWidth( 1 );
+    setMidLineWidth( 0 );
+    setOrientation( orientation );
+}
+
+
+
+void KSeparator::setOrientation( int orientation )
+{
+    switch ( orientation )
+    {
+    case Vertical:
+    case VLine:
+        setFrameStyle( QFrame::VLine | QFrame::Sunken );
+        setMinimumSize( 2, 0 );
+        break;
+
+    default:
+        qDebug( "KSeparator::setOrientation(): invalid orientation, using default orientation HLine" );
+
+    case Horizontal:
+    case HLine:
+        setFrameStyle( QFrame::HLine | QFrame::Sunken );
+        setMinimumSize( 0, 2 );
+        break;
+    }
+}
+
+
+
+int KSeparator::orientation() const
+{
+    if ( frameStyle() & VLine )
+        return VLine;
+
+    if ( frameStyle() & HLine )
+        return HLine;
+
+    return 0;
+}
+
+void KSeparator::drawFrame( QPainter *p )
+{
+    QPoint p1, p2;
+    QRect r = frameRect();
+    const QColorGroup & g = colorGroup();
+
+    if ( frameStyle() & HLine )
+    {
+        p1 = QPoint( r.x(), r.height() / 2 );
+        p2 = QPoint( r.x() + r.width(), p1.y() );
+    }
+    else
+    {
+        p1 = QPoint( r.x() + r.width() / 2, 0 );
+        p2 = QPoint( p1.x(), r.height() );
+    }
+
+    QStyleOption opt( lineWidth(), midLineWidth() );
+    style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g,
+                           QStyle::Style_Sunken, opt );
+}
+
+
+QSize KSeparator::sizeHint() const
+{
+    if ( frameStyle() & VLine )
+        return QSize( 2, 0 );
+
+    if ( frameStyle() & HLine )
+        return QSize( 0, 2 );
+
+    return QSize( -1, -1 );
+}
+
+void KSeparator::virtual_hook( int, void* )
+{ /*BASE::virtual_hook( id, data );*/ }
+
+#include "chardict-kseparator.moc"

Added: trunk/qt/chardict-kseparator.h
===================================================================
--- trunk/qt/chardict-kseparator.h	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-kseparator.h	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,85 @@
+/*
+*   Copyright (C) 1997  Michael Roth <mroth at wirlweb.de>
+*
+*   This program is free software; you can redistribute it and/or modify
+*   it under the terms of the GNU Library 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 Library General Public License for more details.
+*
+*   You should have received a copy of the GNU Library General Public License
+*   along with this program; if not, write to the Free Software
+*   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#ifndef __KSEPARATOR_H__
+#define __KSEPARATOR_H__
+
+#include <qframe.h>
+
+/**
+ * Standard horizontal or vertical separator.
+ *
+ * @author Michael Roth <mroth at wirlweb.de>
+ * @version $Id: kseparator.h,v 1.14 2004/09/09 15:23:53 faure Exp $
+*/
+class KSeparator : public QFrame
+{
+    Q_OBJECT
+    Q_PROPERTY( int orientation READ orientation WRITE setOrientation )
+public:
+    /**
+     * Constructor.
+     * @param parent parent object.
+     * @param name name of the new object.
+     * @param f extra QWidget flags.
+     **/
+    KSeparator( QWidget* parent = 0, const char* name = 0, WFlags f = 0 );
+
+    /**
+     * Constructor.
+     * @param orientation Set the orientation of the separator.
+     * Possible values are HLine or Horizontal and VLine or Vertical.
+     * @param parent parent object.
+     * @param name name of the new object.
+     * @param f extra QWidget flags.
+     **/
+    KSeparator( int orientation, QWidget* parent = 0, const char* name = 0,
+                WFlags f = 0 );
+
+    /**
+     * Returns the orientation of the separator.
+     * @return int Possible values are VLine and HLine.
+     **/
+    int orientation() const;
+
+    /**
+     * Set the orientation of the separator to @p orient
+     *
+     * @param orient Possible values are VLine and HLine.
+     */
+    void setOrientation( int orient );
+
+    /**
+     * The recommended height (width) for a horizontal (vertical) separator.
+     **/
+    virtual QSize sizeHint() const;
+
+protected:
+    /**
+     * @param p pointer to painter
+     */
+    virtual void drawFrame( QPainter *p );
+protected:
+    virtual void virtual_hook( int id, void* data );
+private:
+    class KSeparatorPrivate* d;
+};
+
+
+#endif // __KSEPARATOR_H__

Added: trunk/qt/chardict-qt.cpp
===================================================================
--- trunk/qt/chardict-qt.cpp	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-qt.cpp	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,220 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#include "chardict-qt.h"
+#include "chardict-bushuviewwidget.h"
+#include "chardict-unicodeviewwidget.h"
+#include "chardict-kseparator.h"
+
+#include <qapplication.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qhbox.h>
+#include <qframe.h>
+#include <qsizepolicy.h>
+#include <qtoolbutton.h>
+#include <qfont.h>
+#include <qfontdialog.h>
+#include <qvbox.h>
+#include <qsettings.h>
+
+#include "qtgettext.h"
+
+int main( int argc, char *argv[] )
+{
+    QApplication a( argc, argv );
+
+    KUimCharDict::Mode m = KUimCharDict::UNKNOWN;
+    for ( int i = 0; i < argc; i++ )
+    {
+        QString arg( argv[ i ] );
+        if ( !arg.isEmpty() && arg.startsWith( "-mode=" ) )
+        {
+            QString mode = QStringList::split( "=", arg ) [ 1 ];
+            if ( mode.isEmpty() )
+                continue;
+
+            if ( mode == "BUSHU" )
+                m = KUimCharDict::BUSHU;
+            else if ( mode == "UNICODE" )
+                m = KUimCharDict::UNICODE;
+        }
+    }
+
+    KUimCharDict cdict;
+    cdict.changeMode( m );
+    cdict.resize( 600, 400 );
+    cdict.show();
+
+    a.setMainWidget( &cdict );
+
+    return a.exec();
+}
+
+KUimCharDict::KUimCharDict( QWidget *parent, const char *name )
+        : QWidget( parent, name )
+{
+    setupWidgets();
+
+    readConfig();
+}
+
+KUimCharDict::~KUimCharDict()
+{
+    writeConfig();
+}
+
+void KUimCharDict::setupWidgets()
+{
+    QVBoxLayout * layout = new QVBoxLayout( this );
+    layout->setMargin( 4 );
+    layout->setSpacing( 6 );
+
+    QWidget *upperHWidget = new QWidget( this );
+    upperHWidget->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum );
+
+    QLabel *modeLabel = new QLabel( _( "Mode:" ), upperHWidget );
+    m_modeCombo = new QComboBox( upperHWidget );
+    m_modeCombo->insertItem( _( "Bushu Search" ) );
+    m_modeCombo->insertItem( _( "Unicode Search" ) );
+    QObject::connect( m_modeCombo, SIGNAL( activated( int ) ),
+                      this, SLOT( changeMode( int ) ) );
+    modeLabel->setBuddy( m_modeCombo );
+
+    m_fontselButton = new QToolButton( upperHWidget );
+    m_fontselButton->setText( _( "Select Font" ) );
+    QObject::connect( m_fontselButton, SIGNAL( clicked() ),
+                      this, SLOT( slotSelectFont() ) );
+
+    QLabel *charLabel = new QLabel( _( "Chars:" ), upperHWidget );
+    m_charLineEdit = new QLineEdit( upperHWidget );
+    charLabel->setBuddy( m_charLineEdit );
+
+    QHBoxLayout *upperHLayout = new QHBoxLayout( upperHWidget );
+    upperHLayout->setSpacing( 4 );
+    upperHLayout->addWidget( modeLabel );
+    upperHLayout->addWidget( m_modeCombo );
+    upperHLayout->addWidget( m_fontselButton );
+    upperHLayout->addSpacing( 11 );
+    upperHLayout->addWidget( charLabel );
+    upperHLayout->addWidget( m_charLineEdit );
+
+    m_widgetStack = new QWidgetStack( this );
+    m_widgetStack->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+
+    m_bushuView = new BushuViewWidget( this );
+    QObject::connect( m_bushuView, SIGNAL( charSelected( const QString & ) ),
+                      this, SLOT( slotCharSelected( const QString & ) ) );
+    m_bushuView->hide();
+    m_widgetStack->addWidget( m_bushuView, BUSHU );
+
+    m_unicodeView = new UnicodeViewWidget( this );
+    QObject::connect( m_unicodeView, SIGNAL( charSelected( const QString & ) ),
+                      this, SLOT( slotCharSelected( const QString & ) ) );
+    m_unicodeView->hide();
+    m_widgetStack->addWidget( m_unicodeView, UNICODE );
+
+    layout->addWidget( upperHWidget );
+    layout->addWidget( new KSeparator( this ) );
+    layout->addWidget( m_widgetStack );
+}
+
+void KUimCharDict::writeConfig()
+{
+    QSettings settings;
+
+    // font
+    settings.writeEntry( "/uim-kdehelper/chardict/font", m_fontselButton->font().toString() );
+}
+void KUimCharDict::readConfig()
+{
+    QSettings settings;
+    QString str;
+
+    // font
+    str = settings.readEntry( "/uim-kdehelper/chardict/font" );
+    if ( !str.isEmpty() )
+    {
+        QFont font;
+        font.fromString( str );
+
+        setCharDictFont( font );
+    } else {
+        setCharDictFont( font() );        
+    }
+}
+
+void KUimCharDict::setCharDictFont( const QFont &font )
+{
+    // button
+    m_fontselButton->setFont( font );
+    // bushu
+    m_bushuView->setFont( font );
+    // unicode
+    m_unicodeView->setFont( font );
+}
+
+
+void KUimCharDict::changeMode( int mode )
+{
+    // not implemented yet
+    switch ( mode )
+    {
+    case BUSHU:
+        m_widgetStack->raiseWidget( BUSHU );
+        break;
+    case UNICODE:
+        m_widgetStack->raiseWidget( UNICODE );
+        break;
+    default:
+        qDebug( "Unknown Mode" );
+        break;
+    }
+}
+
+void KUimCharDict::slotSelectFont()
+{
+    bool ok;
+    QFont font = QFontDialog::getFont( &ok, m_fontselButton->font(), this );
+    if ( ok )
+    {
+        // font is set to the font the user selected
+        setCharDictFont( font );
+    }
+}
+
+void KUimCharDict::slotCharSelected( const QString &c )
+{
+    m_charLineEdit->setText( m_charLineEdit->text() + c );
+}
+
+#include "chardict-qt.moc"

Added: trunk/qt/chardict-qt.h
===================================================================
--- trunk/qt/chardict-qt.h	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-qt.h	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,103 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#ifndef _UIM_CHARDICT_QT_H_
+#define _UIM_CHARDICT_QT_H_
+
+#include <qstring.h>
+#include <qwidget.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qwidgetstack.h>
+#include <qscrollview.h>
+#include <qgridview.h>
+#include <qstringlist.h>
+#include <qtoolbutton.h>
+
+class BushuViewWidget;
+class UnicodeViewWidget;
+
+class KUimCharDict : public QWidget
+{
+    Q_OBJECT
+
+public:
+    KUimCharDict( QWidget *parent = 0, const char *name = 0 );
+    ~KUimCharDict();
+
+    enum Mode {
+        BUSHU = 0,
+        UNICODE = 1,
+        UNKNOWN = 20
+    };
+
+protected:
+    void setupWidgets();
+    void setupBushuWidgets();
+
+    void writeConfig();
+    void readConfig();
+
+    void setCharDictFont( const QFont &font );
+
+public slots:
+    void changeMode( int mode );
+
+protected slots:
+    void slotSelectFont();
+    void slotCharSelected( const QString &c );
+
+protected:
+    QComboBox *m_modeCombo;
+    QToolButton *m_fontselButton;
+    QLineEdit *m_charLineEdit;
+
+    QWidgetStack *m_widgetStack;
+    BushuViewWidget *m_bushuView;
+    UnicodeViewWidget *m_unicodeView;
+};
+
+class CharDictViewBase : public QWidget
+{
+    Q_OBJECT
+
+public:
+    CharDictViewBase( QWidget *parent = 0, const char *name = 0 )
+            : QWidget( parent, name ) {}
+
+    virtual void setFont( const QFont &font ) = 0;
+
+signals:
+    void charSelected( const QString & );
+};
+
+#endif /* Not def: _UIM_CHARDICT_QT_H_ */

Added: trunk/qt/chardict-unicodeviewwidget.cpp
===================================================================
--- trunk/qt/chardict-unicodeviewwidget.cpp	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-unicodeviewwidget.cpp	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,285 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#include "chardict-unicodeviewwidget.h"
+#include "chardict-chargridview.h"
+
+#include <qlayout.h>
+#include <qvbox.h>
+#include <qlabel.h>
+#include <qheader.h>
+#include <qsettings.h>
+
+#include "qtgettext.h"
+
+class UnicodeBlock
+{
+public:
+    UnicodeBlock( const QString &name, ushort startHex, ushort endHex )
+    {
+        m_name = name;
+        m_startHex = startHex;
+        m_endHex = endHex;
+    }
+
+    QString getName() const { return m_name; }
+    ushort getStartHex() const { return m_startHex; }
+    ushort getEndHex() const { return m_endHex; }
+
+protected:
+    QString m_name;
+    ushort m_startHex;
+    ushort m_endHex;
+};
+
+#define UBLOCK_SIZE 125
+static UnicodeBlock uBlocks[ UBLOCK_SIZE ] = {
+            UnicodeBlock( _( "Basic Latin" ), 0x0000, 0x007F ),
+            UnicodeBlock( _( "Latin-1 Supplement" ), 0x0080, 0x00FF ),
+            UnicodeBlock( _( "Latin Extended-A" ), 0x0100, 0x017F ),
+            UnicodeBlock( _( "Latin Extended-B" ), 0x0180, 0x024F ),
+            UnicodeBlock( _( "IPA Extensions" ), 0x0250, 0x02AF ),
+            UnicodeBlock( _( "Spacing Modifier Letters" ), 0x02B0, 0x02FF ),
+            UnicodeBlock( _( "Combining Diacritical Marks" ), 0x0300, 0x036F ),
+            UnicodeBlock( _( "Greek and Coptic" ), 0x0370, 0x03FF ),
+            UnicodeBlock( _( "Cyrillic" ), 0x0400, 0x04FF ),
+            UnicodeBlock( _( "Cyrillic Supplement" ), 0x0500, 0x052F ),
+            UnicodeBlock( _( "Armenian" ), 0x0530, 0x058F ),
+            UnicodeBlock( _( "Hebrew" ), 0x0590, 0x05FF ),
+            UnicodeBlock( _( "Arabic" ), 0x0600, 0x06FF ),
+            UnicodeBlock( _( "Syriac" ), 0x0700, 0x074F ),
+            UnicodeBlock( _( "Thaana" ), 0x0780, 0x07BF ),
+            UnicodeBlock( _( "Devanagari" ), 0x0900, 0x097F ),
+            UnicodeBlock( _( "Bengali" ), 0x0980, 0x09FF ),
+            UnicodeBlock( _( "Gurmukhi" ), 0x0A00, 0x0A7F ),
+            UnicodeBlock( _( "Gujarati" ), 0x0A80, 0x0AFF ),
+            UnicodeBlock( _( "Oriya" ), 0x0B00, 0x0B7F ),
+            UnicodeBlock( _( "Tamil" ), 0x0B80, 0x0BFF ),
+            UnicodeBlock( _( "Telugu" ), 0x0C00, 0x0C7F ),
+            UnicodeBlock( _( "Kannada" ), 0x0C80, 0x0CFF ),
+            UnicodeBlock( _( "Malayalam" ), 0x0D00, 0x0D7F ),
+            UnicodeBlock( _( "Sinhala" ), 0x0D80, 0x0DFF ),
+            UnicodeBlock( _( "Thai" ), 0x0E00, 0x0E7F ),
+            UnicodeBlock( _( "Lao" ), 0x0E80, 0x0EFF ),
+            UnicodeBlock( _( "Tibetan" ), 0x0F00, 0x0FFF ),
+            UnicodeBlock( _( "Myanmar" ), 0x1000, 0x109F ),
+            UnicodeBlock( _( "Georgian" ), 0x10A0, 0x10FF ),
+            UnicodeBlock( _( "Hangul Jamo" ), 0x1100, 0x11FF ),
+            UnicodeBlock( _( "Ethiopic" ), 0x1200, 0x137F ),
+            UnicodeBlock( _( "Cherokee" ), 0x13A0, 0x13FF ),
+            UnicodeBlock( _( "Unified Canadian Aboriginal Syllabics" ), 0x1400, 0x167F ),
+            UnicodeBlock( _( "Ogham" ), 0x1680, 0x169F ),
+            UnicodeBlock( _( "Runic" ), 0x16A0, 0x16FF ),
+            UnicodeBlock( _( "Tagalog" ), 0x1700, 0x171F ),
+            UnicodeBlock( _( "Hanunoo" ), 0x1720, 0x173F ),
+            UnicodeBlock( _( "Buhid" ), 0x1740, 0x175F ),
+            UnicodeBlock( _( "Tagbanwa" ), 0x1760, 0x177F ),
+            UnicodeBlock( _( "Khmer" ), 0x1780, 0x17FF ),
+            UnicodeBlock( _( "Mongolian" ), 0x1800, 0x18AF ),
+            UnicodeBlock( _( "Limbu" ), 0x1900, 0x194F ),
+            UnicodeBlock( _( "Tai Letters" ), 0x1950, 0x197F ),
+            UnicodeBlock( _( "Khmer Symbols" ), 0x19E0, 0x19FF ),
+            UnicodeBlock( _( "Phonetic Extensions" ), 0x1D00, 0x1D7F ),
+            UnicodeBlock( _( "Latin Extended Additional" ), 0x1E00, 0x1EFF ),
+            UnicodeBlock( _( "Greek Extended-B" ), 0x1F00, 0x1FFF ),
+            UnicodeBlock( _( "General Punctuation" ), 0x2000, 0x206F ),
+            UnicodeBlock( _( "Superscripts and Subscripts" ), 0x2070, 0x209F ),
+            UnicodeBlock( _( "Currency Symbols" ), 0x20A0, 0x20CF ),
+            UnicodeBlock( _( "Combining Diacritical Marks for Symbols" ), 0x20D0, 0x20FF ),
+            UnicodeBlock( _( "Letterlike Symbols" ), 0x2100, 0x214F ),
+            UnicodeBlock( _( "Number Forms" ), 0x2150, 0x218F ),
+            UnicodeBlock( _( "Arrows" ), 0x2190, 0x21FF ),
+            UnicodeBlock( _( "Mathematical Operators" ), 0x2200, 0x22FF ),
+            UnicodeBlock( _( "Miscellaneous Technical" ), 0x2300, 0x23FF ),
+            UnicodeBlock( _( "Control Pictures" ), 0x2400, 0x243F ),
+            UnicodeBlock( _( "Optical Character Recognition" ), 0x2440, 0x245F ),
+            UnicodeBlock( _( "Enclosed Alphanumerics" ), 0x2460, 0x24FF ),
+            UnicodeBlock( _( "Box Drawing" ), 0x2500, 0x257F ),
+            UnicodeBlock( _( "Block Elements" ), 0x2580, 0x259F ),
+            UnicodeBlock( _( "Geometric Shapes" ), 0x25A0, 0x25FF ),
+            UnicodeBlock( _( "Miscellaneous Symbols" ), 0x2600, 0x26FF ),
+            UnicodeBlock( _( "Dingbats" ), 0x2700, 0x27BF ),
+            UnicodeBlock( _( "Miscellaneous Mathematical Symbols-A" ), 0x27C0, 0x27EF ),
+            UnicodeBlock( _( "Supplemental Arrows-A" ), 0x27F0, 0x27FF ),
+            UnicodeBlock( _( "Braille Patterns" ), 0x2800, 0x28FF ),
+            UnicodeBlock( _( "Supplemental Arrows-B" ), 0x2900, 0x297F ),
+            UnicodeBlock( _( "Miscellaneous Mathematical Symbols-B" ), 0x2980, 0x29FF ),
+            UnicodeBlock( _( "Supplemental Mathematical Operators" ), 0x2A00, 0x2AFF ),
+            UnicodeBlock( _( "Miscellaneous Symbols and Arrows-B" ), 0x2B00, 0x2BFF ),
+            UnicodeBlock( _( "CJK Radicals Supplemental" ), 0x2E80, 0x2EFF ),
+            UnicodeBlock( _( "Kangxi Radicals" ), 0x2F00, 0x2FDF ),
+            UnicodeBlock( _( "Ideographic Description Characters" ), 0x2FF0, 0x2FFF ),
+            UnicodeBlock( _( "CJK Symbols and Punctuation" ), 0x3000, 0x303F ),
+            UnicodeBlock( _( "Hiragana" ), 0x3040, 0x309F ),
+            UnicodeBlock( _( "Katakana" ), 0x30A0, 0x30FF ),
+            UnicodeBlock( _( "Bopomofo" ), 0x3100, 0x312F ),
+            UnicodeBlock( _( "Hangul Compatibility Jamo" ), 0x3130, 0x318F ),
+            UnicodeBlock( _( "Kanbun" ), 0x3190, 0x319F ),
+            UnicodeBlock( _( "Bopomofo Extended-B 1F00" ), 0x31A0, 0x31BF ),
+            UnicodeBlock( _( "Katakana Phonetic Extensions" ), 0x31F0, 0x31FF ),
+            UnicodeBlock( _( "Enclosed CJK Letters and Months" ), 0x3200, 0x32FF ),
+            UnicodeBlock( _( "CJK Compatibility" ), 0x3300, 0x33FF ),
+            UnicodeBlock( _( "CJK Unified Ideographs Extension and" ), 0x3400, 0x4DBF ),
+            UnicodeBlock( _( "Yijing Hexagram Symbols-B" ), 0x4DC0, 0x4DFF ),
+            UnicodeBlock( _( "CJK Unified Ideographs" ), 0x4E00, 0x9FFF ),
+            UnicodeBlock( _( "Yi Syllables" ), 0xA000, 0xA48F ),
+            UnicodeBlock( _( "Yi Radicals" ), 0xA490, 0xA4CF ),
+            UnicodeBlock( _( "Hangul Syllables" ), 0xAC00, 0xD7AF ),
+            UnicodeBlock( _( "High Surrogates" ), 0xD800, 0xDB7F ),
+            UnicodeBlock( _( "High Private Use Surrogates" ), 0xDB80, 0xDBFF ),
+            UnicodeBlock( _( "Low Surrogates" ), 0xDC00, 0xDFFF ),
+            UnicodeBlock( _( "Private Use Area" ), 0xE000, 0xF8FF ),
+            UnicodeBlock( _( "CJK Compatibility Ideographs" ), 0xF900, 0xFAFF ),
+            UnicodeBlock( _( "Alphabetic Presentation Forms" ), 0xFB00, 0xFB4F ),
+            UnicodeBlock( _( "Arabic Presentation Forms-A" ), 0xFB50, 0xFDFF ),
+            UnicodeBlock( _( "Variation Selectors" ), 0xFE00, 0xFE0F ),
+            UnicodeBlock( _( "Combining Half Marks" ), 0xFE20, 0xFE2F ),
+            UnicodeBlock( _( "CJK Compatibility Forms-A" ), 0xFE30, 0xFE4F ),
+            UnicodeBlock( _( "Small Form Variants" ), 0xFE50, 0xFE6F ),
+            UnicodeBlock( _( "Arabic Presentation Forms-B" ), 0xFE70, 0xFEFF ),
+            UnicodeBlock( _( "Halfwidth and Fullwidth Forms-B" ), 0xFF00, 0xFFEF ),
+            UnicodeBlock( _( "Specials" ), 0xFFF0, 0xFFFF ),
+            UnicodeBlock( _( "Linear B Syllabary" ), 0x10000, 0x1007F ),
+            UnicodeBlock( _( "Linear B Ideograms" ), 0x10080, 0x100FF ),
+            UnicodeBlock( _( "Aegean Numbers" ), 0x10100, 0x1013F ),
+            UnicodeBlock( _( "Old Italic" ), 0x10300, 0x1032F ),
+            UnicodeBlock( _( "Gothic" ), 0x10330, 0x1034F ),
+            UnicodeBlock( _( "Ugaritic" ), 0x10380, 0x1039F ),
+            UnicodeBlock( _( "Deseret" ), 0x10400, 0x1044F ),
+            UnicodeBlock( _( "Shavian" ), 0x10450, 0x1047F ),
+            UnicodeBlock( _( "Osmanya" ), 0x10480, 0x104AF ),
+            UnicodeBlock( _( "Cypriot Syllabary" ), 0x10800, 0x1083F ),
+            UnicodeBlock( _( "Byzantine Musical Symbols-B 4DC0" ), 0x1D000, 0x1D0FF ),
+            UnicodeBlock( _( "Musical Symbols-B 4DC0 1D000" ), 0x1D100, 0x1D1FF ),
+            UnicodeBlock( _( "Tai Xuan Jing Symbols-B 4DC0 1D000 1D100" ), 0x1D300, 0x1D35F ),
+            UnicodeBlock( _( "Mathematical Alphanumeric Symbols-B 4DC0 1D000 1D100 1D300" ), 0x1D400, 0x1D7FF ),
+            UnicodeBlock( _( "CJK Unified Ideographs Extension B 4DC0 1D000 1D100 1D300 1D400" ), 0x20000, 0x2A6DF ),
+            UnicodeBlock( _( "CJK Compatibility Ideographs Supplemental 2E80" ), 0x2F800, 0x2FA1F ),
+            UnicodeBlock( _( "Tags" ), 0xE0000, 0xE007F ),
+            UnicodeBlock( _( "Variation Selectors Supplemental 2E80 2F800" ), 0xE0100, 0xE01EF ),
+            UnicodeBlock( _( "Supplementary Private Use Area-A" ), 0xF0000, 0xFFFFF ),
+            UnicodeBlock( _( "Supplementary Private Use Area-B" ), 0x100000, 0x10FFFF )
+        };
+
+UnicodeViewWidget::UnicodeViewWidget( QWidget *parent, const char *name )
+        : CharDictViewBase( parent, name )
+{
+    uBlockMap.clear();
+
+    setupWidgets();
+
+    readConfig();
+}
+
+UnicodeViewWidget::~UnicodeViewWidget()
+{
+    writeConfig();
+}
+
+void UnicodeViewWidget::setupWidgets()
+{
+    m_mainSplitter = new QSplitter( this );
+
+    QVBox *leftVBox = new QVBox( m_mainSplitter );
+    QLabel *unicodeBlockLabel = new QLabel( leftVBox );
+    unicodeBlockLabel->setText( _( "UnicodeBlock List" ) );
+    unicodeBlockLabel->setAlignment( Qt::AlignHCenter );
+    m_unicodeBlockListView = new QListView( leftVBox );
+    m_unicodeBlockListView->setSorting( -1 );
+    m_unicodeBlockListView->setSelectionMode( QListView::Single );
+    m_unicodeBlockListView->addColumn( "0" );
+    m_unicodeBlockListView->header() ->setStretchEnabled( true, 0 );
+    m_unicodeBlockListView->header() ->hide();
+    m_unicodeBlockListView->setColumnWidthMode( 1, QListView::Maximum );
+    m_unicodeBlockListView->setHScrollBarMode( QScrollView::AlwaysOff );
+    m_unicodeBlockListView->setAllColumnsShowFocus( true );
+    QObject::connect( m_unicodeBlockListView, SIGNAL( selectionChanged( QListViewItem * ) ),
+                      this, SLOT( slotUnicodeBlockSelected( QListViewItem * ) ) );
+    // add Item
+    for ( int i = ( UBLOCK_SIZE - 1 ); i >= 0; i-- )
+    {
+        QListViewItem *item = new QListViewItem( m_unicodeBlockListView, uBlocks[ i ].getName() );
+        uBlockMap[ item ] = &uBlocks[ i ];
+    }
+
+    m_charGridView = new CharGridView( 10, 0, m_mainSplitter );
+    QObject::connect( m_charGridView, SIGNAL( charSelected( const QString & ) ),
+                      this, SIGNAL( charSelected( const QString & ) ) );
+
+    // main layout
+    QHBoxLayout* layout = new QHBoxLayout( this );
+    layout->addWidget( m_mainSplitter );
+}
+
+void UnicodeViewWidget::slotUnicodeBlockSelected( QListViewItem *item )
+{
+    UnicodeBlock * block = uBlockMap[ item ];
+
+    QStringList charList;
+    for ( ushort d = block->getStartHex(); d < block->getEndHex(); d++ )
+    {
+        charList.append( QString( QChar( d ) ) );
+    }
+
+    m_charGridView->setCharacters( charList );
+}
+
+void UnicodeViewWidget::writeConfig()
+{
+    QSettings settings;
+
+    // splitter
+    QString str;
+    QTextOStream out( &str );
+    out << *m_mainSplitter;
+    settings.writeEntry( "/uim-kdehelper/chardict/unicodeview/splitter", str );
+}
+void UnicodeViewWidget::readConfig()
+{
+    QSettings settings;
+    QString str;
+
+    // splitter
+    str = settings.readEntry( "/uim-kdehelper/chardict/unicodeview/splitter" );
+    if ( !str.isEmpty() )
+    {
+        QTextIStream in( &str );
+        in >> *m_mainSplitter;
+    }
+}
+
+void UnicodeViewWidget::setFont( const QFont &font )
+{
+    m_charGridView->setFont( font );
+}
+
+#include "chardict-unicodeviewwidget.moc"

Added: trunk/qt/chardict-unicodeviewwidget.h
===================================================================
--- trunk/qt/chardict-unicodeviewwidget.h	2005-02-05 05:17:25 UTC (rev 530)
+++ trunk/qt/chardict-unicodeviewwidget.h	2005-02-05 05:41:11 UTC (rev 531)
@@ -0,0 +1,74 @@
+/*
+
+Copyright (c) 2003,2004,2005 uim Project http://uim.freedesktop.org/
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+3. Neither the name of authors nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+*/
+#ifndef _UNICODE_VIEW_WIDGET_H_
+#define _UNICODE_VIEW_WIDGET_H_
+
+#include "chardict-qt.h"
+
+#include <qlistview.h>
+#include <qwidget.h>
+#include <qsplitter.h>
+#include <qmap.h>
+#include <qfont.h>
+
+class CharGridView;
+class UnicodeBlock;
+
+class UnicodeViewWidget : public CharDictViewBase
+{
+    Q_OBJECT
+
+public:
+    UnicodeViewWidget( QWidget *parent = 0, const char *name = 0 );
+    ~UnicodeViewWidget();
+
+    void setFont( const QFont &font );
+
+protected:
+    void setupWidgets();
+
+    void writeConfig();
+    void readConfig();
+
+protected slots:
+    void slotUnicodeBlockSelected( QListViewItem * );
+
+protected:
+    QMap<QListViewItem *, UnicodeBlock*> uBlockMap;
+
+    QSplitter *m_mainSplitter;
+    QListView *m_unicodeBlockListView;
+    CharGridView *m_charGridView;
+};
+
+#endif /* Not def: _UNICODE_VIEW_WIDGET_H_ */



More information about the Uim-commit mailing list