void ConnectionManager::paint(QPainter &p) {
	for (ConnectionList::iterator it = m_conns.begin(); it != m_conns.end(); ++it) {
		paint(p, *it);
	}

	if (m_fromPin != -1) {
		QPoint from = QPoint(m_movingX, m_movingY);
		QPoint to;
		std::vector<QPoint>::iterator it = m_points.begin();
		if (it != m_points.end()) {
			from = *it;
			for (it++; it != m_points.end(); ++it) {
				to = *it;
				p.drawLine(from, to);
				from = to;
			}
		}


		to = m_screen->mapFromGlobal(QCursor::pos());
		to.setX(to.x() - to.x() % 12 + 6);
		to.setY(to.y() - to.y() % 12 + 6);

		QPointF fto(to);
		QPointF ffrom(from);

		if (m_screen->getObject(from.x(), to.y()) == m_fromObject ||
			(!m_points.empty() && m_points[m_points.size()-1].y() == to.y())) {
			p.drawLine(from, QPoint(to.x(), from.y()));
			p.drawLine(QPoint(to.x(), from.y()), to);
		}
		else {
			p.drawLine(from, QPoint(from.x(), to.y()));
			p.drawLine(QPoint(from.x(), to.y()), to);
		}
	}
}
示例#2
0
bool plFileSystem::Copy(const plFileName &from, const plFileName &to)
{
#if HS_BUILD_FOR_WIN32
    return CopyFileW(from.AsString().ToWchar(), to.AsString().ToWchar(), FALSE);
#else
    typedef std::unique_ptr<FILE, std::function<int (FILE *)>> _FileRef;

    _FileRef ffrom(Open(from, "rb"), fclose);
    _FileRef fto(Open(to, "wb"), fclose);
    if (!ffrom.get() || !fto.get())
        return false;

    size_t count;
    uint8_t buffer[4096];
    while (!feof(ffrom.get())) {
        count = fread(buffer, sizeof(uint8_t), arrsize(buffer), ffrom.get());
        if (ferror(ffrom.get()))
            return false;
        fwrite(buffer, sizeof(uint8_t), count, fto.get());
    }

    return true;
#endif
}