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

kzk at freedesktop.org kzk at freedesktop.org
Mon Jan 31 06:18:12 PST 2005


Author: kzk
Date: 2005-01-31 06:18:08 -0800 (Mon, 31 Jan 2005)
New Revision: 423

Modified:
   trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp
   trunk/qt/uim-kdehelper/src/pref/customwidgets.h
   trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp
   trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h
Log:
* implement "setDefault" feature in uim-pref-qt

* uim-kdehelper/src/pref/uim-pref-qt.h
  - (class GroupPageWidget): new class
  - (UimPrefDialog::addCustom,
     UimPrefDialog::addCustomTypeBool,
     UimPrefDialog::addCustomTypeInteger,
     UimPrefDialog::addCustomTypeString,
     UimPrefDialog::addCustomTypePathname,
     UimPrefDialog::addCustomTypeChoice,
     UimPrefDialog::addCustomTypeOrderedList,
     UimPrefDialog::addCustomTypeKey)
     : move to GroupPageWidget
  - (UimPrefDialog::slotSetDefault): new function
* uim-kdehelper/src/pref/uim-pref-qt.cpp
  - Ditto
  - (UimPrefDialog::slotCancel): not confirm the change

* uim-kdehelper/src/pref/customwidgets.h
  - (UimCustomItemIface::setDefault): new pure virtual function
  - (CustomCheckBox::setDefault,
     CustomSpinBox::setDefault,
     CustomLineEdit::setDefault,
     CustomPathnameEdit::setDefault,
     CustomChoiceCombo::setDefault,
     CustomOrderedListEdit::setDefault)
     : new function
  - (CustomPathnameEdit::slotActivated): rename from slotHighlighted
* uim-kdehelper/src/pref/customwidgets.cpp
  - Ditto
  - (CustomPathnameEdit::update): clear combobox's contents before
    inserting new item



Modified: trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp	2005-01-31 13:13:06 UTC (rev 422)
+++ trunk/qt/uim-kdehelper/src/pref/customwidgets.cpp	2005-01-31 14:18:08 UTC (rev 423)
@@ -55,6 +55,14 @@
     }
 }
 
+void CustomCheckBox::setDefault()
+{
+    m_custom->value->as_bool = m_custom->default_value->as_bool;
+
+    setCustom( m_custom );
+    update();
+}
+
 void CustomCheckBox::slotCustomToggled( bool check )
 {
     Q_ASSERT( m_custom->type == UCustom_Bool );
@@ -84,6 +92,14 @@
     }
 }
 
+void CustomSpinBox::setDefault()
+{
+    m_custom->value->as_int = m_custom->default_value->as_int;
+
+    setCustom( m_custom );
+    update();
+}
+
 void CustomSpinBox::slotCustomValueChanged( int value )
 {
     Q_ASSERT( m_custom->type == UCustom_Int );
@@ -112,6 +128,15 @@
     }
 }
 
+void CustomLineEdit::setDefault()
+{
+    free( m_custom->value->as_str );
+    m_custom->value->as_str = strdup( m_custom->default_value->as_str );
+
+    setCustom( m_custom );
+    update();
+}
+
 void CustomLineEdit::slotCustomTextChanged( const QString &text )
 {
     Q_ASSERT( m_custom->type == UCustom_Str );
@@ -150,6 +175,15 @@
     }
 }
 
