[uim-commit] r382 - trunk/qt/uim-kdehelper/src/pref

kzk@freedesktop.org kzk@freedesktop.org
Fri Jan 28 11:22:16 PST 2005


Author: kzk
Date: 2005-01-28 11:22:01 -0800 (Fri, 28 Jan 2005)
New Revision: 382

Added:
   trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp
   trunk/qt/uim-kdehelper/src/pref/kseparator.cpp
   trunk/qt/uim-kdehelper/src/pref/kseparator.h
   trunk/qt/uim-kdehelper/src/pref/olisteditformbase.ui
Modified:
   trunk/qt/uim-kdehelper/src/pref/Makefile.am
   trunk/qt/uim-kdehelper/src/pref/customwidgets.h
   trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp
Log:
* Enhancement of uim-pref-qt. (this is my escaping from test:-P)
  The main enhancement is implementing ordered list editing.

* uim-kdehelper/src/Makefile.am
  - add customwidgets.cpp, kseparator.h, kseparator.cpp,
    and  olisteditformbase.ui.
* uim-kdehelper/src/olisteditformbase.ui
  - the ui file for OrderedListEdit dialog
* uim-kdehelper/src/pref/customwidgets.h
  - move contents to customwidgets.cpp
  - (class CustomOrderedListEdit): new class
  - (class OListEditForm): new class
* uim-kdehelper/src/pref/customwidgets.cpp
  - new file(the contents is moved from customwidgets.h)
  - (class CustomOrderedListEdit): new class
  - (class OListEditForm): new class
* uim-kdehelper/src/pref/uim-pref-qt.cpp
  - (createGroupWidget): display title as KControl and use KSeparator
  - (slotCancel): not confirm change if nothing is changed when
    cancel button is clicked.
  - (addCustomTypeOrderedList): new function
* uim-kdehelper/src/pref/kseparator.h
* uim-kdehelper/src/pref/kseparator.cpp
  - separator widget ported from kdelibs



Modified: trunk/qt/uim-kdehelper/src/pref/Makefile.am
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/Makefile.am	2005-01-28 18:29:09 UTC (rev 381)
+++ trunk/qt/uim-kdehelper/src/pref/Makefile.am	2005-01-28 19:22:01 UTC (rev 382)
@@ -1,10 +1,9 @@
 INCLUDES = $(all_includes)
 METASOURCES = AUTO
 
-noinst_HEADERS = uim-pref-qt.h customwidgets.h
+noinst_HEADERS = uim-pref-qt.h customwidgets.h kseparator.h
 
 bin_PROGRAMS = uim-pref-qt
-uim_pref_qt_SOURCES = uim-pref-qt.cpp
+uim_pref_qt_SOURCES = uim-pref-qt.cpp customwidgets.cpp kseparator.cpp olisteditformbase.ui
 uim_pref_qt_LDFLAGS = $(all_libraries) $(KDE_RPATH) -luim -luim-custom
 uim_pref_qt_LDADD = $(LIB_QT) $(LIB_KUTILS)
-

