コード例 #1
0
void UmlComponent::manageInterface(Token & token, FileIn & in) {
  QCString idref = token.valueOf("supplier");
  
  QMap<QCString, UmlItem *>::Iterator it = All.find(idref);
  int c = ((const char *) token.what())[0];
  
  if (it != All.end()) {
    if ((*it)->kind() == aClass) {
      if (c == 'i') {
	// provided
	QVector<UmlClass> provided = providedClasses();
	unsigned sz = provided.size();
	
	provided.resize(sz + 1);
	provided.insert(sz, (UmlClass *) *it);
	set_AssociatedClasses(realizingClasses(), provided, requiredClasses());
      }
      else {
	// realization
	QVector<UmlClass> realizing = realizingClasses();
	unsigned sz = realizing.size();
	
	realizing.resize(sz + 1);
	realizing.insert(sz, (UmlClass *) *it);
	set_AssociatedClasses(realizing, providedClasses(), requiredClasses());
      }
    }
  }
  else
    UnresolvedWithContext::add(this, idref, c);
    
  if (! token.closed())
    in.finish(token.what());
}
コード例 #2
0
void UmlComponent::solve(int context, QCString idref) {
  QMap<QCString, UmlItem *>::Iterator it = All.find(idref);
  
  if (it != All.end()) {
    if ((*it)->kind() == aClass) {
      if (context == 'i') {
	// provided
	QVector<UmlClass> provided = providedClasses();
	unsigned sz = provided.size();
	
	provided.resize(sz + 1);
	provided.insert(sz, (UmlClass *) *it);
	set_AssociatedClasses(realizingClasses(), provided, requiredClasses());
      }
      else {
	// realization
	QVector<UmlClass> realizing = realizingClasses();
	unsigned sz = realizing.size();
	
	realizing.resize(sz + 1);
	realizing.insert(sz, (UmlClass *) *it);
	set_AssociatedClasses(realizing, providedClasses(), requiredClasses());
      }
    }
  }
  else if (!FileIn::isBypassedId(idref))
    UmlCom::trace("component : unknown reference '" + idref + "'<br>");
}
コード例 #3
0
void FileListDownload::addVersionItem( QVector<VersionListItem*>& vct, VersionListItem* pItem )
{
    for( int i = 0; i < vct.size(); i++ )
    {
        QString strFilePath;
        if(pItem->m_strFileVersion.isEmpty())
        {
            if( vct[i]->m_fSizeKb <= pItem->m_fSizeKb )
            {
                vct.insert( i, pItem );
                return;
            }
        }
        else
        {
            if( VersionListItem::isGreaterVersion( pItem->m_strFileVersion, vct[i]->m_strFileVersion ) )
            {
                vct.insert( i, pItem );
                return;
            }
        }


    }

    vct.push_back(pItem);
}
コード例 #4
0
ファイル: main.cpp プロジェクト: MyandMine/GoodJob
void snakelong(Mat &dst,Point p){
    QVector<Point> snakeLineTemp;
    snakeLineTemp=snakeLine;
    snakeLine.insert(0,p);
    for(int a=1;a<snakeLength;a++){
        snakeLine.insert(a,snakeLineTemp.at(a-1));
        circle(dst,snakeLine.at(a),15,Scalar( 255, 0, 0 ),-1,8);
    }
}
コード例 #5
0
ファイル: cdatabase.cpp プロジェクト: jiacheng2012/311_tester
//***提取测试记录
QVector<testRecord> CDatabase::getTest(QString id)
{
    QVector<testRecord> t;

    QSqlQuery sql(_db);
    sql.exec("select * from test where meter='" + id + "'");
    int i=0;
    while(sql.next())
    {
        testRecord a;
        a._id       = sql.value(0).toInt();
        a._meter    = sql.value(1).toString();
        a._user     = sql.value(2).toString();
        a._date     = sql.value(3).toInt();
        a._inittest = sql.value(4).toInt();
        a._fulltest = sql.value(5).toInt();
        a._adjusttest   = sql.value(6).toInt();
        a._functiontest = sql.value(7).toInt();
        a._comment      = sql.value(8).toString();

        t.insert(i++,1,a);
    }

    return t;
}
コード例 #6
0
ファイル: vabstracttool.cpp プロジェクト: a-dilla/Valentina
/**
 * @brief AddRecord add record about tool in history.
 * @param id object id in container
 * @param toolType tool type
 * @param doc dom document container
 */
