Example #1
0
static void markDomain(CT& ct,FaceHandle start,int index,QList<Edge>& border)
{
	QList<FaceHandle> queue;
	queue.append(start);
	while(!queue.isEmpty()) {
		FaceHandle fh=queue.takeFirst();
		fh->info().nestingLevel=index;
		for(auto i=0; i<3; ++i) {
			FaceHandle n=fh->neighbor(i);
			if(!n->info().isNested()) {
				Edge e(fh,i);
				if(ct.is_constrained(e))
					border.append(e);
				else
					queue.append(n);
			}
		}
	}
}
Example #2
0
void HelpPage::onHandleUnsupportedContent(QNetworkReply *reply)
{
    // sub resource of this page
    if (m_loadingUrl != reply->url()) {
        qWarning() << "Resource" << reply->url().toEncoded() << "has unknown Content-Type, will be ignored.";
        reply->deleteLater();
        return;
    }

    // set a default error string we are going to display
    QString errorString = HelpViewer::tr("Unknown or unsupported content.");
    if (reply->error() == QNetworkReply::NoError) {
        // try to open the url using using the desktop service
        if (QDesktopServices::openUrl(reply->url())) {
            reply->deleteLater();
            return;
        }
        // seems we failed, now we show the error page inside creator
    } else {
        errorString = reply->errorString();
    }

    const QString html = QString::fromUtf8(LocalHelpManager::loadErrorMessage(reply->url(),
                                                                              errorString));

    // update the current layout
    QList<QWebFrame*> frames;
    frames.append(mainFrame());
    while (!frames.isEmpty()) {
        QWebFrame *frame = frames.takeFirst();
        if (frame->url() == reply->url()) {
            frame->setHtml(html, reply->url());
            return;
        }

        QList<QWebFrame *> children = frame->childFrames();
        foreach (QWebFrame *frame, children)
            frames.append(frame);
    }

    if (m_loadingUrl == reply->url())
        mainFrame()->setHtml(html, reply->url());
}
///
/// Delete serverList entry
///
void SoundLibraryRepositoryDialog::on_DeleteBtn_clicked()
{
	QList<QListWidgetItem *> selectedItems;
	selectedItems = ServerListWidget->selectedItems();

	//std::list<std::string>::const_iterator cur_Server;
	H2Core::Preferences *pPref = H2Core::Preferences::get_instance();

	while( ! selectedItems.isEmpty() ){

		QString selText;
	
		selText = selectedItems.takeFirst()->text();

		pPref->sServerList.remove(selText);

	}
	updateDialog();
}
Example #4
0
void QQuickTextNode::addTextDocument(const QPointF &position, QTextDocument *textDocument,
                                  const QColor &textColor,
                                  QQuickText::TextStyle style, const QColor &styleColor,
                                  const QColor &anchorColor,
                                  const QColor &selectionColor, const QColor &selectedTextColor,
                                  int selectionStart, int selectionEnd)
{
    initEngine(textColor, selectedTextColor, selectionColor, anchorColor);

    QList<QTextFrame *> frames;
    frames.append(textDocument->rootFrame());
    while (!frames.isEmpty()) {
        QTextFrame *textFrame = frames.takeFirst();
        frames.append(textFrame->childFrames());

        m_engine->addFrameDecorations(textDocument, textFrame);

        if (textFrame->firstPosition() > textFrame->lastPosition()
         && textFrame->frameFormat().position() != QTextFrameFormat::InFlow) {
            const int pos = textFrame->firstPosition() - 1;
            ProtectedLayoutAccessor *a = static_cast<ProtectedLayoutAccessor *>(textDocument->documentLayout());
            QTextCharFormat format = a->formatAccessor(pos);
            QRectF rect = a->frameBoundingRect(textFrame);

            QTextBlock block = textFrame->firstCursorPosition().block();
            m_engine->setCurrentLine(block.layout()->lineForTextPosition(pos - block.position()));
            m_engine->addTextObject(rect.topLeft(), format, QQuickTextNodeEngine::Unselected, textDocument,
                                 pos, textFrame->frameFormat().position());
        } else {
            QTextFrame::iterator it = textFrame->begin();

            while (!it.atEnd()) {
                Q_ASSERT(!m_engine->currentLine().isValid());

                QTextBlock block = it.currentBlock();
                m_engine->addTextBlock(textDocument, block, position, textColor, anchorColor, selectionStart, selectionEnd);
                ++it;
            }
        }
    }

    m_engine->addToSceneGraph(this, style, styleColor);
}
void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (!dragEnabled())
    {
        event->ignore();
        return;
    }

    if (!(event->buttons() & Qt::LeftButton))
        return;

    if ((event->pos() - mMousePressPos).manhattanLength()
             < QApplication::startDragDistance())
             return;

    QList<QGraphicsItem*> graphicsItems = items(mMousePressPos);

    UBSceneThumbnailPixmap* sceneItem = 0;

    while (!graphicsItems.isEmpty() && !sceneItem)
    {
        sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(graphicsItems.takeFirst());
    }

    if (sceneItem)
    {
        QDrag *drag = new QDrag(this);
        QList<UBMimeDataItem> mimeDataItems;
        foreach (QGraphicsItem *item, selectedItems())
            mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item)));
        UBMimeData *mime = new UBMimeData(mimeDataItems);
        drag->setMimeData(mime);

        drag->setPixmap(sceneItem->pixmap().scaledToWidth(100));
        drag->setHotSpot(QPoint(drag->pixmap().width()/2,
                                     drag->pixmap().height() / 2));

        drag->exec(Qt::MoveAction);
    }

    UBThumbnailWidget::mouseMoveEvent(event);
}
Example #6
0
void LC_Align::execComm(Document_Interface *doc,
                             QWidget *parent, QString cmd)
{
    Q_UNUSED(parent);
    Q_UNUSED(cmd);
    QPointF base1, base2, target1, target2;
    QList<Plug_Entity *> obj;
    bool yes  = doc->getSelect(&obj);
    if (!yes || obj.isEmpty()) return;
    yes = doc->getPoint(&base1, QString(tr("first base point:")));
    if (yes) {
        yes = doc->getPoint(&target1, QString(tr("first target point:")), &base1);
        if (yes) {
            yes = doc->getPoint(&base2, QString(tr("second base point:")));
            if (yes) {
                yes = doc->getPoint(&target2, QString(tr("second target point:")), &base2);
            }
        }

    }
    if (yes) {
        //first, move selection
        QPointF movev = target1 - base1;

        //calculate angle
        double abase, atarget, angle;
        abase = atan2( base2.y() - base1.y(),
                       base2.x() - base1.x());
        atarget = atan2( target2.y() - target1.y(),
                         target2.x() - target1.x());
        angle = atarget - abase;
        //end, rotate selection
        for (int i = 0; i < obj.size(); ++i) {
			obj.at(i)->moveRotate(movev, target1, angle);
        }

    }

//selection cleanup
    while (!obj.isEmpty())
        delete obj.takeFirst();
}
int HistoryManager::getPageRank(const QString &url)
{
 //Check for a valid entry
    if (url.isNull())
        return 0;

    int rank = 0;
	QList<HistoryLeaf*> historyNodes = d->m_historySession->fetchHistory();

    for (int i=0; i < historyNodes.count(); i++) {
      //Update rank if there is a history for this URL.
        if (!historyNodes[i]->getUrl().compare(url))
           rank++;
    }

	while (!historyNodes.isEmpty())
     delete historyNodes.takeFirst();

    return rank;
}
Example #8
0
void RiskAI_TitanNet::attackPhase()
{
	QList<RiskMapLand *> willAttack;
	
	eval->filterOnlyPlayer( player->getPlayerId() );
	eval->addFilterHasEnemyNeighbor();
	eval->addFilterHasMoreThanXArmys( 1 );
	willAttack = eval->getFilteredList();

	if( eval->addFilterHasMoreThanXArmys( 3 ) > 0 )
	{
		willAttack = eval->getFilteredList();
	}

	while( !willAttack.isEmpty() )
	{
		RiskMapLand *newAttack = attackFrom( willAttack.takeFirst() );
		if( newAttack != NULL ) willAttack.append( newAttack );
	}
}
Example #9
0
bool QtUndoStackPrivate::checkUndoLimit()
{
    if (undo_limit <= 0 || !macro_stack.isEmpty() || undo_limit >= command_list.count())
        return false;

    int del_count = command_list.count() - undo_limit;

    for (int i = 0; i < del_count; ++i)
        delete command_list.takeFirst();

    index -= del_count;
    if (clean_index != -1) {
        if (clean_index < del_count)
            clean_index = -1; // we've deleted the clean command
        else
            clean_index -= del_count;
    }

    return true;
}
static QList<qint64> findSnapshotIdsRecursively(QScriptDebuggerLocalsModelNode *root)
{
    QList<qint64> result;
    if (root->snapshotId == -1) {
        Q_ASSERT(root->children.isEmpty());
        return result;
    }
    QList<QScriptDebuggerLocalsModelNode*> nodeStack;
    nodeStack.append(root);
    while (!nodeStack.isEmpty()) {
        QScriptDebuggerLocalsModelNode *node = nodeStack.takeFirst();
        result.append(node->snapshotId);
        for (int i = 0; i < node->children.count(); ++i) {
            QScriptDebuggerLocalsModelNode *child = node->children.at(i);
            if (child->snapshotId != -1)
                nodeStack.prepend(child);
        }
    }
    return result;
}
Example #11
0
	void ItemsFilterModel::SetItemTags (QList<ITagsManager::tag_id> tags)
	{
		if (tags.isEmpty ())
			TaggedItems_.clear ();
		else
		{
			const auto& sb = StorageBackendManager::Instance ().MakeStorageBackendForThread ();
			TaggedItems_ = QSet<IDType_t>::fromList (sb->GetItemsForTag (tags.takeFirst ()));

			for (const auto& tag : tags)
			{
				const auto& set = QSet<IDType_t>::fromList (sb->GetItemsForTag (tag));
				TaggedItems_.intersect (set);
				if (TaggedItems_.isEmpty ())
					TaggedItems_ << -1;
			}
		}

		invalidate ();
	}
