コード例 #1
0
ファイル: player.c プロジェクト: masterhou/drillerman
void player_Frame(float lag)
{
    updatePlayerPosition(lag);
    collectItems();

    if(player->sclass != newAnimation)
        snge_SwitchAnim(player, newAnimation);

    float oldy = viewportPos.y;

    float gY = (float)((_BRICK_HEIGHT * (mapHeight + _INTER_ROW_COUNT - 1) * level) + (_BRICK_HEIGHT * vy)) + voff;
    float gX = (float)(_BRICK_WIDTH * vx) + hoff;

    viewportPos.x = - _MAP_OFFSET_X;
    viewportPos.y = - _MAP_OFFSET_Y + gY;

    bcg_Move(&bcg, oldy - viewportPos.y);

    snge_MoveViewport(viewportPos);

    player->x = gX - _PLAYER_WIDTH2 - _PLAYER_SPRITE_PADDING_X + _MAP_OFFSET_X;

    air -= _AIR_DECREASE_SPEED * lag;
    if(air < 0.0)
        air = 0.0;
    depth = (mapHeight * level) + vy;
    hud_SetDepth(depth);
    hud_SetPoints(points);
    hud_SetAir(air);
}
コード例 #2
0
void
BookmarkModel::setupCache(const QModelIndex &parent)
{
    const QModelIndexList &list = collectItems(parent);
    foreach (const QModelIndex &index, list)
        cache.insert(itemFromIndex(index), index);
}
コード例 #3
0
QList<QPersistentModelIndex>
BookmarkModel::indexListFor(const QString &label) const
{
    QList<QPersistentModelIndex> hits;
    const QModelIndexList &list = collectItems(QModelIndex());
    foreach(const QModelIndex &index, list) {
        if (index.data().toString().contains(label, Qt::CaseInsensitive))
            hits.prepend(index);    // list is reverse sorted
    }
    return hits;
}
コード例 #4
0
QModelIndexList
BookmarkModel::collectItems(const QModelIndex &parent) const
{
    QModelIndexList list;
    for (int i = rowCount(parent) - 1; i >= 0 ; --i) {
        const QModelIndex &next = index(i, 0, parent);
        if (data(next, UserRoleFolder).toBool())
            list += collectItems(next);
        list.append(next);
    }
    return list;
}
コード例 #5
0
QByteArray
BookmarkModel::bookmarks() const
{
    QByteArray ba;
    QDataStream stream(&ba, QIODevice::WriteOnly);

    const QModelIndex &root = index(0,0, QModelIndex());
    for (int i = 0; i < rowCount(root); ++i)
        collectItems(index(i, 0, root), 0, &stream);

    return ba;
}
コード例 #6
0
void
BookmarkModel::collectItems(const QModelIndex &parent, qint32 depth,
    QDataStream *stream) const
{
    if (parent.isValid()) {
        *stream << depth;
        *stream << parent.data().toString();
        *stream << parent.data(UserRoleUrl).toString();
        *stream << parent.data(UserRoleExpanded).toBool();

        for (int i = 0; i < rowCount(parent); ++i) {
            if (parent.data(UserRoleFolder).toBool())
                collectItems(index(i, 0 , parent), depth + 1, stream);
        }
    }
}
コード例 #7
0
QMimeData*
BookmarkModel::mimeData(const QModelIndexList &indexes) const
{
    if (indexes.isEmpty())
        return 0;

    QByteArray data;
    QDataStream stream(&data, QIODevice::WriteOnly);

    foreach (const QModelIndex &index, indexes) {
        if (index.column() == 0)
            collectItems(index, 0, &stream);
    }

    QMimeData *mimeData = new QMimeData();
    mimeData->setData(MIMETYPE, data);
    return mimeData;
}
コード例 #8
0
bool
BookmarkModel::removeItem(const QModelIndex &index)
{
    if (!index.isValid())
        return false;

    QModelIndexList indexes;
    if (rowCount(index) > 0)
        indexes = collectItems(index);
    indexes.append(index);

    foreach (const QModelIndex &itemToRemove, indexes) {
        if (!removeRow(itemToRemove.row(), itemToRemove.parent()))
            return false;
        cache.remove(itemFromIndex(itemToRemove));
    }
    return true;
}
コード例 #9
0
ファイル: collect4output.cpp プロジェクト: aoloe/scribus
QString CollectForOutput::collect(QString &newFileName)
{
    if (!newDirDialog())
        return "Collect cancelled or unable to create collect destination directory";
    ScCore->fileWatcher->forceScan();
    ScCore->fileWatcher->stop();
    dirs->set("collect", m_outputDirectory.left(m_outputDirectory.lastIndexOf("/",-2)));
    ScCore->primaryMainWindow()->setStatusBarInfoText( tr("Collecting..."));

    if (!collectItems())
    {
        QString errorMsg( tr("Cannot collect all files for output for file:\n%1").arg(newName) );
        ScMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning,
                              "<qt>" + errorMsg + "</qt>");
        return errorMsg;
    }

    if (m_withFonts)
        collectFonts();
    if (m_withProfiles)
        collectProfiles();

    /* collect document must go last because of image paths changes in collectItems() */
    if (!collectDocument())
    {
        QString errorMsg( tr("Cannot collect the file: \n%1").arg(newName) );
        ScMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, "<qt>" + errorMsg + "</qt>");
        return errorMsg;
    }

    QDir::setCurrent(m_outputDirectory);
    ScCore->primaryMainWindow()->updateActiveWindowCaption(newName);
    UndoManager::instance()->renameStack(newName);
    ScCore->primaryMainWindow()->scrActions["fileSave"]->setEnabled(false);
    ScCore->primaryMainWindow()->scrActions["fileRevert"]->setEnabled(false);
    ScCore->primaryMainWindow()->updateRecent(newName);
    ScCore->primaryMainWindow()->setStatusBarInfoText("");
    ScCore->primaryMainWindow()->mainWindowProgressBar->reset();
    ScCore->fileWatcher->start();
    collectedFiles.clear();
    newFileName = newName;

    return QString::null;
}
コード例 #10
0
ファイル: collectforoutput_ui.cpp プロジェクト: JLuc/scribus
QString CollectForOutput_UI::collect(QString &newFileName)
{
	if (!newDirDialog())
		return "Collect cancelled or unable to create collect destination directory";

	progressDialog=new MultiProgressDialog("Collect for Output", "Cancel");
	QStringList barNames, barTexts;
	QList<bool> barsNumeric;
	barNames << "items";
	barTexts << tr("Collecting Items:");
	barsNumeric << true;
	barNames << "patterns";
	barTexts << tr("Collecting Patterns:");
	barsNumeric << true;

	if (m_withFonts)
	{
		barNames << "fonts";
		barTexts << tr("Collecting Fonts:");
		barsNumeric << true;
	}
	if (m_withProfiles)
	{
		barNames << "profiles";
		barTexts << tr("Collecting Profiles:");
		barsNumeric << true;
	}

	progressDialog->addExtraProgressBars(barNames, barTexts, barsNumeric);
	progressDialog->setOverallTotalSteps(profileCount+itemCount+fontCount+patternCount);
	progressDialog->setTotalSteps("items", itemCount);
	progressDialog->setTotalSteps("patterns", patternCount);
	progressDialog->setProgress("items", 0);
	progressDialog->setProgress("patterns", 0);
	if (m_withFonts)
	{
		progressDialog->setTotalSteps("fonts", fontCount);
		progressDialog->setProgress("fonts", 0);
	}
	if (m_withProfiles)
	{
		progressDialog->setTotalSteps("profiles", profileCount);
		progressDialog->setProgress("profiles", 0);
	}
	progressDialog->setOverallProgress(0);



	ScCore->fileWatcher->forceScan();
	ScCore->fileWatcher->stop();


	progressDialog->show();
//	connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelRequested()));
	ScQApp->processEvents();

	dirs->set("collect", m_outputDirectory.left(m_outputDirectory.lastIndexOf("/",-2)));
	ScCore->primaryMainWindow()->setStatusBarInfoText( tr("Collecting..."));

	if (!collectItems())
	{
		QString errorMsg( tr("Cannot collect all files for output for file:\n%1").arg(newName) );
		QMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning,
							 "<qt>" + errorMsg + "</qt>",
							 CommonStrings::tr_OK);
		return errorMsg;
	}
	progressDialog->setOverallProgress(itemCount+patternCount);

	if (m_withFonts)
	{
		collectFonts();
		progressDialog->setProgress("fonts", fontCount);
		progressDialog->setOverallProgress(itemCount+patternCount+fontCount);
	}
	if (m_withProfiles)
	{
		collectProfiles();
		progressDialog->setProgress("profiles", profileCount);
		progressDialog->setOverallProgress(itemCount+patternCount+fontCount+profileCount);
	}
	/* collect document must go last because of image paths changes in collectItems() */
	if (!collectDocument())
	{
		QString errorMsg( tr("Cannot collect the file: \n%1").arg(newName) );
		QMessageBox::warning(ScCore->primaryMainWindow(), CommonStrings::trWarning, "<qt>" + errorMsg + "</qt>", CommonStrings::tr_OK);
		return errorMsg;
	}

	QDir::setCurrent(m_outputDirectory);
	ScCore->primaryMainWindow()->updateActiveWindowCaption(newName);
	UndoManager::instance()->renameStack(newName);
	ScCore->primaryMainWindow()->scrActions["fileRevert"]->setEnabled(false);
	ScCore->primaryMainWindow()->updateRecent(newName);
	ScCore->primaryMainWindow()->setStatusBarInfoText("");
	ScCore->primaryMainWindow()->mainWindowProgressBar->reset();
	ScCore->fileWatcher->start();
	collectedFiles.clear();
	newFileName=newName;
	progressDialog->close();
	delete progressDialog;
	return QString::null;
}
コード例 #11
0
ファイル: lintormanager.cpp プロジェクト: jpietrzak8/Linguine
void LinTORManager::parseItemIDs()
{
  QJson::Parser parser;
  bool ok;
  QVariantMap result = parser.parse(itemIDsReply->readAll(), &ok).toMap();
  itemIDsReply->deleteLater();
  itemIDsReply = 0;

  if (!ok)
  {
    qWarning() << "Failed to parse The Old Reader id list";
    return;
  }


  QList<QVariant> itemRefsVariants = result["itemRefs"].toList();

  torItems.clear();

  if (itemRefsVariants.isEmpty())
  {
    // Return an empty list:
    emit itemsReady();
    return;
  }

  QString itemRequestString =
    "https://theoldreader.com/reader/api/0/stream/items/contents?output=json";

  QList<QVariant>::const_iterator currentID = itemRefsVariants.constBegin();
  QList<QVariant>::const_iterator endOfIDs = itemRefsVariants.constEnd();

  while (currentID != endOfIDs)
  {
    QVariantMap itemIDMap = (*currentID).toMap();
    itemRequestString += "&i=";
    itemRequestString += itemIDMap["id"].toString();
    ++currentID;
  }

  if (torItemReply)
  {
    // Stop any existing request:
    torItemReply->abort();
    torItemReply = 0;
  }

  QUrl qurl(itemRequestString);

  QNetworkRequest itemRequest(qurl);

  itemRequest.setRawHeader(
    "Authorization", authHeaderString.toAscii());

  torItemReply = qnam->get(itemRequest);

  connect(
    torItemReply,
    SIGNAL(finished()),
    this,
    SLOT(collectItems()));
}