Eneboo - Documentación para desarrolladores
|
00001 /*************************************************************************** 00002 FLTableMetaData.h 00003 ------------------- 00004 begin : Mon Jul 2 2001 00005 copyright : (C) 2001-2005 by InfoSiAL S.L. 00006 email : mail@infosial.com 00007 ***************************************************************************/ 00008 /*************************************************************************** 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; version 2 of the License. * 00012 ***************************************************************************/ 00013 /*************************************************************************** 00014 Este programa es software libre. Puede redistribuirlo y/o modificarlo 00015 bajo los términos de la Licencia Pública General de GNU en su 00016 versión 2, publicada por la Free Software Foundation. 00017 ***************************************************************************/ 00018 00019 #ifndef FLTABLEMETADATA_H 00020 #define FLTABLEMETADATA_H 00021 00022 #include <qobject.h> 00023 #include <qdict.h> 00024 #include <qstringlist.h> 00025 00026 class FLFieldMetaData; 00027 class FLRelationMetaData; 00028 class FLCompoundKey; 00029 class FLTableMetaDataPrivate; 00030 00043 class FLTableMetaData : public QObject 00044 { 00045 Q_OBJECT 00046 00047 public: 00048 00056 FLTableMetaData(const QString &n, const QString &a, const QString &q = QString::null); 00057 00061 ~FLTableMetaData(); 00062 00066 typedef QDict<FLFieldMetaData> FLFieldMetaDataList; 00067 00073 QString name() const; 00074 00080 void setName(const QString &n); 00081 00087 void setAlias(const QString &a); 00088 00094 void setQuery(const QString &q); 00095 00099 QString alias() const; 00100 00109 QString query() const; 00110 00114 bool isQuery() const; 00115 00121 void addFieldMD(FLFieldMetaData *f); 00122 00128 void removeFieldMD(const QString &fN); 00129 00135 void setCompoundKey(FLCompoundKey *cK); 00136 00142 QString primaryKey(bool prefixTable = false) const; 00143 00149 QString fieldNameToAlias(const QString &fN) const; 00150 00156 QString fieldAliasToName(const QString &aN) const; 00157 00163 int fieldType(const QString &fN) const; 00164 00170 bool fieldIsPrimaryKey(const QString &fN) const; 00171 00177 bool fieldIsIndex(const QString &fN) const; 00178 00185 bool fieldIsCounter(const QString &fN) const; 00186 00192 bool fieldAllowNull(const QString &fN) const; 00193 00199 bool fieldIsUnique(const QString &fN) const; 00200 00210 QString fieldTableM1(const QString &fN) const; 00211 00220 QString fieldForeignFieldM1(const QString &fN) const; 00221 00231 FLRelationMetaData *relation(const QString &fN, const QString &fFN, const QString &fTN) const; 00232 00238 int fieldLength(const QString &fN) const; 00239 00245 int fieldPartInteger(const QString &fN) const; 00246 00252 int fieldPartDecimal(const QString &fN) const; 00253 00259 bool fieldCalculated(const QString &fN) const; 00260 00266 bool fieldVisible(const QString &fN) const; 00267 00273 FLFieldMetaData *field(const QString &fN) const; 00274 00280 FLFieldMetaDataList *fieldList() const; 00281 00288 QString fieldList(bool prefixTable) const; 00289 00299 FLFieldMetaDataList *fieldListOfCompoundKey(const QString &fN) const; 00300 00307 QString fieldsNames() const; 00308 00312 QStringList fieldsNamesUnlock() const; 00313 00317 bool concurWarn() const; 00318 00322 void setConcurWarn(bool b = true); 00323 00327 bool detectLocks() const; 00328 00332 void setDetectLocks(bool b = true); 00333 00334 private: 00335 00339 FLTableMetaDataPrivate *d; 00340 }; 00341 00342 class FLTableMetaDataPrivate 00343 { 00344 public: 00345 00346 FLTableMetaDataPrivate(const QString &n, const QString &a, const QString &q); 00347 ~FLTableMetaDataPrivate(); 00348 00354 void addFieldName(const QString &n); 00355 00361 void removeFieldName(const QString &n); 00362 00368 void formatAlias(FLFieldMetaData *f); 00369 00373 QString name_; 00374 00378 QString alias_; 00379 00383 FLTableMetaData::FLFieldMetaDataList *fieldList_; 00384 00388 FLCompoundKey *compoundKey_; 00389 00393 QString query_; 00394 00398 QString fieldsNames_; 00399 00403 QMap<QString, QString> aliasFieldMap_; 00404 QMap<QString, QString> fieldAliasMap_; 00405 00409 QStringList fieldsNamesUnlock_; 00410 00414 QString primaryKey_; 00415 00425 bool concurWarn_; 00426 00435 bool detectLocks_; 00436 }; 00437 00438 inline void FLTableMetaData::setCompoundKey(FLCompoundKey *cK) 00439 { 00440 d->compoundKey_ = cK; 00441 } 00442 00443 inline bool FLTableMetaData::isQuery() const 00444 { 00445 return !d->query_.isEmpty(); 00446 } 00447 00448 inline QString FLTableMetaData::name() const 00449 { 00450 return d->name_; 00451 } 00452 00453 inline QString FLTableMetaData::alias() const 00454 { 00455 return d->alias_; 00456 } 00457 00458 inline QString FLTableMetaData::query() const 00459 { 00460 return d->query_; 00461 } 00462 00463 inline FLTableMetaData::FLFieldMetaDataList *FLTableMetaData::fieldList() const 00464 { 00465 return d->fieldList_; 00466 } 00467 00468 inline QString FLTableMetaData::fieldsNames() const 00469 { 00470 return d->fieldsNames_; 00471 } 00472 00473 inline void FLTableMetaData::setAlias(const QString &a) 00474 { 00475 d->alias_ = a; 00476 } 00477 00478 inline void FLTableMetaData::setQuery(const QString &q) 00479 { 00480 d->query_ = q; 00481 } 00482 00483 inline QStringList FLTableMetaData::fieldsNamesUnlock() const 00484 { 00485 return d->fieldsNamesUnlock_; 00486 } 00487 00488 inline bool FLTableMetaData::concurWarn() const 00489 { 00490 return d->concurWarn_; 00491 } 00492 00493 inline void FLTableMetaData::setConcurWarn(bool b) 00494 { 00495 d->concurWarn_ = b; 00496 } 00497 00498 inline bool FLTableMetaData::detectLocks() const 00499 { 00500 return d->detectLocks_; 00501 } 00502 00503 inline void FLTableMetaData::setDetectLocks(bool b) 00504 { 00505 d->detectLocks_ = b; 00506 } 00507 00508 #endif