+void CustomPathnameEdit::setDefault()
+{
+    free( m_custom->value->as_pathname );
+    m_custom->value->as_pathname = strdup( m_custom->default_value->as_pathname );
+
+    setCustom( m_custom );
+    update();
+}
+
 void CustomPathnameEdit::slotPathnameButtonClicked()
 {
     QFileDialog* fd = new QFileDialog( this, "file dialog" );
@@ -175,8 +209,8 @@
     : QComboBox( parent, name ),
       UimCustomItemIface( c )
 {
-    QObject::connect( this, SIGNAL(highlighted(int)),
-                      this, SLOT(slotHighlighted(int)) );
+    QObject::connect( this, SIGNAL(activated(int)),
+                      this, SLOT(slotActivated(int)) );
 
     update();
 }
@@ -185,6 +219,7 @@
 {
     setEnabled( m_custom->is_active );
 
+    clear();
     if( m_custom->is_active )
     {
         char *default_symbol = m_custom->value->as_choice->symbol;
@@ -206,8 +241,22 @@
     }
 }
 
-void CustomChoiceCombo::slotHighlighted( int index )
+void CustomChoiceCombo::setDefault()
 {
+    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( m_custom->default_value->as_choice->symbol );
+    m_custom->value->as_choice->label  = strdup( m_custom->default_value->as_choice->label );
+    m_custom->value->as_choice->desc   = strdup( m_custom->default_value->as_choice->desc );
+
+    setCustom( m_custom );
+    update();
+}
+
+void CustomChoiceCombo::slotActivated( int index )
+{
     Q_ASSERT( m_custom->type == UCustom_Choice );
 
     struct uim_custom_choice **valid_items = m_custom->range->as_choice.valid_items;
@@ -261,6 +310,47 @@
     }
 }
 
+void CustomOrderedListEdit::setDefault()
+{
+    /* free old items */
+    int num = 0;
+    for( num = 0; m_custom->value->as_olist[num]; num++ )
+        ;
+    
+    for( int i = 0; i < num; 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] );
+    }
+
+    /* copy default_value to value */
+    int default_num = 0;
+    for( default_num = 0; m_custom->default_value->as_olist[default_num]; default_num++ )
+        ;
+
+    m_custom->value->as_olist = (struct uim_custom_choice **)realloc( m_custom->value->as_olist,
+                                                                      sizeof(struct uim_custom_choice *) * (default_num + 1) );
+    
+    for( int i = 0; i < default_num; i++ )
+    {
+        struct uim_custom_choice *default_item = m_custom->default_value->as_olist[i];
+        struct uim_custom_choice *item = (struct uim_custom_choice *)malloc(sizeof(struct uim_custom_choice));
+
+        item->symbol = default_item->symbol ? strdup(default_item->symbol) : NULL;
+        item->label  = default_item->label  ? strdup(default_item->label)  : NULL;
+        item->desc   = default_item->desc   ? strdup(default_item->desc)   : NULL;
+
+        m_custom->value->as_olist[i] = item;
+    }
+    m_custom->value->as_olist[default_num] = NULL; /* NULL-terminated */
+
+    setCustom( m_custom );
+    initPtrList();
+    update();
+}
+
 void CustomOrderedListEdit::initPtrList()
 {
     m_itemList.clear();

Modified: trunk/qt/uim-kdehelper/src/pref/customwidgets.h
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/customwidgets.h	2005-01-31 13:13:06 UTC (rev 422)
+++ trunk/qt/uim-kdehelper/src/pref/customwidgets.h	2005-01-31 14:18:08 UTC (rev 423)
@@ -66,8 +66,6 @@
 
         // callback
         uim_custom_cb_add( m_custom->symbol, this, UimCustomItemIface::update_cb );
-
-//        update();
     }
     virtual ~UimCustomItemIface()
     {
@@ -83,6 +81,8 @@
     }
     virtual void update() = 0;
 
+    /* Set to default */
+    virtual void setDefault() = 0;    
 
 protected:
     void setCustom( struct uim_custom *custom )
@@ -113,7 +113,9 @@
 
 public:
     CustomCheckBox( struct uim_custom *c, QWidget *parent, const char *name = 0);
+
     virtual void update();
+    virtual void setDefault();
 protected slots:
     void slotCustomToggled( bool check );
 protected:
@@ -128,7 +130,9 @@
 
 public:
     CustomSpinBox( struct uim_custom *c, QWidget *parent, const char *name = 0 );
+    
     virtual void update();
+    virtual void setDefault();
 public slots:
     void slotCustomValueChanged( int value );
 protected:
@@ -143,7 +147,9 @@
 
 public:
     CustomLineEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 );
+
     virtual void update();
+    virtual void setDefault();
 public slots:
     void slotCustomTextChanged( const QString &text );
 protected:
@@ -158,8 +164,9 @@
 
 public:
     CustomPathnameEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 );
+
     virtual void update();
-    
+    virtual void setDefault();
 protected slots:
     void slotPathnameButtonClicked();
     void slotCustomTextChanged( const QString & text );
