DumontEXE 0.0.1
cmcFormField.cpp
00001 /* ***************************************************************************
00002 **
00003 ** Copyright (C) 2007 Lorimark Solutions, LLC. All rights reserved.
00004 **
00005 ** This file is part of the DumontEXE Scripting Extension Kit
00006 **
00007 ** This file may be used under the terms of the GNU General Public
00008 ** License version 2.0 as published by the Free Software Foundation
00009 ** and appearing in the file LICENSE.GPL included in the packaging of
00010 ** this file.  Please review the following information to ensure GNU
00011 ** General Public Licensing requirements will be met:
00012 ** http://dumont.showoff-db.org/opensource.html
00013 **
00014 ** If you are unsure which license is appropriate for your use, please
00015 ** review the following information:
00016 ** http://dumont.showoff-db.org/licensing.html 
00017 ** or contact the sales department at sales@lorimarksolutions.com.
00018 **
00019 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 **
00022 ** author: Mark Petryk ~ Lorimark Solutions, LLC
00023 ** **************************************************************************/
00024 
00025 #include <QString>
00026 #include <QDomDocument>
00027 #include <QDomNode>
00028 #include <QDomElement>
00029 #include <QDate>
00030 
00031 #include "cmcFormField.h"
00032 #include "cmcForm.h"
00033 #include "cmcFieldDefs.h"
00034 #include "cmcFieldDef.h"
00035 
00036 namespace cmcDatabaseApi {
00037 
00038 cmcFormField::cmcFormField( const cmcFormField & copy ):
00039   cmcField( copy )
00040 {
00041 }
00042 
00043 cmcFormField::cmcFormField
00044 (
00045   const QString & fieldName,
00046   IDispatch * dispatch,
00047   cmcApplication * application,
00048   cmcForm * parentForm
00049 ):
00050   cmcField( fieldName, application, (QObject*) parentForm )
00051 {
00052 //  TRACE_FUNCTION
00053 
00054   m_api = new cmcApi( fieldName, dispatch, application, (QObject*) parentForm );
00055 
00056   reset();
00057 
00058 }
00059 
00060 cmcFormField::~cmcFormField()
00061 {
00062 //  TRACE_FUNCTION
00063 }
00064 
00065 cmcApi * cmcFormField::api()
00066 {
00067   return( m_api );
00068 }
00069 
00070 QString cmcFormField::label()
00071 {
00072   if( m_label == "" )
00073       m_label = api()-> GetServerString( "Label" );
00074   return( m_label );
00075 }
00076 
00077 QString cmcFormField::value()
00078 {
00079   /*
00080   ** Get the value from the field.
00081   **
00082   */
00083   QString retVal = api()-> GetServerString( "Value" );
00084 
00085   /*
00086   ** If we don't know what the previous value is then record
00087   **  it now.
00088   **
00089   */
00090   if( m_gotPreviousValue == false )
00091   {
00092     m_previousValue = retVal;
00093     m_gotPreviousValue = true;
00094   }
00095 
00096   return( retVal );
00097 }
00098 
00099 void cmcFormField::value( QString newValue )
00100 {
00101   /*
00102   ** Before setting the value check it against the existing value.
00103   **  If the two are the same then we will NOT set the value again
00104   **  since that is redundant, and it causes the form to go dirty
00105   **  for no reason.
00106   **
00107   */
00108   if( newValue != value() )
00109   {
00110     api()-> PutServerString( "Value", newValue );
00111   }
00112 }
00113 
00114 void cmcFormField::value( bool newValue )
00115 {
00116   api()-> PutServerString( "Value", newValue? "1":"0" );
00117 }
00118 
00119 
00120 cmcForm * cmcFormField::form()
00121 {
00122   return( qobject_cast<cmcForm*>(parent()) );
00123 }  
00124 
00125 bool cmcFormField::onEnter()
00126 {
00127   m_enterValue = value();
00128   emit enter( name(), m_enterValue );
00129   return( true );
00130 } 
00131 
00132 bool cmcFormField::onLeave()
00133 {
00134   bool retVal = false;
00135   if( m_enterValue != value() )
00136   {
00137     onChange();
00138     retVal = true;
00139   }
00140   emit leave( name(), value() );
00141   return( retVal );
00142 }  
00143 
00144 bool cmcFormField::onChange()
00145 {
00146   emit change( name(), value() );
00147   return( true );
00148 }  
00149 
00150 
00151 } // endnamespace cmcDatabaseApi
00152 
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties




~ ~ ~ ~ ~ ~
Source Code without Comments is like a Cranberry Garland
without the berries. Comment your Code!
 
Commence Database User Support Group Forum
http://newsgroup.showoff-db.org/
~ ~ ~ ~ ~ ~
Author: Mark Petryk
Lorimark Solutions, LLC
mark@lorimarksolutions.com