Added: trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp	2005-01-28 18:29:09 UTC (rev 381)
+++ trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp	2005-01-28 19:22:01 UTC (rev 382)
@@ -0,0 +1,372 @@
+/*
+
+ 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 "customwidgets.h"
+
+#define _FU8(String) QString::fromUtf8(String)
+
+CustomCheckBox::CustomCheckBox( struct uim_custom *c, QWidget *parent, const char *name )
+    : QCheckBox( parent, name ),
+      UimCustomItemIface( c )
+{
+    QObject::connect( this, SIGNAL(toggled(bool)),
+                      this, SLOT(slotCustomToggled(bool)) );
+}
+
+void CustomCheckBox::slotCustomToggled( bool check )
+{
+    Q_ASSERT( m_custom->type == UCustom_Bool );
+
+    m_custom->value->as_bool = check;
+    setCustom( m_custom );
+}
+
+CustomSpinBox::CustomSpinBox( struct uim_custom *c, QWidget *parent, const char *name)
+    : QSpinBox( parent, name ),
+      UimCustomItemIface( c )
+{
+    QObject::connect( this, SIGNAL(valueChanged(int)),
+                      this, SLOT(slotCustomValueChanged(int)) );
+}
+
+void CustomSpinBox::slotCustomValueChanged( int value )
+{
+    Q_ASSERT( m_custom->type == UCustom_Int );
+
+    m_custom->value->as_int = value;
+    setCustom( m_custom );
+}
+
+CustomLineEdit::CustomLineEdit( struct uim_custom *c, QWidget *parent, const char *name)
+    : QLineEdit( parent, name ),
+      UimCustomItemIface( c )
+{
+    QObject::connect( this, SIGNAL(textChanged(const QString&)),
+                      this, SLOT(slotCustomTextChanged(const QString&)) );
+}
+
+void CustomLineEdit::slotCustomTextChanged( const QString &text )
+{
+    Q_ASSERT( m_custom->type == UCustom_Str );
+
+    free( m_custom->value->as_str );
+    m_custom->value->as_str = strdup( (const char*)text.utf8() );
+
+    setCustom( m_custom );
+}
+
+CustomPathnameEdit::CustomPathnameEdit( struct uim_custom *c, QWidget *parent, const char *name)
+    : QHBox( parent, name ),
+      UimCustomItemIface( c )
+{
+    setSpacing( 3 );
+    m_lineEdit = new QLineEdit( this );
+    m_lineEdit->setText( m_custom->value->as_pathname );
+    QObject::connect( m_lineEdit, SIGNAL(textChanged(const QString &)),
+                      this, SLOT(slotCustomTextChanged(const QString &)) );
+    m_fileButton = new QToolButton( this );
+    m_fileButton->setText( "File" );
+    QObject::connect( m_fileButton, SIGNAL(clicked()),
+                      this, SLOT(slotPathnameButtonClicked()) );
+}
+
+void CustomPathnameEdit::slotPathnameButtonClicked()
+{
+    QFileDialog* fd = new QFileDialog( this, "file dialog" );
+    fd->setMode( QFileDialog::Directory );
+    if ( fd->exec() == QDialog::Accepted )
+    {
+        QString fileName = fd->selectedFile();
+        m_lineEdit->setText( fileName );
+    }
+}
+
+void CustomPathnameEdit::slotCustomTextChanged( const QString & text )
+{
+    Q_ASSERT( m_custom->type == UCustom_Pathname );
+
+    free( m_custom->value->as_pathname );
+    m_custom->value->as_pathname = strdup( (const char*)text.utf8() );
+
+    setCustom( m_custom );
+}
+
+CustomChoiceCombo::CustomChoiceCombo( struct uim_custom *c, QWidget *parent, const char *name)
+    : QComboBox( parent, name ),
+      UimCustomItemIface( c )
+{
+    QObject::connect( this, SIGNAL(highlighted(int)),
+                      this, SLOT(slotHighlighted(int)) );
+}
+
+void CustomChoiceCombo::slotHighlighted( int index )
+{
+    Q_ASSERT( m_custom->type == UCustom_Choice );
+
+    struct uim_custom_choice **valid_items = m_custom->range->as_choice.valid_items;
+    struct uim_custom_choice *choice = NULL;
+    if( valid_items )
+    {
+        for( int i = 0; valid_items[i]; i++ )
+        {
+            if( i == index )
+                choice = valid_items[i];
+        }
+    }
+
+    free( m_custom->value->as_choice->symbol );
+    free( m_custom->value->as_choice->label );
+    free( m_custom->value->as_choice->desc );
+
+    m_custom->value->as_choice->symbol = strdup( choice->symbol );
+    m_custom->value->as_choice->label  = strdup( choice->label );
+    m_custom->value->as_choice->desc   = strdup( choice->desc );
+
+    setCustom( m_custom );
+}
+
+CustomOrderedListEdit::CustomOrderedListEdit( struct uim_custom *c, QWidget *parent, const char *name )
+    : QHBox( parent, name ),
+      UimCustomItemIface( c )
+{
+    setSpacing( 3 );
+
+    m_lineEdit = new QLineEdit( this );
+    m_editButton = new QToolButton( this );
+    m_editButton->setText( "Edit" );
+
+    initPtrList();
+
+    QString str = QString::null;
+    if( m_custom->value->as_olist )
+    {
+        struct uim_custom_choice *item = NULL;
+        int i = 0;
+        for( item = m_custom->value->as_olist[0], i = 0;
+             item;
+             item = m_custom->value->as_olist[++i] )
+        {
+            if( i != 0 )
+                str.append(",");
+            str.append( _FU8(item->label) );
+        }
+    }
+    m_lineEdit->setText( str );
+
+    QObject::connect( m_editButton, SIGNAL(clicked()),
+                      this, SLOT(slotEditButtonClicked()) );
+}
+
+void CustomOrderedListEdit::initPtrList()
+{
+    m_itemList.clear();
+    m_validItemList.clear();
+    
+    if( m_custom->value->as_olist )
+    {
+        struct uim_custom_choice *item = NULL;
+        int i = 0;
+        for( item = m_custom->value->as_olist[0], i = 0;
+             item;
+             item = m_custom->value->as_olist[++i] )
+        {
+            m_itemList.append( item );
+        }
+    }
+
+    if( m_custom->value->as_olist && m_custom->range->as_olist.valid_items )
+    {
+        struct uim_custom_choice *item = NULL;
+        int i = 0;
+        for( item = m_custom->range->as_olist.valid_items[0], i = 0;
+             item;
+             item = m_custom->range->as_olist.valid_items[++i] )
+        {
+            m_validItemList.append( item );
+        }
+    }
+}
+
+void CustomOrderedListEdit::slotEditButtonClicked()
+{
+    OListEditForm *d = new OListEditForm( this );
+
+    /*
+     * Adding items
+     * The item whose symbol doesn't match any valid_item's symbol is inactive.
+     */
+    for( struct uim_custom_choice *valid_item = m_validItemList.first();
+         valid_item;
+         valid_item = m_validItemList.next() )
+    {
+        bool isActive = false;
+        for( struct uim_custom_choice *item = m_itemList.first();
+             item;
+             item = m_itemList.next() )
+        {
+            if( QString::compare( valid_item->symbol, item->symbol ) == 0 )
+            {
+                isActive = true;
+                break;
+            }
+        }
+
+        d->addCheckItem( isActive, _FU8(valid_item->label) );
+    }
+
+    /* Exec Dialog */
+    if( d->exec() == OListEditForm::Accepted )
+    {
+        /* search active item's ptr, realloc it, and store in activeItemList */
+        QPtrList<struct uim_custom_choice> activeItemList;
+        activeItemList.setAutoDelete( false );
+
+        QStringList activeItemLabelList = d->activeItemLabels();
+        for( unsigned int i = 0; i < activeItemLabelList.count(); i++ )
+        {
+            qDebug("label = %s", (const char*)activeItemLabelList[i] );
+            struct uim_custom_choice *item = NULL;
+            int j = 0;
+            for( item = m_custom->range->as_olist.valid_items[0], j = 0;
+                 item;
+                 item = m_custom->range->as_olist.valid_items[++j] )
+            {
+                if( QString::compare( activeItemLabelList[i], _FU8(item->label) ) == 0 )
+                {
+                    /* allocate new struct because we will free the old struct */
+                    struct uim_custom_choice *activeItem = (struct uim_custom_choice *)malloc(sizeof(struct uim_custom_choice));
+                    activeItem->symbol = item->symbol ? strdup(item->symbol) : NULL;
+                    activeItem->label  = item->label  ? strdup(item->label)  : NULL;
+                    activeItem->desc   = item->desc   ? strdup(item->desc)   : NULL;
+                    activeItemList.append( activeItem );
+
+                    qDebug("active sym2 = %s", (const char*)activeItemLabelList[i] );
+                    qDebug("active sym1 = %s", (const char*)_FU8(item->label) );
+                    qDebug("active sym  = %s", (const char*)_FU8(activeItem->symbol) );
+
+                    break;
+                }
+            }
+        }
+
+        /* free old olist */
+        for( unsigned int i = 0; i < m_itemList.count(); i++ )
+        {
+            free( m_custom->value->as_olist[i]->symbol );
+            free( m_custom->value->as_olist[i]->label );
+            free( m_custom->value->as_olist[i]->desc );
+            free( m_custom->value->as_olist[i] );
+        }
+
+        /* create null-terminated new olist */
+        m_custom->value->as_olist = (struct uim_custom_choice **)realloc( m_custom->value->as_olist,
+                                                                         sizeof(struct uim_custom_choice *) * (activeItemList.count() + 1) );
+        for( unsigned int i = 0; i < activeItemList.count(); i++ )
+        {
+            m_custom->value->as_olist[i] = activeItemList.at(i);
+        }
+        m_custom->value->as_olist[activeItemList.count()] = NULL;
+
+        /* save */
+        setCustom( m_custom );
+
+        /* reload */
+        initPtrList();
+    }
+}
+
+OListEditForm::OListEditForm( QWidget *parent, const char *name )
+    : OListEditFormBase( parent, name )
+{
+    m_listView->setSorting( -1 );
+
+    QObject::connect( m_upButton, SIGNAL(clicked()),
+                      this, SLOT(upItem()) );
+    QObject::connect( m_downButton, SIGNAL(clicked()),
+                      this, SLOT(downItem()) );
+}
+
+void OListEditForm::addCheckItem( bool isActive, const QString &str )
+{
+    QCheckListItem *item = NULL;
+    QListViewItem *lastItem = m_listView->lastItem();
+    if( lastItem )
+        item = new QCheckListItem( m_listView, lastItem, str, QCheckListItem::CheckBox );
+    else
+        item = new QCheckListItem( m_listView, str, QCheckListItem::CheckBox );
+
+    if( item )
+        item->setOn( isActive );
+}
+
+void OListEditForm::upItem()
+{
+    QListViewItem *selectedItem = m_listView->selectedItem();
+    if( selectedItem )
+    {
+        QListViewItem *previousItem = NULL;
+        for( QListViewItem *item = m_listView->firstChild(); item; item = item->nextSibling() )
+        {
+            if( item->nextSibling() == selectedItem )
+                previousItem = item;
+        }
+
+        if( previousItem )
+            previousItem->moveItem( selectedItem );
+    }
+}
+
+void OListEditForm::downItem()
+{
+    QListViewItem *selectedItem = m_listView->selectedItem();
+    if( selectedItem )
+    {
+        QListViewItem *nextItem = selectedItem->nextSibling();
+        if( nextItem )
+            selectedItem->moveItem( nextItem );
+    }
+}
+
+QStringList OListEditForm::activeItemLabels() const
+{
+    QStringList activeItemLabelList;
+    for( QCheckListItem *item = (QCheckListItem*)m_listView->firstChild();
+         item;
+         item = (QCheckListItem*)item->nextSibling() )
+    {
+        if( item->isOn() )
+        {
+            activeItemLabelList << item->text( 0 );
+        }
+    }
+    return activeItemLabelList;
+}