@@ -178,9 +185,11 @@
 
 public:
     CustomChoiceCombo( struct uim_custom *c, QWidget *parent, const char *name = 0 );
+
     virtual void update();
+    virtual void setDefault();
 public slots:
-    void slotHighlighted( int index );
+    void slotActivated( int index );
 protected:
     void currentCustomValueChanged(){ emit customValueChanged(); }
 signals:
@@ -193,7 +202,9 @@
 
 public:
     CustomOrderedListEdit( struct uim_custom *c, QWidget *parent, const char *name = 0 );
+    
     virtual void update();
+    virtual void setDefault();
 public slots:
     void slotEditButtonClicked();
 private:

Modified: trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp	2005-01-31 13:13:06 UTC (rev 422)
+++ trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp	2005-01-31 14:18:08 UTC (rev 423)
@@ -32,7 +32,7 @@
 */
 #include "uim-pref-qt.h"
 #include "customwidgets.h"
-#include <kseparator.h>
+#include "kseparator.h"
 
 #include <qvbox.h>
 #include <qhbox.h>
@@ -94,6 +94,7 @@
 void UimPrefDialog::createMainWidgets()
 {
     QVBoxLayout *mainVLayout = new QVBoxLayout( this );
+    mainVLayout->setMargin( 6 );
 
     QSplitter *mainSplitter = new QSplitter( this );
 
@@ -109,25 +110,27 @@
     QWidget *buttonHWidget = new QWidget( leftSideWidget );
     m_groupWidgetStack = new QWidgetStack( leftSideWidget );
     QHBoxLayout *buttonHLayout = new QHBoxLayout( buttonHWidget );
-    buttonHLayout->insertStretch( 0 );
-    buttonHLayout->setMargin( 10 );
     buttonHLayout->setSpacing( 6 );
-    QPushButton *applyButton  = new QPushButton( "Apply" , buttonHWidget );
+    QPushButton *defaultButton = new QPushButton( "Defaults", buttonHWidget );
+    QObject::connect( defaultButton, SIGNAL(clicked()),
+                      this, SLOT(slotSetDefault()) );
+    QPushButton *applyButton = new QPushButton( "Apply" , buttonHWidget );
     QObject::connect( applyButton, SIGNAL(clicked()),
                       this, SLOT(slotApply()) );
-    QPushButton *okButton     = new QPushButton( "OK"    , buttonHWidget );
+    QPushButton *okButton = new QPushButton( "OK"    , buttonHWidget );
     QObject::connect( okButton, SIGNAL(clicked()),
                       this, SLOT(slotOK()) );
     QPushButton *cancelButton = new QPushButton( "Cancel", buttonHWidget );
     QObject::connect( cancelButton, SIGNAL(clicked()),
                       this, SLOT(slotCancel()) );
+    buttonHLayout->addWidget( defaultButton );
+    buttonHLayout->addStretch();
     buttonHLayout->addWidget( applyButton );
     buttonHLayout->addWidget( okButton );
     buttonHLayout->addWidget( cancelButton );
-    leftVLayout->setMargin( 10 );
     leftVLayout->setSpacing( 6 );
     leftVLayout->addWidget( m_groupWidgetStack );
-    leftVLayout->insertStretch( 1 );
+    leftVLayout->addWidget( new KSeparator( leftSideWidget ) );
     leftVLayout->addWidget( buttonHWidget );
 
     mainVLayout->addWidget( mainSplitter );
@@ -149,33 +152,141 @@
         else
             item = new QListViewItem( m_groupListView, _FU8(group->label) );
 
-        QWidget *w = createGroupWidget( *grp );
+        GroupPageWidget *w = new GroupPageWidget( m_groupWidgetStack, *grp );
+        QObject::connect( w, SIGNAL(customValueChanged()),
+                          this, SLOT(slotCustomValueChanged()) );
+
         m_groupWidgetsDict.insert( _FU8(group->label), w );
         m_groupWidgetStack->addWidget( w );
 
         uim_custom_group_free( group );
     }
+    uim_custom_symbol_list_free( primary_groups );
 }
 
