void MythCCExtractorPlayer::IngestSubtitle(
    QList<OneSubtitle> &list, const QStringList &content)
{
    bool update_last =
        !list.isEmpty() &&
        (int64_t)m_curTime == list.back().start_time &&
        !content.isEmpty();

    if (update_last)
    {
        //update text only (need for cc608)
        list.back().text = content;
        return;
    }

    OneSubtitle last_one = list.isEmpty() ? OneSubtitle() : list.back();
    if (content != last_one.text || last_one.length >= 0)
    {
        // Finish previous subtitle.
        if (!last_one.text.isEmpty() && last_one.length < 0)
        {
            list.back().length = (int64_t)m_curTime - last_one.start_time;
        }

        // Put new one if it isn't empty.
        if (!content.isEmpty())
        {
            OneSubtitle new_one;
            new_one.start_time = (int64_t)m_curTime;
            new_one.text = content;

            list.push_back(new_one);
        }
    }
}
/**
 * Adds new subtitle, finishes last if needed.
 * This is a version for DVB graphical subtitles only.
 * @param content Content of the new subtitle (may be empty).
 * We're going to use it's img & start_time fields.
 */
void MythCCExtractorPlayer::IngestSubtitle(
    QList<OneSubtitle> &list, const OneSubtitle &content)
{
    bool update_last =
        !list.isEmpty() &&
        content.start_time == list.back().start_time &&
        !content.img.isNull();

    if (update_last)
    {
        list.back().img = content.img; // update image only
        return;
    }

    OneSubtitle last_one = list.isEmpty() ? OneSubtitle() : list.back();
    if (content.img != last_one.img || last_one.length >= 0)
    {
        // Finish previous subtitle.
        if (!last_one.img.isNull() && last_one.length < 0)
        {
            list.back().length = content.start_time - last_one.start_time;
        }

        // Put new one if it isn't empty.
        if (!content.img.isNull())
        {
            OneSubtitle new_one;
            new_one.start_time = content.start_time;
            new_one.img = content.img;

            list.push_back(new_one);
        }
    }
}
 void accept(const FullySpecifiedType &ty)
 {
     TypeVisitor::accept(ty.type());
     unsigned flags = ty.flags();
     flags |= temps.back().flags();
     temps.back().setFlags(flags);
 }
Beispiel #4
0
void MainWindow::UpdateHierarchy()
{
    sceneTree->clear();
    sceneTree->setHeaderLabel( "Hierarchy" );

    QList< QTreeWidgetItem* > nodes;
    const int count = sceneWidget->GetGameObjectCount();

    std::cout << "cleared scene tree" << std::endl;
    for (int i = 0; i < count; ++i)
    {
        nodes.append(new QTreeWidgetItem( (QTreeWidget*)0, QStringList( QString( sceneWidget->GetGameObject( i )->GetName().c_str() ) ) ) );
        nodes.back()->setFlags( nodes.back()->flags() | Qt::ItemIsEditable );
        std::cout << "added to list: " <<  sceneWidget->GetGameObject( i )->GetName()<< std::endl;
    }

    sceneTree->insertTopLevelItems( 0, nodes );

    // Highlights selected game objects.
    for (int i = 0; i < count; ++i)
    {
        for (auto goIndex : sceneWidget->selectedGameObjects)
        {
            if (i == goIndex)
            {
                sceneTree->setCurrentItem( nodes.at(i) );
            }
        }
    }
}
	bool endElement( const QString& /*namespaceURI*/, const QString& /*localName*/, const QString& /*qName*/ )
	{
		cElement* element = elements.pop();
		if ( --( levels.back() ) == 0 )
		{
			// Ignore root
			return true;
		}

		if ( element == elements.top() )
		{
			// Ignore include
			return true;
		}

		// Did we complete a parent node?
		if ( elements.top() == NULL )
		{
			// Find a category node
			unsigned int i = 0;

			// Sort it into a category.
			while ( categories[i].name != 0 )
			{
				if ( element->name() == categories[i].name )
				{
					QString tagId = element->getAttribute( "id" );

					// If the element has an id,
					if ( !tagId.isEmpty() )
					{
						if ( impl->unique[categories[i].key].contains( tagId ) && !Config::instance()->overwriteDefinitions() )
						{
							Console::instance()->log( LOG_WARNING, tr( "Duplicate %1: %2\n[File: %3, Line: %4]\n" )
								.arg( QString( element->name() ) ).arg( tagId ).arg( filenames.back() ).arg( locators.top()->lineNumber() ) );
							delete element;
						}
						else
						{
							impl->unique[categories[i].key].insert( tagId, element );
						}
					}
					else
					{
						impl->nonunique[categories[i].key].push_back( element );
					}

					return true;
				}
				++i;
			}

			Console::instance()->log( LOG_WARNING, tr( "Unknown element: %1\n[File: %2, Line: %3]\n" )
				.arg( QString( element->name() ) ).arg( filenames.back() ).arg( locators.top()->lineNumber() ) );
			delete element;
		}

		return true;
	}
	bool startElement( const QString& /*namespaceURI*/, const QString& localName, const QString& qName, const QXmlAttributes& atts )
	{
		levels.back()++;

		// Ignore document root
		if ( levels.back() == 1 )
		{
			if ( levels.isEmpty() )
			{
				// Top level
				elements.push( NULL );
			}
			else
			{
				// Within an include
				if ( elements.isEmpty() )
					elements.push( 0 );
				else
					elements.push( elements.top() );
			}
			return true;
		}

		// Include another file
		if ( qName == "include" )
		{
			QString value = atts.value( "file" );
			load( value );

			elements.push( elements.top() );
			return true;
		}

		cElement* element = new cElement;
		element->setName( localName.toLatin1() );
		element->copyAttributes( atts );

		// Child Element?
		if ( elements.top() != NULL )
		{
			cElement* parent = elements.top(); // Pop the potential parent
			parent->addChild( element ); // Add the child to it's parent
			element->setParent( parent );
		} else {
			Definitions::instance()->addElement(element);
		}

		elements.push( element ); // Push our element (there may be children)

		return true;
	}
void SchematicScene::clearAllItems()
{
	clearSelection();
	m_highlightedLinks.clear();
	QList<SchematicWindowEditor *> editors;
	QList<SchematicNode *> nodes;
	QList<SchematicLink *> links;
	int i;
	QList<QGraphicsItem *> sceneItems = items();
	int size = sceneItems.size();
	//create nodes and links list
	for (i = 0; i < size; i++) {
		QGraphicsItem *item = sceneItems.at(i);
		SchematicWindowEditor *editor = dynamic_cast<SchematicWindowEditor *>(item);
		SchematicNode *node = dynamic_cast<SchematicNode *>(item);
		SchematicLink *link = dynamic_cast<SchematicLink *>(item);
		if (editor)
			editors.append(editor);
		if (node)
			nodes.append(node);
		if (link)
			links.append(link);
	}
	while (links.size() > 0) {
		SchematicLink *link = links.back();
		removeItem(link);
		links.removeLast();
		SchematicPort *startPort = link->getStartPort();
		SchematicPort *endPort = link->getEndPort();
		if (startPort)
			startPort->removeLink(link);
		if (endPort)
			endPort->removeLink(link);
		delete link;
	}
	while (editors.size() > 0) {
		SchematicWindowEditor *editor = editors.back();
		removeItem(editor);
		editors.removeLast();
		delete editor;
	}
	while (nodes.size() > 0) {
		SchematicNode *node = nodes.back();
		removeItem(node);
		nodes.removeLast();
		delete node;
	}
	assert(items().size() == 0);
}
Beispiel #8
0
int
Splitter::getRightChildrenSize() const
{
    QList<int> list = sizes();
    assert(list.size() == 2);
    return list.back();
}
Beispiel #9
0
void nodeWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * )
    {
    QString title( "Hello" );
    QList <QString> properties;

    properties << "Thing" << "lalala" << "bouind" << "hahaha";

    QRectF originalRect( titlebarRect( painter->font() ) );

    _titlePath = QPainterPath();
    _titlePath.addRect( originalRect );

    QRectF titleRect( originalRect );
    titleRect.setHeight( titleRect.height() + ( ROUNDRADIUS * 2 + 1 ) );

    QRectF contentsRect( titleRect );
    contentsRect.setY( originalRect.height() );
    contentsRect.setHeight( originalRect.height() + NODEPROPERTYHEIGHT*( properties.size() - 1 ) - 2*ROUNDRADIUS - 4 );

    QPainterPath titleBar( makeRoundedPath( titleRect ) );
    QPainterPath contents( makeRoundedPath( contentsRect ) );

    QPen outlinePen( Qt::black, 3 );
    if( isSelected() )
        {
        outlinePen.setColor( SELECTED_COLOUR );
        }
    QPainterPath globalLine( makeRoundedPath( titleRect.unite( contentsRect ) ) );
    painter->setPen( outlinePen );
    painter->drawPath( globalLine );
    painter->fillPath( titleBar, titleGradient( titleRect ) );


    painter->fillPath( contents, contentsBrush( contentsRect ) );

    QColor separatingLineColor( Qt::black );
    if( isSelected() )
        {
        separatingLineColor = SELECTED_COLOUR;
        }
    separatingLineColor.setAlpha( 128 );
    QPen separatingLinePen( separatingLineColor );
    QPen whitePen( Qt::white );

    painter->setPen( whitePen );
    painter->drawText( originalRect, Qt::AlignCenter, title );

    QRectF textRect( titleRect );
    textRect.moveTop( textRect.top() + originalRect.height() - 2*ROUNDRADIUS - 2 );
    FOREACH( properties, prop )
        {
        painter->setPen( whitePen );
        painter->drawText( textRect, Qt::AlignCenter, *prop );
        if( &(*prop) != &(properties.back()) )
            {
            painter->setPen( separatingLinePen );
            painter->drawLine( titleRect.x(), textRect.y()+NODEPROPERTYHEIGHT+4, titleRect.x()+titleRect.width(), textRect.y()+NODEPROPERTYHEIGHT+4 );
            }
        textRect.moveTop( textRect.top() + NODEPROPERTYHEIGHT );
        }
bool v3dViewAnnIntImageMaskHelper::addAnnotation( medAnnotationData * annData )
{
    medImageMaskAnnotationData * imad = qobject_cast<medImageMaskAnnotationData*>(annData);
    if ( !imad )
        return false;

    medAbstractDataImage * dataImage = imad->maskData();
    v3dView * view = this->getV3dView();
    int oldLayer = view->currentLayer();
    int maskLayer = view->layerCount();

    view->setData(dataImage, maskLayer);

    QList<double> scalars;
    QList<QColor> colors;
    for( medImageMaskAnnotationData::ColorMapType::const_iterator it(imad->colorMap().begin()), end(imad->colorMap().end());
        it != end; ++it )
    {
        scalars.push_back(it->first);
        colors.push_back(it->second);
    }


    view->setCurrentLayer(maskLayer);
    view->setColorLookupTable(scalars,colors);
//    qDebug() << "windowLevel" << view->view2d()->GetWindowLevel(maskLayer);
//    qDebug() << "lookuptable"<< view->view2d()->GetWindowLevel(maskLayer)->GetLookupTable();
    view->view2d()->GetWindowLevel(maskLayer)->GetLookupTable()->SetRange(
        scalars.first() - 1, // v3dView pads the data by one.
        scalars.back()  + 1);
    view->setCurrentLayer(oldLayer);

    this->annotationModified(annData);
    return true;
}
Beispiel #11
0
	void CookiesEditModel::AddCookie (const QNetworkCookie& cookie)
	{
		int i = 0;
		if (Cookies_.size ())
			i = (Cookies_.end () - 1).key () + 1;
		Cookies_ [i] = cookie;
	
		QString domain = cookie.domain ();
	
		QList<QStandardItem*> foundItems = findItems (domain);
		QStandardItem *parent = 0;
		if (!foundItems.size ())
		{
			parent = new QStandardItem (domain);
			parent->setEditable (false);
			parent->setData (-1);
			invisibleRootItem ()->appendRow (parent);
		}
		else
			parent = foundItems.back ();
		QStandardItem *item = new QStandardItem (QString (Cookies_ [i].name ()));
		item->setData (i);
		item->setEditable (false);
		parent->appendRow (item);
	
		Jar_->setAllCookies (Cookies_.values ());
	}
Beispiel #12
0
void TEventsLog::AddNewEvent(TEventExt *e)
	{
	qDebug() << tr("New event: ");
	QFile EvLogFile(EVLOG_FILENAME);
	if (!EvLogFile.open(QIODevice::Append | QIODevice::Text)) qDebug() << tr("File open error!");

	QList<QStandardItem*> items;
	int column=0;
	foreach(const QString &text, QStringList() << e->Event.DateTime.toString(tr("dd.MM.yyyy hh:mm:ss")) << e->Event.Text << ((e->OscIndex>=0)?QString().setNum(e->OscIndex):"") )
		{
		qDebug() << text.toUtf8() << ';';
		items << new QStandardItem(text);
		items.back()->setEditable(false);
		if(EvLogFile.isOpen())
			{
			char *buf=utf8_to_cp1251_qstr(text);
			EvLogFile.write(buf);
			delete buf;
			if((++column)<EventsList_Model.columnCount()) EvLogFile.write(";");
			else EvLogFile.write("\r\n");
			}
		}
	qDebug() << "\r\n";

	EventsList_Model.appendRow(items);
	if(EventsList_Model.rowCount()>EVLOG_NUM_MAX)
		{
		EventsList_Model.removeRow(0);
		}

	GotoLastEvent();
	}
Beispiel #13
0
static void create_segments()
      {
      segment.append(MidiSegment());

      segment[0].start = firstbeat; // Always start a segment at the very beginning of the piece (the first beat)
      for (int b = 0; b < num_sbeats; b++) {
            if (b == 0 && (sbeat[0].time - firstbeat) < ((sbeat[1].time-firstbeat) - (sbeat[0].time-firstbeat))/2)
                  continue;
            /* If it's the first beat of the piece, and the upbeat is
               less than half of the first beat interval, don't start a segment
            */
            else {
                  MidiSegment seg;
                  seg.start          = sbeat[b].time;
                  segment.back().end = sbeat[b].time;
                  segment.append(seg);
                  }
            }
      int s = segment.size() - 1;

    /* If final segment starts at or after final timepoint of piece, ignore it,
       decrementing number of segments by 1; if not, set that segment's ending
       to final timepoint of piece
       */
      if (segment[s].start >= final_timepoint) {
            s--;
            }
      else {
            segment[s].end = final_timepoint;
            /* qDebug("Final segment ends at %d", segment[s].end); */
            }
      segtotal = s; // index of final segment
      }
QSharedPointer<VCSBase::AbstractCheckoutJob> GitoriousCloneWizard::createJob(const QList<QWizardPage*> &parameterPages,
                                                                    QString *checkoutPath)
{
    const Git::CloneWizardPage *cwp = qobject_cast<const Git::CloneWizardPage *>(parameterPages.back());
    QTC_ASSERT(cwp, return QSharedPointer<VCSBase::AbstractCheckoutJob>())
    return cwp->createCheckoutJob(checkoutPath);
}
Beispiel #15
0
void DlgCustomToolbarsImp::moveDownCustomCommand(const QString& name, const QByteArray& userdata)
{
    QVariant data = workbenchBox->itemData(workbenchBox->currentIndex(), Qt::UserRole);
    Workbench* w = WorkbenchManager::instance()->active();
    if (w && w->name() == std::string((const char*)data.toByteArray())) {
        QList<QToolBar*> bars = getMainWindow()->findChildren<QToolBar*>(name);
        if (bars.size() != 1)
            return;

        QByteArray cmd = userdata;
        int numSep = 0, indexSep = 0;
        if (cmd.startsWith("Separator")) {
            numSep = cmd.mid(9).toInt();
            cmd = "Separator";
        }
        QList<QAction*> actions = bars.front()->actions();
        for (QList<QAction*>::ConstIterator it = actions.begin(); it != actions.end(); ++it) {
            if ((*it)->data().toByteArray() == cmd) {
                // if we move a separator then make sure to pick up the right one
                if (numSep > 0) {
                    if (++indexSep < numSep)
                        continue;
                }
                QAction* act = *it;
                if (*it == actions.back())
                    break; // we're already on the last element
                ++it;
                // second last item
                if (*it == actions.back()) {
                    QList<QAction*> group = getActionGroup(act);
                    bars.front()->removeAction(act);
                    bars.front()->addAction(act);
                    if (!group.isEmpty())
                        setActionGroup(act, group);
                    break;
                }
                ++it;
                QList<QAction*> group = getActionGroup(act);
                bars.front()->removeAction(act);
                bars.front()->insertAction(*it, act);
                if (!group.isEmpty())
                    setActionGroup(act, group);
                break;
            }
        }
    }
}
Beispiel #16
0
bool ConnectionManager2::applyConfig(QVariant const & config)
{
    if (config.type() != QVariant::List)
        return false;

    QList<Connection *> newConns;
    struct cleanup
    {
        QList<Connection *> & conns;
        cleanup(QList<Connection *> & conns) : conns(conns) {}
        ~cleanup() { for (int i = 0; i < conns.size(); ++i) conns[i]->releaseAll(); }
    } cleanupGuard(newConns);

    QList<QVariant> const & connConfigs = config.toList();

    for (int i = 0; i < connConfigs.size(); ++i)
    {
        if (connConfigs[i].type() != QVariant::Hash)
            return false;
        QHash<QString, QVariant> const & connConfig = connConfigs[i].toHash();

        QVariant typev = connConfig.value("type");
        if (typev.type() != QVariant::String)
            return false;

        QString const & type = typev.toString();

        ConnectionPointer<Connection> conn;
        if (type == "serial_port")
            conn.reset(new SerialPort());
        else if (type == "tcp_client")
            conn.reset(new TcpSocket());
        else if (type == "udp_socket")
            conn.reset(new UdpSocket());
#ifdef HAVE_LIBYB
        else if (type == "usb_yb_acm")
            conn.reset(new UsbAcmConnection2(m_yb_runner));
#endif

        if (!conn)
            return false;

        QVariant settings = connConfig.value("settings");
        if (settings.type() != QVariant::Hash || !conn->applyConfig(settings.toHash()))
            return false;

        newConns.push_back(conn.data());
        conn.take();
    }

    this->clearUserOwnedConns();
    while (!newConns.empty())
    {
        this->addUserOwnedConn(newConns.back());
        newConns.pop_back();
    }

    return true;
}
Beispiel #17
0
		/// Recalculate the bounding rect.
		/// Also make the new border outline.
		/// QPolygonF cannot have holes or disjointed parts,
		/// it's a single closed line. The outline (implemented as a QPainterPath)
		/// makes it look like it have holes.
		void Shape2DFree::resetBoundingRect()
		{
			m_boundingRect = getPolygonBoundingRect();
			// Clear the outline path.
			m_outline = QPainterPath();
			if (m_polygon.isEmpty()) return;

			// If the polygon has apparent holes/discontinuities
			// it will have extra pairs of edges which we don't want
			// to draw.
			auto n = m_polygon.size() - 1;
			// Find those vertices at which we must break the polygon
			// to get rid of these extra edges.
			QList<int> breaks;
			breaks.push_back(0);
			for (int i = 1; i < m_polygon.size() - 1; ++i)
			{
				auto p = m_polygon[i];
				auto j = m_polygon.indexOf(p, i + 1);
				if (j != -1)
				{
					auto i1 = i + 1;
					auto j1 = j - 1;
					if (m_polygon[i1] == m_polygon[j1])
					{
						breaks.push_back(i);
						breaks.push_back(i1);
						breaks.push_back(j1);
						breaks.push_back(j);
					}
				}
			}
			if (breaks.back() != n)
			{
				breaks.push_back(n);
			}
			qSort(breaks);

			m_outline.moveTo(m_polygon[0]);
			int j1 = 0;
			// Add contiguous portions of the polygon to the outline
			// and break at points from breaks list.
			for (int i = 0; i < breaks.size(); ++i)
			{
				auto j = breaks[i];
				if (j == j1 + 1)
				{
					m_outline.moveTo(m_polygon[j]);
				}
				else
				{
					for (auto k = j1; k <= j; ++k)
					{
						m_outline.lineTo(m_polygon[k]);
					}
				}
				j1 = j;
			}
		}
static void cleanupEffectList(QList<QGLColladaFxEffect*> &effects)
{
    while (effects.count())
    {
        delete effects.back();
        effects.pop_back();
    }
}
Beispiel #19
0
void make_branch( BillonTpl< arma::u8 > *initialSkel, const BillonTpl< arma::u8 > *reducedSkel, 
                  const BillonTpl< tlabel > *reducedLabeledSkel, QList< uint * > &touching ) {
	BillonTpl< arma::u8 >::iterator iterInitial = initialSkel->begin(),
	                                iterInitialEnd = initialSkel->end();
	                                
	BillonTpl< arma::u8 >::const_iterator iterReduced = reducedSkel->begin();
	
	/// step 1 : remove voxels that are activated in both images
	while( iterInitial != iterInitialEnd ) {
		if ( ( (*iterInitial) > 0 ) && ( (*iterReduced) > 0 ) ) {
			*iterInitial = 0 ;
		}
		iterInitial++ ;
		iterReduced++ ;
	}
	
	/// step 2 : identify voxels of the reduced label skeleton being adjacent to a voxel of a branch
	uint x,y,z,neighbor;
	for ( z = 0 ; z < reducedLabeledSkel->n_slices ; z++ )
		for ( y = 0 ; y < reducedLabeledSkel->n_rows ; y++ )
			for ( x = 0 ; x < reducedLabeledSkel->n_cols ; x++ ) {
				if ( (*reducedLabeledSkel)( y, x, z ) == 0 ) continue ;
				for ( neighbor = 0 ; neighbor < 27 ; neighbor++ )
					if ( ( y + (neighbor/9-1)) >= 0 		&& ( y + (neighbor/9-1)) < reducedSkel->n_rows &&
						 ( x + ( (neighbor%9)/3 -1 )) >= 0 	&& ( x + ( (neighbor%9)/3 -1 ))<reducedSkel->n_cols &&
						 ( z + ( neighbor % 3 -1 )) >= 0 	&& ( z + ( neighbor % 3 -1 ))<reducedSkel->n_slices ) {
						if ( (*initialSkel)( y + (neighbor/9-1), x + ( (neighbor%9)/3 -1 ), z + ( neighbor % 3 -1 ) ) ) {
							/// \note we do not update now initialSkel as we may get a side effect on the processing of the next voxels
							touching.append( new uint[3] ) ;
							touching.back()[ 0 ] = x ;
							touching.back()[ 1 ] = y ;
							touching.back()[ 2 ] = z ;
							assert( (*reducedLabeledSkel)( y + (neighbor/9-1), x + ( (neighbor%9)/3 -1 ), z + ( neighbor % 3 -1 ) ) == 0 ) ;
							break ;
						}
					}
			}
	/// step 3 : set active anew voxels being identified during the step 2
	QList< uint * >::ConstIterator voxelIter = touching.begin(),
	                               voxelEnd = touching.end() ;
	while ( voxelIter != voxelEnd ) {
		(*initialSkel)( (*voxelIter)[1], (*voxelIter)[0], (*voxelIter)[2] ) = 1 ;
		voxelIter++ ;
	}
}
void GanttChart::CreateReport()
{
    QSqlQuery query;
    query.exec("SELECT * FROM problem WHERE proj_id = " + QString::number(vecProjId[cbboxProj->currentIndex()]));
    MapTask mapTask;
    QList<GanttTask> lstTaskDep;     //контейнер из неначатых зависимых задач
    QDateTime tBegin, tEnd;
    try
    {
        while(query.next())
        {
            unsigned int id = query.record().value(Problem::iId).toInt();
            QString name = query.record().value(Problem::iName).toString();
            unsigned int timePlan = query.record().value(Problem::iTimePlan).toInt();
            unsigned int stat = query.record().value(Problem::iStatus).toInt();
            if (!stat)  //Если задача не начата
            {
                if (!ProbIsDepend(id))  //если задача независима
                {
                    tBegin = ProjBegin(vecProjId[cbboxProj->currentIndex()]);
                    tEnd = DateTimeAddHours(tBegin, timePlan);
                }
                else
                {
                    lstTaskDep.push_back(GanttTask(id, name, stat));
                    lstTaskDep.back().SetTimePlan(timePlan);
                    continue;
                }
            }
            else
            {
                tBegin = FuncDateFromRep(id, "MIN(date_begin)");
                if (stat == 1)  //если задача начата, но не закончена
                {
                    QDateTime t1 = FuncDateFromRep(id, "MAX(date_end)");
                    QDateTime t2 = DateTimeAddHours(tBegin, timePlan);;
                    tEnd = t1 > t2 ? t1 : t2;
                }
                else
                {
                    tEnd = FuncDateFromRep(id, "MAX(date_end)");
                }
            }
            mapTask.insert(id, GanttTask(id, name, stat, tBegin, tEnd));
        }
        AddTaskDep(mapTask, lstTaskDep);
        CreateHTML(mapTask);
        btnExport->setEnabled(true);
    }
    catch(Error &aErr)
    {
        QMessageBox::critical(0, QObject::tr("Error"), aErr.Text());
        repHTML->SetDefault("EmptyGantt.html");
        btnExport->setEnabled(false);
    }
}
Beispiel #21
0
void MyMoneyReport::validDateRange(QDate& _db, QDate& _de)
{
  _db = fromDate();
  _de = toDate();

  // if either begin or end date are invalid we have one of the following
  // possible date filters:
  //
  // a) begin date not set - first transaction until given end date
  // b) end date not set   - from given date until last transaction
  // c) both not set       - first transaction until last transaction
  //
  // If there is no transaction in the engine at all, we use the current
  // year as the filter criteria.

  if (!_db.isValid() || !_de.isValid()) {
    QList<MyMoneyTransaction> list = MyMoneyFile::instance()->transactionList(*this);
    QDate tmpBegin, tmpEnd;

    if (!list.isEmpty()) {
      qSort(list);
      // try to use the post dates
      tmpBegin = list.front().postDate();
      tmpEnd = list.back().postDate();
      // if the post dates are not valid try the entry dates
      if (!tmpBegin.isValid())
        tmpBegin = list.front().entryDate();
      if (!tmpEnd.isValid())
        tmpEnd = list.back().entryDate();
    }
    // make sure that we leave this function with valid dates no mather what
    if (!tmpBegin.isValid() || !tmpEnd.isValid() || tmpBegin > tmpEnd) {
      tmpBegin = QDate(QDate::currentDate().year(), 1, 1);   // the first date in the file
      tmpEnd = QDate(QDate::currentDate().year(), 12, 31);   // the last date in the file
    }
    if (!_db.isValid())
      _db = tmpBegin;
    if (!_de.isValid())
      _de = tmpEnd;
  }
  if (_db > _de)
    _db = _de;
}
Beispiel #22
0
// true if diagram intersects previous diagram at the begin
QList<QPair<int, bool> > FormSegmentator::findCycle(
		QList<QPair<int, bool> > const &polygon)
{
	Component firstDiagram = mAllComponents.at(polygon.at(0).first);
	Component lastDiagram = mAllComponents.at(polygon.back().first);
	int posFirst = polygon.at(0).second ? 0 : firstDiagram.size() - 1;
	int posLast = (!polygon.back().second) ? 0 : lastDiagram.size() - 1;
	int maxCycleSize = mAllComponents.size();
	QList<QPair<int, bool> > cycle;
	if (firstDiagram.at(posFirst).dist(lastDiagram.at(posLast))
			<= neighbourhoodRad)
	{
		return polygon;
	}
	for (int i = 0; i < mAllComponents.size(); i ++) {
		Component diagram = mAllComponents.at(i);
		if (diagram.back().dist(diagram.at(0)) <= neighbourhoodRad
				|| contains(polygon, i))
		{
			continue;
		}
		if (diagram.at(0).dist(lastDiagram.at(posLast)) <= neighbourhoodRad) {
			QList<QPair<int, bool> > newPolygon = polygon;
			newPolygon.push_back(QPair<int, bool>(i, true));
			newPolygon = findCycle(newPolygon);
			if (newPolygon.size() > 1 && newPolygon.size() <= maxCycleSize) {
				cycle = newPolygon;
				maxCycleSize = newPolygon.size();
			}
		}
		if (diagram.back().dist(lastDiagram.at(posLast)) <= neighbourhoodRad) {
			QList<QPair<int, bool> > newPolygon = polygon;
			newPolygon.push_back(QPair<int, bool>(i, false));
			newPolygon = findCycle(newPolygon);
			if (!newPolygon.empty() && newPolygon.size() <= maxCycleSize) {
				cycle = newPolygon;
				maxCycleSize = newPolygon.size();
			}
		}
	}
	return cycle;
}
Beispiel #23
0
/*! \brief Retrieves the episode data for a given series
    \param showDetail A ShowDetail object for which to retrieve an episode listing
    \return A QList of EpisodeDetail for the show requested
    \sa ShowDetail EpisodeDetail

    Using QNetworkAccessManager and QNetworkReply, a blocking connection is made
    to an XML service provider (in this case TVRage), for the episode listing of
    the show.
    Once the XML data is retrived, it is parsed with QXmlStreamReader and
    necessary EpisodeDetial objects are contructed and returned.
*/
QList< EpisodeDetail > ShowHolder::Fetch( ShowDetail const& showDetail )
{
    QEventLoop waitLoop;
    QNetworkAccessManager netManager;
    QNetworkReply* netReply = netManager.get( QNetworkRequest( QUrl( "http://services.tvrage.com/feeds/episode_list.php?sid=" + QString::number( showDetail.id ) ) ) );
    QObject::connect( netReply, SIGNAL( finished() ), &waitLoop, SLOT( quit() ) );
    waitLoop.exec();

    int currentSeason = 0;
    QList< EpisodeDetail > episodes;
    QXmlStreamReader xmlData;
    xmlData.addData( netReply->readAll() );

    while( !xmlData.atEnd() )
    {
        if( xmlData.readNextStartElement() )
        {
            if( xmlData.name() == "Special" )
                xmlData.skipCurrentElement();
            else if( xmlData.name() == "Season" )
                currentSeason = xmlData.attributes().value( "no" ).toString().toInt();
            else if( xmlData.name() == "episode" )
            {
                episodes.append( EpisodeDetail() );
                episodes.back().show = showDetail.name;
                episodes.back().season = currentSeason;
            }
            else if( xmlData.name() == "epnum" )
                episodes.back().show_episode = xmlData.readElementText().toInt();
            else if( xmlData.name() == "seasonnum" )
                episodes.back().episode = xmlData.readElementText().toInt();
            else if( xmlData.name() == "title" )
                episodes.back().title = xmlData.readElementText();
        }
    }

    netReply->deleteLater();

    qSort( episodes );

    return episodes;
}
bool CFileBrowser::copyFileToDevice(CLink * d, const QString & filename, const QString & targetDir){
    QList<QString> pathList;
    int err;
    QString target;
    char * buffer;
    int nbyte;
    pathList = filename.split('/');
    target = targetDir + "/" + pathList.back();
    qDebug("Target Dir: %s  Target: %s", targetDir.toStdString().c_str(), target.toStdString().c_str());
    if( (targetDir == "/app") ||
            (targetDir == "/app/flash") ||
            (target == "/app/.install") ){
        QFile f(filename);
        target = "/app/.install";
        f.open(QIODevice::ReadOnly);
        nbyte = f.size();
        buffer = (char*)malloc(nbyte);
        if( buffer == 0 ){
            return false;
        }
        f.read(buffer, nbyte);
        f.close();
        qDebug("Appfs create");
        err = Appfs::create(pathList.back().toStdString().c_str(),
                            buffer,
                            nbyte,
                            "/app",
                            d->driver());
        qDebug("Appfs returned %d", err);
        free(buffer);
    } else {
        qDebug("Copy file");
        err = d->copy(filename.toStdString(), target.toStdString(), 0777, true, updateProgress, 0);
    }
    if ( err < 0 ){
        qDebug("Err is %d %d", err, link_errno);
        //notify.execLinkError(link_errno);
        return false;
    }

    return true;
}
Highlight::Highlight(QString stringCode) {
	QList<QString> tokens = stringCode.split(" ");

	upperLeft[0] = tokens[0].toDouble();
	upperLeft[1] = tokens[1].toDouble();
	lowerRight[0] = tokens[2].toDouble();
	lowerRight[1] = tokens[3].toDouble();
	for (int i = 4; i < tokens.size() - 1; ++i)
		phoneIds.push_back(tokens[i]);
	value_ = tokens.back().toFloat();
}
Beispiel #26
0
int main ()
{
  QList<int> myQList;

  myQList.push_back(10);
  int n = 10;
  while (myQList.back() != 0)
  {
    assert(myQList.back() == n--);
    myQList.push_back ( myQList.back() -1 );
  }

  cout << "myQList contains:";
  for (QList<int>::iterator it=myQList.begin(); it!=myQList.end() ; ++it)
    cout << " " << *it;

  cout << endl;

  return 0;
}
Beispiel #27
0
void
Tab::addAttachments(QStringList const &fileNames) {
  QList<AttachmentPtr> attachmentsToAdd;
  for (auto &fileName : fileNames) {
    attachmentsToAdd << std::make_shared<Attachment>(fileName);
    attachmentsToAdd.back()->guessMIMEType();
  }

  m_attachmentsModel->addAttachments(attachmentsToAdd);
  resizeAttachmentsColumnsToContents();
}
void GroupSelectionBox::selectedGroupNames(QList<QString> &groupNames) const
{
	int itemCount = count();

	for (int i = 0; i < itemCount; ++i) {
		QListWidgetItem *listItem = item(i);
		if (listItem->checkState() == Qt::Checked) {
			groupNames.push_back(item(i)->text());
			std::cerr << "Adding selected item " << groupNames.back().toUtf8().constData() << std::endl;
		}
	}
}
void AnimalMovesWindow::on_pushButton_AddMove_clicked()
{
    // chose arbitraty move -> todo: fix
    const auto move = *m_db.getMoves().begin();
    QList<QStandardItem *> itemList;
    itemList.append(new QStandardItem("1"));
    itemList.append(new QStandardItem(move.first));
    itemList.append(new QStandardItem(move.second.getType()));
    itemList.back()->setEditable(false);
    itemList.append(new QStandardItem(move.second.getCategory()));
    itemList.back()->setEditable(false);
    itemList.append(new QStandardItem(QString::number(move.second.getBaseDamage())));
    itemList.back()->setEditable(false);
    itemList.append(new QStandardItem(QString::number(move.second.getAccuracy())));
    itemList.back()->setEditable(false);
    itemList.append(new QStandardItem(QString::number(move.second.getPriority())));
    itemList.back()->setEditable(false);

    m_movesModel.appendRow(itemList);
    ui->tableView_Moves->sortByColumn(0, Qt::AscendingOrder);
}
Beispiel #30
0
QList<pseudoWithColorStruct> settingToolClass::getListOfColorPseudo()
{
    QList<pseudoWithColorStruct> listOfColorPseudo;
    QList<QString> listOfPseudo = createStringListWithThisQVariantList(setting->value("listOfPseudoForColor", QList<QVariant>()).toList());
    QList<QString> listOfRed = createStringListWithThisQVariantList(setting->value("listOfRedForColor", QList<QVariant>()).toList());
    QList<QString> listOfGreen = createStringListWithThisQVariantList(setting->value("listOfGreenForColor", QList<QVariant>()).toList());
    QList<QString> listOfBlue = createStringListWithThisQVariantList(setting->value("listOfBlueForColor", QList<QVariant>()).toList());

    if(listOfPseudo.size() == listOfRed.size() && listOfRed.size() == listOfGreen.size() && listOfGreen.size() == listOfBlue.size())
    {
        for(int i = 0; i < listOfPseudo.size(); ++i)
        {
            listOfColorPseudo.push_back(pseudoWithColorStruct());
            listOfColorPseudo.back().pseudo = listOfPseudo.at(i);
            listOfColorPseudo.back().red = listOfRed.at(i).toInt();
            listOfColorPseudo.back().green = listOfGreen.at(i).toInt();
            listOfColorPseudo.back().blue = listOfBlue.at(i).toInt();
        }
    }

    return listOfColorPseudo;
}