Example #1
0
void PltWin::drawIt(QPainter *p)
{
  QString txt;
  double x, y, x0, y0, x1, y1, x2, y2, xprev, yprev, shift, ubmin, ubmax, ub, alpha;
  int n, layer, lay, prev_layer, circDia, i, j, at, ichain, a, istart, iend, icurr, xs, ys;
  int idx, nmax;
  bool dum;

  QPen *pen = new QPen();
  QBrush *brush = new QBrush();
  QBrush *brush_unrld = new QBrush();

  // antialiasing of primitives if ANTIALIASE is set to true
  if (!paintEPS) p->setRenderHint(QPainter::Antialiasing, ANTIALIASE);

  // plot the grain boundary line
  if (isGBfile && showGB) {
    x0 = ZFact*xyzMin(1) - xPan - (ZFact-1)*xyzCen(1);
    x1 = ZFact*xyzMax(1) - xPan - (ZFact-1)*xyzCen(1);
    y  = ZFact*gbYcoor - yPan - (ZFact-1)*xyzCen(2);
    DrawLine(p, x0, y, x1, y);
  }

  if (AtomPos==COMPOSITE) {
    if (!paintEPS) {
      brush_unrld->setColor( Qt::lightGray );
      brush_unrld->setStyle( Qt::SolidPattern );
    }
  }

  // plotting of atomic arrangement in the initial configuration
  prev_layer = -1;
  x0 = y0 = x1 = y1 = 0;

  // need to construct the neighbor list in the relaxed configuration
  if (plotType == PLOT_ATOM_NEIGHBORS) {    
    if (AtomPos == UNRELAXED && NeighListInit.data == NULL)
      InitNeighborList(this, NeighListInit, numNeighInit);
    
    if ((AtomPos == RELAXED || AtomPos == COMPOSITE) && NeighListRel.data == NULL)
      RelNeighborList(this, rcut, NeighListRel, numNeighRel);

    if (AtomPos == UNRELAXED) {
      nmax = -1;
      for (at=1; at<=NInit; at++) {
	n = numNeighInit(at);
	if (n > nmax) nmax = n;
      }
      colormap(nmax+1, cmap);
    }

    if (AtomPos == RELAXED) {
      nmax = -1;
      for (at=1; at<=NRel; at++) {
	n = numNeighRel(at);
	if (n > nmax) nmax = n;
      }
      colormap(nmax+1, cmap);
    }
  }

  if (plotType == PLOT_ATOM_TYPES) {
    nmax = -1;
    for (at=1; at<=NInit; at++) {
      n = atomType(at);
      if (n > nmax) nmax = n;
    }
    colormap(nmax, cmap);
  }
  
  //
  //  Plot the atomic configuration such that the atoms in the front (in the top layer) are plotted
  //  at the end.
  //

  for (i=1; i<=NInit; i++) {
    at = aorder(i);
    if (!zLayerSel(zLayer(at)))
      continue;    

    layer = zLayer(at);
    circDia = zDiamLayer(layer);
    
    switch(plotType) {
      case PLOT_ATOM_LAYERS:
	layer = zLayer(at);

	if (!paintEPS && layer != prev_layer) {
	  pen->setColor(zColorLayer(layer, 1));
	  pen->setWidth(zLineThickLayer(layer));
	  p->setPen(*pen);
	  
	  brush->setColor(zColorLayer(layer, 2));
	  brush->setStyle(Qt::SolidPattern);
	  p->setBrush(*brush);
	}
	break;
	
      case PLOT_ATOM_TYPES:
	lay = layer;
	layer = atomType(at);
	
	if (!paintEPS && layer != prev_layer) {
	  pen->setColor(Qt::black);
	  pen->setWidth(zLineThickLayer(lay));
	  p->setPen(*pen);
	  
	  if (layer == 0) {
	    brush->setColor(Qt::lightGray);
	  } else {
	    brush->setColor(cmap[layer-1]);
	  }
	  brush->setStyle(Qt::SolidPattern);
	  p->setBrush(*brush);
	}
	break;

      case PLOT_ATOM_NEIGHBORS:
	lay = layer;
	if (AtomPos == UNRELAXED)
	  layer = numNeighInit(at);
	else if (AtomPos == RELAXED || AtomPos == COMPOSITE)	  
	  layer = numNeighRel(at);

	if (!paintEPS && layer != prev_layer) {
	  pen->setColor(Qt::black);
	  pen->setWidth(zLineThickLayer(lay));
	  p->setPen(*pen);
	  
	  if (layer == 0)
	    brush->setColor(Qt::lightGray);
	  else {
	    brush->setColor(QColor(cmap[layer]));
	  }
	  brush->setStyle(Qt::SolidPattern);
	  p->setBrush(*brush);
	}
	break;
    }
    
    if (layer != prev_layer) prev_layer = layer;

    switch(AtomPos) {
      case UNRELAXED:
        x = ZFact*xyzInit(at,1) - xPan - (ZFact-1)*xyzCen(1);
	y = ZFact*xyzInit(at,2) - yPan - (ZFact-1)*xyzCen(2);
	DrawAtom(p, at, x, y, circDia);	
        break;

      case RELAXED:
	x = ZFact*(xyzInit(at,1) + AtomDispScale*aDisp(at,1)) - xPan - (ZFact-1)*xyzCen(1);
        y = ZFact*(xyzInit(at,2) + AtomDispScale*aDisp(at,2)) - yPan - (ZFact-1)*xyzCen(2);
        DrawAtom(p, at, x, y, circDia);
	break;

      case COMPOSITE:
	if (!paintEPS) { p->setBrush( *brush_unrld ); }
	x = ZFact*xyzInit(at,1) - xPan - (ZFact-1)*xyzCen(1);
	y = ZFact*xyzInit(at,2) - yPan - (ZFact-1)*xyzCen(2);
        DrawAtom(p, -1, x, y, circDia);
        if (!paintEPS) { p->setBrush( *brush ); }
	x = ZFact*(xyzInit(at,1) + AtomDispScale*aDisp(at,1)) - xPan - (ZFact-1)*xyzCen(1);
	y = ZFact*(xyzInit(at,2) + AtomDispScale*aDisp(at,2)) - yPan - (ZFact-1)*xyzCen(2); 
        DrawAtom(p, at, x, y, circDia);
	break;
    }

    if (x < x0) x0 = x;
    if (x > x1) x1 = x;
    if (y < y0) y0 = y;
    if (y > y1) y1 = y;

    // atom numbers
    if (AtomNumbers) {
      txt.sprintf("%d", at);
      shift = circDia/(2.0*factor);
      DrawText(p, x+shift, y+shift, txt);
    }
  }

  // plot the inert atoms
  if (InertAtoms) {
    if (!paintEPS) {
      pen->setColor(Qt::black);
      pen->setWidth(zLineThickLayer(layer));
      p->setPen(*pen);
      
      brush->setColor(Qt::black);
      brush->setStyle(Qt::NoBrush);
      p->setBrush( *brush );
    }
            
    for (at=1; at<=NInert; at++) {
      // plot only those atoms which belong to the selected (active) layers
      //      if (!zLayerSel(zLayer(n)))
      //	continue;
      x = ZFact*xyzInert(at,1) - xPan - (ZFact-1)*xyzCen(1);
      y = ZFact*xyzInert(at,2) - yPan - (ZFact-1)*xyzCen(2);
      DrawAtom(p, 0, x, y, circDia);
    }    
  }

  // highlight the atoms picked
  if (!paintEPS && napicked > 0) {
    pen->setColor(Qt::green);
    pen->setWidth(2);
    p->setPen(*pen);    
    brush->setStyle(Qt::NoBrush);
    p->setBrush(*brush);
    
    dum = ATOM_3DSPHERE;
    ATOM_3DSPHERE = false;
    for (n=1; n<=napicked; n++) {
      at = apicked(n);
      x = ZFact*xyzInit(at,1) - xPan - (ZFact-1)*xyzCen(1);
      y = ZFact*xyzInit(at,2) - yPan - (ZFact-1)*xyzCen(2);
      DrawAtom(p, at, x, y, circDia+4);
      if (n > 1) DrawLine(p, xprev, yprev, x, y);
      xprev = x;
      yprev = y;
    }
    ATOM_3DSPHERE = dum;
  }

  // highlight the atoms in selected chains
  if (!paintEPS && nchain > 0) {
    pen->setColor(Qt::green);
    pen->setWidth(2);
    p->setPen(*pen);

    for (ichain=1; ichain<=nchain; ichain++) {
      for (i=1; i<=nachain(ichain); i++) {
	a = achain(ichain,i);
	x = ZFact*xyzInit(a,1) - xPan - (ZFact-1)*xyzCen(1);
	y = ZFact*xyzInit(a,2) - yPan - (ZFact-1)*xyzCen(2);	
	if (i>1) DrawLine(p, x0, y0, x, y);       
	x0 = x;
	y0 = y;

      }
    }

    if (!paintEPS && nchain >= 2) {
      QPen *pen2 = new QPen();
      pen2->setColor(Qt::green);
      pen2->setStyle(Qt::DashLine);
      p->setPen(*pen2);

      for (i=1; i<nchain; i+=2) {
	x1 = ZFact*dposchain(i,1) - xPan - (ZFact-1)*xyzCen(1);
	y1 = ZFact*dposchain(i,2) - yPan - (ZFact-1)*xyzCen(2);
	x2 = ZFact*dposchain(i+1,1) - xPan - (ZFact-1)*xyzCen(1);
	y2 = ZFact*dposchain(i+1,2) - yPan - (ZFact-1)*xyzCen(2);
	DrawLine(p, x1, y1, x2, y2);
      }
    }
  }

  // plotting the coordinate system centered at the initial position of
  // the dislocation line
  if (PlaneTraces) DrawPlaneTraces(p, x0, y0, x1, y1);

  // plotting of arrows
  if (arrNeighNum > 0) {
    if (!paintEPS) {
      pen->setColor(Qt::black);
      pen->setWidth(thicknessArrow);
      p->setPen(*pen); 
      p->setBrush(Qt::black);
    }
    
    switch(DispComponent) {
      case EDGE:
	plotEdgeComponent(p);
	break;
	
      case SCREW:
	plotScrewComponent(p);
	break;
      
      case PROJ:
	plotScrewComponent(p);   // plotted the same way as screw components
	break;
      
      case DIFF_EDGE:
      case DIFF_SCREW:
	plotDifference(p);
	break;
    }
  }
  
  // position of dislocation center
  if (DisloCenter) {
    DrawLine(p, xCore, y0, xCore, y1);    
    DrawLine(p, x0, yCore, x1, yCore);    
  }

  // small inset to show the active Z-layers
  if (!paintEPS && showZLayers)
    ShowActiveZLayers(p);

  // show color map
  if (!paintEPS && (plotType == PLOT_ATOM_TYPES || plotType == PLOT_ATOM_NEIGHBORS))
    ShowColorMap(p);

  // lines showing the division of the block into cells (for the linked neighbor list)
  if (showNeighCells) {
    if (!paintEPS) {
      pen->setColor(Qt::black);
      p->setPen(*pen);
    }

    for (i=0; i<=ncell(1); i++) {
      x = ZFact*(xyzMin(1)+i*cellsize(1)) - xPan - (ZFact-1)*xyzCen(1);
      y0 = ZFact*xyzMin(2) - yPan - (ZFact-1)*xyzCen(2);
      y1 = ZFact*xyzMax(2) - yPan - (ZFact-1)*xyzCen(2);
      DrawLine(p, x, y0, x, y1);    
      
      for (j=0; j<=ncell(2); j++) {
	y = ZFact*(xyzMin(2)+j*cellsize(2)) - yPan - (ZFact-1)*xyzCen(2);
	x0 = ZFact*xyzMin(1) - xPan - (ZFact-1)*xyzCen(1);
	x1 = ZFact*xyzMax(1) - xPan - (ZFact-1)*xyzCen(1);
	DrawLine(p, x0, y, x1, y);
      }
    }
  }

  // coordinate system of the block
  if (!paintEPS && showCSys)
    ShowCSys(p);

  // show the polygon that encompasses the dislocation center
  if (!paintEPS && ndpoly > 0) {
    pen->setColor(Qt::green);
    p->setPen(*pen);

    for (n=1; n<=ndpoly; n++) {
      x1 = ZFact*dpoly(n,1) - xPan - (ZFact-1)*xyzCen(1);
      y1 = ZFact*dpoly(n,2) - yPan - (ZFact-1)*xyzCen(2);
      if (n<ndpoly) {
	x2 = ZFact*dpoly(n+1,1) - xPan - (ZFact-1)*xyzCen(1);
	y2 = ZFact*dpoly(n+1,2) - yPan - (ZFact-1)*xyzCen(2);
      } else {
	x2 = ZFact*dpoly(1,1) - xPan - (ZFact-1)*xyzCen(1);
	y2 = ZFact*dpoly(1,2) - yPan - (ZFact-1)*xyzCen(2);
      }
      DrawLine(p, x1, y1, x2, y2);
    }
  }

  if (!paintEPS && ndpath > 0) {
    pen->setColor(Qt::green);
    p->setPen(*pen);
    brush->setColor(Qt::green);
    brush->setStyle(Qt::NoBrush);
    p->setBrush(*brush);

    for (n=1; n<ndpath; n++) {
      x1 = ZFact*dpath(n,1) - xPan - (ZFact-1)*xyzCen(1);
      y1 = ZFact*dpath(n,2) - yPan - (ZFact-1)*xyzCen(2);
      x2 = ZFact*dpath(n+1,1) - xPan - (ZFact-1)*xyzCen(1);
      y2 = ZFact*dpath(n+1,2) - yPan - (ZFact-1)*xyzCen(2);
      DrawLine(p, x1, y1, x2, y2);
      if (n==1) {
	xyWorldToScreen(x1, y1, xs, ys);
	xs -= 2;
	ys -= 2;
	p->drawEllipse(xs, ys, 4, 4);
      }
      xyWorldToScreen(x2, y2, xs, ys);
      xs -= 2;
      ys -= 2;
      p->drawEllipse(xs, ys, 4, 4);
    }
  }
}
QtPropertyDataInspColl::QtPropertyDataInspColl(void *_object, const DAVA::InspColl *_collection, bool autoAddChilds)
	: object(_object)
	, collection(_collection)
{
	if(NULL != collection && collection->Size(object) > 0 && autoAddChilds)
	{
		int index = 0;
		DAVA::MetaInfo *valueType = collection->ItemType();
		DAVA::InspColl::Iterator i = collection->Begin(object);
		while(NULL != i)
		{
			if(NULL != valueType->GetIntrospection())
			{
				void * itemObject = collection->ItemData(i);
				const DAVA::InspInfo *itemInfo = valueType->GetIntrospection(itemObject);

				if(NULL != itemInfo && NULL != itemObject)
				{
					QtPropertyData *childData = new QtPropertyDataIntrospection(itemObject, itemInfo);
					ChildAdd(QString::number(index), childData);
				}
				else
				{
					QString s;
					QtPropertyData* childData = new QtPropertyData(s.sprintf("[%p] Pointer", itemObject));
					childData->SetEnabled(false);
					ChildAdd(QString::number(index), childData);
				}
			}
			else
			{
				if(!valueType->IsPointer())
				{
					QtPropertyDataMetaObject *childData = new QtPropertyDataMetaObject(collection->ItemPointer(i), valueType);
					ChildAdd(QString::number(index), childData);
				}
				else
				{
					QString s;
					QtPropertyData* childData = new QtPropertyData(s.sprintf("[%p] Pointer", collection->ItemData(i)));
					childData->SetEnabled(false);

					if(collection->ItemKeyType() == DAVA::MetaInfo::Instance<DAVA::FastName>())
					{
						const DAVA::FastName *fname = (const DAVA::FastName *) collection->ItemKeyData(i);
						ChildAdd(fname->operator*(), childData);
					}
					else
					{
						ChildAdd(QString::number(index), childData);
					}
				}
			}

			index++;
			i = collection->Next(i);
		}
	}

	SetEnabled(false);
}
Example #3
0
void KBBGraphic::paintCellDefault( QPainter* p, int row, int col )
{
    int w = cellW;
    int h = cellH;
    int x2 = w - 1;
    int y2 = h - 1;
    int type;
    QColor color;

    switch (type = graphicBoard->get( col, row )) {
    case MARK1BBG:
        color = darkRed;
        break;
    case OUTERBBG:
        color = white;
        break;
    case INNERBBG:
        color = gray;
        break;
    case LASERBBG:
        color = darkGreen;
        break;
    case LFIREBBG:
        color = green;
        break;
    case FBALLBBG:
        color = red;
        break;
    case TBALLBBG:
        color = blue;
        break;
    case WBALLBBG:
        color = cyan;
        break;
    default:
        color = white;
    }
    p->fillRect( 0, 0, x2, y2, color );

    p->setPen( black );
    p->drawLine( x2, 0, x2, y2 );		// draw vertical line on right
    p->drawLine( 0, y2, x2, y2 );		// draw horiz. line at bottom

    /*
       Extra drawings for boxes aroud lasers.
    */
    QString s;
    switch (type) {
    case RLASERBBG:
        s.sprintf( "%c", 'R' );
        p->drawText( 1, 1, x2-1, y2-1, AlignCenter, s );
        break;
    case HLASERBBG:
        s.sprintf( "%c", 'H' );
        p->drawText( 1, 1, x2-1, y2-1, AlignCenter, s );
        break;
    }
    if (type < 0) {
        s.sprintf( "%d", -type );
        p->drawText( 1, 1, x2-1, y2-1, AlignCenter, s );
    }

    /*
       Draw extra frame inside if this is the current cell.
    */
    if ( (row == curRow) && (col == curCol) ) {	// if we are on current cell,
        if ( hasFocus() ) {
            p->drawEllipse( 1, 1, x2-2, y2-2 );	// draw ellipse
        }
        else {					// we don't have focus, so
            p->setPen( DotLine );		        // use dashed line to
            p->drawEllipse( 1, 1, x2-2, y2-2 );	// draw ellipse
            p->setPen( SolidLine );		        // restore to normal
        }
    }
}
vogleditor_stateTreeProgramItem::vogleditor_stateTreeProgramItem(QString name, QString value, vogleditor_stateTreeItem *parentNode, vogl_program_state &state, const vogl_context_info &info)
    : vogleditor_stateTreeItem(name, value, parentNode),
      m_pState(&state)
{
    QString tmp;

    // basic info
    this->appendChild(new vogleditor_stateTreeProgramBoolItem("GL_LINK_STATUS", &vogl_program_state::get_link_status, this, state));
    if (info.supports_extension("GL_ARB_separate_shader_objects"))
        this->appendChild(new vogleditor_stateTreeProgramBoolItem("GL_PROGRAM_SEPARABLE", &vogl_program_state::get_separable, this, state));
    this->appendChild(new vogleditor_stateTreeProgramBoolItem("GL_DELETE_STATUS", &vogl_program_state::get_marked_for_deletion, this, state));
    this->appendChild(new vogleditor_stateTreeProgramBoolItem("GL_VALIDATE_STATUS", &vogl_program_state::get_verify_status, this, state));
    if (info.get_version() >= VOGL_GL_VERSION_3_1)
    {
        this->appendChild(new vogleditor_stateTreeProgramUIntItem("GL_ACTIVE_UNIFORM_BLOCKS", &vogl_program_state::get_num_active_uniform_blocks, this, state));
    }

    // program binary
    this->appendChild(new vogleditor_stateTreeItem("GL_PROGRAM_BINARY_RETRIEVABLE_HINT", "TODO", this));
    this->appendChild(new vogleditor_stateTreeProgramUIntItem("GL_PROGRAM_BINARY_LENGTH", &vogl_program_state::get_program_binary_size, this, state));
    this->appendChild(new vogleditor_stateTreeProgramEnumItem("GL_PROGRAM_BINARY_FORMAT", &vogl_program_state::get_program_binary_format, this, state));
    if (m_pState->get_program_binary().size() > 0)
    {
        this->appendChild(new vogleditor_stateTreeItem("Program Binary", "TODO: open in a new tab", this));
    }

    // info log
    this->appendChild(new vogleditor_stateTreeProgramLogItem("GL_INFO_LOG_LENGTH", &vogl_program_state::get_info_log, this, state));

    // linked shaders
    const vogl_unique_ptr<vogl_program_state> &linked_program = m_pState->get_link_time_snapshot();
    if (linked_program.get())
    {
        uint num_attached_shaders = linked_program->get_shaders().size();
        vogleditor_stateTreeItem *pLinkedShadersNode = new vogleditor_stateTreeItem("Linked Shaders", tmp.sprintf("[%u]", num_attached_shaders), this);
        this->appendChild(pLinkedShadersNode);

        for (uint i = 0; i < num_attached_shaders; i++)
        {
            vogl_shader_state &shader = const_cast<vogl_shader_state &>(linked_program->get_shaders()[i]);
            GLuint64 shaderId = shader.get_snapshot_handle();
            pLinkedShadersNode->appendChild(new vogleditor_stateTreeShaderItem(tmp.sprintf("%" PRIu64, shaderId), enum_to_string(shader.get_shader_type()), pLinkedShadersNode, shader));
        }
    }

    // attached shaders
    uint num_attached_shaders = m_pState->get_shaders().size();
    vogleditor_stateTreeItem *pAttachedShadersNode = new vogleditor_stateTreeItem("GL_ATTACHED_SHADERS", tmp.sprintf("[%u]", num_attached_shaders), this);
    this->appendChild(pAttachedShadersNode);
    for (uint i = 0; i < num_attached_shaders; i++)
    {
        vogl_shader_state &shader = const_cast<vogl_shader_state &>(m_pState->get_shaders()[i]);
        GLuint64 shaderId = shader.get_snapshot_handle();
        pAttachedShadersNode->appendChild(new vogleditor_stateTreeShaderItem(tmp.sprintf("%" PRIu64, shaderId), enum_to_string(shader.get_shader_type()), pAttachedShadersNode, shader));
    }

    // active attribs
    vogleditor_stateTreeItem *pAttribsNode = new vogleditor_stateTreeItem("GL_ACTIVE_ATTRIBUTES", tmp.sprintf("[%u]", m_pState->get_num_active_attribs()), this);
    this->appendChild(pAttribsNode);
    uint num_active_attributes = m_pState->get_attrib_state_vec().size();
    for (uint i = 0; i < num_active_attributes; i++)
    {
        const vogl_program_attrib_state &attrib = m_pState->get_attrib_state_vec()[i];
        vogleditor_stateTreeProgramAttribItem *pItem = new vogleditor_stateTreeProgramAttribItem(tmp.sprintf("%s", attrib.m_name.get_ptr()), pAttribsNode, attrib);
        m_attribItems.push_back(pItem);
        pAttribsNode->appendChild(pItem);
    }

    // uniforms
    vogleditor_stateTreeItem *pUniformsNode = new vogleditor_stateTreeItem("GL_ACTIVE_UNIFORMS", tmp.sprintf("[%u]", m_pState->get_num_active_uniforms()), this);
    this->appendChild(pUniformsNode);
    uint num_uniforms = m_pState->get_uniform_state_vec().size();
    for (uint i = 0; i < num_uniforms; i++)
    {
        const vogl_program_uniform_state &uniform = m_pState->get_uniform_state_vec()[i];
        //      pUniformsNode->appendChild(new vogleditor_stateTreeItem(QString(uniform.m_name.get_ptr()), tmp.sprintf("Loc: %d, Size: %d, Type: %s", uniform.m_base_location, uniform.m_size, enum_to_string(uniform.m_type).toStdString().c_str()), pUniformsNode));
        vogleditor_stateTreeProgramUniformItem *pItem = new vogleditor_stateTreeProgramUniformItem(QString(uniform.m_name.get_ptr()), pUniformsNode, uniform);
        m_uniformItems.push_back(pItem);
        pUniformsNode->appendChild(pItem);
    }

    // uniform blocks
}
Example #5
0
bool DiscoInfo::processEvent(Event *e)
{
    if (e->type() == eEventVCard){
        EventVCard *evc = static_cast<EventVCard*>(e);
        JabberUserData *data = evc->data();
        if (m_data.ID.str() == data->ID.str() && m_data.Node.str() == data->Node.str()){
            edtFirstName->setText(data->FirstName.str());
            edtNick->setText(data->Nick.str());
            edtBirthday->setText(data->Bday.str());
            edtUrl->setText(data->Url.str());
            urlChanged(edtUrl->text());
            edtEMail->setText(data->EMail.str());
            edtPhone->setText(data->Phone.str());
        }
    } else
    if (e->type() == eEventDiscoItem){
        EventDiscoItem *edi = static_cast<EventDiscoItem*>(e);
        DiscoItem *item = edi->item();
        if (m_statId == item->id){
            if (item->jid.isEmpty()){
                m_statId = QString::null;
                return true;
            }
            ListViewItem *i = new ListViewItem(lstStat);
            i->setText(0, item->jid);
            i->setText(1, item->name);
            i->setText(2, item->node);
            return true;
        }
    } else
    if (e->type() == eEventClientVersion){
        EventClientVersion *ecv = static_cast<EventClientVersion*>(e);
        ClientVersionInfo* info = ecv->info();
        if (m_data.ID.str() == info->jid && m_data.Node.str() == info->node){
            edtName->setText(info->name);
            edtVersion->setText(info->version);
            edtSystem->setText(info->os);
        }
    } else
    if (e->type() == eEventClientLastInfo){
        EventClientLastInfo *ecli = static_cast<EventClientLastInfo*>(e);
        ClientLastInfo* info = ecli->info();
        if (m_data.ID.str() == info->jid){
            unsigned ss = info->seconds;
            unsigned mm = ss / 60;
            ss -= mm * 60;
            unsigned hh = mm / 60;
            mm -= hh * 60;
            unsigned dd = hh / 24;
            hh -= dd * 24;
            QString date;
            if (dd){
                date  = i18n("%n day", "%n days", dd);
                date += ' ';
            }
            QString time;
            time.sprintf("%02u:%02u:%02u", hh, mm, ss);
            date += time;
            edtLast->setText(date);
        }
    } else
    if (e->type() == eEventClientTimeInfo){
        EventClientTimeInfo *ecti = static_cast<EventClientTimeInfo*>(e);
        ClientTimeInfo* info = ecti->info();
        if (m_data.ID.str() == info->jid){
          /*
            if (!info->display.isEmpty())
                edtTime->setText(info->display);
            else
          */
                edtTime->setText(info->utc);
        }
    }
    return false;
}
int DoIt(const char* outFile, const char* regFile, const char* maskFile, const char* resultFile,
          int mask_x, int mask_y, int mask_size_x, int mask_size_y)
{
  // Read maskfile
  FILE *mfp = fopen(maskFile, "r");
//      FILE *mfp=fopen("/project/geoaida/tmp/mask.pbm","r");

  if (!mfp) {
    fprintf(stderr, "mask file %s not found\n", maskFile);
    return 1;
  }
  GaMaskImage mask;
  mask.read(mfp);
  fclose(mfp);

  QList<ArgDict> *regionSourceList=readRegionFile(regFile);
  if (!regionSourceList) return 1;
  QList<ArgDict> regionList;

  // Process regions
  for (ArgDict* arg = regionSourceList->first();
       arg;
       arg=regionSourceList->next()) {
    ArgDict* args=new ArgDict(*arg);
    if (processRegion
	(*args, mask, mask_x, mask_y, mask_size_x, mask_size_y))
      regionList.append(args);
    else
      delete args;
  }
  
  // Write labels
  QFile rfp(outFile ? outFile : regFile);
  if (outFile) {
    if (labelImageDict.count() > 1) {
      fprintf(stderr, "regionmask: Cannot generate multiple labelfiles\n");
      return 1;
    }
    else {
      if (regionList.count()>0) {
        ArgDict *dict = regionList.first();
        QString *oldfile = (*dict)["file"];
        QString *labelfile = new QString();
        if (resultFile)
          labelfile->sprintf("%s", resultFile);
        else
          labelfile->sprintf("%s.plm", outFile);
        LabelImage *im = labelImageDict.take(*oldfile);
        labelImageDict.replace(*labelfile, im);
        QListIterator < ArgDict > it(regionList);
        for (; it.current(); ++it) {
          ArgDict *argDict = it.current();
          assert(argDict);
          argDict->replace("file", labelfile);
        }
      }
    }
  }
  else {
    printf("regionmask: overwriting %s\n",regFile);
    outFile = regFile;
  }
  QDictIterator < LabelImage > git(labelImageDict);
  if (regionList.count()>0) {
    for (; git.current(); ++git) {
      LabelImage *im = git.current();
      qDebug("Writing %s", git.currentKey().latin1());
      im->image.write(git.currentKey().latin1());
    }
  }
  // Write regions
  if (!rfp.open(IO_WriteOnly)) {
    fprintf(stderr, "cannot open regionfile %s for writing\n", outFile);
    return 1;
  }
  if (regionList.count()>0) {
    QListIterator < ArgDict > it(regionList);
    QTextStream ts(&rfp);
    for (; it.current(); ++it) {
      ArgDict *argDict = it.current();
      assert(argDict);
      ts << "<region ";
      ts << (*argDict);
      ts << " />" << endl;
    }
  }
  rfp.close();
  labelImageDict.setAutoDelete(true);
  labelImageDict.clear();
  regionList.setAutoDelete(true);
  return 0;
}
Example #7
0
void EQPacketStream::dispatchPacket(const uint8_t* data, size_t len, 
				    uint16_t opCode, 
				    const EQPacketOPCode* opcodeEntry)
{
  emit decodedPacket(data, len, m_dir, opCode, opcodeEntry);

  bool unknown = true;

  // unless there is an opcode entry, there is nothing to dispatch...
  if (opcodeEntry)
  {
    EQPacketPayload* payload;
    EQPacketDispatch* dispatch;

#ifdef PACKET_INFO_DIAG
    seqDebug(
	    "dispatchPacket: attempting to dispatch opcode %#04x '%s'",
	    opcodeEntry->opcode(), (const char*)opcodeEntry->name());
#endif

    // iterate over the payloads in the opcode entry, and dispatch matches
    EQPayloadListIterator pit(*opcodeEntry);
    bool found = false;
    while ((payload = pit.current()) != 0)
    {
      // see if this packet matches
      if (payload->match(data, len, m_dir))
      {
	found = true;
	unknown = false; // 

#ifdef PACKET_INFO_DIAG
	seqDebug(
		"\tmatched payload, find dispatcher in dict (%d/%d)",
		m_dispatchers.count(), m_dispatchers.size());
#endif

	// find the dispather for the payload
	dispatch = m_dispatchers.find((void*)payload);
	
	// if found, dispatch
	if (dispatch)
	{
#ifdef PACKET_INFO_DIAG
	  seqDebug("\tactivating signal...");
#endif
	  dispatch->activate(data, len, m_dir);
	}
      }

      // go to next possible payload
      ++pit;
    }

 #ifdef PACKET_PAYLOAD_SIZE_DIAG
    if (!found && !opcodeEntry->isEmpty())
    {
      QString tempStr;
      tempStr.sprintf("%s  (%#04x) (dataLen: %u) doesn't match:",
		      (const char*)opcodeEntry->name(), opcodeEntry->opcode(), 
		      len);
      
      for (payload = pit.toFirst(); 
	   payload != 0; 
	   payload = ++pit)
      {
	if (payload->dir() & m_dir)
        {
	  if (payload->sizeCheckType() == SZC_Match)
	    tempStr += QString(" sizeof(%1):%2")
	      .arg(payload->typeName()).arg(payload->typeSize());
	  else if (payload->sizeCheckType() == SZC_Modulus)
	    tempStr += QString(" modulus of sizeof(%1):%2")
	      .arg(payload->typeName()).arg(payload->typeSize());
	}
      }      

      seqWarn(tempStr);
    }
#endif // PACKET_PAYLOAD_SIZE_DIAG
  }
#ifdef PACKET_INFO_DIAG
  else
  {
    seqWarn("dispatchPacket(): buffer size %d opcode %04x stream %s (%d) not in opcodeDB",
       len, opCode, EQStreamStr[m_streamid], m_streamid);
  }
#endif

  emit decodedPacket(data, len, m_dir, opCode, opcodeEntry, unknown);
}
// solaris, not 2.6
void qt_parseEtcLpPrinters(QList<QPrinterDescription> *printers)
{
    QDir lp(QLatin1String("/etc/lp/printers"));
    QFileInfoList dirs = lp.entryInfoList();
    if (dirs.isEmpty())
        return;

    QString tmp;
    for (int i = 0; i < dirs.size(); ++i) {
        QFileInfo printer = dirs.at(i);
        if (printer.isDir()) {
            tmp.sprintf("/etc/lp/printers/%s/configuration",
                         printer.fileName().toAscii().data());
            QFile configuration(tmp);
            char *line = new char[1025];
            QString remote(QLatin1String("Remote:"));
            QString contentType(QLatin1String("Content types:"));
            QString printerHost;
            bool canPrintPostscript = false;
            if (configuration.open(QIODevice::ReadOnly)) {
                while (!configuration.atEnd() &&
                        configuration.readLine(line, 1024) > 0) {
                    if (QString::fromLatin1(line).startsWith(remote)) {
                        const char *p = line;
                        while (*p != ':')
                            p++;
                        p++;
                        while (isspace((uchar) *p))
                            p++;
                        printerHost = QString::fromLocal8Bit(p);
                        printerHost = printerHost.simplified();
                    } else if (QString::fromLatin1(line).startsWith(contentType)) {
                        char *p = line;
                        while (*p != ':')
                            p++;
                        p++;
                        char *e;
                        while (*p) {
                            while (isspace((uchar) *p))
                                p++;
                            if (*p) {
                                char s;
                                e = p;
                                while (isalnum((uchar) *e))
                                    e++;
                                s = *e;
                                *e = '\0';
                                if (!qstrcmp(p, "postscript") ||
                                     !qstrcmp(p, "any"))
                                    canPrintPostscript = true;
                                *e = s;
                                if (s == ',')
                                    e++;
                                p = e;
                            }
                        }
                    }
                }
                if (canPrintPostscript)
                    qt_perhapsAddPrinter(printers, printer.fileName(),
                                         printerHost, QLatin1String(""));
            }
            delete[] line;
        }
    }
}
Example #9
0
QString UI::stringFrequency(long long frequency) {
    QString strFrequency;
    strFrequency.sprintf("%lld.%03lld.%03lld",frequency/1000000,frequency%1000000/1000,frequency%1000);
    return strFrequency;
}
Example #10
0
QString appendNum(int number)
{
    QString str;
    str=str.sprintf("%d",number);
    return str;
}
Example #11
0
/**
 * refreshReport()
 *
 * Fills the report body with data.
 */
void salesByServiceDetailReport::refreshReport()
{
    repBody->clear();
    if (!myBillableID) return;

    ADB     DB;
    QDate   sDate = this->startDateCal->date();
    QDate   eDate = this->endDateCal->date();
    QString companyName;
    QString customerName;
    QString tmpStr;
    double  grandTotal = 0.00;

    QApplication::setOverrideCursor(waitCursor);

    if (myIsPackage) {
        PackagesDB  PDB;
        PDB.get(myBillableID);
        tmpStr = tmpStr.sprintf("Sales Detail Report\n%s (Package)", PDB.getStr("Description"));
        setTitle(tmpStr);

        //debug(1,"select AcctsRecv.TransDate, AcctsRecv.PackageItem, Packages.InternalID, Packages.PackageTag, AcctsRecv.Amount, Customers.CustomerID, Customers.FullName, Customers.ContactName from AcctsRecv, Packages, Customers where Packages.InternalID = AcctsRecv.PackageItem and AcctsRecv.TransType = 0 and AcctsRecv.ItemID = %d and AcctsRecv.TransDate  >= '%04d-%02d-%02d' and AcctsRecv.TransDate <= '%04d-%02d-%02d' and Customers.CustomerID = AcctsRecv.CustomerID order by Customers.CustomerID\n", myBillableID, sDate.year(), sDate.month(), sDate.day(), eDate.year(), eDate.month(), eDate.day());
        DB.query("select AcctsRecv.TransDate, AcctsRecv.PackageItem, Packages.InternalID, Packages.PackageTag, AcctsRecv.Amount, Customers.CustomerID, Customers.FullName, Customers.ContactName from AcctsRecv, Packages, Customers where Packages.InternalID = AcctsRecv.PackageItem and AcctsRecv.TransType = 0 and AcctsRecv.PackageItem = %d and AcctsRecv.TransDate  >= '%04d-%02d-%02d' and AcctsRecv.TransDate <= '%04d-%02d-%02d' and Customers.CustomerID = AcctsRecv.CustomerID order by Customers.CustomerID", myBillableID, sDate.year(), sDate.month(), sDate.day(), eDate.year(), eDate.month(), eDate.day());

    } else {
        // Get the title.
        BillablesDB BDB;
        BDB.get(myBillableID);
        tmpStr = tmpStr.sprintf("Sales Detail Report\n%s", BDB.getStr("Description"));
        setTitle(tmpStr);

        // Two queries, one for standalone billables, one for packages.
        DB.query("select AcctsRecv.TransDate, AcctsRecv.ItemID, Billables.ItemID, AcctsRecv.Amount, AcctsRecv.StatementNo, Customers.CustomerID, Customers.FullName, Customers.ContactName from AcctsRecv, Billables, Customers where Billables.ItemNumber = AcctsRecv.ItemID and AcctsRecv.TransType = 0 and AcctsRecv.ItemID = %d and AcctsRecv.PackageItem = 0 and AcctsRecv.TransDate  >= '%04d-%02d-%02d' and AcctsRecv.TransDate <= '%04d-%02d-%02d' and Customers.CustomerID = AcctsRecv.CustomerID order by Customers.CustomerID", myBillableID, sDate.year(), sDate.month(), sDate.day(), eDate.year(), eDate.month(), eDate.day());
    }
    // Both queries return compatible result sets for a single pass
    // through the returned rows.
    if (DB.rowCount) while (DB.getrow()) {
        customerName = "";
        companyName  = "";
        // Check for a company name.
        if (strlen(DB.curRow["ContactName"])) {
            customerName = DB.curRow["ContactName"];
            companyName  = DB.curRow["FullName"];
        } else {
            customerName = DB.curRow["FullName"];
        }
        new Q3ListViewItem(repBody, 
                DB.curRow["TransDate"],
                DB.curRow["Amount"], 
                DB.curRow["CustomerID"],
                customerName,
                companyName,
                DB.curRow["StatementNo"]
                );
        grandTotal += atof(DB.curRow["Amount"]);
    }
    tmpStr = tmpStr.sprintf("%.2f", grandTotal);
    new Q3ListViewItem(repBody, "Total", tmpStr);

    QApplication::restoreOverrideCursor();
}
Example #12
0
QString EQStr::formatMessage(uint32_t formatid, const char* arguments, size_t argsLen) const
{
	QString tempStr;

	if (!m_messageStrings.contains(formatid))
	{
		tempStr.sprintf("Unknown: %04x: ", formatid);
		tempStr += QString::fromUtf8(arguments);

		size_t totalArgsLen = strlen(arguments) + 1;

		const char* curMsg;
		while (totalArgsLen < argsLen)
		{
			curMsg = arguments + totalArgsLen;
			tempStr += QString(", ") + QString::fromUtf8(curMsg);
			totalArgsLen += strlen(curMsg) + 1;
		}
	}
	else
	{
		QVector<QString> argList;
		argList.reserve(5); // reserve space for 5 elements to handle most common sizes

		size_t totalArgsLen = 0;
		while (totalArgsLen < argsLen)
		{
			const char* curArg = arguments + totalArgsLen;
			
			// insert argument into the argument list
			argList.push_back(QString::fromUtf8(curArg));
			totalArgsLen += strlen(curArg) + 1;
		}

		bool ok, ok2;
		int curPos;
		size_t substArg;
		int substArgValue;
		QString substFormatString;

		////////////////////////////
		// replace template (%T) arguments in formatted string
		QString formatString = m_messageStrings[formatid];
		QRegExp rxt("%T(\\d{1,3})", true, false);

		// find first template substitution
		curPos = rxt.search(formatString, 0);

		while (curPos != -1)
		{
			ok2 = false;
			substArg = rxt.cap(1).toInt(&ok);
			if (ok && (substArg <= argList.size()))
			{
				substArgValue = argList[substArg-1].toInt(&ok2);
			}

			// Find the message and replace, or skip over if not found.
			if (ok2 && m_messageStrings.contains(substArgValue))
				formatString.replace(curPos, rxt.matchedLength(), m_messageStrings[substArgValue]);
			else
				curPos += rxt.matchedLength();

			// find next substitution
			curPos = rxt.search(formatString, curPos);
		}

		////////////////////////////
		// now replace substitution arguments in formatted string
		// NOTE: not using QString::arg() because not all arguments are always used
		//       and it will do screwy stuff in this situation
		QRegExp rx("%(\\d{1,3})", true, false);

		// find first template substitution
		curPos = rx.search(formatString, 0);

		while (curPos != -1)
		{
			substArg = rx.cap(1).toInt(&ok);

			// replace substitution argument with argument from list
			if (ok && (substArg <= argList.size()))
				formatString.replace(curPos, rx.matchedLength(), argList[substArg-1]);
			else
				curPos += rx.matchedLength(); // if no such argument, skip over

			// find next substitution
			curPos = rx.search(formatString, curPos);
		}

		return formatString;
	}

	return tempStr;
}
Example #13
0
QString KeyBind::keyString(int key, int mod)
{
  QString modString = QString::null;
  QString keyString = QString::null;

  if (key >= Key_F1 && key <= Key_F12)
    {
      // Function keys
      keyString.sprintf("F%d", key - Key_F1 + 1);
    }
  else if (key >= Key_0 && key <= Key_9)
    {
      // Number keys
      keyString.sprintf("%d", key - Key_0);
    }
  else if (key >= Key_A && key <= Key_Z)
    {
      // A-Z
      keyString.sprintf("%c", 'A' + key - Key_A);
    }
  else
    {
      switch(key)
	{
	case Key_Exclam:
	  keyString.sprintf("!");
	  break;
	case Key_QuoteDbl:
	  keyString.sprintf("\"");
	  break;
	case Key_NumberSign:
	  keyString.sprintf("Unknown");
	  break;
	case Key_Dollar:
	  keyString.sprintf("$");
	  break;
	case Key_Percent:
	  keyString.sprintf("%%");
	  break;
	case Key_Ampersand:
	  keyString.sprintf("&");
	  break;
	case Key_Apostrophe:
	  keyString.sprintf("'");
	  break;
	case Key_ParenLeft:
	  keyString.sprintf("(");
	  break;
	case Key_ParenRight:
	  keyString.sprintf(")");
	  break;
	case Key_Asterisk:
	  keyString.sprintf("*");
	  break;
	case Key_Plus:
	  keyString.sprintf("+");
	  break;
	case Key_Comma:
	  keyString.sprintf(",");
	  break;
	case Key_Minus:
	  keyString.sprintf("-");
	  break;
	case Key_Period:
	  keyString.sprintf(".");
	  break;
	case Key_Slash:
	  keyString.sprintf("/");
	  break;
	case Key_Colon:
	  keyString.sprintf(":");
	  break;
        case Key_Semicolon:
	  keyString.sprintf(";");
	  break;
        case Key_Less:
	  keyString.sprintf("<");
	  break;
        case Key_Equal:
	  keyString.sprintf("/");
	  break;
        case Key_Greater:
	  keyString.sprintf(">");
	  break;
        case Key_Question:
	  keyString.sprintf("?");
	  break;
	case Key_BracketLeft:
	  keyString.sprintf("?");
	  break;
        case Key_Backslash:
	  keyString.sprintf("?");
	  break;
	case Key_BracketRight:
	  keyString.sprintf("?");
	  break;
	case Key_AsciiCircum:
	  keyString.sprintf("?");
	  break;
	case Key_Underscore:
	  keyString.sprintf("_");
	  break;
	case Key_QuoteLeft:
	  keyString.sprintf("`");
	  break;
	case Key_BraceLeft:
	  keyString.sprintf("{");
	  break;
	case Key_Bar:
	  keyString.sprintf("|");
	  break;
	case Key_BraceRight:
	  keyString.sprintf("}");
	  break;
	case Key_AsciiTilde:
	  keyString.sprintf("~");
	  break;
	case Key_At:
	  keyString.sprintf("@");
	  break;
	case Key_Space:
	  keyString.sprintf("Space");
	  break;
	case Key_Escape:
	  keyString.sprintf("Escape");
	  break;
	case Key_Return:
	  keyString.sprintf("Return");
	  break;
	case Key_Enter:
	  keyString.sprintf("Enter");
	  break;
	case Key_Insert:
	  keyString.sprintf("Insert");
	  break;
	case Key_Delete:
	  keyString.sprintf("Delete");
	  break;
	case Key_Pause:
	  keyString.sprintf("Pause");
	  break;
	case Key_Home:
	  keyString.sprintf("Home");
	  break;
	case Key_End:
	  keyString.sprintf("End");
          break;
	case Key_PageUp:
	  keyString.sprintf("PageUp");
	  break;
	case Key_PageDown:
	  keyString.sprintf("PageDown");
	  break;
	case Key_Left:
	  keyString.sprintf("Left");
          break;
	case Key_Right:
	  keyString.sprintf("Right");
          break;
	case Key_Up:
	  keyString.sprintf("Up");
          break;
	case Key_Down:
	  keyString.sprintf("Down");
          break;
	case Key_Shift:
	  keyString.sprintf("Shift +");
	  break;
	case Key_Alt:
	  keyString.sprintf("Alt +");
	  break;
	case Key_Control:
	  keyString.sprintf("Control +");
	  break;
	case 0:
	  keyString.sprintf("None");
	  break;
	case Key_unknown:
	  keyString.sprintf("Unknown");
	  break;
	default:
	  keyString.sprintf("Code %d", key);
	  break;
	}
    }

  if (mod & ShiftButton)
    {
      modString += QString("Shift + ");
    }
  
  if (mod & AltButton)
    {
      modString += QString("Alt + ");
    }

  if (mod & ControlButton)
    {
      modString += QString("Control + ");
    }

  if (key == 0)
    {
      return QString("None");
    }
  else
    {
      return QString(modString + keyString);
    }
}
Example #14
0
void UIDebugSCUDSP::updateRegList()
{
   scudspregs_struct regs;
   QString str;

   if (ScuRegs == NULL)
      return;

   memset(&regs, 0, sizeof(regs));
   ScuDspGetRegisters(&regs);
   lwRegisters->clear();

   str.sprintf("PR = %d   EP = %d", regs.ProgControlPort.part.PR, regs.ProgControlPort.part.EP);
   lwRegisters->addItem(str);

   str.sprintf("T0 = %d   S =  %d", regs.ProgControlPort.part.T0, regs.ProgControlPort.part.S);
   lwRegisters->addItem(str);

   str.sprintf("Z =  %d   C =  %d", regs.ProgControlPort.part.Z, regs.ProgControlPort.part.C);
   lwRegisters->addItem(str);

   str.sprintf("V =  %d   E =  %d", regs.ProgControlPort.part.V, regs.ProgControlPort.part.E);
   lwRegisters->addItem(str);

   str.sprintf("ES = %d   EX = %d", regs.ProgControlPort.part.ES, regs.ProgControlPort.part.EX);
   lwRegisters->addItem(str);

   str.sprintf("LE =          %d", regs.ProgControlPort.part.LE);
   lwRegisters->addItem(str);

   str.sprintf("P =          %02X", regs.ProgControlPort.part.P);
   lwRegisters->addItem(str);

   str.sprintf("TOP =        %02X", regs.TOP);
   lwRegisters->addItem(str);

   str.sprintf("LOP =        %02X", regs.LOP);
   lwRegisters->addItem(str);

   str.sprintf("CT = %02X:%02X:%02X:%02X", regs.CT[0], regs.CT[1], regs.CT[2], regs.CT[3]);
   lwRegisters->addItem(str);

   str.sprintf("RA =   %08lX", regs.RA0);
   lwRegisters->addItem(str);

   str.sprintf("WA =   %08lX", regs.WA0);
   lwRegisters->addItem(str);

   str.sprintf("RX =   %08lX", regs.RX);
   lwRegisters->addItem(str);

   str.sprintf("RY =   %08lX", regs.RX);
   lwRegisters->addItem(str);

   str.sprintf("PH =       %04X", regs.P.part.H & 0xFFFF);
   lwRegisters->addItem(str);

   str.sprintf("PL =   %08X", (int)(regs.P.part.L & 0xFFFFFFFF));
   lwRegisters->addItem(str);

   str.sprintf("ACH =      %04X", regs.AC.part.H & 0xFFFF);
   lwRegisters->addItem(str);

   str.sprintf("ACL =  %08X", (int)(regs.AC.part.L & 0xFFFFFFFF));
   lwRegisters->addItem(str);
}
Example #15
0
QT_BEGIN_NAMESPACE

void
UnixMakefileGenerator::init()
{
    ProStringList &configs = project->values("CONFIG");
    if(project->isEmpty("ICON") && !project->isEmpty("RC_FILE"))
        project->values("ICON") = project->values("RC_FILE");
    if(project->isEmpty("QMAKE_EXTENSION_PLUGIN"))
        project->values("QMAKE_EXTENSION_PLUGIN").append(project->first("QMAKE_EXTENSION_SHLIB"));

    project->values("QMAKE_ORIG_TARGET") = project->values("TARGET");

    //version handling
    if (project->isEmpty("VERSION")) {
        project->values("VERSION").append(
            "1.0." + (project->isEmpty("VER_PAT") ? QString("0") : project->first("VER_PAT")));
    }
    QStringList l = project->first("VERSION").toQString().split('.');
    l << "0" << "0"; //make sure there are three
    project->values("VER_MAJ").append(l[0]);
    project->values("VER_MIN").append(l[1]);
    project->values("VER_PAT").append(l[2]);

    QString sroot = project->sourceRoot();
    foreach (const ProString &iif, project->values("QMAKE_INTERNAL_INCLUDED_FILES")) {
        if (iif == project->cacheFile())
            continue;
        if (iif.startsWith(sroot) && iif.at(sroot.length()) == QLatin1Char('/'))
            project->values("DISTFILES") += fileFixify(iif.toQString(), FileFixifyRelative);
    }

    /* this should probably not be here, but I'm using it to wrap the .t files */
    if(project->first("TEMPLATE") == "app")
        project->values("QMAKE_APP_FLAG").append("1");
    else if(project->first("TEMPLATE") == "lib")
        project->values("QMAKE_LIB_FLAG").append("1");
    else if(project->first("TEMPLATE") == "subdirs") {
        MakefileGenerator::init();
        if(project->isEmpty("MAKEFILE"))
            project->values("MAKEFILE").append("Makefile");
        return; /* subdirs is done */
    }

    project->values("QMAKE_ORIG_DESTDIR") = project->values("DESTDIR");
    project->values("QMAKE_LIBS") += project->values("LIBS");
    project->values("QMAKE_LIBS_PRIVATE") += project->values("LIBS_PRIVATE");
    if((!project->isEmpty("QMAKE_LIB_FLAG") && !project->isActiveConfig("staticlib")) ||
       (project->isActiveConfig("qt") &&  project->isActiveConfig("plugin"))) {
        if(configs.indexOf("dll") == -1) configs.append("dll");
    } else if(!project->isEmpty("QMAKE_APP_FLAG") || project->isActiveConfig("dll")) {
        configs.removeAll("staticlib");
    }
    if(!project->isEmpty("QMAKE_INCREMENTAL"))
        project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_INCREMENTAL");
    else if(!project->isEmpty("QMAKE_LFLAGS_PREBIND") &&
            !project->values("QMAKE_LIB_FLAG").isEmpty() &&
            project->isActiveConfig("dll"))
        project->values("QMAKE_LFLAGS") += project->values("QMAKE_LFLAGS_PREBIND");
    if(!project->isEmpty("QMAKE_INCDIR"))
        project->values("INCLUDEPATH") += project->values("QMAKE_INCDIR");
    ProStringList ldadd;
    if(!project->isEmpty("QMAKE_LIBDIR")) {
        const ProStringList &libdirs = project->values("QMAKE_LIBDIR");
        for(int i = 0; i < libdirs.size(); ++i) {
            if(!project->isEmpty("QMAKE_LFLAGS_RPATH") && project->isActiveConfig("rpath_libdirs"))
                project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + libdirs[i];
            project->values("QMAKE_LIBDIR_FLAGS") += "-L" + escapeFilePath(libdirs[i]);
        }
    }
    ldadd += project->values("QMAKE_LIBDIR_FLAGS");
    if (project->isActiveConfig("mac")) {
        if (!project->isEmpty("QMAKE_FRAMEWORKPATH")) {
            const ProStringList &fwdirs = project->values("QMAKE_FRAMEWORKPATH");
            for (int i = 0; i < fwdirs.size(); ++i)
                project->values("QMAKE_FRAMEWORKPATH_FLAGS") += "-F" + escapeFilePath(fwdirs[i]);
        }
        ldadd += project->values("QMAKE_FRAMEWORKPATH_FLAGS");
    }
    ProStringList &qmklibs = project->values("QMAKE_LIBS");
    qmklibs = ldadd + qmklibs;
    if (!project->isEmpty("QMAKE_RPATHDIR") && !project->isEmpty("QMAKE_LFLAGS_RPATH")) {
        const ProStringList &rpathdirs = project->values("QMAKE_RPATHDIR");
        for (int i = 0; i < rpathdirs.size(); ++i) {
            QString rpathdir = rpathdirs[i].toQString();
            if (rpathdir.length() > 1 && rpathdir.at(0) == '$' && rpathdir.at(1) != '(') {
                rpathdir.replace(0, 1, "\\$$");  // Escape from make and the shell
            } else if (!rpathdir.startsWith('@') && fileInfo(rpathdir).isRelative()) {
                QString rpathbase = project->first("QMAKE_REL_RPATH_BASE").toQString();
                if (rpathbase.isEmpty()) {
                    fprintf(stderr, "Error: This platform does not support relative paths in QMAKE_RPATHDIR (%s)\n",
                                    rpathdir.toLatin1().constData());
                    continue;
                }
                if (rpathbase.startsWith('$'))
                    rpathbase.replace(0, 1, "\\$$");  // Escape from make and the shell
                if (rpathdir == ".")
                    rpathdir = rpathbase;
                else
                    rpathdir.prepend(rpathbase + '/');
                project->values("QMAKE_LFLAGS").insertUnique(project->values("QMAKE_LFLAGS_REL_RPATH"));
            }
            project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + escapeFilePath(rpathdir);
        }
    }
    if (!project->isEmpty("QMAKE_RPATHLINKDIR")) {
        const ProStringList &rpathdirs = project->values("QMAKE_RPATHLINKDIR");
        for (int i = 0; i < rpathdirs.size(); ++i) {
            if (!project->isEmpty("QMAKE_LFLAGS_RPATHLINK"))
                project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATHLINK") + escapeFilePath(QFileInfo(rpathdirs[i].toQString()).absoluteFilePath());
        }
    }

    if(project->isActiveConfig("GNUmake") && !project->isEmpty("QMAKE_CFLAGS_DEPS"))
        include_deps = true; //do not generate deps

    MakefileGenerator::init();

    if (project->isActiveConfig("objective_c"))
        project->values("QMAKE_BUILTIN_COMPILERS") << "OBJC" << "OBJCXX";

    foreach (const ProString &compiler, project->values("QMAKE_BUILTIN_COMPILERS")) {
        QString compile_flag = var("QMAKE_COMPILE_FLAG");
        if(compile_flag.isEmpty())
            compile_flag = "-c";

        if(doPrecompiledHeaders() && !project->isEmpty("PRECOMPILED_HEADER")) {
            QString pchFlags = var(ProKey("QMAKE_" + compiler + "FLAGS_USE_PRECOMPILE"));

            QString pchBaseName;
            if(!project->isEmpty("PRECOMPILED_DIR")) {
                pchBaseName = Option::fixPathToTargetOS(project->first("PRECOMPILED_DIR").toQString());
                if(!pchBaseName.endsWith(Option::dir_sep))
                    pchBaseName += Option::dir_sep;
            }
            pchBaseName += project->first("QMAKE_ORIG_TARGET").toQString();

            // replace place holders
            pchFlags.replace(QLatin1String("${QMAKE_PCH_INPUT}"),
                             escapeFilePath(project->first("PRECOMPILED_HEADER").toQString()));
            pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT_BASE}"), escapeFilePath(pchBaseName));
            if (project->isActiveConfig("icc_pch_style")) {
                // icc style
                pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT}"),
                                 escapeFilePath(pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT")));
            } else {
                // gcc style (including clang_pch_style)
                QString headerSuffix;
                if (project->isActiveConfig("clang_pch_style"))
                    headerSuffix = project->first("QMAKE_PCH_OUTPUT_EXT").toQString();
                else
                    pchBaseName += project->first("QMAKE_PCH_OUTPUT_EXT").toQString();

                pchBaseName += Option::dir_sep;

                ProString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler));
                if (!language.isEmpty()) {
                    pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT}"),
                                     escapeFilePath(pchBaseName + language + headerSuffix));
                }
            }

            if (!pchFlags.isEmpty())
                compile_flag += " " + pchFlags;
        }

        QString compilerExecutable;
        if (compiler == "C" || compiler == "OBJC") {
            compilerExecutable = "$(CC)";
            compile_flag += " $(CFLAGS)";
        } else {
            compilerExecutable = "$(CXX)";
            compile_flag += " $(CXXFLAGS)";
        }

        compile_flag += " $(INCPATH)";

        ProString compilerVariable = compiler;
        if (compilerVariable == "C")
            compilerVariable = ProString("CC");

        const ProKey runComp("QMAKE_RUN_" + compilerVariable);
        if(project->isEmpty(runComp))
            project->values(runComp).append(compilerExecutable + " " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "$obj $src");
        const ProKey runCompImp("QMAKE_RUN_" + compilerVariable + "_IMP");
        if(project->isEmpty(runCompImp))
            project->values(runCompImp).append(compilerExecutable + " " + compile_flag + " " + var("QMAKE_CC_O_FLAG") + "\"$@\" \"$<\"");
    }

    if (project->isActiveConfig("mac") && !project->isEmpty("TARGET") &&
       ((project->isActiveConfig("build_pass") || project->isEmpty("BUILDS")))) {
        ProString bundle;
        if(project->isActiveConfig("bundle") && !project->isEmpty("QMAKE_BUNDLE_EXTENSION")) {
            bundle = project->first("TARGET");
            if(!project->isEmpty("QMAKE_BUNDLE_NAME"))
                bundle = project->first("QMAKE_BUNDLE_NAME");
            if(!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
                bundle += project->first("QMAKE_BUNDLE_EXTENSION");
        } else if(project->first("TEMPLATE") == "app" && project->isActiveConfig("app_bundle")) {
            bundle = project->first("TARGET");
            if(!project->isEmpty("QMAKE_APPLICATION_BUNDLE_NAME"))
                bundle = project->first("QMAKE_APPLICATION_BUNDLE_NAME");
            if(!bundle.endsWith(".app"))
                bundle += ".app";
            if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
                project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
            project->values("QMAKE_PKGINFO").append(project->first("DESTDIR") + bundle + "/Contents/PkgInfo");
            project->values("QMAKE_BUNDLE_RESOURCE_FILE").append(project->first("DESTDIR") + bundle + "/Contents/Resources/empty.lproj");
        } else if(project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") &&
                  ((!project->isActiveConfig("plugin") && project->isActiveConfig("lib_bundle")) ||
                   (project->isActiveConfig("plugin") && project->isActiveConfig("plugin_bundle")))) {
            bundle = project->first("TARGET");
            if(project->isActiveConfig("plugin")) {
                if(!project->isEmpty("QMAKE_PLUGIN_BUNDLE_NAME"))
                    bundle = project->first("QMAKE_PLUGIN_BUNDLE_NAME");
                if (project->isEmpty("QMAKE_BUNDLE_EXTENSION"))
                    project->values("QMAKE_BUNDLE_EXTENSION").append(".plugin");
                if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
                    bundle += project->first("QMAKE_BUNDLE_EXTENSION");
                if(project->isEmpty("QMAKE_BUNDLE_LOCATION"))
                    project->values("QMAKE_BUNDLE_LOCATION").append("Contents/MacOS");
            } else {
                if(!project->isEmpty("QMAKE_FRAMEWORK_BUNDLE_NAME"))
                    bundle = project->first("QMAKE_FRAMEWORK_BUNDLE_NAME");
                if (project->isEmpty("QMAKE_BUNDLE_EXTENSION"))
                    project->values("QMAKE_BUNDLE_EXTENSION").append(".framework");
                if (!bundle.endsWith(project->first("QMAKE_BUNDLE_EXTENSION")))
                    bundle += project->first("QMAKE_BUNDLE_EXTENSION");
            }
        }
        if(!bundle.isEmpty()) {
            project->values("QMAKE_BUNDLE") = ProStringList(bundle);
        } else {
            project->values("QMAKE_BUNDLE").clear();
            project->values("QMAKE_BUNDLE_LOCATION").clear();
        }
    } else { //no bundling here
        project->values("QMAKE_BUNDLE").clear();
        project->values("QMAKE_BUNDLE_LOCATION").clear();
    }

    init2();
    project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_LIBS";
    ProString target = project->first("TARGET");
    int slsh = target.lastIndexOf(Option::dir_sep);
    if (slsh != -1)
        target.chopFront(slsh + 1);
    project->values("LIB_TARGET").prepend(target);
    if(!project->isEmpty("QMAKE_MAX_FILES_PER_AR")) {
        bool ok;
        int max_files = project->first("QMAKE_MAX_FILES_PER_AR").toInt(&ok);
        ProStringList ar_sublibs, objs = project->values("OBJECTS");
        if(ok && max_files > 5 && max_files < (int)objs.count()) {
            QString lib;
            for(int i = 0, obj_cnt = 0, lib_cnt = 0; i != objs.size(); ++i) {
                if((++obj_cnt) >= max_files) {
                    if(lib_cnt) {
                        lib.sprintf("lib%s-tmp%d.a",
                                    project->first("QMAKE_ORIG_TARGET").toLatin1().constData(), lib_cnt);
                        ar_sublibs << lib;
                        obj_cnt = 0;
                    }
                    lib_cnt++;
                }
            }
        }
        if(!ar_sublibs.isEmpty()) {
            project->values("QMAKE_AR_SUBLIBS") = ar_sublibs;
            project->values("QMAKE_INTERNAL_PRL_LIBS") << "QMAKE_AR_SUBLIBS";
        }
    }
}
Example #16
0
void EventLabel::mousePressEvent(QMouseEvent *e){
	QString msg;
	msg.sprintf("(%d,%d)",e->x(),e->y());
	this->setText(msg);
	setMouseTracking(true); //打開滑鼠追蹤,這樣mouseMoveEvent才能在不用按滑鼠時,就有作用
}
HealpixSource::HealpixSource(KConfig *cfg, const QString& filename, const QString& type, const QDomElement& e) : KstDataSource(cfg, filename, type) {
  int ret;
  size_t poff;
   
  _valid = false;
  if (type.isEmpty( ) || type == "HEALPIX") {
    strncpy(_healpixfile, filename.latin1(), HEALPIX_STRNL);
    
    _names = healpix_strarr_alloc(HEALPIX_FITS_MAXCOL);
    _units = healpix_strarr_alloc(HEALPIX_FITS_MAXCOL);
    _keys = healpix_keys_alloc();
    
    ret = healpix_fits_map_info(_healpixfile, &_mapNside, &_mapOrder, &_mapCoord, &_mapType, &_nMaps, _creator, _extname, _names, _units, _keys);
    
    if (_mapType == HEALPIX_FITS_CUT) {
      poff = 1;
    } else {
      poff = 0;
    }
    if (ret) {
      _valid = true;
      _mapNpix = 12 * _mapNside * _mapNside;
      _nX = 800;
      _nY = 600;
      _autoTheta = true;
      _autoPhi = true;
      //FIXME switch to radians default later
      _thetaUnits = HPUNIT_RADEC;
      _phiUnits = HPUNIT_RADEC;
      _vecUnits = HPUNIT_RADEC;
      _autoMag = true;
      _vecDegrade = 0;
      _vecTheta = 0;
      _vecPhi = 0;
      _vecQU = false;
      loadConfig(cfg);
      if (!e.isNull()) {
        load(e);
      }
      
      // populate the metadata
      QString metaVal;
      QString metaName;
      metaVal.sprintf("%lu", (long unsigned int)_mapNside);
      _metaData["NSIDE"] = metaVal;
      metaVal.sprintf("%lu", (long unsigned int)_mapNpix);
      _metaData["NPIX"] = metaVal;
      metaVal.sprintf("%d", _mapOrder);
      _metaData["ORDER"] = metaVal;
      metaVal.sprintf("%d", _mapCoord);
      _metaData["COORD"] = metaVal;
      metaVal.sprintf("%d", _mapType);
      _metaData["TYPE"] = metaVal;
      metaVal.sprintf("%lu", (long unsigned int)_nMaps);
      _metaData["NMAPS"] = metaVal;
      metaVal.sprintf("%s", _creator);
      _metaData["CREATOR"] = metaVal;
      metaVal.sprintf("%s", _extname);
      _metaData["EXTNAME"] = metaVal;
      for (size_t j = 0; j < _keys->nskeys; j++) {
        metaName.sprintf("%s", _keys->skeynames[j]);
        metaVal.sprintf("%s", _keys->skeyvals[j]);
        _metaData[metaName] = metaVal;
      }
      for (size_t j = 0; j < _keys->nikeys; j++) {
        metaName.sprintf("%s", _keys->ikeynames[j]);
        metaVal.sprintf("%d", _keys->ikeyvals[j]);
        _metaData[metaName] = metaVal;
      }
      for (size_t j = 0; j < _keys->nfkeys; j++) {
        metaName.sprintf("%s", _keys->fkeynames[j]);
        metaVal.sprintf("%e", _keys->fkeyvals[j]);
        _metaData[metaName] = metaVal;
      }
      
      // populate the field list
      QString mapName;
      for (size_t i = 0; i < _nMaps; i++) {
        if (strlen(_names[i+poff]) == 0) {
          mapName.sprintf("%d - %s",(int)(i+1),"MAP");
        } else {
          mapName.sprintf("%d - %s",(int)(i+1),_names[i+poff]);
        }
        if (strlen(_units[i+poff]) == 0) {
          mapName.sprintf("%s (%s)",mapName.ascii(),"Unknown Units");
        } else {
          mapName.sprintf("%s (%s)",mapName.ascii(),_units[i+poff]);
        }
        _matrixList.append(mapName);
      }
      if (_mapType == HEALPIX_FITS_CUT) {
        if (strlen(_names[_nMaps+1]) == 0) {
          mapName.sprintf("%s","HITS");
        } else {
          mapName.sprintf("%s",_names[_nMaps+1]);
        }
        _matrixList.append(mapName);
        if (strlen(_names[_nMaps+2]) == 0) {
          mapName.sprintf("%s","ERRORS");
        } else {
          mapName.sprintf("%s",_names[_nMaps+2]);
        }
        if (strlen(_units[_nMaps+2]) == 0) {
          mapName.sprintf("%s (%s)",mapName.ascii(),"Unknown Units");
        } else {
          mapName.sprintf("%s (%s)",mapName.ascii(),_units[_nMaps+2]);
        }
        _matrixList.append(mapName);
      }
      _fieldList.append("1 - Vector Field Head Theta");
      _fieldList.append("2 - Vector Field Head Phi");
      _fieldList.append("3 - Vector Field Tail Theta");
      _fieldList.append("4 - Vector Field Tail Phi");
    } else {
      healpix_keys_free(_keys);
      healpix_strarr_free(_names, HEALPIX_FITS_MAXCOL);
      healpix_strarr_free(_units, HEALPIX_FITS_MAXCOL);
    }
  }
}
Example #18
0
void EventLabel::mouseMoveEvent(QMouseEvent *e){
	QString msg;
	msg.sprintf("(%d,%d)",e->x(),e->y());
	this->setText(msg);
}
Example #19
0
/*
    Format a variant value as a string representation of time.
    This method was written to convert a QVariant of type ??? (the type used to represent times in CA),
    but should cope with a variant of any type.
*/
void QEStringFormatting::formatFromTime( const QVariant &value ) {
    bool okay;
    double seconds;
    double time;
    QString sign;
    int days;
    int hours;
    int mins;
    int secs;
    int nanoSecs;
    QString image;
    int effectivePrecision;
    QString fraction;


    if( value.type() == QVariant::String )
        stream << value.toString();
    else {
        seconds = value.toDouble( &okay );
        if (okay) {
           if (seconds >= 0.0) {
              time = seconds;
              sign= "";
           } else {
              time = -seconds;
              sign= "-";
           }

           #define EXTRACT(item, spi) { item = int (floor (time / spi)); time = time - (spi * item); }

           EXTRACT (days, 86400.0);
           EXTRACT (hours, 3600.0);
           EXTRACT (mins, 60.0);
           EXTRACT (secs, 1.0);
           EXTRACT (nanoSecs, 1.0E-9);

           #undef EXTRACT

           // Include days field if rquired or if requested.
           //
           if ((days > 0) || leadingZero) {
              image.sprintf ("%d %02d:%02d:%02d", days, hours, mins, secs);
           } else {
              image.sprintf ("%02d:%02d:%02d", hours, mins, secs);
           }

           // Select data base or user precision as appropriate.
           //
           effectivePrecision = useDbPrecision ? dbPrecision : precision;
           if (effectivePrecision > 9) effectivePrecision = 9;

           if (effectivePrecision > 0) {
              fraction.sprintf (".%09d", nanoSecs);
              fraction.truncate( effectivePrecision + 1 );
           } else {
              fraction = "";
           }

           stream << sign << image << fraction;

        } else {
            stream << QString( "not a valid numeric" );
        }
    }
}
Example #20
0
void BcBloqueaFechaView::inicializa()
{
    BL_FUNC_DEBUG
    BcTreeWidgetItem *itemlevel0;
    BcTreeWidgetItem *itemlevel1 = 0;

    QString consultabd;
    mui_treeWidget->setColumnCount ( 2 );
    QStringList cabecera;
    cabecera << _ ( "Ejercicio" ) << _ ( "Estado" );
    mui_treeWidget->setColumnWidth ( 0, 200 );
    mui_treeWidget->setHeaderLabels ( cabecera );

    mui_treeWidget->clear();
    mui_treeWidget->setSortingEnabled ( FALSE );

    /// Consultamos a la base de datos.
    consultabd.sprintf ( "SELECT * FROM ejercicios WHERE periodo = 0 ORDER BY ejercicio DESC" );
    BlDbRecordSet *curPeri, *curEjer = mainCompany() ->loadQuery ( consultabd );

    while ( !curEjer->eof() ) {

        itemlevel0 = new BcTreeWidgetItem ( mui_treeWidget );
        itemlevel0->setText ( 0, curEjer->value( "ejercicio" ) ); /// Columna 0.

        if ( curEjer->value( "bloqueado" ) == "t" ) {
            itemlevel0->setText ( 1, qsbloqueado );
        } else {
            itemlevel0->setText ( 1, qsabierto );
        } // end if

        itemlevel0->ej = curEjer->value( "ejercicio" );
        itemlevel0->per = curEjer->value( "periodo" );


        consultabd.sprintf ( "SELECT * FROM ejercicios WHERE ejercicio = '%s' ORDER BY periodo DESC", curEjer->value( "ejercicio" ).toAscii().constData() );
        curPeri = mainCompany() ->loadQuery ( consultabd );
        while ( !curPeri->eof() ) {
            switch ( curPeri->value( "periodo" ).toInt() ) {
            case 12:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Diciembre" ) ); /// Columna 0.
                break;
            case 11:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Noviembre" ) ); /// Columna 0.
                break;
            case 10:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Octubre" ) ); /// Columna 0.
                break;
            case 9:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Septiembre" ) ); /// Columna 0.
                break;
            case 8:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Agosto" ) ); /// Columna 0.
                break;
            case 7:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Julio" ) ); /// Columna 0.
                break;
            case 6:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Junio" ) ); /// Columna 0.
                break;
            case 5:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Mayo" ) ); /// Columna 0.
                break;
            case 4:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Abril" ) ); /// Columna 0.
                break;
            case 3:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Marzo" ) ); /// Columna 0.
                break;
            case 2:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Febrero" ) ); /// Columna 0.
                break;
            case 1:
                itemlevel1 = new BcTreeWidgetItem ( itemlevel0 );
                itemlevel1->setText ( 0, _ ( "Enero" ) ); /// Columna 0.
                break;
            } // end switch
            itemlevel1->ej = curEjer->value( "ejercicio" );
            itemlevel1->per = curPeri->value( "periodo" );
            curPeri->value( "bloqueado" ) == "t" ? itemlevel1->setText ( 1, qsbloqueado ) : itemlevel1->setText ( 1, qsabierto );
            curPeri->nextRecord();
        } // end while
        curEjer->nextRecord();
    } // end while

    
}
QString QTime::toString() const
{
    QString buf;
    buf.sprintf( "%.2d:%.2d:%.2d", hour(), minute(), second() );
    return buf;
}
Example #22
0
void Spectrum::paintEvent(QPaintEvent*) {
    QPainter painter(this);
    int filterLeft;
    int filterRight;
    QString text;

    QLinearGradient gradient(0, 0, 0,height());
    gradient.setColorAt(0, Qt::black);
    gradient.setColorAt(1, Qt::gray);
    painter.setBrush(gradient);
    painter.drawRect(0, 0, width(), height());

    if(sampleRate==0) {
        qDebug() << "sampleRate is 0";
        return;
    }

    // draw filter
    filterLeft = (filterLow - (-sampleRate / 2)) * width() / sampleRate;
    filterRight = (filterHigh - (-sampleRate / 2)) * width() / sampleRate;
    painter.setBrush(Qt::SolidPattern);
    painter.setOpacity(0.5);
    painter.fillRect(filterLeft,0,filterRight-filterLeft,height(),Qt::gray);

    // draw sub rx filter and cursor
    if(subRx) {
        int cursor=(subRxFrequency-(frequency-(sampleRate/2))) * width() / sampleRate;
        filterLeft = (filterLow - (-sampleRate / 2) + (subRxFrequency-frequency)) * width() / sampleRate;
        filterRight = (filterHigh - (-sampleRate / 2) + (subRxFrequency-frequency)) * width() / sampleRate;
        painter.setBrush(Qt::SolidPattern);
        painter.setOpacity(0.5);
        painter.fillRect(filterLeft, 0, filterRight - filterLeft, height(), Qt::lightGray);

        painter.setPen(QPen(Qt::red, 1));
        painter.drawLine(cursor,0,cursor,height());
    }

    // plot horizontal dBm lines
    int V = spectrumHigh - spectrumLow;
    int numSteps = V / 20;
    for (int i = 1; i < numSteps; i++) {
        int num = spectrumHigh - i * 20;
        int y = (int) floor((spectrumHigh - num) * height() / V);

        painter.setOpacity(0.5);
        painter.setPen(QPen(Qt::white, 1,Qt::DotLine));
        painter.drawLine(0, y, width(), y);

        painter.setOpacity(1.0);
        painter.setPen(QPen(Qt::green, 1));
        painter.setFont(QFont("Arial", 10));
        painter.drawText(3,y,QString::number(num)+" dBm");
    }
    
    // plot the vertical frequency lines
    float hzPerPixel=(float)sampleRate/(float)width();
    long long f=frequency-(sampleRate/2);

    for(int i=0;i<width();i++) {
        f=frequency-(sampleRate/2)+(long long)(hzPerPixel*(float)i);
        if(f>0) {
            if((f%10000)<(long long)hzPerPixel) {
                painter.setOpacity(0.5);
                painter.setPen(QPen(Qt::white, 1,Qt::DotLine));
                painter.drawLine(i, 0, i, height());

                painter.setOpacity(1.0);
                painter.setPen(QPen(Qt::black, 1));
                painter.setFont(QFont("Arial", 10));
                text.sprintf("%lld.%02lld",f/1000000,f%1000000/10000);
                painter.drawText(i,height(),text);
            }
        }
    }

    // draw the band limits
    long long min_display=frequency-(sampleRate/2);
    long long max_display=frequency+(sampleRate/2);
    if(band_min!=0LL && band_max!=0LL) {
        int i;
        painter.setPen(QPen(Qt::red, 2));
        if((min_display<band_min)&&(max_display>band_min)) {
            i=(band_min-min_display)/(long long)hzPerPixel;
            painter.drawLine(i,0,i,height());
        }
        if((min_display<band_max)&&(max_display>band_max)) {
            i=(band_max-min_display)/(long long)hzPerPixel;
            painter.drawLine(i+1,0,i+1,height());
        }
    }

    // draw cursor
    painter.setPen(QPen(Qt::red, 1));
    painter.drawLine(width()/2,0,width()/2,height());

    // show the frequency
    painter.setPen(QPen(Qt::green,1));
    painter.setFont(QFont("Verdana", 30));
    painter.drawText(width()/2,30,strFrequency);

    // show the band and mode and filter
    painter.setFont(QFont("Arial", 12));
    text=band+" "+mode+" "+filter+"Hz";
    painter.drawText((width()/2),50,text);

    // show the server and receiver
    text="Server:"+host+" Rx:"+QString::number(receiver);
    painter.drawText(5,15,text);

    // draw the analog meters
//    painter.setOpacity(0.8);
//    QImage image=sMeterMain->getImage(meter);
//    painter.drawImage(width()-image.width()-5,0,image);
    emit meterValue(meter, subrx_meter);

//    qDebug() << "Spectrum meter value = " << meter;
    if(subRx) {
//        image=sMeterSub->getImage(subrx_meter);
//        painter.drawImage(width()-image.width()-5,image.height()+5,image);
//        emit meterValue(subrx_meter);
    }


    // plot Spectrum
    painter.setOpacity(0.9);
    painter.setPen(QPen(Qt::yellow, 1));
    if(plot.count()==width()) {
        painter.drawPolyline(plot.constData(),plot.count());
    }


    // show the subrx frequency
    if(subRx) {
        /*
        filterRight = (filterHigh - (-sampleRate / 2) + (subRxFrequency-frequency)) * width() / sampleRate;
        painter.setPen(QPen(Qt::black,1));
        painter.setFont(QFont("Arial", 12));
        painter.drawText(filterRight,height()-20,strSubRxFrequency);
        */
        // show the frequency
        painter.setPen(QPen(Qt::green,1));
        painter.setFont(QFont("Verdana", 30));
//        painter.drawText(width()/2,image.height()+5+30,strSubRxFrequency);
    }
}
Example #23
0
void TGLFunWidget::paintScale(void)
{
    QRect rc = rect();
    QFont glFont("Courier", 12, QFont::Normal);
    QFontMetrics fm(glFont);
    QString val;
    int num = 8,
        fontW1 = fm.width("12"),
        fontW2 = fm.width("1234567890"),
        fontH = fm.height(),
        i;
    Float minU = 0,
          maxU = 0,
          v_start,
          v_stop,
          v_step,
          v,
          cy;

    if (!(mesh && mesh->getFEType() != NOTYPE) || rc.height() < 9*fontH)
        return;

    minU = *min_element((*results)[funIndex].getResults().begin(),(*results)[funIndex].getResults().end());;
    maxU = *max_element((*results)[funIndex].getResults().begin(),(*results)[funIndex].getResults().end());;
    v_start = maxU;
    v_stop  = minU;
    v_step  = (maxU - minU)/(num - 1);
    cy      = rc.top() + 20;

    v = v_start;
    if (minU == maxU)
    {
        i = getColorIndex(v);
        glColor3f(colorTable[i].red(),colorTable[i].green(),colorTable[i].blue());
        glFont.setStyleStrategy(QFont::OpenGLCompatible);
        renderText(rc.width() - fontW1 - fontW2 - 10,cy,"█",glFont);
        glColor3f(1.0 - float(params.bkgColor.red())/255.0,1.0 - float(params.bkgColor.green())/255.0,1.0 - float(params.bkgColor.blue())/255.0);
        //        renderText(rc.width() - fontW2 - 10,cy,QString("%1").arg(v,5,'e',3),glFont);
        renderText(rc.width() - fontW2 - 10,cy,val.sprintf("%+5.3E",colorTable[i].value()),glFont);
        return;
    }



    for (int k = 0; k < 8; k++)
    {
        if (k == 7)
            v = v_stop;

        i = getColorIndex(v);
        glColor3f(colorTable[i].red(),colorTable[i].green(),colorTable[i].blue());
        glFont.setStyleStrategy(QFont::OpenGLCompatible);
        renderText(rc.width() - fontW1 - fontW2 - 10,cy,"█",glFont);
        glColor3f(1.0 - float(params.bkgColor.red())/255.0,1.0 - float(params.bkgColor.green())/255.0,1.0 - float(params.bkgColor.blue())/255.0);
//        glColor3f(0,0,0);
        renderText(rc.width() - fontW2 - 10,cy,val.sprintf("%+5.3E",v),glFont);

        cy += fontH;
        v -= v_step;
    }
}
Example #24
0
static QString formatTime(char n)
{
    QString res;
    res.sprintf("%+i:%02u", -n/2, (n & 1) * 30);
    return res;
}
Example #25
0
/**
 * Creates a DOM document of this project and returns it.
 *
 * @param onlyselected If TRUE, only selected objects are used, otherwise the whole project
 *     is used
 * @param obj If != NULL, only @a obj is used from the project
 * @returns The DOM document
 */