-QWidget* UimPrefDialog::createGroupWidget( const char *group_name )
+/*
+ * GUI event handling
+ */
+void UimPrefDialog::slotSelectionChanged( QListViewItem * item )
 {
-    QWidget *groupWidget = new QWidget( m_groupWidgetStack );
-    QVBoxLayout *vLayout = new QVBoxLayout( groupWidget );
+    /* confirm if save the change */
+    if( m_isValueChanged )    
+        confirmChange();
+    
+    /* switch group widget */
+    QString grpname = item->text( 0 );
+    m_groupWidgetStack->raiseWidget( m_groupWidgetsDict[grpname] );
+}
+
+void UimPrefDialog::slotCustomValueChanged()
+{
+    m_isValueChanged = true;    
+}
+
+void UimPrefDialog::confirmChange()
+{
+    QConfirmDialog *cDialog = new QConfirmDialog( "The value was changed.\nSave?",
+                                                  this );
+    if( cDialog->exec() == QDialog::Accepted )
+    {
+        slotApply();
+    }
+    else
+    {
+        m_isValueChanged = false;
+    }
+}
+
+void UimPrefDialog::slotSetDefault()
+{
+    QWidget *w = m_groupWidgetStack->visibleWidget();
+    if( w )
+    {
+        ((GroupPageWidget*)w)->setDefault();
+    }
+}
+
+void UimPrefDialog::slotApply()
+{
+    if( !m_isValueChanged )
+        return;
+
+    qDebug("start saving....");
+
+    uim_custom_save();
+    uim_custom_broadcast();
+
+    m_isValueChanged = false;
+}
+
+void UimPrefDialog::slotOK()
+{
+    if( m_isValueChanged )
+    {
+        slotApply();
+    }
+    accept();
+}
+
+void UimPrefDialog::slotCancel()
+{
+    /*
+    if( m_isValueChanged )
+        confirmChange();
+    */
+
+    reject();
+}
+
+//-------------------------------------------------------------------------------------
+QConfirmDialog::QConfirmDialog( const QString &msg, QWidget *parent, const char *name )
+    : QDialog( parent, name )
+{
+    QVBoxLayout *vLayout = new QVBoxLayout( this );
+    vLayout->setSpacing( 6 );
+    vLayout->setMargin( 10 );
+    QLabel *msgLabel = new QLabel( msg, this );
+    QHBox *buttonHBox = new QHBox( this );
+    QPushButton *okButton = new QPushButton( "OK", buttonHBox );
+    QPushButton *cancelButton = new QPushButton( "Cancel", buttonHBox );
+    vLayout->addWidget( msgLabel );
+    vLayout->addWidget( buttonHBox );
+
+    QObject::connect( okButton, SIGNAL(clicked()),
+                      this, SLOT(accept()) );
+    QObject::connect( cancelButton, SIGNAL(clicked()),
+                      this, SLOT(reject()) );
+}
+
+//-----------------------------------------------------------------------------------
+
+GroupPageWidget::GroupPageWidget( QWidget *parent, const char *group_name )
+    : QWidget( parent )
+{
+    m_customIfaceList.clear();
+    m_customIfaceList.setAutoDelete( false );
+    
+    setupWidgets( group_name );
+}
+
+void GroupPageWidget::setupWidgets( const char *group_name )
+{
+    QVBoxLayout *vLayout = new QVBoxLayout( this );
     vLayout->setSpacing( 3 );
-
+    
     struct uim_custom_group *group = uim_custom_group_get( group_name );
     if( group == NULL )
-        return NULL;
+        return;
 
-    QLabel *groupLabel = new QLabel( _FU8(group->label), groupWidget );
+    QLabel *groupLabel = new QLabel( _FU8(group->label), this );
     groupLabel->setAlignment( Qt::AlignLeft );
     vLayout->addWidget( groupLabel );
     
-    KSeparator *separator = new KSeparator( groupWidget );
+    KSeparator *separator = new KSeparator( this );
     vLayout->addWidget( separator );
 
     /* subgroup data */
-    SubgroupData *sd = new SubgroupData( groupWidget, group_name );
+    SubgroupData *sd = new SubgroupData( this, group_name );
 
     /* add various widgets to the vbox */
     char **custom_syms = uim_custom_collect_by_group( group_name );
@@ -184,7 +295,8 @@
         for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ )
         {
             QVGroupBox *vbox = sd->searchGroupVBoxByCustomSym( *custom_sym );
-            addCustom( vbox, *custom_sym );
+            UimCustomItemIface *iface = addCustom( vbox, *custom_sym );
+            m_customIfaceList.append( iface );
         }
 
         uim_custom_symbol_list_free( custom_syms );
