Bug 102381 - In the Edit Form, last viewed file's info showing when it shouldn't.
Summary: In the Edit Form, last viewed file's info showing when it shouldn't.
Status: RESOLVED FIXED
Alias: None
Product: datakiosk
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Adam Treat
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-24 18:29 UTC by oliver klein
Modified: 2005-03-30 01:42 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description oliver klein 2005-03-24 18:29:10 UTC
Version:            (using KDE KDE 3.4.0)

When a table has no values, the Edit Form is displaying the last information it showed as opposed of showing nothing, or greying-out fields.
Comment 1 Adam Treat 2005-03-30 01:42:18 UTC
CVS commit by treat: 

* Handle null values in the edit form.
BUGS:102381


  M +2 -1      datatable.cpp   1.24
  M +26 -1     datatableedit.cpp   1.13
  M +39 -5     datatableeditorfactory.cpp   1.24
  M +5 -3      datatableeditorfactory.h   1.14


--- kdeextragear-1/datakiosk/src/datatable.cpp  #1.23:1.24
@@ -455,7 +455,8 @@ void DataTable::slotUpdate()
     if ( m_tableView->currentSelection() == -1 && m_tableView->numRows() < 1 )
     {
+        m_tableEdit->setCurrentRow( -1 );
         emit myCurrentChanged( 0L );
     }
-    else
+    else if ( m_tableView->currentSelection() != -1 )
     {
         m_tableEdit->setCurrentRow( m_tableView->currentRow() );

--- kdeextragear-1/datakiosk/src/datatableedit.cpp  #1.12:1.13
@@ -17,8 +17,8 @@
 #include <qpalette.h>
 #include <qpushbutton.h>
-#include <qsqlform.h>
 
 #include <qlabel.h>
 #include <qpainter.h>
+#include <qsqlform.h>
 #include <qdrawutil.h>
 
@@ -158,4 +158,16 @@ QFrame* DataTableEdit::getFormBox() cons
 void DataTableEdit::setCurrentRow( int row )
 {
+    if ( row == -1 )
+    {
+        form()->clearValues( true );
+        setEnabled( FALSE );
+        m_scroll->viewport()->hide();
+    }
+    else if ( !isEnabled() )
+    {
+        setEnabled( TRUE );
+        m_scroll->viewport()->show();
+    }
+
     seek( row, FALSE);
 }
@@ -238,4 +250,17 @@ void DataTableEdit::readFields()
     m_refreshing = true;
     QDataBrowser::readFields();
+
+    QLayoutIterator it = m_formLayout->iterator();
+    QLayoutItem *item;
+    while ( (item = it.current()) != 0 )
+    {
+        DataEditorBase *editor = ::qt_cast<DataEditorBase*>( item->widget() );
+        if ( editor->getField()->isNull() )
+        {
+            editor->setNullValue( "" ); //needs to sync with QDataTable::nullText
+        }
+        ++it;
+    }
+
     m_refreshing = false;
 }

--- kdeextragear-1/datakiosk/src/datatableeditorfactory.cpp  #1.23:1.24
@@ -228,4 +228,32 @@ bool DataEditorBase::currentEdited() con
 }
 
+void DataEditorBase::setNullValue( const QString txt )
+{
+    if ( ::qt_cast<QLineEdit*>( m_editor ) )
+    {
+        ( ( QLineEdit* ) m_editor ) ->setText( txt );
+    }
+
+//     else if ( ::qt_cast<DateEdit*>( m_editor ) )
+//     {
+//         ( ( DateEdit* ) m_editor ) ->setText( txt );
+//     }
+//
+//     else if ( ::qt_cast<TimeEdit*>( m_editor ) )
+//     {
+//         ( ( TimeEdit* ) m_editor ) ->setText( txt );
+//     }
+//
+//     else if ( ::qt_cast<DateTimeEdit*>( m_editor ) )
+//     {
+//         ( ( DateTimeEdit* ) m_editor ) ->setText( txt );
+//     }
+
+    else if ( ::qt_cast<RelationCombo*>( m_editor ) )
+    {
+        ( ( RelationCombo* ) m_editor ) ->setNullValue( txt );
+    }
+}
+
 void DataEditorBase::editorChanged( const QString &txt )
 {
@@ -457,15 +485,21 @@ void RelationCombo::initializeFields( bo
 }
 
-int RelationCombo::relationId() const
+QString RelationCombo::relationId() const
 {
-    return m_relationId;
+    return QString::number( m_relationId );
 }
 
-void RelationCombo::setRelationId( int id )
+void RelationCombo::setRelationId( const QString &id )
 {
     if ( m_constrained )
         initializeFields();
 
-    setCurrentId( id );
+    setCurrentId( id.toInt() );
+}
+
+void RelationCombo::setNullValue( const QString txt )
+{
+    setCurrentItem( -1 );
+    setCurrentText( txt );
 }
 

--- kdeextragear-1/datakiosk/src/datatableeditorfactory.h  #1.13:1.14
@@ -56,4 +56,5 @@ public:
     QSize getRecommendedSize () const;
     bool currentEdited() const;
+    void setNullValue( const QString txt );
 
 signals:
@@ -104,5 +105,5 @@ class RelationCombo : public KComboTable
 {
     Q_OBJECT
-    Q_PROPERTY( int relationid READ relationId WRITE setRelationId )
+    Q_PROPERTY( QString relationid READ relationId WRITE setRelationId )
 public:
     RelationCombo( DataField* field, DataTable *m_dataTable,
@@ -110,6 +111,7 @@ public:
                    const char *name = 0 );
 
-    int relationId() const;
-    void setRelationId( int id );
+    QString relationId() const;
+    void setRelationId( const QString &id );
+    void setNullValue( const QString txt );
 
 signals: