Пример #1
0
/**
 * \en
 * Save pattern
 * \_en
 * \ru
 * Сохраняет шаблон в файл с заданным именем. Перед сохранением необходимо выполнить функцию cleanUpTags() чтобы удалить тэги из сохраняемого документа.
 * \_ru
 */
bool
aMSOTemplate::save( const QString & fname)
{
	QFile fContent( QDir::convertSeparators(fname) );
	if( !fContent.open( IO_WriteOnly ) ) 
	{
		aLog::print(aLog::MT_ERROR, tr("aMSOTemplate save %1 open for write").arg(fContent.name()));
		return false;
	}
	QTextStream stream4content(&fContent);
	docTpl.save(stream4content,2);
	fContent.close();	
	return true;	
}
Пример #2
0
bool TetrisCup::hasPlace(const Figure &_figure)
{
    Matrix fContent(_figure.getContent());

    for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j)
            if ((fContent.getValue(j, i) == 1)) {
                if (j + _figure.getX() < 0 ||
                        i + _figure.getY() < 0 ||
                        j + _figure.getX() >= m_content.getWidth() ||
                        i + _figure.getY() >= m_content.getHeight() ||
                        (m_content.getValue(j + _figure.getX(), i + _figure.getY()) == 1))
                    return false;
            }

    return true;
}