@@ -195,43 +307,43 @@
     uim_custom_group_free( group );
 
     /* bottom up */
-    vLayout->addStretch();
-    
-    return groupWidget;
+    vLayout->addStretch();    
 }
 
 /*
  * Building up GUI in accordance with Custom Type.
  */
-void UimPrefDialog::addCustom( QVGroupBox *vbox, const char *custom_sym )
+UimCustomItemIface *GroupPageWidget::addCustom( QVGroupBox *vbox, const char *custom_sym )
 {
+    UimCustomItemIface *w = NULL;
     struct uim_custom *custom = uim_custom_get( custom_sym );
     if( custom )
     {
         switch( custom->type )
         {
         case UCustom_Bool:
-            addCustomTypeBool( vbox, custom );
+            w = addCustomTypeBool( vbox, custom );
             break;
         case UCustom_Int:
-            addCustomTypeInteger( vbox, custom );
+            w = addCustomTypeInteger( vbox, custom );
             break;
         case UCustom_Str:
-            addCustomTypeString( vbox, custom );
+            w = addCustomTypeString( vbox, custom );
             break;
         case UCustom_Pathname:
-            addCustomTypePathname( vbox, custom );
+            w = addCustomTypePathname( vbox, custom );
             break;
         case UCustom_Choice:
-            addCustomTypeChoice( vbox, custom );
+            w = addCustomTypeChoice( vbox, custom );
             break;
         case UCustom_OrderedList:
-            addCustomTypeOrderedList( vbox, custom );
+            w = addCustomTypeOrderedList( vbox, custom );
             break;
         case UCustom_Key:
-            addCustomTypeKey( vbox, custom );
+            w = addCustomTypeKey( vbox, custom );
             break;
         default:
+            w = NULL;
             qWarning( "Invalid custom type: %d\n", custom->type );
             uim_custom_free( custom );
             break;
@@ -239,16 +351,22 @@
     } else {
         qWarning( "Failed to get uim_custom object for %s.", custom_sym );
     }
+
+    /* custom is freed by UimCustomItemIface's destructor */
+
+    return w;
 }
 
-void UimPrefDialog::addCustomTypeBool( QVGroupBox *vbox, struct uim_custom *custom )
+UimCustomItemIface *GroupPageWidget::addCustomTypeBool( QVGroupBox *vbox, struct uim_custom *custom )
 {
     CustomCheckBox *checkBox = new CustomCheckBox( custom, vbox );
     QObject::connect( checkBox, SIGNAL(customValueChanged()),
                       this, SLOT(slotCustomValueChanged()) );
+
+    return checkBox;
 }
 
-void UimPrefDialog::addCustomTypeInteger( QVGroupBox *vbox, struct uim_custom *custom )
+UimCustomItemIface *GroupPageWidget::addCustomTypeInteger( QVGroupBox *vbox, struct uim_custom *custom )
 {
     QHBox *hbox = new QHBox( vbox );
     hbox->setSpacing( 6 );
@@ -259,9 +377,11 @@
 
     QObject::connect( spinBox, SIGNAL(customValueChanged()),
                       this, SLOT(slotCustomValueChanged()) );
+
+    return spinBox;
 }
 
-void UimPrefDialog::addCustomTypeString( QVGroupBox *vbox, struct uim_custom *custom )
+UimCustomItemIface *GroupPageWidget::addCustomTypeString( QVGroupBox *vbox, struct uim_custom *custom )
 {
     QHBox *hbox = new QHBox( vbox );
     hbox->setSpacing( 6 );
@@ -271,9 +391,11 @@
 
     QObject::connect( lineEdit, SIGNAL(customValueChanged()),
                       this, SLOT(slotCustomValueChanged()) );
+
+    return lineEdit;
 }
 
-void UimPrefDialog::addCustomTypePathname( QVGroupBox *vbox, struct uim_custom *custom )
+UimCustomItemIface *GroupPageWidget::addCustomTypePathname( QVGroupBox *vbox, struct uim_custom *custom )
 {
     QHBox *hbox = new QHBox( vbox );
     hbox->setSpacing( 6 );
@@ -283,9 +405,11 @@
 
     QObject::connect( pathnameEdit, SIGNAL(customValueChanged()),
                       this, SLOT(slotCustomValueChanged()) );
+
+    return pathnameEdit;
 }
 
-void UimPrefDialog::addCustomTypeChoice( QVGroupBox *vbox, struct uim_custom *custom )
+UimCustomItemIface *GroupPageWidget::addCustomTypeChoice( QVGroupBox *vbox, struct uim_custom *custom )
 {
     QHBox *hbox = new QHBox( vbox );
     hbox->setSpacing( 6 );
@@ -296,9 +420,11 @@
 
     QObject::connect( choiceCombo, SIGNAL(customValueChanged()),
                       this, SLOT(slotCustomValueChanged()) );
+
+    return choiceCombo;
 }
 
-void UimPrefDialog::addCustomTypeOrderedList( QVGroupBox *vbox, struct uim_custom *custom )
+UimCustomItemIface *GroupPageWidget::addCustomTypeOrderedList( QVGroupBox *vbox, struct uim_custom *custom )
 {
     QHBox *hbox = new QHBox( vbox );
     hbox->setSpacing( 6 );
@@ -308,97 +434,27 @@
 
     QObject::connect( olistEditBox, SIGNAL(customValueChanged()),
                       this, SLOT(slotCustomValueChanged()) );
+
+    return olistEditBox;
 }
 
-void UimPrefDialog::addCustomTypeKey( QVGroupBox *vbox, struct uim_custom *custom )
+UimCustomItemIface *GroupPageWidget::addCustomTypeKey( QVGroupBox *vbox, struct uim_custom *custom )
 {
     // FIXME: not implemented yet
+    return NULL;
 }
 
-/*
- * GUI event handling
- */
-void UimPrefDialog::slotSelectionChanged( QListViewItem * item )
+void GroupPageWidget::setDefault()
 {
-    /* confirm if save the change */
-    if( m_isValueChanged )    
-        confirmChange();
-    
-    /* switch group widget */
-    QString grpname = item->text( 0 );
-    m_groupWidgetStack->raiseWidget( m_groupWidgetsDict[grpname] );
-}
-
-void UimPrefDialog::slotCustomValueChanged()
-{
-    m_isValueChanged = true;    
-}
-
-void UimPrefDialog::confirmChange()
-{
-    QConfirmDialog *cDialog = new QConfirmDialog( "The value was changed.\nSave?",
-                                                  this );
-    if( cDialog->exec() == QDialog::Accepted )
+    for( UimCustomItemIface *iface = m_customIfaceList.first();
+         iface;
+         iface = m_customIfaceList.next() )
     {
-        slotApply();
+        iface->setDefault();
     }
-    else
-    {
-        m_isValueChanged = false;
-    }
 }
 
-void UimPrefDialog::slotApply()
-{
-    if( !m_isValueChanged )
-        return;
-
-    qDebug("start saving....");
-
-    uim_custom_save();
-    uim_custom_broadcast();
-
-    m_isValueChanged = false;
-}
-
-void UimPrefDialog::slotOK()
-{
-    if( m_isValueChanged )
-    {
-        slotApply();
-    }
-    accept();
-}
-
-void UimPrefDialog::slotCancel()
-{
-    if( m_isValueChanged )
-        confirmChange();
-
-    reject();
-}
-
-//-------------------------------------------------------------------------------------
-QConfirmDialog::QConfirmDialog( const QString &msg, QWidget *parent, const char *name )
-    : QDialog( parent, name )
-{
-    QVBoxLayout *vLayout = new QVBoxLayout( this );
-    vLayout->setSpacing( 6 );
-    vLayout->setMargin( 10 );
-    QLabel *msgLabel = new QLabel( msg, this );
-    QHBox *buttonHBox = new QHBox( this );
-    QPushButton *okButton = new QPushButton( "OK", buttonHBox );
-    QPushButton *cancelButton = new QPushButton( "Cancel", buttonHBox );
-    vLayout->addWidget( msgLabel );
-    vLayout->addWidget( buttonHBox );
-
-    QObject::connect( okButton, SIGNAL(clicked()),
-                      this, SLOT(accept()) );
-    QObject::connect( cancelButton, SIGNAL(clicked()),
-                      this, SLOT(reject()) );
-}
-
-//--------------------------------------------------------------------------
+//-----------------------------------------------------------------------------------
 SubgroupData::SubgroupData( QWidget*parentWidget, const char *parent_group_name )
 {
     // QVGroupBox for other subgroups
@@ -438,6 +494,7 @@
 
         uim_custom_group_free( sgroup_custom );
     }
+    uim_custom_symbol_list_free( sub_groups );
 }
 
 QVGroupBox * SubgroupData::searchGroupVBoxByCustomSym( const char *custom_sym )

