Ejemplo n.º 1
0
int Q3DataBrowser::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 24)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 24;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = boundaryChecking(); break;
        case 1: *reinterpret_cast< QString*>(_v) = filter(); break;
        case 2: *reinterpret_cast< QStringList*>(_v) = sort(); break;
        case 3: *reinterpret_cast< bool*>(_v) = confirmEdits(); break;
        case 4: *reinterpret_cast< bool*>(_v) = confirmInsert(); break;
        case 5: *reinterpret_cast< bool*>(_v) = confirmUpdate(); break;
        case 6: *reinterpret_cast< bool*>(_v) = confirmDelete(); break;
        case 7: *reinterpret_cast< bool*>(_v) = confirmCancels(); break;
        case 8: *reinterpret_cast< bool*>(_v) = isReadOnly(); break;
        case 9: *reinterpret_cast< bool*>(_v) = autoEdit(); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setBoundaryChecking(*reinterpret_cast< bool*>(_v)); break;
        case 1: setFilter(*reinterpret_cast< QString*>(_v)); break;
        case 2: setSort(*reinterpret_cast< QStringList*>(_v)); break;
        case 3: setConfirmEdits(*reinterpret_cast< bool*>(_v)); break;
        case 4: setConfirmInsert(*reinterpret_cast< bool*>(_v)); break;
        case 5: setConfirmUpdate(*reinterpret_cast< bool*>(_v)); break;
        case 6: setConfirmDelete(*reinterpret_cast< bool*>(_v)); break;
        case 7: setConfirmCancels(*reinterpret_cast< bool*>(_v)); break;
        case 8: setReadOnly(*reinterpret_cast< bool*>(_v)); break;
        case 9: setAutoEdit(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 10;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 10;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 10;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 2
0
/*!
 *\~english
 *	Initialisation the widget on form loaded in engine.
 *\~russian
 *	Инициализация виджета при загрузке в форму инжина.
 *\~
 */
void
wDBTable::init(aDatabase *adb, aEngine *e )
{

	aLog::print(aLog::Debug, tr("wDBTable init in engine "));
//	printf("begin init wdbtable\n");
	unsigned int countField,i;
	aCfgItem o, own;
	QString str, ctype;
	QStringList lst,lstHead,lstWidth;
	int tid;
	aWidget *container = NULL;

	t_doc = rcIcon( "t_doc.png" );
        t_doc_d = rcIcon( "t_doc_d.png" );
        t_doc_t = rcIcon( "t_doc_t.png" );
        t_doc_m = rcIcon( "t_doc_m.png" );
        t_doc_tm = rcIcon( "t_doc_tm.png" );
	t_cat_e = rcIcon( "t_cat_e.png" );
        t_cat_ed = rcIcon( "t_cat_ed.png" );
	t_cat_g = rcIcon( "t_cat_g.png" );
	t_cat_gd = rcIcon( "t_cat_gd.png" );

	engine = e;
	setConfirmDelete(true);
	db = adb;
	md = &adb->cfg;
	tid = property("TableInd").toInt();
	container = aWidget::parentContainer( this );
	if ( !container )
	{
		aLog::print(aLog::Error, tr("wDBTable not in Ananas object container "));
		return; //printf("!no wDBTable parent container\n");
	}
	else
	{
		o = md->objTable( container->getId(), tid );
		if ( o.isNull() )
		{
			//debug_message("Table not found\n");
			aLog::print(aLog::Error, tr("wDBTable init meta object not found "));
		}
		ctype = container->className();
		aLog::print(aLog::Info, tr("wDBTable container type is %1 ").arg(ctype));

		setContainerType(ctype);
	}

	//o  = md->find(property("TableInd").toInt());
	if ( o.isNull() )
	{
		aLog::print(aLog::Error, tr("wDBTable init meta object not found "));
		return;
	}
	countField = numCols();
	for(i=0; i<countField;i++)
	{
		removeColumn(0);
	}
	aSQLTable *tbl = NULL;
	//printf("ctype = %s\n",( const char *) ctype );
	if ( containerType() == "wDocument" )
	{
		QString flt;
		flt = QString("idd=%1").arg(container->uid());
		aLog::print(aLog::Info, tr("wDBTable filter is %1 ").arg(flt));
		setFilter(flt);
		//TODO: fix memory leak
		tbl = new aSQLTable( o, adb );
//		printf("new table ok\n");
	//	tbl->first();

	}
	if ( containerType() == "wCatalogue" ) {
                tbl = container->table(); //new aSQLTable( o, adb );
		setFilter(QString("idg=0"));
		newDataId(0);
		tbl->append( Q3SqlFieldInfo("system_icon") );
//		tbl->setGenerated( "system_icon", false );
		tbl->setCalculated("system_icon", true );
          }
	if ( containerType() == "wJournal" ) {
		tbl = container->table(); //new aSQLTable( o, adb );
		tbl->setMode( 0 );
		tbl->append( Q3SqlFieldInfo( "system_icon" ) );
//		tbl->setGenerated( "system_icon", false );
		tbl->setCalculated( "system_icon", true );
//		tbl->append( QSqlFieldInfo( "t1" ) );
//		tbl->setGenerated( "t1", false );
//		tbl->setCalculated("t1", true );
        }
	refresh();
	cur->clear();
	setSqlCursor(tbl,true);
	refresh(RefreshColumns);
	countField = numCols();
	lst = property("DefIdList").toStringList();
	lstHead = property("DefHeaders").toStringList();
	lstWidth = property("ColWidth").toStringList();
	for ( i = 0; i < countField; i++ )
	{
		//remove all columns in wDBTable, not in sql cursor
		removeColumn( 0 );
		QString s = sqlCursor()->fieldName(i);
//		printf(">>>>s = %s\n",s.ascii());
//		if(sqlCursor()->isCalculated(s))
//		{
//			if((s.left(7)=="text_uf" && lst.findIndex(s.mid(7))!=-1) || s == "system_icon")
//			{
//				continue;
//			}
			// not calculate field, if is not contents in wDBTable
//			sqlCursor()->setCalculated(sqlCursor()->fieldName(i),false);
//		}
	}
	if ( containerType() == "wJournal" ) {
		addColumn( "system_icon", "", 20 );
		setColumnReadOnly( 0, true );
		if (md->objClass(*(container->getMDObject()))==md_journal && !((aDocJournal*) container->dataObject())->type() ) {
			// we have common journal
			// Insert journal system columns.
			addColumn( "ddate", tr("Date"), 100 );
			addColumn( "pnum", tr("Prefix"), 200 );
			addColumn( "num", tr("Number"), 100 );
		}
	}
	if ( containerType() == "wCatalogue" ) {
		addColumn( "system_icon", "", 20 );
	//	printf("set column ro\n");
		setColumnReadOnly( 0, true );
	}

	if ( containerType() == "wDocument" || containerType() == "wCatalogue" ) {

	// Задаем сортировку по индентификатору в обратном порядке для
	// табличной части документа
	// чтобы при добавлении новых позиций в список строки не скакали
	    QSqlIndex pk = sqlCursor()->primaryIndex();
	    pk.setDescending( 0, false);
	    setSort( pk );
	    sqlCursor()->select();
	    sqlCursor()->first();
	    refresh();
	}


	//refresh(RefreshColumns);
	if (md->objClass(*(container->getMDObject()))!=md_journal || ((aDocJournal*) container->dataObject())->type() ) {
		// we have not common journal
		for(i=0; i<lst.count();i++)
		{
			// assemble sql table field names
			if ( containerType() == "wJournal" )
			{
//				str = journalFieldName(lst[i].toLong());

				str = "uf"+QString::number(journalFieldId(lst[i].toLong()));
				//printf(">>>>>>ss=%s\n",str.ascii());
			}
			else
			{
				str = "uf"+lst[i];
			}
			// add defined fields
			addColumn(str,lstHead[i],lstWidth[i].toInt());
		}
	}
	refresh(RefreshAll);
	setWFieldEditor();
	aLog::print(aLog::Debug, tr("wDBTable init in engine ok"));
}