void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VPattern *doc)
{
    QVector<VToolRecord> *history = doc->getHistory();
    VToolRecord record = VToolRecord(id, toolType, doc->GetNameActivPP());
    if (history->contains(record))
    {
        return;
    }

    quint32 cursor = doc->getCursor();
    if (cursor <= 0)
    {
        history->append(record);
    }
    else
    {
        qint32 index = 0;
        for (qint32 i = 0; i<history->size(); ++i)
        {
            VToolRecord rec = history->at(i);
            if (rec.getId() == cursor)
            {
                index = i;
                break;
            }
        }
        history->insert(index+1, record);
    }
}
コード例 #7
0
ファイル: filemodel.cpp プロジェクト: arcean/text-editor
bool FileModel::insertRows(int row, int count, const QModelIndex &parent)
{
    if (count <= 0)
        return true; // Successfully added 0 rows.

    QVector<Entry *> entries = entryList;
    Entry *entry = NULL;
    QString data;
    QString name;
    QDateTime modification;

    for (int i = row; i < row + count; i++) {
        data = Utils::getTextFromFile(i);
        name = Utils::getFileName(i);
        modification = Utils::getModificationDate(i);

        entry = new Entry(name, data, modification, i);

        if (entry)
            entries.insert(i, entry);
    }

    QStringList entriesList;
    foreach (Entry *entry, entries) {
        Q_ASSERT(entry);
        if (selectedBuckets)
            entriesList << entry->getFileData();
        else
            entriesList << entry->getModificationDate().toString("dd MMMM yyyy");
    }
コード例 #8
0
ファイル: main.cpp プロジェクト: Ryzh/voc
void merge_vec_to_vec(const QVector<word_t*>& src, QVector<word_t*>& target)
{
	bool bInserted = false;
	for (int i = 0; i < src.size(); ++i)
	{
		for (int j = 0; j < target.size(); ++j)
		{
			if (src[i]->name == target[j]->name)
			{
				target[j]->marks += src[i]->marks;
				bInserted = true;
				break;
			}
			else if (src[i]->name > target[j]->name)
			{
				target.insert(j, new word_t(*src[i]));
				bInserted = true;
				break;
			}
		}
		if (!bInserted)
		{
			target.append(new word_t(*src[i]));
		}
	}
}
コード例 #9
0
void EziDebugScanChain::addToRegChain(QString clock ,int chainNum , const QStringList& reglist)
{
    QVector<QStringList> iregListVec  = m_iregChainStructure.value(clock) ;
    int i = 0 ;

    qDebug() << "EziDebug Info: The insert chain number:" << chainNum  ;

    if(iregListVec.count())
    {
        for(i = 0 ; i < iregListVec.count() ; i++)
        {
            // 加入到 未完毕的链
            if(i == chainNum)
            {
                QStringList ioriginRegList = iregListVec.at(i) ;
                ioriginRegList << reglist ;
                iregListVec.replace(i,ioriginRegList);
                m_iregChainStructure.insert(clock,iregListVec);
                break ;
            }
        }
        // 新增链
        if(i == iregListVec.count())
        {
            // 新增 链
            if(chainNum != iregListVec.count())
            {
                qDebug() << "EziDebug Error: the reglist is insert chain number:" << chainNum  <<" is not equal to total number:" << iregListVec.count() ;
            }
            iregListVec.insert(chainNum ,reglist);
            m_iregChainStructure.insert(clock,iregListVec);
        }
    }
    else
    {
       if(chainNum != 0)
       {
           qDebug() << "EziDebug Error: the reglist is insert chain number:" << chainNum  <<" is not right" ;
       }
       iregListVec.insert(0,reglist);
       m_iregChainStructure.insert(clock,iregListVec);
    }

    return ;
}
コード例 #10
0
Configuration* NewPointMethodLeppBisection::getConfiguration(){
    Configuration* ret;
    int i;
    Vertex* a;
    Vertex* b;
    Point* p;
    QVector<Point*> ps;
    QVector<int>    es;
    Triangle *t, *t1, *t2;

    QVector<Triangle*> lepp = this->tp->lepp();
    t1 = lepp.last();
    t2 = t1->neighbour(t1->getLongestEdge());

    if( t1->isConstrained(t1->getLongestEdge()) || (!t1->isConstrained(t1->getSecondLongestEdge()) && t2 != 0 && !t2->isConstrained(t2->getSecondLongestEdge())) ){
        i = t1->getLongestEdge();
        a = t1->vertex((i+1)%3);
        b = t1->vertex((i+2)%3);
        t = t1;
    }
    else{
        if( t1->isConstrained(t1->getSecondLongestEdge()) ){
            i = t1->getSecondLongestEdge();
            a = t1->vertex((i+1)%3);
            b = t1->vertex((i+2)%3);
            t = t1;
        }
        else if(t2 != 0 && t2->isConstrained(t2->getSecondLongestEdge())){
            i = t2->getSecondLongestEdge();
            a = t2->vertex((i+1)%3);
            b = t2->vertex((i+2)%3);
            t = t2;
        }
        else
            throw QString("aaaaaaaaaa");
    }

    p = Util::midpoint(a, b);
    ps.insert(0, p);
    es.insert(0, i);

    ret = new Configuration(this->mp, t, ps, es, Constant::BORDER_INCLUDED);

    return ret;
}
コード例 #11
0
bool QtTestModel::insertRows(int row, int count, const QModelIndex &parent)
{
    QAbstractItemModel::beginInsertRows(parent, row, row + count - 1);
    int cc = columnCount(parent);
    table.insert(row, count, QVector<QString>(cc));
    rCount = table.count();
    QAbstractItemModel::endInsertRows();
    return true;
}
コード例 #12
0
ファイル: scmdpathremovepoint.cpp プロジェクト: jobar/shimmer
void SCmdPathRemovePoint::undo()
{
    QVector<SEditPoint*>* editPoints = _manager->getEditPoints();
    SEditPointPath* editPoint = new SEditPointPath(_point);
    _scene->addItem(editPoint);
    editPoints->insert(_numPoint, editPoint);

    _graphicsItem->path()->insertPoint(_numPoint, _point);
    _graphicsItem->recomputeGeometry();
}
コード例 #13
0
ファイル: colorwidget.cpp プロジェクト: Qt-Widgets/uav
void ColorWidget::applyButtonSlot()
{
    QVector<QColor> colrVect;
    for(int i = 0 ; i < 12 ; i++)
    {
        colrVect.insert(i,ptrVector->at(i)->color());
    }
    emit setColor(this->ui->backLabel->color(),this->ui->textLabel->color(),
                  ui->gridLabel->color(),colrVect);
}
コード例 #14
0
ファイル: qtexttable.cpp プロジェクト: Fale/qtmoko
/*!
    \fn void QTextTable::insertColumns(int index, int columns)

    Inserts a number of \a columns before the column with the specified \a index.

    \sa insertRows() resize() removeRows() removeColumns() appendRows() appendColumns()
*/
void QTextTable::insertColumns(int pos, int num)
{
    Q_D(QTextTable);
    if (num <= 0)
	return;

    if (d->dirty)
        d->update();

    if (pos > d->nCols || pos < 0)
        pos = d->nCols;

//     qDebug() << "-------- insertCols" << pos << num;
    QTextDocumentPrivate *p = d->pieceTable;
    QTextFormatCollection *c = p->formatCollection();
    p->beginEditBlock();

    for (int i = 0; i < d->nRows; ++i) {
        int cell;
        if (i == d->nRows - 1 && pos == d->nCols)
            cell = d->fragment_end;
        else
            cell = d->grid[i*d->nCols + pos];
        QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), cell);
        QTextCharFormat fmt = c->charFormat(it->format);
        if (pos > 0 && pos < d->nCols && cell == d->grid[i*d->nCols + pos - 1]) {
            // cell spans the insertion place, extend it
            fmt.setTableCellColumnSpan(fmt.tableCellColumnSpan() + num);
            p->setCharFormat(it.position(), 1, fmt);
        } else {
            fmt.setTableCellRowSpan(1);
            fmt.setTableCellColumnSpan(1);
            Q_ASSERT(fmt.objectIndex() == objectIndex());
            int position = it.position();
            int cfmt = p->formatCollection()->indexForFormat(fmt);
            int bfmt = p->formatCollection()->indexForFormat(QTextBlockFormat());
            for (int i = 0; i < num; ++i)
                p->insertBlock(QTextBeginningOfFrame, position, bfmt, cfmt, QTextUndoCommand::MoveCursor);
        }
    }

    QTextTableFormat tfmt = format();
    tfmt.setColumns(tfmt.columns()+num);
    QVector<QTextLength> columnWidths = tfmt.columnWidthConstraints();
    if (! columnWidths.isEmpty()) {
        for (int i = num; i > 0; --i)
            columnWidths.insert(pos, columnWidths[qMax(0, pos-1)]);
    }
    tfmt.setColumnWidthConstraints (columnWidths);
    QTextObject::setFormat(tfmt);