Modified: trunk/qt/uim-kdehelper/src/pref/customwidgets.h
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/customwidgets.h	2005-01-28 18:29:09 UTC (rev 381)
+++ trunk/qt/uim-kdehelper/src/pref/customwidgets.h	2005-01-28 19:22:01 UTC (rev 382)
@@ -53,7 +53,10 @@
 #include <qlineedit.h>
 #include <qfiledialog.h>
 #include <qcombobox.h>
+#include <qptrlist.h>
 
+#include "olisteditformbase.h"
+
 class UimCustomItemIface
 {
 public:
@@ -87,23 +90,9 @@
     Q_OBJECT
 
 public:
-    CustomCheckBox( struct uim_custom *c, QWidget *parent, const char *name = 0 )
-        : QCheckBox( parent, name ),
-          UimCustomItemIface( c )
-    {
-        QObject::connect( this, SIGNAL(toggled(bool)),
-                          this, SLOT(slotCustomToggled(bool)) );
-    }
-
+    CustomCheckBox( struct uim_custom *c, QWidget *parent, const char *name = 0);
 protected slots:
-    void slotCustomToggled( bool check )
-    {
-        Q_ASSERT( m_custom->type == UCustom_Bool );
-
-        m_custom->value->as_bool = check;
-        setCustom( m_custom );
-    }
-
+    void slotCustomToggled( bool check );
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }
 signals:
@@ -115,23 +104,9 @@
     Q_OBJECT
 
 public:
-    CustomSpinBox( struct uim_custom *c, QWidget *parent, const char *name = 0 )
-        : QSpinBox( parent, name ),
-          UimCustomItemIface( c )
-    {
-        QObject::connect( this, SIGNAL(valueChanged(int)),
-                          this, SLOT(slotCustomValueChanged(int)) );
-    }
-
+    CustomSpinBox( struct uim_custom *c, QWidget *parent, const char *name = 0 );
 public slots:
-    void slotCustomValueChanged( int value )
-    {
-        Q_ASSERT( m_custom->type == UCustom_Int );
-
-        m_custom->value->as_int = value;
-        setCustom( m_custom );
-    }
-
+    void slotCustomValueChanged( int value );
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }    
 signals:
@@ -143,25 +118,9 @@
     Q_OBJECT
 
 public:
-    CustomLineEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 )
-        : QLineEdit( parent, name ),
-          UimCustomItemIface( c )
-    {
-        QObject::connect( this, SIGNAL(textChanged(const QString&)),
-                          this, SLOT(slotCustomTextChanged(const QString&)) );
-    }
-
+    CustomLineEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 );
 public slots:
-    void slotCustomTextChanged( const QString &text )
-    {
-        Q_ASSERT( m_custom->type == UCustom_Str );
-
-        free( m_custom->value->as_str );
-        m_custom->value->as_str = strdup( (const char*)text.utf8() );
-
-        setCustom( m_custom );
-    }
-
+    void slotCustomTextChanged( const QString &text );
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }    
 signals:
@@ -173,52 +132,15 @@
     Q_OBJECT
 
 public:
-    CustomPathnameEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 )
-        : QHBox( parent, name ),
-          UimCustomItemIface( c )
-    {
-        setSpacing( 6 );
-        m_lineEdit = new QLineEdit( this );
-        m_lineEdit->setText( m_custom->value->as_pathname );
-        QObject::connect( m_lineEdit, SIGNAL(textChanged(const QString &)),
-                          this, SLOT(slotCustomTextChanged(const QString &)) );
-        QToolButton *m_fileButton = new QToolButton( this );
-        m_fileButton->setText( "File" );
-        QObject::connect( m_fileButton, SIGNAL(clicked()),
-                          this, SLOT(slotPathnameButtonClicked()) );
-    }
+    CustomPathnameEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 );
+    void setText( const QString & str ) { m_lineEdit->setText( str ); }
 
-    void setText( const QString & str )
-    {
-        m_lineEdit->setText( str );
-    }
-
 protected slots:
-    void slotPathnameButtonClicked()
-    {
-        QFileDialog* fd = new QFileDialog( this, "file dialog" );
-        fd->setMode( QFileDialog::Directory );
-        if ( fd->exec() == QDialog::Accepted )
-        {
-            QString fileName = fd->selectedFile();
-            m_lineEdit->setText( fileName );
-        }
-    }
-
-    void slotCustomTextChanged( const QString & text )
-    {
-        Q_ASSERT( m_custom->type == UCustom_Pathname );
-
-        free( m_custom->value->as_pathname );
-        m_custom->value->as_pathname = strdup( (const char*)text.utf8() );
-
-        setCustom( m_custom );
-    }
-
+    void slotPathnameButtonClicked();
+    void slotCustomTextChanged( const QString & text );
 private:
     QLineEdit *m_lineEdit;
-    QToolButton *m_filebutton;
-
+    QToolButton *m_fileButton;
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }
 signals:
@@ -230,45 +152,47 @@
     Q_OBJECT
 
 public:
-    CustomChoiceCombo( struct uim_custom *c, QWidget *parent, const char *name = 0 )
-        : QComboBox( parent, name ),
-          UimCustomItemIface( c )
-    {
-        QObject::connect( this, SIGNAL(highlighted(int)),
-                          this, SLOT(slotHighlighted(int)) );
-    }
-
+    CustomChoiceCombo( struct uim_custom *c, QWidget *parent, const char *name = 0 );
 public slots:
-    void slotHighlighted( int index )
-    {
-        Q_ASSERT( m_custom->type == UCustom_Choice );
+    void slotHighlighted( int index );
+protected:
+    void currentCustomValueChanged(){ emit customValueChanged(); }
+signals:
+    void customValueChanged();
+};
 