QDomDocument Project::getDomDocument(bool onlyselected/*=FALSE*/, GObject* obj/*=NULL*/)
{
    Machine* m = machine;
    m->correctCodes();
    QString prolog="<?xml version=\"1.0\"?>\n"
      		   "<!DOCTYPE qfsmproject SYSTEM \"qfsm.dtd\">\n\n"
                   "<qfsmproject>\n"
                   "</qfsmproject>\n";


    QDomDocument domdoc;
    QDomElement root, me, one, ine, onme, itranse;
    QDomText ontext, intext, onmtext;
    QString stmp;
    int inits;
    GState* s;
    GITransition* initt;
    GTransition* t;
    QList<GState*> slist;
    QList<GTransition*> tlist; 
    double xpos, ypos, endx, endy, c1x, c1y, c2x, c2y;
    AppInfo appinfo(qApp->mainWidget());

    domdoc.setContent(prolog);

    if (!m)
      return domdoc;

    root = domdoc.documentElement();

    // Machine

    root.setAttribute("author", "Qfsm");
    root.setAttribute("version", appinfo.getVersion());
    me = domdoc.createElement("machine");
    me.setAttribute("name", m->getName());
    me.setAttribute("version", m->getVersion());
    me.setAttribute("author", m->getAuthor());
    me.setAttribute("description", m->getDescription());
    me.setAttribute("type", m->getType());
    me.setAttribute("nummooreout", m->getNumMooreOutputs());
    me.setAttribute("numbits", m->getNumEncodingBits());
    me.setAttribute("numin", m->getNumInputs());
    me.setAttribute("numout", m->getNumOutputs());
    s = m->getInitialState();
    if (s)
    {
      inits = s->getEncoding();
      me.setAttribute("initialstate", inits);
    }
    me.setAttribute("statefont", m->getSFont().family());
    me.setAttribute("statefontsize", m->getSFont().pointSize());
    me.setAttribute("statefontweight", m->getSFont().weight());
    me.setAttribute("statefontitalic", m->getSFont().italic());
    me.setAttribute("transfont", m->getTFont().family());
    me.setAttribute("transfontsize", m->getTFont().pointSize());
    me.setAttribute("transfontweight", m->getTFont().weight());
    me.setAttribute("transfontitalic", m->getTFont().italic());
    me.setAttribute("arrowtype", m->getArrowType());
    me.setAttribute("draw_it", m->getDrawITrans());
    
    root.appendChild(me);


    // Input/Output names

    onme = domdoc.createElement("outputnames_moore");
    ine = domdoc.createElement("inputnames");
    one = domdoc.createElement("outputnames");
    intext = domdoc.createTextNode(m->getMealyInputNames());
    ontext = domdoc.createTextNode(m->getMealyOutputNames());
    onmtext = domdoc.createTextNode(m->getMooreOutputNames());
    ine.appendChild(intext);
    one.appendChild(ontext);
    onme.appendChild(onmtext);
    me.appendChild(onme);
    me.appendChild(ine);
    me.appendChild(one);


    // Initial Transition

    initt = m->getInitialTransition();
    if (initt)
    {
      initt->getPos(xpos, ypos);
      initt->getEndPos(endx, endy);
      itranse = domdoc.createElement("itransition");
      itranse.setAttribute("xpos", xpos);
      itranse.setAttribute("ypos", ypos);
      itranse.setAttribute("endx", endx);
      itranse.setAttribute("endy", endy);

      me.appendChild(itranse);
    }


    // States
    
    slist = m->getSList();
    QListIterator<GState*> sit(slist);

    for(;sit.hasNext();)
    {
      s = sit.next();
      if (!s->isDeleted() && (!onlyselected || s->isSelected() || (s==obj && s!=NULL)))
      {
	s->getPos(xpos, ypos);
	QDomElement se = domdoc.createElement("state");
	QDomText st = domdoc.createTextNode(s->getStateName());
	
	se.setAttribute("description", s->getDescription());
	se.setAttribute("code", s->getEncoding());
	se.setAttribute("moore_outputs", s->getMooreOutputsStr());
	se.setAttribute("xpos", xpos);
	se.setAttribute("ypos", ypos);
	se.setAttribute("radius", s->getRadius());
	se.setAttribute("pencolor", s->getColor().rgb() & 0xffffff);
	se.setAttribute("linewidth", s->getLineWidth());
	se.setAttribute("finalstate", s->isFinalState());
	se.setAttribute("entry_actions", s->getEntryActions());
	se.setAttribute("exit_actions", s->getExitActions());

	se.appendChild(st);

	me.appendChild(se);
      }
    }


    // Transitions

    sit.toFront();
    for(; sit.hasNext();)
    {
      s = sit.next();
      QListIterator<GTransition*> tit(s->tlist);
      GState *send;

      for(;tit.hasNext();)
      {
        t = tit.next();
        if (!t->isDeleted() && (!onlyselected || t->isSelected() || (t==obj && t!=NULL)))
        {
          t->getPos(xpos, ypos);
          t->getEndPos(endx, endy);
          t->getCPoint1(c1x, c1y);
          t->getCPoint2(c2x, c2y);
          QDomElement te = domdoc.createElement("transition");
	  
            te.setAttribute("type", t->getInfo()->getType());
            te.setAttribute("xpos", xpos);
            te.setAttribute("ypos", ypos);
            te.setAttribute("endx", endx);
            te.setAttribute("endy", endy);
            te.setAttribute("c1x", c1x);
            te.setAttribute("c1y", c1y);
            te.setAttribute("c2x", c2x);
            te.setAttribute("c2y", c2y);
            te.setAttribute("straight", t->isStraight());
            te.setAttribute("description", t->getDescription());
            
            send = (GState*)t->getEnd();
            
            if (!onlyselected || s->isSelected())
            {
            QDomElement from = domdoc.createElement("from");
            QString sfrom;
            sfrom.sprintf("%d", s->getEncoding());
            QDomText fromt = domdoc.createTextNode(sfrom);
            from.appendChild(fromt);
            te.appendChild(from);
            }
            
            if (send && (!onlyselected || send->isSelected()))
            {
            QDomElement to = domdoc.createElement("to");
            QString sto;
            sto.sprintf("%d", send->getEncoding());
            QDomText tot = domdoc.createTextNode(sto);
            to.appendChild(tot);
            te.appendChild(to);
            }

	  QDomElement inpute, outpute;
	  QDomText inputt, outputt;

	  inpute = domdoc.createElement("inputs");
	  inpute.setAttribute("invert", t->getInfo()->getInputInfo()->isInverted());
	  inpute.setAttribute("any", t->getInfo()->getInputInfo()->getAnyInput());
	  inpute.setAttribute("default", t->getInfo()->getInputInfo()->isDefault());
	  outpute = domdoc.createElement("outputs");

	  inputt = domdoc.createTextNode(t->getInfo()->getInputsStr(NULL));
	  outputt = domdoc.createTextNode(t->getInfo()->getOutputsStr(NULL));

	  inpute.appendChild(inputt);
	  outpute.appendChild(outputt);

	  te.appendChild(inpute);
	  te.appendChild(outpute);

	  me.appendChild(te);
	}
      }
    }


    // Phantom State

    s = m->getPhantomState();
    QListIterator<GTransition*> tit(s->tlist);
    GState *send;

    for(;tit.hasNext();)
    {
      t = tit.next();
      if (!t->isDeleted() && (!onlyselected || t->isSelected() || (t==obj && t!=NULL)))
      {
	t->getPos(xpos, ypos);
	t->getEndPos(endx, endy);
	t->getCPoint1(c1x, c1y);
	t->getCPoint2(c2x, c2y);
	QDomElement te = domdoc.createElement("transition");
	
	te.setAttribute("type", t->getInfo()->getType());
	te.setAttribute("xpos", xpos);
	te.setAttribute("ypos", ypos);
	te.setAttribute("endx", endx);
	te.setAttribute("endy", endy);
	te.setAttribute("c1x", c1x);
	te.setAttribute("c1y", c1y);
	te.setAttribute("c2x", c2x);
	te.setAttribute("c2y", c2y);
	te.setAttribute("straight", t->isStraight());

	send = (GState*)t->getEnd();
	if (send && (!onlyselected || send->isSelected()))
	{
	  QDomElement to = domdoc.createElement("to");
	  QString sto;
	  sto.sprintf("%d", send->getEncoding());
	  QDomText tot = domdoc.createTextNode(sto);
	  to.appendChild(tot);
	  te.appendChild(to);
	}

	QDomElement inpute, outpute;
	QDomText inputt, outputt;

	inpute = domdoc.createElement("inputs");
	outpute = domdoc.createElement("outputs");

	inputt = domdoc.createTextNode(t->getInfo()->getInputsStr(NULL));
	outputt = domdoc.createTextNode(t->getInfo()->getOutputsStr(NULL));

	inpute.appendChild(inputt);
	outpute.appendChild(outputt);

	te.appendChild(inpute);
	te.appendChild(outpute);

	me.appendChild(te);
      }
    }

  return domdoc;
}
Example #26
0
QString RenameImagesWidget::oldToNewName(BatchProcessImagesItem* item, int itemPosition)
{
    KUrl url;
    url.setPath(item->pathSrc());

    QFileInfo fi(item->pathSrc());

    KIPI::ImageInfo info = m_interface->info(url);

    bool useExtraSymbols = ui->m_addFileDateCheck->isChecked() &&
                           ui->m_useExtraSymbolsCheck->isChecked();

    QString newName = ui->m_prefixEdit->text();

    if (ui->m_addFileNameCheck->isChecked())
    {
        newName += fi.baseName();
        newName += '_';
    }

    int seqNumber = itemPosition + ui->m_seqSpin->value();
    if (ui->m_addFileDateCheck->isChecked())
    {
        QString format = ui->m_formatDateEdit->text();
        format         = format.simplified();
        if (useExtraSymbols)
        {
            QRegExp rxI("\\[i(:(\\d+))?\\]");
            QRegExp rxN("\\[([anbBeEp])([-+]?)(:(\\d*|-\\d+)\\.\\.(\\d*|-\\d+))?\\]");

            for (int watchDog = 0; watchDog < 100; watchDog++)
            {
                QString to;
                int j, i = rxI.indexIn(format);
                if (i != -1)
                {
                    j              = rxI.matchedLength();
                    QString digits = rxI.cap(2);
                    int k          = digits.isEmpty() ? 0 : digits.toInt();
                    if (k < 2)
                    {
                        to = QString::number(seqNumber);
                    }
                    else
                    {
                        QString fmt;
                        fmt.sprintf("0%dd", (k > 10 ? 10 : k));
                        fmt = '%' + fmt;
                        to.sprintf(fmt.toLatin1(), seqNumber);
                    }
                }
                else
                {
                    if ((i = rxN.indexIn(format)) == -1)
                    {
                        break;
                    }
                    j            = rxN.matchedLength();
                    QString from = rxN.cap(1);
                    from = (from == "e") ? fi.suffix() :
                           (from == "E") ? fi.completeSuffix() :
                           (from == "b") ? fi.baseName() :
                           (from == "B") ? fi.completeBaseName() :
                           (from == "n") ? fi.fileName() :
                           (from == "a") ? fi.absoluteDir().dirName() :
                           (from == "p") ? fi.absolutePath() :
                           "";
                    int len            = from.length();
                    QString start      = rxN.cap(4);
                    QString end        = rxN.cap(5);
                    int k              = start.isEmpty() ? 1 : start.toInt();
                    int l              = end.isEmpty() ? len : end.toInt();
                    k                  = (k < -len) ? 0 : (k < 0) ? (len + k) : (k > 0) ? (k - 1) : 0;
                    l                  = (l < -len) ? -1 : (l < 0) ? (len + l) : (l > 0) ? (l - 1) : 0;
                    to                 = l < k ? "" : from.mid(k, l - k + 1);
                    QString changeCase = rxN.cap(2);
                    if (!changeCase.isEmpty())
                    {
                        to = (changeCase == "+") ? to.toUpper() : to.toLower();
                    }
                }
                format.replace(i, j, to);
            }
        }
        format.replace("%%", "%");
        format.remove("%s");
        format.replace('/', '!');
        format.replace("%[", "% [");

        time_t time        = info.time().toTime_t();
        struct tm* time_tm = ::localtime(&time);
        char s[100];
        ::strftime(s, 100, QFile::encodeName(format), time_tm);

        newName += QString::fromLocal8Bit(s);
        if (!useExtraSymbols)
        {
            newName += '_';
        }
    }

    if (!useExtraSymbols)
    {
        int numDigits = 1;
        int count = ui->m_listView->topLevelItemCount();
        while (count > 0)
        {
            numDigits++;
            count = count / 10;
        }

        QString format;
        format.sprintf("0%dd", numDigits);
        format = '%' + format;

        QString seq;
        seq.sprintf(format.toLatin1(), seqNumber);
        newName += seq;

        newName += QString::fromLatin1(".") + fi.suffix();
    }

    return newName;
}
Example #27
0
void KBBGraphic::paintCellPixmap( QPainter* p, int row, int col )
{
    int w = cellW;
    int h = cellH;
    int x2 = w - 1;
    int y2 = h - 1;
    int type;
    QPixmap pm;

    //  kdDebug(12009) << p->viewport().width() << endl;

    switch (type = graphicBoard->get( col, row )) {
    case MARK1BBG:
        pm = *pixScaled[MARK1BBG];
        break;
    case OUTERBBG:
        pm = *pixScaled[OUTERBBG];
        break;
    case INNERBBG:
        pm = *pixScaled[INNERBBG];
        break;
    case LASERBBG:
        pm = *pixScaled[LASERBBG];
        break;
    case LFIREBBG:
        pm = *pixScaled[LFIREBBG];
        break;
    case FBALLBBG:
        pm = *pixScaled[FBALLBBG];
        break;
    case TBALLBBG:
        pm = *pixScaled[TBALLBBG];
        break;
    case WBALLBBG:
        pm = *pixScaled[WBALLBBG];
        break;
    default:
        pm = *pixScaled[OUTERBBG];
    }
    //  kdDebug(12009) << pm.width() << " " << w << endl;
    p->drawPixmap( 0, 0, pm );
    //  bitBlt( this, col * w, row * h, &pm );

    p->setPen( black );

    if (type == INNERBBG) {
        p->drawLine( x2, 0, x2, y2 );		// draw vertical line on right
        p->drawLine( 0, y2, x2, y2 );		// draw horiz. line at bottom
        p->drawLine( 0, 0, x2, 0 );
        p->drawLine( 0, 0, 0, y2 );
    }

    /*
       Extra drawings for boxes aroud lasers.
    */
    QString s;
    switch (type) {
    case RLASERBBG:
        s.sprintf( "%c", 'R' );
        p->drawText( 1, 1, x2-1, y2-1, AlignCenter, s );
        break;
    case HLASERBBG:
        s.sprintf( "%c", 'H' );
        p->drawText( 1, 1, x2-1, y2-1, AlignCenter, s );
        break;
    }
    if (type < 0) {
        s.sprintf( "%d", -type );
        p->drawText( 1, 1, x2-1, y2-1, AlignCenter, s );
    }

    /*
       Draw extra frame inside if this is the current cell.
    */
    p->setPen( yellow );
    if ( (row == curRow) && (col == curCol) ) {	// if we are on current cell,
        if ( hasFocus() ) {
            p->drawRect( 0, 0, x2, y2 );
        }
        else {					// we don't have focus, so
            p->setPen( DotLine );		        // use dashed line to
            p->drawRect( 0, 0, x2, y2 );
            p->setPen( SolidLine );		        // restore to normal
        }
    }
}
Example #28
0
File: menus.cpp Project: Kafay/vlc
int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
        vlc_object_t *p_object, bool b_root )
{
    vlc_value_t val, val_list, text_list;
    int i_type, i;

    /* Check the type of the object variable */
    i_type = var_Type( p_object, psz_var );

    /* Make sure we want to display the variable */
    if( submenu->isEmpty() && IsMenuEmpty( psz_var, p_object, b_root ) )
        return VLC_EGENERIC;

    switch( i_type & VLC_VAR_TYPE )
    {
        case VLC_VAR_VOID:
        case VLC_VAR_BOOL:
        case VLC_VAR_VARIABLE:
        case VLC_VAR_STRING:
        case VLC_VAR_INTEGER:
        case VLC_VAR_FLOAT:
            break;
        default:
            /* Variable doesn't exist or isn't handled */
            return VLC_EGENERIC;
    }

    if( var_Change( p_object, psz_var, VLC_VAR_GETLIST,
                    &val_list, &text_list ) < 0 )
    {
        return VLC_EGENERIC;
    }

#define CURVAL val_list.p_list->p_values[i]
#define CURTEXT text_list.p_list->p_values[i].psz_string

    for( i = 0; i < val_list.p_list->i_count; i++ )
    {
        vlc_value_t another_val;
        QString menutext;
        QMenu *subsubmenu = new QMenu( submenu );

        switch( i_type & VLC_VAR_TYPE )
        {
            case VLC_VAR_VARIABLE:
                CreateChoicesMenu( subsubmenu, CURVAL.psz_string, p_object, false );
                subsubmenu->setTitle( qfu( CURTEXT ? CURTEXT :CURVAL.psz_string ) );
                submenu->addMenu( subsubmenu );
                break;

            case VLC_VAR_STRING:
                var_Get( p_object, psz_var, &val );
                another_val.psz_string = strdup( CURVAL.psz_string );
                menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
                CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
                        p_object, another_val, i_type,
                        val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) );

                free( val.psz_string );
                break;

            case VLC_VAR_INTEGER:
                var_Get( p_object, psz_var, &val );
                if( CURTEXT ) menutext = qfu( CURTEXT );
                else menutext.sprintf( "%d", CURVAL.i_int );
                CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
                        p_object, CURVAL, i_type,
                        ( CURVAL.i_int == val.i_int )
                        && CheckTitle( p_object, psz_var ) );
                break;

            case VLC_VAR_FLOAT:
                var_Get( p_object, psz_var, &val );
                if( CURTEXT ) menutext = qfu( CURTEXT );
                else menutext.sprintf( "%.2f", CURVAL.f_float );
                CreateAndConnect( submenu, psz_var, menutext, "", ITEM_RADIO,
                        p_object, CURVAL, i_type,
                        CURVAL.f_float == val.f_float );
                break;

            default:
                break;
        }
    }
    currentGroup = NULL;

    /* clean up everything */
    var_FreeList( &val_list, &text_list );