Example #12
0
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
    if (reply->error() == QNetworkReply::NoError) {
        BrowserApplication::downloadManager()->handleUnsupportedContent(reply);
        return;
    }

    QFile file(QLatin1String(":/notfound.html"));
    bool isOpened = file.open(QIODevice::ReadOnly);
    Q_ASSERT(isOpened);
    QString title = tr("Error loading page: %1").arg(reply->url().toString());
    QString html = QString(QLatin1String(file.readAll()))
                        .arg(title)
                        .arg(reply->errorString())
                        .arg(reply->url().toString());

    QBuffer imageBuffer;
    imageBuffer.open(QBuffer::ReadWrite);
    QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view());
    QPixmap pixmap = icon.pixmap(QSize(32, 32));
    if (pixmap.save(&imageBuffer, "PNG")) {
        html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"),
                     QString(QLatin1String(imageBuffer.buffer().toBase64())));
    }

    QList<QWebFrame*> frames;
    frames.append(mainFrame());
    while (!frames.isEmpty()) {
        QWebFrame *frame = frames.takeFirst();
        if (frame->url() == reply->url()) {
            frame->setHtml(html, reply->url());
            return;
        }
        QList<QWebFrame *> children = frame->childFrames();
        foreach(QWebFrame *frame, children)
            frames.append(frame);
    }
    if (m_loadingUrl == reply->url()) {
        mainFrame()->setHtml(html, reply->url());
    }
}
void SqlTransactionTests::testMySqlTransactionCommit()
{
    MySqlStorage storage = prepareMySqlStorage();
    QVERIFY( storage.database().open() );

    QList<Task> tasksBefore = storage.getAllTasks();
    QVERIFY( ! tasksBefore.isEmpty() );
    Task first = tasksBefore.takeFirst();
    // test a simple transaction that is completed and committed:
    {
        SqlRaiiTransactor transactor( storage.database() );
        QSqlQuery query( storage.database() );
        query.prepare("DELETE from Tasks where id=:id");
        query.bindValue( "id", first.id() );
        QVERIFY( storage.runQuery( query ) );
        transactor.commit();
    } // this transaction WAS commited
    QList<Task> tasksAfter = storage.getAllTasks();
    QVERIFY( ! tasksAfter.isEmpty() );
    QVERIFY( tasksBefore == tasksAfter );
}
Example #14
0
int RiskMapEvaluator::addFilterHasNoEnemyNeighbor()
{
	QList<RiskMapLand*> list;
	for( int i = filtered.size()-1; i>=0; i-- )
	{
		list = filtered[i]->getNeighbors();
		bool takeIt = true;
		while( !list.isEmpty() )
		{
			if( list.takeFirst()->getOwner() != filtered[i]->getOwner() )
			{
				takeIt = false;
			}
		}
		if( !takeIt )
		{
			filtered.takeAt( i );
		}
	}
	return( filtered.size() );
}
Example #15
0
/*!
    \since 4.2

    Sets \a shortcuts as the list of shortcuts that trigger the
    action. The first element of the list is the primary shortcut.

    \sa shortcut
*/
void QAction::setShortcuts(const QList<QKeySequence> &shortcuts)
{
    Q_D(QAction);

    QList <QKeySequence> listCopy = shortcuts;

    QKeySequence primary;
    if (!listCopy.isEmpty())
        primary = listCopy.takeFirst();

    if (d->shortcut == primary && d->alternateShortcuts == listCopy)
        return;

    QAPP_CHECK("setShortcuts");

    d->shortcut = primary;
    d->alternateShortcuts = listCopy;
    d->redoGrab(qApp->d_func()->shortcutMap);
    d->redoGrabAlternate(qApp->d_func()->shortcutMap);
    d->sendDataChanged();
}
RelationMember parseMemberUrl(const QString &string)
{
    if (string.startsWith("urn:uuid:")) {
        RelationMember member;
        member.gid = string.mid(9);
        return member;
    }
    QUrl url(QUrl::fromEncoded(string.toLatin1()));
    QList<QByteArray> path;
    Q_FOREACH(const QByteArray &fragment, url.encodedPath().split('/')) {
        path.append(ownUrlDecode(fragment).toUtf8());
    }
    // qDebug() << path;
    bool isShared = false;
    int start = path.indexOf("user");
    if (start < 0) {
        start = path.indexOf("shared");
        isShared = true;
    }
    if (start < 0) {
        Warning() << "Couldn't find \"user\" or \"shared\" in path: " << path;
        return RelationMember();
    }
    path = path.mid(start + 1);
    if (path.size() < 2) {
        Warning() << "Incomplete path: " << path;
        return RelationMember();
    }
    RelationMember member;
    if (!isShared) {
        member.user = path.takeFirst();
    }
    member.uid = path.takeLast().toLong();
    member.mailbox = path;
    member.messageId = ownUrlDecode(url.encodedQueryItemValue("message-id"));
    member.subject = ownUrlDecode(url.encodedQueryItemValue("subject"));
    member.date = ownUrlDecode(url.encodedQueryItemValue("date"));
    // qDebug() << member.uid << member.mailbox;
    return member;
}
Example #17
0
void Element::advance(int step) {

    if (!step)
        return;

    /* Update x and y state based on gravity laws */
    updateStateY();
    updateStateX();

    /* Detect and resolve collisions with other objects */
    QList<Manifold *> listOfCollidingObjects = detectCollidingObjects();

    while (!listOfCollidingObjects.isEmpty()) {
        Manifold * secondObjectManifold = listOfCollidingObjects.takeFirst();

        /* Calculate relative velocity between two colliding objects */
        qreal rv_x = secondObjectManifold->second_object->getVelocityX() - this->getVelocityX();
        qreal rv_y = secondObjectManifold->second_object->getVelocityY() - this->getVelocityY();

        /* Calculate velocity along normal direction */
        qreal vetAlongNormal = secondObjectManifold->normal_x * rv_x + secondObjectManifold->normal_y * rv_y;

        if (vetAlongNormal <= 0.0) {

            qreal minElasticity = std::min(this->getElasticity(), secondObjectManifold->second_object->getElasticity());
            qreal j = -(1 + minElasticity) * vetAlongNormal;
            j /= this->getInvWeight() + secondObjectManifold->second_object->getInvWeight();

            this->setVelocityX(this->getVelocityX() - this->getInvWeight() * j * secondObjectManifold->normal_x);
            this->setVelocityY(this->getVelocityY() - this->getInvWeight() * j * secondObjectManifold->normal_y);

            secondObjectManifold->second_object->setVelocityX(secondObjectManifold->second_object->getVelocityX() + secondObjectManifold->second_object->getInvWeight() * j * secondObjectManifold->normal_x);
            secondObjectManifold->second_object->setVelocityY(secondObjectManifold->second_object->getVelocityY() + secondObjectManifold->second_object->getInvWeight() * j * secondObjectManifold->normal_y);

            adjustPosition(secondObjectManifold);
        }
    }

}
Example #18
0
    /**
     * Removes entries from the sink and the cache.
     */
    void prune()
    {
        DENG2_ASSERT_IN_MAIN_THREAD();

        if(isRewrapping())
        {
            // Rewrapper is busy, let's not do this right now.
            return;
        }

        // We must lock the sink so no new entries are added.
        DENG2_GUARD(sink);

        if(sink.isBusy())
        {
            // New entries are being added, prune later.
            return;
        }

        fetchNewCachedEntries();

        DENG2_ASSERT(sink.entryCount() == cache.size());

        int num = sink.entryCount() - sink.maxEntries();
        if(num > 0)
        {
            sink.remove(0, num);
            for(int i = 0; i < num; ++i)
            {
                self.modifyContentHeight(-cache[0]->height());
                delete cache.takeFirst();
            }
            // Adjust existing indices to match.
            for(int i = 0; i < cache.size(); ++i)
            {
                cache[i]->sinkIndex -= num;
            }
        }
    }