-        struct uim_custom_choice **valid_items = m_custom->range->as_choice.valid_items;
-        struct uim_custom_choice *choice = NULL;
-        if( valid_items )
-        {
-            for( int i = 0; valid_items[i]; i++ )
-            {
-                if( i == index )
-                    choice = valid_items[i];
-            }
-        }
+class CustomOrderedListEdit : public QHBox, public UimCustomItemIface
+{
+    Q_OBJECT
 
-        free( m_custom->value->as_choice->symbol );
-        free( m_custom->value->as_choice->label );
-        free( m_custom->value->as_choice->desc );
+public:
+    CustomOrderedListEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 );
+public slots:
+    void slotEditButtonClicked();
+private:
+    QLineEdit *m_lineEdit;
+    QToolButton *m_editButton;
 
-        m_custom->value->as_choice->symbol = strdup( choice->symbol );
-        m_custom->value->as_choice->label  = strdup( choice->label );
-        m_custom->value->as_choice->desc   = strdup( choice->desc );
-
-        setCustom( m_custom );
-    }
-
+    QPtrList<struct uim_custom_choice> m_validItemList;
+    QPtrList<struct uim_custom_choice> m_itemList;
 protected:
+    void initPtrList();
     void currentCustomValueChanged(){ emit customValueChanged(); }
 signals:
     void customValueChanged();
 };
 
+class OListEditForm : public OListEditFormBase {
+    Q_OBJECT
+
+public:
+    OListEditForm( QWidget *parent = 0, const char *name = 0 );
+    void addCheckItem( bool isActive, const QString &str );
+    QStringList activeItemLabels() const;
+
+protected slots:
+    void upItem();
+    void downItem();
+};
+
 #endif /* Not def: _CUSTOMWIDGETS_H_ */

Added: trunk/qt/uim-kdehelper/src/pref/kseparator.cpp
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/kseparator.cpp	2005-01-28 18:29:09 UTC (rev 381)
+++ trunk/qt/uim-kdehelper/src/pref/kseparator.cpp	2005-01-28 19:22:01 UTC (rev 382)
@@ -0,0 +1,113 @@
+/*
+*   Copyright (C) 1997  Michael Roth <mroth@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 "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 );*/ }
+

Added: trunk/qt/uim-kdehelper/src/pref/kseparator.h
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/kseparator.h	2005-01-28 18:29:09 UTC (rev 381)
+++ trunk/qt/uim-kdehelper/src/pref/kseparator.h	2005-01-28 19:22:01 UTC (rev 382)
@@ -0,0 +1,85 @@
+/*
+*   Copyright (C) 1997  Michael Roth <mroth@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@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/uim-kdehelper/src/pref/olisteditformbase.ui
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/olisteditformbase.ui	2005-01-28 18:29:09 UTC (rev 381)
+++ trunk/qt/uim-kdehelper/src/pref/olisteditformbase.ui	2005-01-28 19:22:01 UTC (rev 382)
@@ -0,0 +1,138 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>OListEditFormBase</class>
+<widget class="QDialog">
+    <property name="name">
+        <cstring>OListEditFormBase</cstring>
+    </property>
+    <property name="geometry">
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>380</width>
+            <height>200</height>
+        </rect>
+    </property>
+    <property name="sizePolicy">
+        <sizepolicy>
+            <hsizetype>5</hsizetype>
+            <vsizetype>5</vsizetype>
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+        </sizepolicy>
+    </property>
+    <property name="caption">
+        <string>OListEditBase</string>
+    </property>
+    <widget class="QLayoutWidget">
+        <property name="name">
+            <cstring>layout3</cstring>
+        </property>
+        <property name="geometry">
+            <rect>
+                <x>10</x>
+                <y>10</y>
+                <width>360</width>
+                <height>180</height>
+            </rect>
+        </property>
+        <hbox>
+            <property name="name">
+                <cstring>unnamed</cstring>
+            </property>
+            <widget class="QListView">
+                <column>
+                    <property name="text">
+                        <string>Column 1</string>
+                    </property>
+                    <property name="clickable">
+                        <bool>true</bool>
+                    </property>
+                    <property name="resizable">
+                        <bool>false</bool>
+                    </property>
+                </column>
+                <property name="name">
+                    <cstring>m_listView</cstring>
+                </property>
+                <property name="selectionMode">
+                    <enum>Single</enum>
+                </property>
+            </widget>
+            <widget class="QLayoutWidget">
+                <property name="name">
+                    <cstring>layout2</cstring>
+                </property>
+                <vbox>
+                    <property name="name">
+                        <cstring>unnamed</cstring>
+                    </property>
+                    <widget class="QPushButton">
+                        <property name="name">
+                            <cstring>m_upButton</cstring>
+                        </property>
+                        <property name="text">
+                            <string>Up</string>
+                        </property>
+                    </widget>
+                    <widget class="QPushButton">
+                        <property name="name">
+                            <cstring>m_downButton</cstring>
+                        </property>
+                        <property name="text">
+                            <string>Down</string>
+                        </property>
+                    </widget>
+                    <spacer>
+                        <property name="name">
+                            <cstring>spacer2</cstring>
+                        </property>
+                        <property name="orientation">
+                            <enum>Vertical</enum>
+                        </property>
+                        <property name="sizeType">
+                            <enum>Expanding</enum>
+                        </property>
+                        <property name="sizeHint">
+                            <size>
+                                <width>20</width>
+                                <height>140</height>
+                            </size>
+                        </property>
+                    </spacer>
+                    <widget class="QPushButton">
+                        <property name="name">
+                            <cstring>m_okButton</cstring>
+                        </property>
+                        <property name="text">
+                            <string>OK</string>
+                        </property>
+                    </widget>
+                    <widget class="QPushButton">
+                        <property name="name">
+                            <cstring>m_cancelButton</cstring>
+                        </property>
+                        <property name="text">
+                            <string>Cancel</string>
+                        </property>
+                    </widget>
+                </vbox>
+            </widget>
+        </hbox>
+    </widget>
+</widget>
+<connections>
+    <connection>
+        <sender>m_okButton</sender>
+        <signal>clicked()</signal>
+        <receiver>OListEditFormBase</receiver>
+        <slot>accept()</slot>
+    </connection>
+    <connection>
+        <sender>m_cancelButton</sender>
+        <signal>clicked()</signal>
+        <receiver>OListEditFormBase</receiver>
+        <slot>reject()</slot>
+    </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>

Modified: trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp	2005-01-28 18:29:09 UTC (rev 381)
+++ trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp	2005-01-28 19:22:01 UTC (rev 382)
@@ -32,6 +32,7 @@
 */
 #include "uim-pref-qt.h"
 #include "customwidgets.h"
