Logo Search packages:      
Sourcecode: facturalux version File versions  Download package

int FLSqlCursor::del ( bool  invalidate = true  )  [slot]

Redefinicion del métdo del() de QSqlCursor.

Este método invoca al método del() original de QSqlCursor() y comprueba si hay borrado en cascada, en caso afirmativo borrar también los registros relacionados en cardinalidad 1M .

Definition at line 592 of file FLSqlCursor.cpp.

References buffer_, FLRelationMetaData::field(), FLTableMetaData::fieldList(), FLRelationMetaData::foreignField(), FLRelationMetaData::foreignTable(), FLManager::formatValue(), metadata_, FLFieldMetaData::name(), and FLFieldMetaData::relationList().

Referenced by commitBuffer().

{
  int r = QSqlCursor::del (invalidate);

  FLTableMetaData::FLFieldMetaDataList * fieldList = metadata_->fieldList ();
  FLFieldMetaData *field;

  for (unsigned int i = 0; i < fieldList->count (); i++)
      {
        field = fieldList->at (i);
        QString s = buffer_->value (field->name ()).toString ();

        FLFieldMetaData::FLRelationMetaDataList * relationList = field->relationList ();

        if (!relationList)
            continue;

        if (!relationList->isEmpty ())
            {
              FLRelationMetaData *r;

              for (unsigned int i = 0; i < relationList->count (); i++)
                  {
                    r = relationList->at (i);
                    FLSqlCursor c (r->foreignTable ());

                    FLFieldMetaData *f = c.metadata ()->field (r->foreignField ());
                    if (f->relationM1 ()->deleteCascade ())
                        {
                          c.select ("upper(" + r->foreignField () + ")=" + FLManager::formatValue (f, QVariant (s.upper ())));
                          while (c.next ())
                              {
                                c.primeDelete ();
                                c.del (false);
                              }
                        }
                  }
            }
      }

  return r;
}


Generated by  Doxygen 1.6.0   Back to index