Exemplo n.º 1
0
void Data::parsePrices(QString page) {
    bool isPriceUpdated = false; // prices in the feed are from newest to oldest so we want the first
    Data::ctime = QDateTime::fromString(page.section("<latest_timestamp>",1,1).left(14), "yyyyMMddhhmmss");
    if(cstyle%Constants::getStyle()->size() == 1) {
        dataBars = new QList<Bar>();
        QStringListIterator listIterator(page.split("<bar>"));
        if(listIterator.hasNext()) {
            listIterator.next(); // skip the "0" index
            xmin = 999999; xmax = 0; ymin = 99999999; ymax = 0;
        }
        while(listIterator.hasNext()) {
            QString nextBar = listIterator.next();
            QString lowStr = nextBar.section("<low>",1,1).section("</low>",0,0);
            QString highStr = nextBar.section("<high>",1,1).section("</high>",0,0);
            QString closeStr = nextBar.section("<close>",1,1).section("</close>",0,0);
            if(closeStr != "") {
                if(lowStr.toDouble() < ymin) ymin = lowStr.toDouble();
                if(highStr.toDouble() > ymax) ymax = highStr.toDouble();
                dataBars->prepend(Bar(lowStr.toDouble(), highStr.toDouble(), closeStr.toDouble()));
            } else {
                dataBars->prepend(Bar());
            }
            if(!isPriceUpdated && closeStr.toDouble() > 0) {
                isPriceUpdated = true;
                lastChartPrice = closeStr.toDouble();
            }
        }
        xmax = dataBars->size()+1.5;
    } else if(cstyle%Constants::getStyle()->size() == 0) {
        dataPoints = new QList<double>();
        QStringListIterator listIterator(page.split("<point>"));
        if(listIterator.hasNext()) {
            listIterator.next(); // skip the "0" index
            xmin = 999999; xmax = 0; ymin = 999999; ymax = 0;
        }
        while(listIterator.hasNext()) {
            QString nextPoint = listIterator.next();
            QString priceStr = nextPoint.section("<price>",1,1).section("</price>",0,0);
            if(priceStr != "") {
                if(priceStr.toDouble() < ymin) ymin = priceStr.toDouble();
                if(priceStr.toDouble() > ymax) ymax = priceStr.toDouble();
                dataPoints->prepend(priceStr.toDouble());
            } else {
                dataPoints->prepend(-1);
            }
            if(!isPriceUpdated && priceStr.toDouble() > 0) {
                isPriceUpdated = true;
                lastChartPrice = priceStr.toDouble();
            }
        }
        xmax = dataPoints->size()+1.5;
    }
    xmin = 0;
    double ydiff = ymax - ymin;
    ymin = ymin-ydiff/20;
    ymax = ymax+ydiff/20;

    // 'callback' to chart to update once the data is parsed
    chart->update();
}
void QTodoExportPluginCSV::exportBody( )
{
    for(; listIterator().current(); ++listIterator())
    {
        if(QTodoItem* item = listIterator().item())
            exportItem(*item);
    }
}
void QTodoExportPluginHTML::exportBody( )
{
	for(; listIterator().current(); ++listIterator())
	{
		if(QTodoItem* item = listIterator().item())
			exportItem(*item);
	}	

	addLine("</body></html>");
}
Exemplo n.º 4
0
bool ACDQueue_Linear::buildTargetAgentList(UtlSList& rTargetAgentList, ACDCall* pCallRef)
{
   ACDAgent* pAgent;
   ACDAgent* pLastAttemptedAgent;

   // Always rebuild the list to get the agents added on the fly
   buildACDAgentList();

   UtlSListIterator listIterator(mAcdAgentList);
   int numAgents = mAcdAgentList.entries();

   // Iterate through the ACDAgent list, starting after the agent that
   // The ACDCall was last using.  If the end of the list is
   // reached, wrap around to the beginning.  If this LastAttemptedAgent
   // is NULL, start from the head of the list
   pLastAttemptedAgent = pCallRef->getLastAgent();
   if (pLastAttemptedAgent != NULL) {
      // walk the iterator to point after pLastAttemptedAgent
      if (listIterator.findNext(pLastAttemptedAgent) == NULL) {
         // Didn't find pLastAttemptedAgent, start again from the top.
         listIterator.reset();
         pCallRef->setLastAgent(NULL);
      }
   }

   for(int i=0; i<numAgents; i++) {
      // Check the next agent
      pAgent = dynamic_cast<ACDAgent*>(listIterator());
      if (pAgent == NULL) {
         // We've hit the end of the list start back from the head of the list
         listIterator.reset();
         pAgent = dynamic_cast<ACDAgent*>(listIterator());
         if (pAgent == NULL) {
            // All out of agents to try
            return false;
         }
      }

      if (pAgent->isAvailable(true)) {
         rTargetAgentList.append(pAgent);
         // Remember the agent chosen
         pCallRef->setLastAgent(pAgent);
         OsSysLog::add(FAC_ACD, gACD_DEBUG, "%s::buildTargetAgentList - agent(%s) is added to the target list",
                       mAcdSchemeString, pAgent->getUriString()->data());
         return true;
      }
   }

   // The whole list was tried, yet no appropriate agents were found.
   return false;
}
Exemplo n.º 5
0
void SearchSet::addItems(QStringList patentNumberList, int depth)
{
	QStringListIterator listIterator(patentNumberList);
	while(listIterator.hasNext()){
		addItem(listIterator.next(), depth);
	}
}
Exemplo n.º 6
0
QString VerticalLayout::toHtml()
{
	QString asHtml;
	
	QListIterator<PageObject*> listIterator( _containedObjects );
	while( listIterator.hasNext() )
	{	
		PageObject* pageObject = listIterator.next();
		
		HtmlElements::Td td;
		td.setContent( pageObject->toHtml() );
		
		HtmlElements::Tr tr;
		tr.setContent( td.toHtml() );
		
		asHtml += tr.toHtml();
	}
		
	HtmlElements::TBody tbody;
	tbody.setContent( asHtml );
	
	HtmlElements::Table table;
	table.setContent( tbody.toHtml() );
	
	return table.toHtml();
}
Exemplo n.º 7
0
ACDCallMsg::ACDCallMsg(const ACDCallMsg& rACDCallMsg)
: OsMsg(rACDCallMsg)
{
   mhCallHandle = SIPX_CALL_NULL;
   mCallEvent   = 0;
   mCallCause   = 0;
   mpRequestingQueue = NULL;
   mConnectionScheme = 0;
   mTimeout = 0;

   if (getMsgSubType() == SET_QUEUE) {
      mpRequestingQueue = rACDCallMsg.mpRequestingQueue;
      mTimeout          = rACDCallMsg.mTimeout;
   }
   else if (getMsgSubType() == UPDATE_STATE) {
      mhCallHandle = rACDCallMsg.mhCallHandle;
      mCallEvent   = rACDCallMsg.mCallEvent;
      mCallCause   = rACDCallMsg.mCallCause;
   }
   else if (getMsgSubType() == ROUTE_CALL) {
      mConnectionScheme = rACDCallMsg.mConnectionScheme;
      mTimeout          = rACDCallMsg.mTimeout;
      // Make a copy of the UtlSList
      UtlSListIterator listIterator(rACDCallMsg.mTargetAgentList);
      UtlContainable* pElement;
      while ((pElement = listIterator()) != NULL) {
         mTargetAgentList.append(pElement);
      }
   }
   else if (getMsgSubType() == ROUTE_ADD) {
      mpTargetAgent = rACDCallMsg.mpTargetAgent;
   }
   else if (getMsgSubType() == ANSWER_CALL) {
      mAudio1  = rACDCallMsg.mAudio1;
      mBargeIn = rACDCallMsg.mBargeIn;
   }
   else if (getMsgSubType() == PLAY_AUDIO) {
      mAudio1  = rACDCallMsg.mAudio1;
      mTimeout = rACDCallMsg.mTimeout;
      mAudio2  = rACDCallMsg.mAudio2;
   }
   else if (getMsgSubType() == DROP_CALL) {
      mTimeout = rACDCallMsg.mTimeout;
      mAudio1  = rACDCallMsg.mAudio1;
   }
}
Exemplo n.º 8
0
ACDCallMsg::ACDCallMsg(eACDCallMsgSubTypes type, UtlSList* pTargetAgentList, int connectionScheme, int timeout)
: OsMsg(USER_START, type)
{   
   mConnectionScheme = connectionScheme;
   mTimeout          = timeout;

   mhCallHandle = SIPX_CALL_NULL;
   mCallEvent   = 0;
   mCallCause   = 0;
   mpRequestingQueue = NULL;

   // Make a copy of the UtlSList
   UtlSListIterator listIterator(*pTargetAgentList);
   UtlContainable* pElement;
   while ((pElement = listIterator()) != NULL) {
      mTargetAgentList.append(pElement);
   }
}
Exemplo n.º 9
0
bool ACDQueue_LongestIdle::buildTargetAgentList(UtlSList& rTargetAgentList, ACDCall* pCallRef)
{
    // Always rebuild the list to get the agents added on the fly
    buildACDAgentList();

    // Iterate through the ACDAgent list, starting at the head of the list
    // and find the agent that has been idle the longest.
    for(;;) {
        ACDAgent* pAgent;
        ACDAgent* pLongestIdleAgent = NULL;
        unsigned long maxIdleTime = 0;
        UtlSListIterator listIterator(mAcdAgentList);

        // Find the available agent with the longest idle time
        while ((pAgent = dynamic_cast<ACDAgent*>(listIterator())) != NULL) {
            if (pAgent->isAvailable(false)) {
                if (pAgent->getIdleTime() >= maxIdleTime) {
                    maxIdleTime = pAgent->getIdleTime();
                    pLongestIdleAgent = pAgent;
                }
            }
        }

        if (pLongestIdleAgent == NULL) {
            // None available
            break ;
        }

        // If he is still available, use him.  Otherwise start again.
        if (pLongestIdleAgent->isAvailable(true)) {
            rTargetAgentList.append(pLongestIdleAgent);
            OsSysLog::add(FAC_ACD, gACD_DEBUG, "%s::buildTargetAgentList - agent(%s) is added to the target list.  Idle time was %lu seconds",
                          mAcdSchemeString, pLongestIdleAgent->getUriString()->data(),
                          maxIdleTime);
            return true ;
        }
    }

    // The whole list was tried, yet no appropriate agents were found.
    return false;
}