//     qDebug() << "-------- end insertCols" << pos << num;
    p->endEditBlock();
}
コード例 #15
0
QVector<Command_Helper::defaultCMD_Structure> Command_Helper::getcmdstructure_TakeOff(const GPS_Position &currentGPS)
{
    QVector<defaultCMD_Structure> returnVector;

    defaultCMD_Structure defaultReturn;

    defaultReturn.parameterName = "Takeoff Pitch";

    returnVector.insert(0 , defaultReturn);

    defaultReturn.parameterName = "";
    defaultReturn.enabled = false;

    returnVector.insert(1 , defaultReturn);
    returnVector.insert(2 , defaultReturn);
    returnVector.insert(3 , defaultReturn);

    defaultReturn.enabled = true;

    defaultReturn.defaultValue = currentGPS.Latitude;
    defaultReturn.parameterName = "Latitude";
    returnVector.insert(4 , defaultReturn);

    defaultReturn.defaultValue = currentGPS.Longitude;
    defaultReturn.parameterName = "Longitude";
    returnVector.insert(5 , defaultReturn);

    defaultReturn.defaultValue = 5.0;
    defaultReturn.parameterName = "Altitude (m)";
    returnVector.insert(6 , defaultReturn);

    return(returnVector);

}
コード例 #16
0
/// <summary>
/// Refreshes the available window list
/// </summary>
void WindowLayerDialog::refreshClicked()
{
	// Generate the list of available windows and sort them. We cannot add them
	// directly to the combo box as the user data doesn't move when we reorder
	// the items.
	CaptureManager *mgr = App->getCaptureManager();
	mgr->cacheWindowList();
	QVector<WinId> windows = mgr->getWindowList();
	QVector<WindowSortData> sortData;
	sortData.reserve(windows.size());
	for(int i = 0; i < windows.count(); i++) {
		WinId winId = windows.at(i);
		const QString exe = mgr->getWindowExeFilename(winId);
		const QString title = mgr->getWindowTitle(winId);
		const QString itemName = QStringLiteral("[%1] %2").arg(exe).arg(title);

		// Alphabetically sort items as they are processed
		int j = 0;
		if(sortData.size()) {
			for(; j < sortData.size(); j++) {
				const WindowSortData &data = sortData.at(j);
				if(data.name.compare(itemName, Qt::CaseInsensitive) > 0) {
					j--;
					break;
				}
			}
			j++;
		}

		// Insert the item to our list
		WindowSortData data;
		data.name = itemName;
		data.exe = exe;
		data.title = title;
		if(j <= sortData.size())
			sortData.insert(j, data);
		else
			sortData.append(data);
	}
	mgr->uncacheWindowList();

	// Add the items to the actual combo box
	m_ui.windowCombo->clear();
	for(int i = 0; i < sortData.size(); i++) {
		const WindowSortData &data = sortData.at(i);
		m_ui.windowCombo->addItem(data.name);
		m_ui.windowCombo->setItemData(
			i, qVariantFromValue<QString>(data.exe), Qt::UserRole);
		m_ui.windowCombo->setItemData(
			i, qVariantFromValue<QString>(data.title), Qt::UserRole + 1);
	}
}
コード例 #17
0
ファイル: UmlBaseClass.cpp プロジェクト: gregsmirnov/bouml
const QVector<UmlComponent> UmlBaseClass::associatedComponents() {
  UmlCom::send_cmd(_identifier, assocComponentCmd);

  QVector<UmlComponent> result;
  unsigned n = UmlCom::read_unsigned();

  result.resize(n);

  for (unsigned index = 0; index != n; index += 1)
    result.insert(index, (UmlComponent *) UmlBaseItem::read_());

  return result;
}
コード例 #18
0
void UmlCom::read_item_list(QVector<UmlItem> & v)
{
  unsigned n = read_unsigned();
  
  v.resize(n);
  
#ifdef TRACE
  //cout << "UmlCom::read_item_list " << n << " items\n";
#endif
  
  for (unsigned index = 0; index != n; index += 1)
    v.insert(index, UmlBaseItem::read_());
}
コード例 #19
0
void UmlComponent::generalizeDependRealize(UmlItem * target, FileIn & in, int context, QCString label, QCString constraint) {
  if ((context == 3) && (target->kind() == aClass)) {
    // usage indicate a required interface
    QVector<UmlClass> required = requiredClasses();
    unsigned sz = required.size();
    
    required.resize(sz + 1);
    required.insert(sz, (UmlClass *) target);
    set_AssociatedClasses(realizingClasses(), providedClasses(), required);
  }
  else
    UmlItem::generalizeDependRealize(target, in, context, label, constraint);
}
コード例 #20
0
QVector<Command_Helper::defaultCMD_Structure> Command_Helper::getcmdstructure_SwarmTakeOff()
{
    QVector<defaultCMD_Structure> returnVector;

    defaultCMD_Structure defaultReturn;

    defaultReturn.parameterName = "";
    defaultReturn.enabled = false;

    returnVector.insert(0 , defaultReturn);
    returnVector.insert(1 , defaultReturn);
    returnVector.insert(2 , defaultReturn);
    returnVector.insert(3 , defaultReturn);
    returnVector.insert(4 , defaultReturn);
    returnVector.insert(5 , defaultReturn);

    defaultReturn.enabled = true;
    defaultReturn.defaultValue = 5.0;
    defaultReturn.parameterName = "Altitude (m)";
    returnVector.insert(6 , defaultReturn);

    return(returnVector);

}
コード例 #21
0
void QDeclarativeChangeSet::applyChanges(QVector<Change> &changes)
{
    QVector<Insert>::iterator insert = m_inserts.begin();
    QVector<Change>::iterator change = m_changes.begin();
    for (QVector<Change>::iterator cit = changes.begin(); cit != changes.end(); ++cit) {
        for (; insert != m_inserts.end() && insert->end() < cit->index; ++insert) {}
        for (; insert != m_inserts.end() && insert->index < cit->end(); ++insert) {
            const int offset = insert->index - cit->index;
            const int count = cit->count + cit->index - insert->index - insert->count;
            if (offset == 0) {
                cit->index = insert->index + insert->count;
                cit->count = count;
            } else {
                cit = changes.insert(++cit, Change(insert->index + insert->count, count));
                --cit;
                cit->count = offset;
            }
        }

        for (; change != m_changes.end() && change->index + change->count < cit->index; ++change) {}
        if (change == m_changes.end() || change->index > cit->index + cit->count) {
            if (cit->count > 0) {
                change = m_changes.insert(change, *cit);
                ++change;
            }
        } else {
            if (cit->index < change->index) {
                change->count += change->index - cit->index;
                change->index = cit->index;
            }

            if (cit->index + cit->count > change->index + change->count) {
                change->count = cit->index + cit->count - change->index;
                QVector<Change>::iterator rbegin = change;
                QVector<Change>::iterator rend = ++rbegin;
                for (; rend != m_changes.end() && rend->index <= change->index + change->count; ++rend) {
                    if (rend->index + rend->count > change->index + change->count)
                        change->count = rend->index + rend->count - change->index;
                }
                if (rbegin != rend) {
                    change = m_changes.erase(rbegin, rend);
                    --change;
                }
            }
        }
    }
}
コード例 #22
0
void UmlComponent::solveGeneralizationDependencyRealization(int context, QCString idref, QCString label, QCString constraint) {
  QMap<QCString, UmlItem *>::Iterator it;
  
  if ((context == 3) &&
      ((it = All.find(idref)) != All.end()) &&
      ((*it)->kind() == aClass)) {
    // usage indicate resuired interface
    QVector<UmlClass> required = requiredClasses();
    unsigned sz = required.size();
    
    required.resize(sz + 1);
    required.insert(sz, (UmlClass *) *it);
    set_AssociatedClasses(realizingClasses(), providedClasses(), required);
  }
  else
    UmlItem::solveGeneralizationDependencyRealization(context, idref, label, constraint);
}
コード例 #23
0
    void insertModule(int i, QString module)
    {
		_lists.insert(i, List());

		// insert new option
		if(_lists.size() > _ld->levelOptionsCount())
		{
            QVector<BtMiniLevelOption> os;
			for(int ii = 0; ii < _ld->levelOptionsCount(); ++ii)
				os.append(_ld->levelOption(ii));

			os.insert(i, _ld->levelOption(i));

			for(int ii = 0; ii < os.size(); ++ii)
				_ld->setLevelOption(ii, os[ii]);
		}

		setupModule(i, module);
    }