Modified: trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h	2005-01-31 13:13:06 UTC (rev 422)
+++ trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h	2005-01-31 14:18:08 UTC (rev 423)
@@ -45,7 +45,10 @@
 #include <qhbox.h>
 #include <qvgroupbox.h>
 #include <qmap.h>
+#include <qptrlist.h>
 
+#include "customwidgets.h"
+
 #include <uim/uim.h>
 #include <uim/uim-custom.h>
 
@@ -61,20 +64,11 @@
     void setupWidgets();
     void createMainWidgets();
     void createGroupWidgets();
-    QWidget* createGroupWidget( const char *grpname );
 
-    void addCustom( QVGroupBox *vbox, const char *custom_sym );
-    void addCustomTypeBool( QVGroupBox *vbox, struct uim_custom *custom );
-    void addCustomTypeInteger( QVGroupBox *vbox, struct uim_custom *custom );
-    void addCustomTypeString( QVGroupBox *vbox, struct uim_custom *custom );
-    void addCustomTypePathname( QVGroupBox *vbox, struct uim_custom *custom );
-    void addCustomTypeChoice( QVGroupBox *vbox, struct uim_custom *custom );
-    void addCustomTypeOrderedList( QVGroupBox *vbox, struct uim_custom *custom );
-    void addCustomTypeKey( QVGroupBox *vbox, struct uim_custom *custom );
-
     void confirmChange();
