DumontEXE 0.0.1
cmcItems.cpp
00001 
00002 #include <QString>
00003 
00004 #include "cmcItem.h"
00005 #include "cmcItems.h"
00006 
00007 namespace cmcDatabaseApi {
00008 
00009 cmcItems::cmcItems
00010 (
00011   const QString & connectionName,
00012   const QString & targetCategoryName,
00013   const QString & reverseConnectionName,
00014   cmcApplication * application,
00015   cmcItem * _parentItem
00016 ):
00017   cmcObject( connectionName + " -> " + targetCategoryName, application, _parentItem )
00018 {
00019 //  TRACE_FUNCTION
00020 
00021   /*
00022   ** Get a cursor on the target category.  We'll hold on to this.
00023   **
00024   */
00025   m_cursor = app()-> db()-> getCursor( targetCategoryName );
00026   m_cursor-> setParent( this );
00027 
00028   /*
00029   ** Remember these things.
00030   **
00031   */
00032   m_connectionName        = connectionName;
00033   m_targetCategoryName    = targetCategoryName;
00034   m_reverseConnectionName = reverseConnectionName;
00035 
00036   /*
00037   ** If this category allows duplicates then we need to do
00038   **  some additional filtering.
00039   **
00040   */
00041   if( parentItem()-> categoryDef()-> duplicatesAllowed() && 
00042       parentItem()-> categoryDef()-> hasClarifyField()      )
00043   {
00044     /*
00045     ** Set up the primary filter
00046     **
00047     */
00048     if( !cursor()-> setFilter
00049         (
00050           "[ViewFilter(1,CTCF,,"  + 
00051                 dq( QString(reverseConnectionName == ""? connectionName:reverseConnectionName) ) +
00052           "," + dq( parentItem()-> categoryName()      ) +
00053           "," + dq( parentItem()-> keyField()-> name() ) +
00054           "," + "Equal to"                               +
00055           "," + dq( parentItem()-> itemName()          ) +
00056           ")]"
00057         )
00058       )
00059     {
00060       CMC_ERROR( 4, "cannot set filter: " + cursor()-> error()-> description() )
00061       qDebug( "items error %s", qPrintable(error()-> description()) );
00062       return;
00063     }
00064 
00065     /*
00066     ** Set the filter for the clarify field.
00067     **
00068     */
00069     if( !cursor()-> setFilter
00070       (
00071         "[ViewFilter(2,CTCF,,"  
00072             + dq( QString(reverseConnectionName == ""? connectionName:reverseConnectionName) ) +
00073         "," + dq( parentItem()-> categoryName()      ) +
00074         "," + dq( parentItem()-> cfyField()-> name() ) +
00075         "," + "Equal to"                               +
00076         "," + dq( parentItem()-> itemClarify()       ) +
00077         ")]"
00078       )
00079     )
00080     {
00081       CMC_ERROR( 4, "cannot set filter: " + cursor()-> error()-> description() )
00082       qDebug( "items error %s", qPrintable(error()-> description()) );
00083       return;
00084     }
00085 
00086   }
00087   else
00088   {
00089     /*
00090     ** Set up the primary filter
00091     **
00092     */
00093     if( !cursor()-> setFilter
00094         (
00095           "[ViewFilter(1,CTI,,"  + 
00096                 dq( QString(reverseConnectionName == ""? connectionName:reverseConnectionName) ) +
00097           "," + dq( parentItem()-> categoryName()      ) +
00098           "," + dq( parentItem()-> itemName()          ) +
00099           ")]"
00100         )
00101       )
00102     {
00103       CMC_ERROR( 4, "cannot set filter: " + cursor()-> error()-> description() )
00104       qDebug( "items error %s", qPrintable(error()-> description()) );
00105       return;
00106     }
00107 
00108   }
00109 
00110 
00111 }
00112 
00113 cmcItems::cmcItems
00114 (
00115   const QString & categoryName,
00116   cmcDatabase * database
00117 ):
00118   cmcObject( categoryName, database-> app(), database )
00119 {
00120   /*
00121   ** Get a cursor on the target category.  We'll hold on to this.
00122   **
00123   */
00124   m_cursor = app()-> db()-> getCursor( categoryName );
00125   m_cursor-> setParent( this );
00126 
00127   /*
00128   ** Remember these things.
00129   **
00130   */
00131   m_targetCategoryName    = categoryName;
00132 
00133 
00134 }
00135 
00136 
00137 
00138 cmcItems::~cmcItems()
00139 {
00140 //  TRACE_FUNCTION
00141 }
00142 
00143 QString cmcItems::name()
00144 {
00145   return( m_connectionName );
00146 }
00147 
00148 QString cmcItems::toCategory()
00149 {
00150   return( m_targetCategoryName );
00151 }
00152 
00153 QString cmcItems::reverseName()
00154 {
00155   return( m_reverseConnectionName );
00156 }
00157 
00158 QString cmcItems::conCatName()
00159 {
00160   return( name() + " -> " + toCategory() );
00161 }
00162 
00163 cmcItem * cmcItems::parentItem()
00164 {
00165   return( qobject_cast<cmcItem*>(parent()) );
00166 }
00167 
00168 long cmcItems::count()
00169 {
00170   return( cursor()-> rowCount() );
00171 }
00172 
00173 cmcItem * cmcItems::item( long index )
00174 {
00175   cmcItem * retVal = items[index];
00176 
00177   if( !retVal )
00178   {
00179     retVal = new cmcItem( rowset(), index, app(), this );
00180     items.insert( index, retVal );
00181   }
00182 
00183   return( retVal );
00184 }
00185 
00186 
00187 bool cmcItems::loadByField( const QString &, const QString &, const QString &, bool, bool )
00188 {
00189   return( false );
00190 }
00191 
00192 bool cmcItems::loadByKey(const QString &)
00193 {
00194   return( false );
00195 }
00196 
00197 long cmcItems::setColumn( const QString &, const QString &, const QString & )
00198 {
00199   return( 0 );
00200 }
00201 
00202 long cmcItems::setColumn( const QString & )
00203 {
00204   return( 0 );
00205 }
00206 
00207 cmcCursor * cmcItems::cursor()
00208 {
00209   return( m_cursor );
00210 }
00211 
00212 cmcRowSet * cmcItems::rowset()
00213 {
00214   if( !m_rowset )
00215   {
00216     m_rowset = cursor()-> getEditRowSet();
00217     m_rowset-> setParent(this);
00218   }
00219 
00220   return( m_rowset );
00221 }
00222 
00223 cmcCategoryDef * cmcItems::categoryDef()
00224 {
00225   return( NULL );
00226 }
00227 
00228 QString cmcItems::categoryName()
00229 {
00230   return( "" );
00231 }
00232 
00233 } // endnamespace cmcDatabaseApi
00234 
 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