コード例 #24
0
ファイル: avarlistmodel.cpp プロジェクト: pgregory/giselle
void AvarListModel::populateModel()
{
    avarList.clear();

    try
    {
        _maxColumns = 0;
        // Build a list of AvarItems from the list of avars passed.
        for(QList<int>::const_iterator av = m_avarRefs.begin(), end = m_avarRefs.end(); av != end; ++av)
        {
            QString name = DataManager::instance().getAvarNameFromRef(*av);
            QList<Keyframe> kfs;
            DataManager::instance().getKeyframesFromRef(*av, kfs);

            // Now build a list of ints, over the span, filling in valid keyframes where available.
            QVector<int> keyframes;

            keyframes.insert(0, (_endFrame-_startFrame)+1, LUA_NOREF);
            if(kfs.size() > 0)
            {
                Keyframe kf;
                foreach(kf, kfs)
                {
                    if(kf.frame >= _startFrame && kf.frame <= _endFrame)
                        keyframes[kf.frame-_startFrame] = kf.ref;
                }
            }
            _maxColumns = (_endFrame - _startFrame) + 1;
            avarList << AvarListItem(*av, name, keyframes);
        }
    }
    catch(LuaError& e)
    {
        QMessageBox box;
        box.setText(e.what());
        box.exec();
    }
}
コード例 #25
0
ファイル: tst_exceptionsafety.cpp プロジェクト: mpvader/qt
void tst_ExceptionSafety::exceptionVector() {

    {
        QVector<FlexibleThrowerSmall> vector;
        QVector<FlexibleThrowerSmall> vector2;
        QVector<FlexibleThrowerSmall> vector3;

        for (int i = 0; i<10; i++)
            vector.append( FlexibleThrowerSmall(i) );

        try {
            throwType = ThrowAtCopy;
            vector.append( FlexibleThrowerSmall(10));
        } catch (...) {
        }
        QCOMPARE( vector.size(), 10 );

        try {
            throwType = ThrowAtCopy;
            vector.prepend( FlexibleThrowerSmall(10));
        } catch (...) {
        }
        QCOMPARE( vector.at(0).value(), 0 );
        QCOMPARE( vector.size(), 10 );

        try {
            throwType = ThrowAtCopy;
            vector.insert( 8, FlexibleThrowerSmall(10));
        } catch (...) {
        }
        QCOMPARE( vector.at(7).value(), 7 );
        QCOMPARE( vector.at(8).value(), 8 );
        QCOMPARE( vector.size(), 10 );

        try {
            throwType = ThrowAtCopy;
            vector3 = vector;
        } catch (...) {
        }
        QCOMPARE( vector.at(0).value(), 0 );
        QCOMPARE( vector.at(7).value(), 7 );
        QCOMPARE( vector.size(), 10 );
        QCOMPARE( vector3.at(0).value(), 0 );
        QCOMPARE( vector3.at(7).value(), 7 );
        QCOMPARE( vector3.size(), 10 );

        try {
            throwType = ThrowAtCopy;
            vector3.append( FlexibleThrowerSmall(11) );
        } catch (...) {
        }
        QCOMPARE( vector.at(0).value(), 0 );
        QCOMPARE( vector.at(7).value(), 7 );
        QCOMPARE( vector.size(), 10 );
        QCOMPARE( vector3.at(0).value(), 0 );
        QCOMPARE( vector3.at(7).value(), 7 );

        try {
            vector2.clear();
            vector2.append( FlexibleThrowerSmall(11));
            throwType = ThrowAtCopy;
            vector3 = vector+vector2;
        } catch (...) {
        }
        QCOMPARE( vector.at(0).value(), 0 );
        QCOMPARE( vector.at(7).value(), 7 );
        QCOMPARE( vector.size(), 10 );

        // check that copy on write works atomar
        vector2.clear();
        vector2.append( FlexibleThrowerSmall(11));
        vector3 = vector+vector2;
        try {
            throwType = ThrowAtCreate;
            vector3[7]=FlexibleThrowerSmall(12);
        } catch (...) {
        }
        QCOMPARE( vector.at(7).value(), 7 );
        QCOMPARE( vector.size(), 10 );
        QCOMPARE( vector3.at(7).value(), 7 );
        QCOMPARE( vector3.size(), 11 );

        try {
            throwType = ThrowAtCreate;
            vector.resize(15);
        } catch (...) {
        }
        QCOMPARE( vector.at(7).value(), 7 );
        QCOMPARE( vector.size(), 10 );

        try {
            throwType = ThrowAtCreate;
            vector.resize(15);
        } catch (...) {
        }
        QCOMPARE( vector.at(7).value(), 7 );
        QCOMPARE( vector.size(), 10 );

        try {
            throwType = ThrowLater;
            vector.fill(FlexibleThrowerSmall(1), 15);
        } catch (...) {
        }
        QCOMPARE( vector.at(0).value(), 0 );
        QCOMPARE( vector.size(), 10 );


    }
    QCOMPARE(objCounter, 0 ); // check that every object has been freed
}
コード例 #26
0
ファイル: view.hpp プロジェクト: mbouzid/mvc_qt_calculator
		view( QWidget * top = 0 ): m_top(top)
		{

		
			m_numpad = new QWidget(m_top);
			m_operators = new QWidget(m_top) ;
			
			// output
			m_output = new QLineEdit("0",m_top);
			
			m_output->setReadOnly(true);
			m_output->setStyleSheet("QLineEdit { background-color: #8B8B7A; border-style: outset; border-width: 2px; border-color: #8B8B7A ; color: white ; }");
			
			// result output
			m_result = new QLineEdit("0",m_top);
			m_result->setReadOnly(true);
			m_result->setStyleSheet("QLineEdit { background-color: #8B8B7A; border-style: outset; border-width: 2px; border-color: #8B8B7A ; color: white ; }");
		
		
			// numpad grid
			m_grid_numpad = new QGridLayout(m_numpad) ;
			
			
			
			// initialize buttons
			for( int i=0 ; i<10 ; ++i )
			{
				m_figures.insert(i,new QPushButton(QString::number(i),m_numpad) );
				m_figures.at(i)->setStyleSheet(" QPushButton { background-color:  #333333 ; color: white ; }");
			}
			
			m_comma = new QPushButton(",",m_numpad);
			m_comma->setStyleSheet("QPushButton { background-color:  #333333 ; color: white ; }");

			
			int j = 9 ;
			while ( j>=1 )
			{
				for ( int i = 0 ; i < 3 ; ++i )
				{	
					for ( int k = 2 ; k >=0 ; --k )
					{
						m_grid_numpad->addWidget(m_figures[j],i,k);
						--j;
					}
				}
			}
			
			
			m_grid_numpad->addWidget(m_figures[0],3,0,1,2);
			m_grid_numpad->addWidget(m_comma,3,2,1,1);
			m_grid_numpad->setMargin(0); 
			m_grid_numpad->setVerticalSpacing(0) ;
			m_grid_numpad->setHorizontalSpacing(0) ;
			
			

			m_addition = new QPushButton("+",m_operators);
			m_substraction = new QPushButton("-",m_operators);
			m_multiplication = new QPushButton("*",m_operators);
			m_division = new QPushButton("/",m_operators);
			m_r_bracket = new QPushButton("(",m_operators);
			m_l_bracket = new QPushButton(")",m_operators);
			m_square = new QPushButton("^2",m_operators);
			m_equal = new QPushButton("=",m_operators);
			
			
			//style 
			m_addition->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_substraction->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_multiplication->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_division->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_r_bracket->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_l_bracket->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_square->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			m_equal->setStyleSheet("QPushButton { background-color: #333333 ; color: white ; }");
			
			
			m_grid_operators = new QGridLayout(m_operators) ;
			m_grid_operators->setMargin(0); 
			m_grid_operators->setVerticalSpacing(0) ;
			m_grid_operators->setHorizontalSpacing(0) ;
			
			
			m_grid_operators->addWidget(m_addition,0,0);
			m_grid_operators->addWidget(m_substraction,0,1);
			m_grid_operators->addWidget(m_multiplication,1,0);
			m_grid_operators->addWidget(m_division,1,1);
			m_grid_operators->addWidget(m_r_bracket,2,0);
			m_grid_operators->addWidget(m_l_bracket,2,1);
			m_grid_operators->addWidget(m_square,3,0);
			m_grid_operators->addWidget(m_equal,3,1);
			
	
			// main layout
			m_box = new QGridLayout(m_top);
		
			
			m_box->addWidget(m_output,1,1,1,3);
			m_box->addWidget(m_result,2,2,1,2);
			m_box->addWidget(m_numpad,4,1,1,1);
			m_box->addWidget(m_operators,4,3,1,1);
			m_box->setRowStretch(0,1);
			m_box->setRowStretch(3,1);
			m_box->setRowStretch(5,1);
			
			m_box->setColumnStretch(0,1);
			m_box->setColumnStretch(0,1);
			m_box->setColumnStretch(2,1);
			
			m_box->setColumnStretch(4,1);
			
			QObject::connect(m_addition,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_substraction,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_multiplication,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_division,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_r_bracket,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_l_bracket,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_square,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_equal,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			QObject::connect(m_comma,SIGNAL(clicked()),&m_controller,SLOT(add()) );
			

			for( int i=0 ; i<10 ; ++i )
			{
				QObject::connect(m_figures[i],SIGNAL(clicked()),&m_controller,SLOT(add()));
			}
			
			QObject::connect(&m_controller,SIGNAL(result(QString)),m_result,SLOT(setText(QString)));
			QObject::connect(&m_controller,SIGNAL(change_text(QString)),m_output,SLOT(setText(QString)));
			top->show();
		
		}
コード例 #27
0
ファイル: widgettablechart.cpp プロジェクト: aclar48/projects
void WidgetTableChart::on_pushButtonSaveTableData_clicked()
{
    //make sure that the table is not empty
    if (ui->listBarChartMunicipality->selectedItems().isEmpty()
            || ui->listBarChartYears->selectedItems().isEmpty())
    {
        QMessageBox msgBox;
        msgBox.setText("Please select data before saving.");
        msgBox.exec();
        return;
    }

    //first, obtain the names of the municipalities that are selected.

    QVector<QString> selectedMuniList;
    QList<QListWidgetItem*> tempMuniList = ui->listBarChartMunicipality->selectedItems();

    for(QList<QListWidgetItem*>::Iterator it = tempMuniList.begin(); it != tempMuniList.end(); ++it) {
        QListWidgetItem *tempItem = *it;
        selectedMuniList.append(_meas->findMuni(tempItem->text()).name());
    }

    //next, obtain the years that are selected
    QVector<QString> selectedYearList;
    QList<QListWidgetItem*> tempYearList = ui->listBarChartYears->selectedItems();

    int i = 0;
    for(QList<QListWidgetItem*>::Iterator it = tempYearList.begin(); it != tempYearList.end(); ++it) {
        QListWidgetItem *tempItem = *it;
        if (i == 0)
            selectedYearList.append(tempItem->text());
        else
        {
            int j;
            for (j = 0; j < i; ++j){
                if((tempItem->text().compare(selectedYearList.at(j))) < 0)
                {
                     selectedYearList.insert(j, tempItem->text());
                     j=i+1;
                }
            }
            if (j == i)
            {
                selectedYearList.append(tempItem->text());
            }
        }
        ++i;
    }

    //Add all the text necessary to a string in csv format
    QString csvformat;

    //Add the column headers
    csvformat.append(",");
    for (QVector<QString>::Iterator it = selectedYearList.begin(); it != selectedYearList.end(); ++it )
    {
        csvformat.append(*it);
        csvformat.append(",");
    }
    csvformat.append("\n");

    //add each row starting with the municipality names
    for (QVector<QString>::Iterator it = selectedMuniList.begin(); it != selectedMuniList.end(); ++it)
    {
        QString muniName = *it;
        csvformat.append(muniName);
        csvformat.append(",");
        for (QVector<QString>::Iterator jt = selectedYearList.begin(); jt != selectedYearList.end(); ++jt )
        {
            try {
                csvformat.append(_meas->findMuni(muniName).getYear(*jt).toString().remove(0,5));
            }
            catch (std::string s)
            {
                csvformat.append("NA");
            }

            csvformat.append(",");
        }
        csvformat.append("\n");
    }

    //open a qfile dialog to let the user enter a file name
    QString fileName = QFileDialog::getSaveFileName(this,"Save File", _dirname,"*.csv");
    //open the file to write to
    QFile file(fileName);
    file.open(QIODevice::WriteOnly);
    //using a text stream, write the string out to the file.
    QTextStream out(&file);
    out << csvformat;
    out.flush();

    //save the directory the file was saved in so that the file dialog will open there next time
    fileName.chop(fileName.length()-fileName.lastIndexOf("/"));
    _dirname = fileName;

}
コード例 #28
0
// calculateVectorInput(QVector<ExpressionElement> input)
//
//
//
ExpressionElement StringCalculator::calculateVectorInput(QVector<ExpressionElement> input)
{
    // Copy the old list that we will boil down to
    // a single expression element.
    QVector<ExpressionElement> modifiableVector = QVector<ExpressionElement>(input);

    // Put in implied constants at the beginning
    if(!input.at(0).isNumber_)
    {
        if(input.at(0).op_ == "-" || input.at(0).op_ == "+") // Allow for negative numbers
        {
            modifiableVector.insert(0, ExpressionElement(0));
        }
        else if(input.at(0).op_ == "*" || input.at(0).op_ == "/" || input.at(0).op_ == "^") // Complain when we begin with these
        {
            // SYNTAX ERROR
            throw 101;
        }
        else // Allow for stuff like "sin(45)" and "log(100)"
        {
            modifiableVector.insert(0, ExpressionElement(1));
        }
    }

    // Put in implied constants at the end.
    if(!input.at(input.size()-1).isNumber_)
    {
        if(input.at(input.size()-1).op_ == "pi"
                || input.at(input.size()-1).op_ == "e"
                || input.at(input.size()-1).op_ == "!")
        {
            modifiableVector.append(ExpressionElement(1));
        }
        else
        {
            // SYNTAX ERROR
            throw 102;
        }
    }

    if(modifiableVector.size() == 2)
    {
        // INTERNAL ERROR: It's impossible to have an ExpressionElement vector
        // of size 2
        throw 100;
    }

    // BEGIN LOOPS
    // --------------------------------
    // Loop through every operation, in the order defined by OP_ORDER
    for(int opIndex = 0; opIndex < OP_ORDER.size(); opIndex++)
    {

        int opCount = 0; // Represents the number of this type of operation in the list.

        for(int e = 0; e < modifiableVector.size(); e++)
        {
            ExpressionElement elem = modifiableVector[e];
            if(!elem.isNumber_)
            {
                if(elem.op_ == OP_ORDER[opIndex]) // Check to see if this is our operation
                {
                    opCount++;
                }
            }
        }

        // Go through every operation of this type first and calculate it out.
        while(opCount > 0)
        {
            int i = 0; // Iterator for each operation
            while(i < modifiableVector.size()-2)
            {
                // Get the element in front of this one, and check if it's an operation.
                ExpressionElement opElement = modifiableVector[i+1];
                if(!opElement.isNumber_)
                {
                    if(opElement.op_ == OP_ORDER[opIndex])
                    {
                        // TODO:
                        // We need a try catch here for when the calc doesn't work
                        QVector<ExpressionElement> calculatedElements = opElement.calc(modifiableVector[i], modifiableVector[i+2]);

                        // Remove these 3 and substitute my own elements.
                        modifiableVector.removeAt(i+2);
                        modifiableVector.removeAt(i+1);
                        modifiableVector.removeAt(i);

                        for(int j = calculatedElements.size() - 1; j >= 0; j--)
                        {
                            // Insert the elements in reverse order. This is due to how insertion works.
                            modifiableVector.insert(i, calculatedElements.at(j));
                        }
                    }
                    opCount--; // We removed the element from the list
                }
                i++;
            }
        }
    }
    // --------------------------------
    // END LOOPS
    return modifiableVector[0];
}
コード例 #29
0
void OsmAnd::RoutePlanner::splitRoadsAndAttachRoadSegments( OsmAnd::RoutePlannerContext::CalculationContext* context, QVector< std::shared_ptr<RouteSegment> >& route )
{
    for(auto itSegment = iteratorOf(route); itSegment; ++itSegment)
    {
        auto segment = *itSegment;
        /*TODO:GC
        if (ctx.checkIfMemoryLimitCritical(ctx.config.memoryLimitation)) {
            ctx.unloadUnusedTiles(ctx.config.memoryLimitation);
        }
        */
        //TODO:GC:checkAndInitRouteRegion(context, segment->road);

        const bool isIncrement = segment->startPointIndex < segment->endPointIndex;
        for(auto pointIdx = segment->startPointIndex; pointIdx != segment->endPointIndex; isIncrement ? pointIdx++ : pointIdx--)
        {
            const auto nextIdx = (isIncrement ? pointIdx + 1 : pointIdx - 1);

            if (pointIdx == segment->startPointIndex)
                attachRouteSegments(context, route, itSegment.current, pointIdx, isIncrement);

            if (nextIdx != segment->endPointIndex)
                attachRouteSegments(context, route, itSegment.current, nextIdx, isIncrement);

            if (nextIdx < 0 || nextIdx >= segment->attachedRoutes.size())
                continue;
            if (nextIdx >= 0 && nextIdx < segment->attachedRoutes.size() && nextIdx != segment->endPointIndex && !segment->road->isRoundabout())
            {
                const auto& attachedRoutes = segment->attachedRoutes[qAbs(static_cast<int64_t>(nextIdx) - segment->startPointIndex)];

                auto before = segment->getBearing(nextIdx, !isIncrement);
                auto after = segment->getBearing(nextIdx, isIncrement);
                auto straight = qAbs(Utilities::normalizedAngleDegrees(before + 180.0 - after)) < (double)MinTurnAngle;
                auto isSplit = false;

                // split if needed
                for(const auto& attachedSegment : constOf(attachedRoutes))
                {
                    auto diff = Utilities::normalizedAngleDegrees(before + 180.0 - attachedSegment->getBearingBegin());
                    if (qAbs(diff) <= (double)MinTurnAngle)
                        isSplit = true;
                    else if (!straight && qAbs(diff) < 100.0)
                        isSplit = true;
                }

                if (isSplit)
                {
                    std::shared_ptr<RouteSegment> split(new RouteSegment(segment->road, nextIdx, segment->endPointIndex));
                    //TODO:split.copyPreattachedRoutes(segment, qAbs(nextIdx - segment->startPointIndex));?
                    segment->_endPointIndex = nextIdx;
                    segment->_attachedRoutes.resize(qAbs(static_cast<int64_t>(segment->_endPointIndex) - static_cast<int64_t>(segment->_startPointIndex)) + 1);

                    itSegment.set(route.insert((++itSegment).current, split));
                    itSegment.update(route);
                    
                    // switch current segment to the splited
                    segment = split;
                }
            }
        }
    }
}
コード例 #30
0
int runMoc(int _argc, char **_argv)
{
    bool autoInclude = true;
    Preprocessor pp;
    Moc moc;
    pp.macros["Q_MOC_RUN"];
    pp.macros["__cplusplus"];
    QByteArray filename;
    QByteArray output;
    FILE *in = 0;
    FILE *out = 0;
    bool ignoreConflictingOptions = false;

    QVector<QByteArray> argv;
    argv.resize(_argc - 1);
    for (int n = 1; n < _argc; ++n)
        argv[n - 1] = _argv[n];
    int argc = argv.count();

    for (int n = 0; n < argv.count(); ++n) {
        if (argv.at(n).startsWith('@')) {
            QByteArray optionsFile = argv.at(n);
            optionsFile.remove(0, 1);
            if (optionsFile.isEmpty())
                error("The @ option requires an input file");
            QFile f(QString::fromLatin1(optionsFile.constData()));
            if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
                error("Cannot open options file specified with @");
            argv.remove(n);
            while (!f.atEnd()) {
                QByteArray line = f.readLine().trimmed();
                if (!line.isEmpty())
                    argv.insert(n++, line);
            }
        }
    }

    argc = argv.count();

    for (int n = 0; n < argc; ++n) {
        QByteArray arg(argv[n]);
        if (arg[0] != '-') {
            if (filename.isEmpty()) {
                filename = arg;
                continue;
            }
            error("Too many input files specified");
        }
        QByteArray opt = arg.mid(1);
        bool more = (opt.size() > 1);
        switch (opt[0]) {
        case 'o': // output redirection
            if (!more) {
                if (!(n < argc-1))
                    error("Missing output file name");
                output = argv[++n];
            } else
                output = opt.mid(1);
            break;
        case 'E': // only preprocessor
            pp.preprocessOnly = true;
            break;
        case 'i': // no #include statement
            if (more)
                error();
            moc.noInclude        = true;
            autoInclude = false;
            break;
        case 'f': // produce #include statement
            if (ignoreConflictingOptions)
                break;
            moc.noInclude        = false;
            autoInclude = false;
            if (opt[1])                        // -fsomething.h
                moc.includeFiles.append(opt.mid(1));
            break;
        case 'p': // include file path
            if (ignoreConflictingOptions)
                break;
            if (!more) {
                if (!(n < argc-1))
                    error("Missing path name for the -p option.");
                moc.includePath = argv[++n];
            } else {
                moc.includePath = opt.mid(1);
            }
            break;
        case 'I': // produce #include statement
            if (!more) {
                if (!(n < argc-1))
                    error("Missing path name for the -I option.");
                pp.includes += Preprocessor::IncludePath(argv[++n]);
            } else {
                pp.includes += Preprocessor::IncludePath(opt.mid(1));
            }
            break;
        case 'F': // minimalistic framework support for the mac
            if (!more) {
                if (!(n < argc-1))
                    error("Missing path name for the -F option.");
                Preprocessor::IncludePath p(argv[++n]);
                p.isFrameworkPath = true;
                pp.includes += p;
            } else {
                Preprocessor::IncludePath p(opt.mid(1));
                p.isFrameworkPath = true;
                pp.includes += p;
            }
            break;
        case 'D': // define macro
            {
                QByteArray name;
                QByteArray value("1");
                if (!more) {
                    if (n < argc-1)
                        name = argv[++n];
                } else
                    name = opt.mid(1);
                int eq = name.indexOf('=');
                if (eq >= 0) {
                    value = name.mid(eq + 1);
                    name = name.left(eq);
                }
                if (name.isEmpty())
                    error("Missing macro name");
                Macro macro;
                macro.symbols += Symbol(0, PP_IDENTIFIER, value);
                pp.macros.insert(name, macro);

            }
            break;
        case 'U':
            {
                QByteArray macro;
                if (!more) {
                    if (n < argc-1)
                        macro = argv[++n];
                } else
                    macro = opt.mid(1);
                if (macro.isEmpty())
                    error("Missing macro name");
                pp.macros.remove(macro);

            }
            break;
        case 'v':  // version number
            if (more && opt != "version")
                error();
            fprintf(stderr, "Qt Meta Object Compiler version %d (Qt %s)\n",
                    mocOutputRevision, QT_VERSION_STR);
            return 1;
        case 'n': // don't display warnings
            if (ignoreConflictingOptions)
                break;
            if (opt != "nw")
                error();
            moc.displayWarnings = false;
            break;
        case 'h': // help
            if (more && opt != "help")
                error();
            else
                error(0); // 0 means usage only
            break;
        case '-':
            if (more && arg == "--ignore-option-clashes") {
                // -- ignore all following moc specific options that conflict
                // with for example gcc, like -pthread conflicting with moc's
                // -p option.
                ignoreConflictingOptions = true;
                break;
            }
            // fall through
        default:
            error();
        }
    }


    if (autoInclude) {
        int ppos = filename.lastIndexOf('.');
        moc.noInclude = (ppos >= 0
                         && tolower(filename[ppos + 1]) != 'h'
                         && tolower(filename[ppos + 1]) != QDir::separator().toLatin1()
                        );
    }
    if (moc.includeFiles.isEmpty()) {
        if (moc.includePath.isEmpty()) {
            if (filename.size()) {
                if (output.size())
                    moc.includeFiles.append(combinePath(filename, output));
                else
                    moc.includeFiles.append(filename);
            }
        } else {
            moc.includeFiles.append(combinePath(filename, filename));
        }
    }

    if (filename.isEmpty()) {
        filename = "standard input";
        in = stdin;
    } else {
#if defined(_MSC_VER) && _MSC_VER >= 1400
		if (fopen_s(&in, filename.data(), "rb")) {
#else
        in = fopen(filename.data(), "rb");
		if (!in) {
#endif
            fprintf(stderr, "moc: %s: No such file\n", (const char*)filename);
            return 1;
        }
        moc.filename = filename;
    }

    moc.currentFilenames.push(filename);

    // 1. preprocess
    moc.symbols = pp.preprocessed(moc.filename, in);
    fclose(in);

    if (!pp.preprocessOnly) {
        // 2. parse
        moc.parse();
    }

    // 3. and output meta object code

    if (output.size()) { // output file specified
#if defined(_MSC_VER) && _MSC_VER >= 1400
        if (fopen_s(&out, output.data(), "w"))
#else
        out = fopen(output.data(), "w"); // create output file
        if (!out)
#endif
        {
            fprintf(stderr, "moc: Cannot create %s\n", (const char*)output);
            return 1;
        }
    } else { // use stdout
        out = stdout;
    }

    if (pp.preprocessOnly) {
        fprintf(out, "%s\n", composePreprocessorOutput(moc.symbols).constData());
    } else {
        if (moc.classList.isEmpty())
            moc.warning("No relevant classes found. No output generated.");
        else
            moc.generate(out);
    }

    if (output.size())
        fclose(out);

    return 0;
}

QT_END_NAMESPACE

int main(int _argc, char **_argv)
{
    return QT_PREPEND_NAMESPACE(runMoc)(_argc, _argv);
}