+#include <kseparator.h>
 
 #include <qvbox.h>
 #include <qhbox.h>
@@ -159,17 +160,21 @@
 QWidget* UimPrefDialog::createGroupWidget( const char *group_name )
 {
     QVBox *vbox = new QVBox( m_groupWidgetStack );
+    vbox->setSpacing( 3 );
 
     struct uim_custom_group *group = uim_custom_group_get( group_name );
     if( group == NULL )
         return NULL;
 
     QLabel *groupLabel = new QLabel( group_name, vbox );
-    groupLabel->setAlignment( Qt::AlignHCenter );
+    groupLabel->setAlignment( Qt::AlignLeft );
+    new KSeparator( vbox );
+    /*
     QFont font;
     font.setWeight( QFont::Bold );
     font.setPixelSize( fontInfo().pixelSize() + 12 );
     groupLabel->setFont( font );
+    */
 
     /* add various widgets to the vbox */
     char **custom_syms = uim_custom_collect_by_group( group_name );
@@ -315,7 +320,14 @@
 
 void UimPrefDialog::addCustomTypeOrderedList( QVBox *vbox, struct uim_custom *custom )
 {
-    // FIXME: not implemented yet
+    QHBox *hbox = new QHBox( vbox );
+    hbox->setSpacing( 6 );
+    QLabel *label = new QLabel( _FU8(custom->label), hbox );
+    CustomOrderedListEdit *olistEditBox = new CustomOrderedListEdit( custom, hbox );
+    label->setBuddy( olistEditBox );
+
+    QObject::connect( olistEditBox, SIGNAL(customValueChanged()),
+                      this, SLOT(slotCustomValueChanged()) );
 }
 
 void UimPrefDialog::addCustomTypeKey( QVBox *vbox, struct uim_custom *custom )
@@ -376,7 +388,9 @@
 
 void UimPrefDialog::slotCancel()
 {
-    confirmChange();
+    if( m_isValueChanged )
+        confirmChange();
+
     reject();
 }
 



More information about the Uim-commit mailing list