#undef CURVAL
#undef CURTEXT
    return submenu->isEmpty() ? VLC_EGENERIC : VLC_SUCCESS;
}
Example #29
0
void MessageShell::handleSpell(const uint8_t* data, size_t, uint8_t dir)
{
  const memSpellStruct* mem = (const memSpellStruct*)data;
  QString tempStr;

  bool client = (dir == DIR_Client);

  tempStr = "";
  
  switch (mem->param1)
  {
  case 0:
    {
      if (!client)
	tempStr = "You have finished scribing '";
      break;
    }
    
  case 1:
    {
      if (!client)
	tempStr = "You have finished memorizing '";
      break;
    }
    
  case 2:
    {
      if (!client)
	tempStr = "You forget '";
      break;
    }
    
  case 3:
    {
      if (!client)
	tempStr = "You finish casting '";
      break;
    }
    
  default:
    {
      tempStr.sprintf( "Unknown Spell Event ( %s ) - '",
		       client  ?
		     "Client --> Server"   :
		       "Server --> Client"
		       );
      break;
    }
  }
  
  
  if (!tempStr.isEmpty())
  {
    QString spellName;
    const Spell* spell = m_spells->spell(mem->spellId);
    
    if (spell)
      spellName = spell->name();
    else
      spellName = spell_name(mem->spellId);

    if (mem->param1 != 3)
      tempStr.sprintf("%s%s', slot %d.", 
		      tempStr.ascii(), 
		      (const char*)spellName, 
		      mem->slotId);
    else 
    {
      tempStr.sprintf("%s%s'.", 
		      tempStr.ascii(), 
		      (const char*)spellName);
    }

    m_messages->addMessage(MT_Spell, tempStr);
  }
}
Example #30
0
SVNHandler::FileStatus SVNHandler::fstatus( const QString& filename ) const
{
  // no valid repository
  if ( !_isPORepository )
    return NO_REPOSITORY;

  QString fn( filename );
  fn = fn.remove( QRegExp( "/$" ) );

  QFileInfo info( fn );

  // check if '.svn/entries' exists.
  QFile entries( info.dir( true ).path( ) + "/.svn/entries" );

  if ( !entries.exists() )
    return NOT_IN_SVN;

  KProcess proc;
  SVNOutputCollector out( &proc );

  proc << "svn" << "status" << "-v" << "--xml" << info.absFilePath();

  if( !proc.start( KProcess::Block, KProcess::Stdout ) )
    return ERROR_IN_WC;

  QDomDocument doc;
  QString errorMsg;
  int errorLine, errorCol;
  QDomNodeList nodelist;
  QDomNode node;
  QDomElement entry, wcStatus;

  // Parse the output.
  if ( !doc.setContent( out.getOutput(), &errorMsg, &errorLine, &errorCol ) ) {
    kdDebug(8109) << "Cannot parse \"svn status -v --xml\" output for"
        << filename << endl << "Line: " << errorLine << " Column: "
        << errorCol << " Error: " << errorMsg << endl;
    goto no_status_xml;
  }

  // There should be only one "entry" element. If it doesn't exist, path
  // isn't repo path at all.
  nodelist = doc.elementsByTagName("entry");
  if (nodelist.count() < 1)
    return NOT_IN_SVN;

  entry = nodelist.item(0).toElement();

  // Shouldn't fail, but just in case there is some weird error.
  if ( entry.attributeNode("path").value() != info.absFilePath() )
    return ERROR_IN_WC;

  for ( node = entry.firstChild(); !node.isNull(); node = node.nextSibling() ) {
    if ( !node.isElement() )
      continue;
    if (node.toElement().tagName() == "wc-status")
      break;
  }

  if ( node.isNull() )
    return ERROR_IN_WC;

  wcStatus = node.toElement();

  if ( wcStatus.attributeNode("item").value() == "normal" )
    return UP_TO_DATE;
  if ( wcStatus.attributeNode("item").value() == "modified" )
    return LOCALLY_MODIFIED;
  if ( wcStatus.attributeNode("item").value() == "conflicted" )
    return CONFLICT;
  if ( wcStatus.attributeNode("item").value() == "unversioned" )
    return NOT_IN_SVN;
  // TODO Ignored entry should have separate return value probably.
  if ( wcStatus.attributeNode("item").value() == "ignored" )
    return NOT_IN_SVN;
  if ( wcStatus.attributeNode("item").value() == "added" )
    return LOCALLY_ADDED;
  if ( wcStatus.attributeNode("item").value() == "deleted" )
    return LOCALLY_REMOVED;
  // TODO What to do with "missing", "incomplete", "replaced", "merged",
  // "obstructed", "external"? Can these appear at all in our case?

  return ERROR_IN_WC;

no_status_xml:
  if ( !entries.open( IO_ReadOnly ) )
    return ERROR_IN_WC;  // we already know that it is a repository

  // Parse the entries file
  if ( !doc.setContent( &entries, &errorMsg, &errorLine, &errorCol ) ) {
    kdDebug() << "Cannot parse .svn/entries file for " << filename << endl
        << "Line: " << errorLine << " Column: " << errorCol << " Error: " << errorMsg << endl;
    return ERROR_IN_WC;
  }
  entries.close();

  QDomElement element;
  // File name that we are searching
  const QString findName = info.fileName();
  // The entries are <entry> elements, so we have to check them
  QDomNode child = doc.documentElement().firstChild();
  for ( ; !child.isNull() ; child = child.nextSibling() )
  {
    if ( !child.isElement() )
      continue;
    element = child.toElement();
    if ( element.tagName() != "entry" ) {
      // We have another kind of element, so skip it
      // Should not happend with svn 1.1.x
      continue;
    }
    const QString name = element.attribute("name");
    if ( name == findName )
      break;
  }

  if ( child.isNull() ) {
    // We have not found an entry for the file
    return NOT_IN_SVN;
  }

  // ### TODO: should we check the attribute kind to be file and not dir?

  // ### TODO: what do copy and move add here?
  const QString onSchedule = element.attribute( "schedule" );
  if ( onSchedule == "delete" )
    return LOCALLY_REMOVED;
  else if ( onSchedule == "added" )
    return LOCALLY_ADDED;

  if ( element.hasAttribute( "conflict-new" ) || element.hasAttribute( "conflict-old" ) || element.hasAttribute( "conflict-wrk" ) ) {
    return CONFLICT;
  }

  // Note: we do not check the property time stamp
  const QString textTimeStamp( element.attribute( "text-time" ) );

  // calculate the UTC time from the file's last modified date
  struct stat st;
  lstat( QFile::encodeName(fn), &st );
  struct tm * tm_p = gmtime( &st.st_mtime );
  const int year = tm_p->tm_year + 1900;
  const int month = tm_p->tm_mon + 1;
  QString fileTime;
  fileTime.sprintf( "%04i-%02i-%02iT%02i:%02i:%02i.000000Z",
                    year, month, tm_p->tm_mday, tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec );
  //kdDebug() << "File: " << filename << " SVN time: " << textTimeStamp << " File time: " << fileTime << endl;
  if ( fileTime > textTimeStamp ) // ISO 8601 dates/times can be compared as strings if they have the exact same format.
    return LOCALLY_MODIFIED;

  return UP_TO_DATE;

}