Beispiel #1
0
 void qt_dbtableview_impl :: _store() {
   if (!(_model && _parent && _xml)) return;
   if (!_model->columnCount()) return;
   
   xpath_object_ptr tmp(0);
   string expr = _tag_model+ "/columns/column[@number=\"%s\"]";
   for(int i=0; i<_model->columnCount(); ++i) {
     string s(expr);
     s.replace(s.find("%s"), 2, int_to_str(i));
     
     tmp = _xml->xpath_eval_expr((s + "/width[text()!=\"\"]").c_str());
     if (tmp->size()) {
       tmp->set_content(0, int_to_str(_parent->columnWidth(i)).c_str());
       continue;
     }
     
     tmp = _xml->xpath_eval_expr(s.c_str());
     if (tmp->size()) {
       xmlNodePtr node = xmlNewNode(NULL, (xmlChar*)"width");
       if (!node) {
         _lprintf(LOG_ERR, "can't create xml node\n");
         continue;
       }          
       xmlNodeAddContent(node, (xmlChar*)int_to_str(_parent->columnWidth(i)).c_str());
       try {
         tmp->insert_node(0, node);
       } catch (xpath_error& e) {
         xmlFreeNode(node);
         _lprintf(LOG_ERR, "%s\n", e.what());
       }
     }
   }
   _xml->save();
 }
Beispiel #2
0
 //------------------------------------------------------------------------
 const TreeModel::Header* qt_dbtreemodel_impl::_header( int section ) const
 {        
     const TreeModel::Display *display = _treemodel.defaultDisplay();
     if( ! display )
     {
         _lprintf( LOG_INFO, "Default display not found\n");
         return NULL;
     }
     
     const TreeModel::Column *column = display->column( section );
     if( ! column )
     {
         _lprintf( LOG_INFO, "Column %d not found\n", section );
         return NULL;
     }
     
     const TreeModel::Header *header = column->header();
     if( ! header )
     {
         _lprintf( LOG_INFO, "Header %d not exist\n", section );
         return NULL;
     }
     
     return header;
 }
Beispiel #3
0
 template<class T> qt_dbtablewindow<T>
 :: qt_dbtablewindow ( const char* windowname,
                       const char* dbid, 
                       const char* xmlfile,
                       const char* prefix,
                       QWidget* parent,
                       Qt::WindowFlags f )
 : widget_store<T>(windowname, parent, f),
 _db(0),
 _view(0),
 _dialog(0),
 _menu(0),
 _hbox(0) 
 {
   _db = new east_intrpg::pgdb(dbid);
   if (_db->open()) {
     _view = new qt_dbtableview(xmlfile, prefix, _db, this);
     _dialog = new qt_dbdialog(xmlfile, prefix, _db, this);
     _dialog->restore();
     _menu = new qt_dbtablemenu(_view, _dialog);
     _hbox = new QHBoxLayout;
     _hbox->addWidget(_view);
     this->setLayout(_hbox);
   } else
     _lprintf(LOG_ERR, "%s\n", _db->last_error());
 }
Beispiel #4
0
 //------------------------------------------------------------------------
 string qt_dbtreemodel_impl::_value( const row *r, const string& format, const string& columns ) const
 {
     if( !r )
         return string();
     
     string          result( format );
     vector<string>  dest;
     split_str( columns, ",", dest );
     
     for( size_t i = 0; i < dest.size(); ++i )
     {
         size_t n = result.find( "%s" );
         if( n != string::npos )
         {
             try {
                 result.replace( n, 2, r->at( str_to_size_t( dest[i] ) ) );
             } catch( std::out_of_range& ) {
                 _lprintf( LOG_ERR, "Column %lu is wrong\n", dest[i].c_str() );
                 continue;
             }
         }
     }
     
     return result;
 }
Beispiel #5
0
void DeleteFromSetExx( GENERICSET *pSet, void *unit, int unitsize, int max DBG_PASS )
{
	uintptr_t nUnit = (uintptr_t)unit;
	int ofs = ( ( max + 31 ) / 32) * 4;
	if( bLog ) _lprintf(DBG_RELAY)( WIDE("Deleting from  %p of %p "), pSet, unit );
	while( pSet )
	{
		if( bLog ) lprintf( WIDE( "range to check is %")_PTRSZVALfx WIDE("(%d) to %")_PTRSZVALfx WIDE("(%d)" )
				 ,	  ((uintptr_t)(pSet->bUsed) + ofs )
			     ,(nUnit >= ((uintptr_t)(pSet->bUsed) + ofs ))
				  , ((uintptr_t)(pSet->bUsed) + ofs + unitsize*max )
		        , (nUnit <= ((uintptr_t)(pSet->bUsed) + ofs + unitsize*max ))
				 );
		if( (nUnit >= ((uintptr_t)(pSet->bUsed) + ofs )) &&
		    (nUnit <= ((uintptr_t)(pSet->bUsed) + ofs + unitsize*max )) )
		{
			uintptr_t n = nUnit - ( ((uintptr_t)(pSet->bUsed)) + ofs );
			//Log1( WIDE("Found item in set at %d"), n / unitsize );
			if( n % unitsize )
			{
				lprintf( WIDE("Error in set member alignment! %p %p %p  %d %")_PTRSZVALfs WIDE(" %")_PTRSZVALfs WIDE(" of %d")
						 , unit
						 , pSet
						 , &pSet->bUsed
						, ofs
						 , n, n % unitsize, unitsize );
				DebugBreak();
				return;
			}
			n /= unitsize;
			ClearUsed( pSet, n );
			//pSet->nUsed--; // one not used - quick reference counter
			break;
		}
		pSet = pSet->next;
	}
	if( !pSet )
		Log( WIDE("Failed to find node in set!") );
}
Beispiel #6
0
static int DumpErrorEx( DBG_VOIDPASS )
#define DumpError() DumpErrorEx( DBG_VOIDSRC )
{
	_lprintf(DBG_RELAY)( WIDE("Failed create process:%d"), GetLastError() );
   return 0;
}