Example #19
0
void DetailsReply::getPlaceFinished()
{
    QJsonDbRequest *request = qobject_cast<QJsonDbRequest *>(sender());
    Q_ASSERT(request);
    QList<QJsonObject> results = request->takeResults();

    if (results.isEmpty()) {
        triggerDone(QPlaceReply::PlaceDoesNotExistError,
                                  QStringLiteral("Specified place does not exist"));
        return;

    } else {
        QJsonObject placeJson = results.takeFirst();
        setPlace(JsonDb::convertJsonObjectToPlace(placeJson, m_engine));

        QStringList categoryUuids = placeJson.value(JsonDb::CategoryUuids).toVariant().toStringList();
        if (!categoryUuids.isEmpty())
            db()->getCategories(categoryUuids, this, SLOT(getCategoriesForPlaceFinished()));
        else //don't need to retrieve categores so return the details
            triggerDone();
    }
}
void TestSingleSignon::multipleClientsAtOnceContiousTest()
{
    QTime startTime = QTime::currentTime();
    int rounds = 5;

    while(rounds > 0)
    {
        QList<SsoClientThread *> clientThreads;

        for(int i = 0; i < m_numberOfTestClients; i++)
        {
            qDebug() << "\n\nCreating SSO test client thread...\n\n";
            SsoClientThread *thread = new SsoClientThread(SsoTestClient::AllTests /*| SsoTestClient::IdentityStorage*/);
            thread->start();
            clientThreads.append(thread);
        }

        SsoClientThread *thread = NULL;
        bool done = false;
        //this assumes all client threads will be finished at a certain point
        while(!done)
        {
            int finishedThreadsCount = 0;
            foreach(thread, clientThreads)
                if(thread->isFinished()) ++finishedThreadsCount;

            done = ((finishedThreadsCount == m_numberOfTestClients) ? true : false);
            sleep(1);
        }
        while(!clientThreads.empty())
            if(SsoClientThread *thread = clientThreads.takeFirst()) delete thread;

        --rounds;
    }

    QTime endTime = QTime::currentTime();
    int elapsed = startTime.secsTo(endTime);
    qDebug() << QString("TestSingleSignon::multipleClientsAtOnceContiousTest() ---- TIME --> Total elapsed time: %1 seconds.\n\n").arg(elapsed);
}
bool RouteParser::parse(QByteArray& contents, Route& currentRoute)
{

	QList<QByteArray> lines = contents.split('\n');

	currentRoute.difficulty = QString(lines.takeFirst()) == QString("easy") ? DIFFICULTY_EASY : DIFFICULTY_HARD;
	currentRoute.waypoints = std::vector<osg::Vec3>();
	
	for (auto line : lines)
	{
		try{
			osg::Vec3 val = lineToPoint(line);
			currentRoute.waypoints.push_back(val);
		}
		catch (char* exception){
			std::cout << "[RouteParser] error parsing line :" << QString(line).toStdString() << std::endl;
		}

	}

	return true;
}
Example #22
0
void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
    if (reply->error() == QNetworkReply::NoError) {
        if (reply->header(QNetworkRequest::ContentTypeHeader).isValid())
            qDebug() << "download it";
            new OpDownloader(reply);
        return;
    }

    if (reply->error() == QNetworkReply::ProtocolUnknownError) {
        // we currently don't support protocol other than http(s):// and file://
        // return;
    }

    //display notfound
    if (reply->url().isEmpty())
        return;
    QFile file(QLatin1String(":/notfound.html"));
    bool isOpened = file.open(QIODevice::ReadOnly);
    Q_ASSERT(isOpened);
    QString title = ("HTTP 404 Not Found");
    QString html = QString(QLatin1String(file.readAll()));
    
    QList<QWebFrame*> frames;
    frames.append(mainFrame());
    while (!frames.isEmpty()) {
        QWebFrame *frame = frames.takeFirst();
        if (frame->url() == reply->url()) {
            frame->setHtml(html, reply->url());
            return;
        }
        QList<QWebFrame *> children = frame->childFrames();
        foreach (QWebFrame *frame, children)
            frames.append(frame);
    }
    if (m_loadingUrl == reply->url()) {
        mainFrame()->setHtml(html, reply->url());
    }
}
Example #23
0
void EventViewer::deleteAllChildren(QStandardItem * parent)
{
    //delete all children of eventsItem;
    QStandardItem * loopItem = parent; //main loop item
    QList<QStandardItem *> carryItems; //Last In First Out stack of items
    QList<QStandardItem *> itemsToBeDeleted; //List of items to be deleted
    while (loopItem->rowCount())
    {
        itemsToBeDeleted << loopItem->takeRow(0);
        //if the row removed has children:
        if (itemsToBeDeleted.at(0)->hasChildren())
        {
            carryItems << loopItem;                 //put on the stack the current loopItem
            loopItem = itemsToBeDeleted.at(0);      //set the row with children as the loopItem
        }
        //if current loopItem has no more rows but carryItems list is not empty:
        if (!loopItem->rowCount() && !carryItems.isEmpty()) loopItem = carryItems.takeFirst();

    }
    qDeleteAll(itemsToBeDeleted);

}
Example #24
0
void MapThemeManager::Private::fileChanged( const QString& path )
{
    mDebug() << "fileChanged:" << path;

    // 1. if the file does not (anymore) exist, it got deleted and we
    //    have to delete the corresponding item from the model
    // 2. if the file exists it is changed and we have to replace
    //    the item with a new one.

    QString mapThemeId = path.section( '/', -3 );
    mDebug() << "mapThemeId:" << mapThemeId;
    QList<QStandardItem *> matchingItems = m_mapThemeModel.findItems( mapThemeId,
                                           Qt::MatchFixedString
                                           | Qt::MatchCaseSensitive,
                                           columnRelativePath );
    mDebug() << "matchingItems:" << matchingItems.size();
    Q_ASSERT( matchingItems.size() <= 1 );
    int insertAtRow = 0;

    if ( matchingItems.size() == 1 ) {
        const int row = matchingItems.front()->row();
        insertAtRow = row;
        QList<QStandardItem *> toBeDeleted = m_mapThemeModel.takeRow( row );
        while ( !toBeDeleted.isEmpty() ) {
            delete toBeDeleted.takeFirst();
        }
    }

    QFileInfo fileInfo( path );
    if ( fileInfo.exists() ) {
        QList<QStandardItem *> newMapThemeRow = createMapThemeRow( mapThemeId );
        if ( !newMapThemeRow.empty() ) {
            m_mapThemeModel.insertRow( insertAtRow, newMapThemeRow );
        }
    }

    emit q->themesChanged();
}
Example #25
0
void Smb4KBookmarkHandler::removeProfile(const QString& name)
{
  QList<Smb4KBookmark *> allBookmarks;
  QStringList allGroups; // Can be ignored.
 
  // Read all entries for later removal.
  readBookmarks(&allBookmarks, &allGroups, true);
  
  QMutableListIterator<Smb4KBookmark *> it(allBookmarks);
  
  while (it.hasNext())
  {
    Smb4KBookmark *bookmark = it.next();
    
    if (QString::compare(bookmark->profile(), name, Qt::CaseSensitive) == 0)
    {
      it.remove();
    }
    else
    {
      // Do nothing
    }
  }
  
  // Write the new list to the file.
  writeBookmarkList(allBookmarks, true);
  
  // Profile settings changed, so invoke the slot.
  slotActiveProfileChanged(Smb4KProfileManager::self()->activeProfile());
  
  // Clear the temporary lists of bookmarks and groups.
  while (!allBookmarks.isEmpty())
  {
    delete allBookmarks.takeFirst();
  }
  
  allGroups.clear();
}
SEXP InstanceObjectTable::objects() const {
  Method::Qualifiers qual = Method::NotStatic;
  QList<Method *> methods; 
  SEXP nameVector;
  QSet<const char *> nameSet;

  checkInstance();

  if (!_internal)
    qual |= Method::Public;
  methods = _instance->klass()->methods(qual);
  
  foreach(Method *m, methods) // put names into set to get unique ones
    nameSet.insert(m->name());

  int numFields = 0;
  SEXP fields;
  if (_internal) {
    PROTECT(fields = R_lsInternal(fieldEnv(), TRUE));
    numFields = length(fields);
  }
  
  PROTECT(nameVector = allocVector(STRSXP, nameSet.size() + numFields));
  int i = 0; // iterate over set, populate R vector
  foreach(const char *name, nameSet)
    SET_STRING_ELT(nameVector, i++, mkChar(name));
  for(int j = 0; i < length(nameVector); i++, j++)
    SET_STRING_ELT(nameVector, i, STRING_ELT(fields, j));

  while(!methods.isEmpty())
    delete methods.takeFirst();  

  UNPROTECT(1);
  if (_internal)
    UNPROTECT(1);
  
  return nameVector;
}
Example #27
0
void QRWindow::outputSizeReport() {
   if (!m_isDebugMode) return;
   printf("\n\n=============================================[Size Report]===\n");
   stack <QList<QWidget *> > stackWidgets;
   
   QList<QWidget *> listWidgets; listWidgets.append(this);
   stackWidgets.push(listWidgets);
    
   while (!stackWidgets.empty()) {
      QList<QWidget *> widgets = stackWidgets.top(); stackWidgets.pop();
      bool new_level = false;
      while (widgets.size() && !new_level) {
         QWidget *widget = widgets.takeFirst();
         if (QROSE::getName(widget) != "") {
            printf("%*c%s [w:%d,h:%d,x:%d,y:%d]\n", (int) (3*stackWidgets.size()), ' ', 
                QROSE::getName(widget).c_str(), 
                widget->width(), widget->height(),
                widget->x(), widget->y());            
         }
         QList<QWidget *> childrenW;
         int n = widget->children().size();
         for (int i = 0; i < n; i++) {
             QObject *obj = widget->children().at(i);
             if (obj->isWidgetType()) {
                childrenW.append((QWidget *)obj);
             }
         }
         
         if (childrenW.size() != 0) {
            new_level = true;
            stackWidgets.push(widgets);
            stackWidgets.push(childrenW);
         }       
      }
   }
   printf("=============================================================\n");
   
}
Example #28
0
File: wall.cpp Project: gja/lblock
void Wall::generateList()
{
	QList <Window *> list = windows;
	Window *window;

	float startx = 0.0f; // Startx moves from left to right, drawing each window

	// For each window, we draw a solid wall till the window
	while (! list.isEmpty()) {
		window = list.takeFirst();

		// solid wall
		drawSegment(startx, 0.0f, window->position, height);

		// below, then above window
		drawSegment(window->position, 0.0f, window->position + window->length, window->lowerHeight);
		drawSegment(window->position, window->upperHeight, window->position + window->length, height);

		startx = window->position + window->length;
	}

	// The remaining part of the wall
	drawSegment(startx, 0.0f, length, height);

	// Side walls
	glBindTexture(GL_TEXTURE_2D, outerTexture.texture);
	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 0.0f); glVertex3f(0.0f, 0.0f, -thickness);
		glTexCoord2f(0.0f, height / innerTexture.sizey); glVertex3f(0.0f, height, -thickness);
		glTexCoord2f(thickness / innerTexture.sizex, height / innerTexture.sizey); glVertex3f(0.0f, height, 0.0f);
		glTexCoord2f(thickness / innerTexture.sizex, 0.0f); glVertex3f(0.0f, 0.0f, 0.0f);

		glTexCoord2f(0.0f, 0.0f); glVertex3f(length, 0.0f, -thickness);
		glTexCoord2f(0.0f, height / innerTexture.sizey); glVertex3f(length, height, -thickness);
		glTexCoord2f(thickness / innerTexture.sizex, height / innerTexture.sizey); glVertex3f(length, height, 0.0f);
		glTexCoord2f(thickness / innerTexture.sizex, 0.0f); glVertex3f(length, 0.0f, 0.0f);
	glEnd();
}
Example #29
0
/// Tidys up old undo actions.
void UndoBuffer::tidyUp()
{
  QListIterator<Undo*> i(undolist);

  Undo* u;
  GTransition* t;
  GITransition* it;
  QList<GTransition*>* l;

  for(; i.hasNext();)
  {
    u = i.next();
    
    switch (u->getAction())
    {
      case ChangeState:
        delete u->getState();
	break;
      case ChangeTransition:
        delete u->getTransition();
	break;
      case ChangeInitialTransition:
        delete u->getInitialTransition();
	break;
      case ChangeTransitions:
	l = u->getTList();
	t = l->first();
//	while (l->remove());
	while (!l->isEmpty())
	  delete l->takeFirst();
	break;
      case SetInitialState:
	it = u->getInitialTransition();
        if (it)
	  delete it;
    }
  }
}
Example #30
0
void
MarGrid::savePredictionGrid(QString fname)
{
  fstream file_op((fname.toStdString()).c_str(), ios::out);

  //first line is the size of files
  file_op << files.size() << endl;

  for (int i = 0; i < files.size(); i++)
  {
    // output the vector index and filename
    QList<std::string> temp = files[i];
    for(int j = 0; j < files[i].size(); j++ )
    {
      file_op << i;
      file_op << "," + temp.takeFirst() << endl;

    }
  }
  file_op.close();


}