Example #1
0
CharPair PmrWorkspace::gitFileStatus(const QString &pPath) const
{
    // Retrieve and return the status of the file, which path is given

    CharPair res = CharPair(' ', ' ');

    if (isOpen()) {
        uint statusFlags = GIT_STATUS_CURRENT;

        if (git_status_file(&statusFlags, mGitRepository,
                            QDir(mPath).relativeFilePath(pPath).toUtf8().constData()) == GIT_OK) {
             // Retrieve the status itself

             res = gitStatusChars(statusFlags);

            // Also update the status in our file tree

            if (mRepositoryStatusMap.contains(pPath)) {
                mRepositoryStatusMap.value(pPath)->setStatus(res);
            }
         } else {
             emitGitError(tr("An error occurred while trying to get the status of %1.").arg(pPath));
         }
    }

    return res;
}
Example #2
0
void Font::loadKerningBlock(std::istream &ss, unsigned int blockSize, int version)
{
	KerningPairsBlock::KerningPair info;

	unsigned int pos = 0;
	while (ss.good() && (pos < blockSize))
	{
		if (version < 3)
		{
			unsigned short ids;
			ReadRaw(ss, ids);
			info.first = ids;
			ReadRaw(ss, ids);
			info.second = ids;
		}
		else
		{
			ReadRaw(ss, info.first);
			ReadRaw(ss, info.second);
		}
		
		ReadRaw(ss, info.amount);

		if (version < 3)
			pos += 6;
		else
			pos += 10;

		if (info.first >= 256 || info.second >= 256)
			continue;

		mKerningPairs.insert(std::make_pair(
			CharPair(static_cast<char>(info.first), static_cast<char>(info.second)),
			static_cast<float>(info.amount)
		));
	}

	if (pos != blockSize)
		throw std::runtime_error("Cannot load font file (kerning block is truncated or has an incorrect blockSize)");
}