-
+    
 protected slots:
+    void slotSetDefault();
     void slotApply();
     void slotOK();
     void slotCancel();
@@ -101,10 +95,38 @@
 };
 
 //---------------------------------------------------------------------------------
+class GroupPageWidget : public QWidget {
+    Q_OBJECT
+    
+public:
+    GroupPageWidget( QWidget *parent, const char *group_name );
+
+    void setDefault();
+
+protected:
+    void setupWidgets( const char *group_name );
+
+    UimCustomItemIface *addCustom( QVGroupBox *vbox, const char *custom_sym );
+    UimCustomItemIface *addCustomTypeBool( QVGroupBox *vbox, struct uim_custom *custom );
+    UimCustomItemIface *addCustomTypeInteger( QVGroupBox *vbox, struct uim_custom *custom );
+    UimCustomItemIface *addCustomTypeString( QVGroupBox *vbox, struct uim_custom *custom );
+    UimCustomItemIface *addCustomTypePathname( QVGroupBox *vbox, struct uim_custom *custom );
+    UimCustomItemIface *addCustomTypeChoice( QVGroupBox *vbox, struct uim_custom *custom );
+    UimCustomItemIface *addCustomTypeOrderedList( QVGroupBox *vbox, struct uim_custom *custom );
+    UimCustomItemIface *addCustomTypeKey( QVGroupBox *vbox, struct uim_custom *custom );
+
+protected slots:
+    void slotCustomValueChanged(){ emit customValueChanged(); }
+signals:
+    void customValueChanged();
+
+protected:
+    QPtrList<UimCustomItemIface> m_customIfaceList;
+};
+
 class SubgroupData {
 public:
     SubgroupData( QWidget *parentWidget, const char *parent_group_name );
-
     QVGroupBox *searchGroupVBoxByCustomSym( const char *custom_sym );
 
 protected:



More information about the Uim-commit mailing list