コード例 #1
0
ファイル: eventplugin.cpp プロジェクト: mezkov/quickbox
void EventPlugin::onDbEvent(const QString &name, QSqlDriver::NotificationSource source, const QVariant &payload)
{
	qfLogFuncFrame() << "name:" << name << "source:" << source << "payload:" << payload;
	if(name == QLatin1String(DBEVENT_NOTIFY_NAME)) {
		if(source == QSqlDriver::OtherSource) {
			QJsonDocument jsd = QJsonDocument::fromJson(payload.toString().toUtf8());
			QVariantMap m = jsd.toVariant().toMap();
			QString domain = m.value(QStringLiteral("domain")).toString();
			if(domain.isEmpty()) {
				qfWarning() << "DbNotify with invalid domain, payload:" << payload.toString();
				return;
			}
			QString event_name = m.value(QStringLiteral("event")).toString();
			if(event_name.isEmpty()) {
				qfWarning() << "DbNotify with invalid event name, payload:" << payload.toString();
				return;
			}
			if(event_name == eventName()) {
				QVariant pl = m.value(QStringLiteral("payload"));
				qfDebug() << "emitting domain:" << domain << "payload:" << pl;
				emit dbEventNotify(domain, pl);
			}
		}
		else {
			//qfDebug() << "self db notify";
		}
	}
}
コード例 #2
0
ファイル: eventplugin.cpp プロジェクト: mezkov/quickbox
void EventPlugin::emitDbEvent(const QString &domain, const QVariant &payload, bool loopback)
{
	qfLogFuncFrame() << "domain:" << domain << "payload:" << payload;
	if(loopback) {
		// emit queued
		//emit dbEventNotify(domain, payload);
		QMetaObject::invokeMethod(this, "dbEventNotify", Qt::QueuedConnection,
								  Q_ARG(QString, domain),
								  Q_ARG(QVariant, payload));
	}
	if(connectionType() == ConnectionType::SingleFile)
		return;
	//QVariantMap m;
	QJsonObject jso;
	jso[QLatin1String("event")] = eventName();
	jso[QLatin1String("domain")] = domain;
	jso[QLatin1String("payload")] = QJsonValue::fromVariant(payload);
	QJsonDocument jsd(jso);
	QString payload_str = QString::fromUtf8(jsd.toJson(QJsonDocument::Compact));
	payload_str = qf::core::sql::Connection::escapeJsonForSql(payload_str);
	qf::core::sql::Connection conn = qf::core::sql::Connection::forName();
	QString qs = QString("NOTIFY ") + DBEVENT_NOTIFY_NAME + ", '" + payload_str + "'";
	qfDebug() << conn.driver() << "executing SQL:" << qs;
	QSqlQuery q(conn);
	if(!q.exec(qs)) {
		qfError() << "emitDbEventNotify Error:" << qs << q.lastError().text();
	}
}
コード例 #3
0
ファイル: coreplugin.cpp プロジェクト: arnost00/quickbox
void CorePlugin::launchSqlTool()
{
	qfLogFuncFrame();
	QString program = QCoreApplication::applicationDirPath() + "/qsqlmon";
#ifdef Q_OS_WIN
	program += ".exe";
#endif
	qfDebug() << "launchnig" << program;
	QStringList otcs;
	{
		auto conn = qf::core::sql::Connection::forName();
		otcs << "description=QuickEvent";
		otcs << "driver=" + conn.driverName();
		otcs << "host=" + conn.hostName();
		otcs << "port=" + QString::number(conn.port());
		otcs << "user="******"password="******"database=" + conn.databaseName();
	}

	QStringList arguments;
	arguments << "--one-time-connection-settings" << otcs.join('&');
	QProcess *process = new QProcess(this);
	process->start(program, arguments);
}
コード例 #4
0
ファイル: classitem.cpp プロジェクト: fvacek/quickbox
ClassItem::ClashType ClassItem::clashWith(ClassItem *other)
{
	qfLogFuncFrame() << data().className() << "vs" << other->data().className();
	auto dt = data();
	auto odt = other->data();
	int t1 = dt.startTimeMin();
	int t2 = t1 + durationMin();
	int ot1 = odt.startTimeMin();
	int ot2 = ot1 + other->durationMin();
	if(ot1 < t2 && ot2 > t1) {
		// overlap
		if(dt.courseId() == odt.courseId()) {
			qfDebug() << "\t ret: CourseOverlap";
			return ClashType::CourseOverlap;
		}
		if(dt.firstCode() == odt.firstCode()) {
			int si = dt.startIntervalMin();
			int osi = odt.startIntervalMin();
			if(si > 0 && osi > 0) {
				int si_gcd = gcd(si, osi);
				if((t1 % si_gcd) == (ot1 % si_gcd)) {
					qfDebug() << "\t ret: 2RunnersOverlap";
					return ClashType::RunnersOverlap;
				}
			}
		}
	}
	qfDebug() << "\t ret: NONE";
	return ClashType::None;
}
コード例 #5
0
ファイル: runstablemodel.cpp プロジェクト: fvacek/quickbox
QMimeData *RunsTableModel::mimeData(const QModelIndexList &indexes) const
{
	qfLogFuncFrame();
	QMimeData *mimeData = new QMimeData();
	QByteArray encoded_data = QString::number(indexes.value(0).row()).toUtf8();
	mimeData->setData(MIME_TYPE, encoded_data);
	return mimeData;
}
コード例 #6
0
ファイル: examplecppqml.cpp プロジェクト: Paukert/quickbox
void ExampleCppQml::onInstalled()
{
	qfLogFuncFrame();
	qff::MainWindow *fwk = qff::MainWindow::frameWork();
	auto *a = new qfw::Action("Vacuum Database");
	fwk->menuBar()->actionForPath("tools")->addActionInto(a);
	connect(a, &qfw::Action::triggered, this, &ExampleCppQml::doDbVacuum);
}
コード例 #7
0
ファイル: eventplugin.cpp プロジェクト: mezkov/quickbox
bool EventPlugin::closeEvent()
{
	qfLogFuncFrame();
	m_classNameCache.clear();
	setEventName(QString());
	QF_SAFE_DELETE(m_eventConfig);
	emit eventOpened(eventName()); //comment it till QE can load event with invalid name
	return true;
}
コード例 #8
0
ファイル: mainwindow.cpp プロジェクト: Paukert/quickbox
void MainWindow::processSIMessage(const SIMessageData& msg_data)
{
	qfLogFuncFrame();
	//appendLog(qf::core::Log::LOG_INFO, trUtf8("processSIMessage command: %1 , type: %2").arg(SIMessageData::commandName(msg_data.command())).arg(msg_data.type()));
	if(msg_data.type() == SIMessageData::MsgCardReadOut) {
		SIMessageCardReadOut msg(msg_data);
		appendLogPre(qf::core::Log::LOG_DEB, msg.dump());
		appendLog(qf::core::Log::LOG_INFO, trUtf8("card: %1").arg(msg.cardNumber()));
		/*
		SICliScriptDriver *drv = theApp()->scriptDriver();
		try {
			QVariantList args;
			args << msg.toVariant();
			QScriptValue sv = drv->callExtensionFunction("onCardReadOut", args);
			QString ret_type = sv.property("retType").toString();
			if(ret_type == "error") {
				QString err = sv.property("error").toString();
				/// tady by to melo zacit vriskat
				appendLog(qf::core::Log::LOG_ERR, sv.property("message").toString());
			}
			else if(ret_type == "info") {
				//QString info = sv.property("info").toString();
				appendLog(qf::core::Log::LOG_INFO, sv.property("message").toString());
			}
		}
		catch(std::exception &e) {
			appendLog(qf::core::Log::LOG_ERR, e.what());
		}
		catch(...) {
			appendLog(qf::core::Log::LOG_ERR, tr("Unknown exception"));
		}
		*/
	}
	else if(msg_data.type() == SIMessageData::MsgCardEvent) {
		appendLogPre(qf::core::Log::LOG_DEB, msg_data.dump());
		if(msg_data.command() == SIMessageData::CmdSICard5DetectedExt) {
			QByteArray data(1, 0);
			data[0] = 0;
			emit sendSICommand(SIMessageData::CmdGetSICard5Ext, data);
		}
		else if(msg_data.command() == SIMessageData::CmdSICard6DetectedExt) {
			QByteArray data(2, 0);
			data[0] = 1;
			data[1] = 8;
			emit sendSICommand(SIMessageData::CmdGetSICard6Ext, data);
		}
		else if(msg_data.command() == SIMessageData::CmdSICard8AndHigherDetectedExt) {
			QByteArray data(2, 0);
			data[0] = 1;
			data[1] = 8;
			emit sendSICommand(SIMessageData::CmdGetSICard8Ext, data);
		}
	}
	else {
		appendLogPre(qf::core::Log::LOG_DEB, msg_data.dump());
	}
}
コード例 #9
0
ファイル: receiptsplugin.cpp プロジェクト: mezkov/quickbox
QVariantMap ReceiptsPlugin::readCardTablesData(int card_id)
{
	qfLogFuncFrame() << card_id;
	QVariantMap ret;
	CardReader::ReadCard read_card = cardReaderPlugin()->readCard(card_id);
	{
		qfu::TreeTable tt;
		tt.appendColumn("position", QVariant::Int);
		tt.appendColumn("code", QVariant::Int);
		tt.appendColumn("punchTimeMs", QVariant::Int);
		tt.appendColumn("stpTimeMs", QVariant::Int);
		tt.appendColumn("lapTimeMs", QVariant::Int);
 		QMapIterator<QString, QVariant> it(read_card);
		while(it.hasNext()) {
			it.next();
			if(it.key() != QLatin1String("punches"))
				tt.setValue(it.key(), it.value());
		}
		int position = 0;
		int start_time_ms = read_card.startTime();
		if(start_time_ms == 0xeeee)
			start_time_ms = read_card.checkTime();
		start_time_ms *= 1000;
		int prev_stp_time_ms = 0;
		for(auto v : read_card.punches()) {
			CardReader::ReadPunch punch(v.toMap());
			int punch_time_ms = punch.time() * 1000 + punch.msec();
			int stp_time_ms = quickevent::og::TimeMs::msecIntervalAM(start_time_ms, punch_time_ms);
			qfu::TreeTableRow ttr = tt.appendRow();
			++position;
			int code = punch.code();
			ttr.setValue("position", position);
			ttr.setValue("code", code);
			ttr.setValue("punchTimeMs", punch_time_ms);
			ttr.setValue("stpTimeMs", stp_time_ms);
			ttr.setValue("lapTimeMs", stp_time_ms - prev_stp_time_ms);
			prev_stp_time_ms = stp_time_ms;
		}
		{
			qf::core::sql::QueryBuilder qb;
			qb.select2("config", "ckey, cvalue, ctype")
					.from("config")
					.where("ckey LIKE 'event.%'");
			qf::core::sql::Query q;
			q.exec(qb.toString());
			while(q.next()) {
				QVariant v = qf::core::Utils::retypeStringValue(q.value("cvalue").toString(), q.value("ctype").toString());
				tt.setValue(q.value("ckey").toString(), v);
			}
		}
		tt.setValue("stageCount", eventPlugin()->stageCount());
		tt.setValue("currentStageId", eventPlugin()->currentStageId());
		qfDebug() << "card:\n" << tt.toString();
		ret["card"] = tt.toVariant();
	}
	return ret;
}
コード例 #10
0
NetworkReply *NetworkAccessManager::get(const QUrl &url)
{
	qfLogFuncFrame() << url.toString();
	NetworkReply *ret = new NetworkReply();
	QNetworkRequest rq(url);
	//rq.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
	QNetworkReply *repl = Super::get(rq);
	ret->setReply(repl);
	return ret;
}
コード例 #11
0
ファイル: relaysplugin.cpp プロジェクト: Paukert/quickbox
int RelaysPlugin::editRelay(int id, int mode)
{
	qfLogFuncFrame() << "id:" << id;
	auto *w = new  RelayWidget();
	w->setWindowTitle(tr("Edit  Relay"));
	qfd::Dialog dlg(QDialogButtonBox::Save | QDialogButtonBox::Cancel, m_partWidget);
	dlg.setDefaultButton(QDialogButtonBox::Save);
	dlg.setCentralWidget(w);
	w->load(id, (qfm::DataDocument::RecordEditMode)mode);
	return dlg.exec();
}
コード例 #12
0
ファイル: receiptsplugin.cpp プロジェクト: arnost00/quickbox
bool ReceiptsPlugin::printCard(int card_id)
{
	qfLogFuncFrame() << "card id:" << card_id;
	QF_TIME_SCOPE("ReceiptsPlugin::printCard()");
	try {
		QVariantMap dt = readCardTablesData(card_id);
		receiptsPrinter()->printReceipt(manifest()->homeDir() + "/reports/sicard.qml", dt);
		return true;
	}
	catch(const qf::core::Exception &e) {
		qfError() << e.toString();
	}
	return false;
}
コード例 #13
0
ファイル: runstablemodel.cpp プロジェクト: fvacek/quickbox
void RunsTableModel::switchStartTimes(int r1, int r2)
{
	qfLogFuncFrame() << r1 << r2;
	int col_stime = columnIndex("startTimeMs");
	QF_ASSERT(col_stime >= 0, "Bad startTimeMs column!", return);

	int id1 = value(r1, "runs.id").toInt();
	int id2 = value(r2, "runs.id").toInt();
	QString err_msg;
	QModelIndex ix1 = index(r1, col_stime);
	QVariant v1 = ix1.data(Qt::EditRole);
	QModelIndex ix2 = index(r2, col_stime);
	QVariant v2 = ix2.data(Qt::EditRole);

	bool is_single_user = sqlConnection().driverName().endsWith(QLatin1String("SQLITE"), Qt::CaseInsensitive);
	if(is_single_user) {
		setData(ix1, v2);
		setData(ix2, v1);
		postRow(r1, true);
		postRow(r2, true);
	}
	else {
		//qf::core::sql::Transaction transaction(sqlConnection());
		quickevent::core::og::TimeMs t1 = v1.value<quickevent::core::og::TimeMs>();
		quickevent::core::og::TimeMs t2 = v2.value<quickevent::core::og::TimeMs>();
		int msec1 = -1, msec2 = -1;
		qf::core::sql::Query q(sqlConnection());
		QString qs = "SELECT id, startTimeMs FROM runs WHERE id IN (" QF_IARG(id1) ", " QF_IARG(id2) ")";
		q.exec(qs, qf::core::Exception::Throw);
		while(q.next()) {
			int id = q.value("id").toInt();
			if(id == id1)
				msec1 = q.value("startTimeMs").toInt();
			else if(id == id2)
				msec2 = q.value("startTimeMs").toInt();
		}
		qfDebug() << t1.msec() << msec1 << t2.msec() << msec2;
		if(msec1 == t1.msec() && msec2 == t2.msec()) {
			setData(ix1, v2);
			setData(ix2, v1);
			postRow(r1, qf::core::Exception::Throw);
			postRow(r2, qf::core::Exception::Throw);
			//transaction.commit();
		}
		else {
			err_msg = tr("Mid-air collision switching start times, reload table and try it again.");
		}
	}
	emit startTimesSwitched(id1, id2, err_msg);
}
コード例 #14
0
ファイル: classitem.cpp プロジェクト: fvacek/quickbox
void ClassItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
	if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)).length() < QApplication::startDragDistance()) {
		return;
	}
	qfLogFuncFrame();
	setCursor(Qt::ClosedHandCursor);
	QDrag *drag = new QDrag(event->widget());
	QMimeData *mime = new QMimeData;
	drag->setMimeData(mime);
	{
		QVariantMap m;
		auto &dt = data();
		int slot_ix = dt.startSlotIndex();
		int class_ix = dt.classIndex();
		m[QStringLiteral("slotIndex")] = slot_ix;
		m[QStringLiteral("classIndex")] = class_ix;
		QJsonDocument jsd = QJsonDocument::fromVariant(m);
		QString mime_text = QString::fromUtf8(jsd.toJson());
		qfDebug() << "mime:" << mime_text;
		mime->setText(mime_text);

		QPixmap pixmap(rect().size().toSize());
		pixmap.fill(Qt::white);

		QPainter painter(&pixmap);
		//painter.translate(15, 15);
		painter.setRenderHint(QPainter::Antialiasing);
		QStyleOptionGraphicsItem opt;
		paint(&painter, &opt, 0);
		{
			m_classText->paint(&painter, &opt, nullptr);
			painter.translate(m_courseText->pos());
			m_courseText->paint(&painter, &opt, nullptr);
			painter.translate(m_classdefsText->pos() - m_courseText->pos());
			m_classdefsText->paint(&painter, &opt, nullptr);
		}
		painter.end();
		//pixmap.setMask(pixmap.createHeuristicMask());

		drag->setPixmap(pixmap);
		drag->setHotSpot(QPoint(5 * ganttScene()->displayUnit(), 0));
	}
	Qt::DropAction act = drag->exec();
	qfDebug() << "drag exit:" << act;
	if(act == Qt::MoveAction) {

	}
	setCursor(Qt::ArrowCursor);
}
コード例 #15
0
ファイル: eventplugin.cpp プロジェクト: mezkov/quickbox
void EventPlugin::onEventOpened()
{
	qfLogFuncFrame() << "stage count:" << stageCount();
	m_cbxStage->blockSignals(true);
	m_cbxStage->clear();
	int stage_cnt = stageCount();
	for (int i = 0; i < stage_cnt; ++i) {
		m_cbxStage->addItem("E" + QString::number(i + 1), i + 1);
	}
	m_cbxStage->setCurrentIndex(-1);
	m_cbxStage->blockSignals(false);
	loadCurrentStageId();
	//emit this->currentStageIdChanged(currentStageId());
}
コード例 #16
0
QScriptValue SICliScriptDriver::callExtensionFunction(const QString& fn, const QVariantList& params) throw(QFException)
{
	qfLogFuncFrame();
	QScriptValue ret;
	QSettings settings;
	QString extension = settings.value("app/extensions/currentName").toString();
	QString ext_property_name = extension;
	ext_property_name.replace('.', '_');
	ext_property_name = "__sicli_extension_" + ext_property_name;
	if(extension.isEmpty()) return ret;
	QScriptValue mo = scriptEngine()->globalObject().property(ext_property_name);
	qfTrash() << "\t extension module object is undefined:" << mo.isUndefined() << "is valid:" << mo.isValid() << "is null:" << mo.isNull() << "is object:" << mo.isObject();
	if(!mo.isValid()) {
		qfTrash() << "\t loading extension module object";
		mo = constructedModuleObject(extension, QScriptValueList(), Qf::ThrowExc);
		/*
		if(!mo.isObject()) {
			QF_EXCEPTION(tr("Cann't load extension object '%1'").arg(extension));
			//return ret;
		}
		*/
		scriptEngine()->globalObject().setProperty(ext_property_name, mo);
		qfTrash() << "\t loaded extension module object is undefined:" << mo.isUndefined() << "is valid:" << mo.isValid() << "is null:" << mo.isNull() << "is object:" << mo.isObject();
	}
	{
		QScriptValueList args;
		foreach(QVariant v, params) args << variantToScriptValue(v);

		QScriptValue jsfn = mo.property(fn);
		if(jsfn.isFunction()) {
			//qfTrash() << "\t jsfn:" << jsfn.toString();
			QScriptValue sv = callFunction(jsfn, mo, args, !Qf::ThrowExc);
			//qfInfo() << scriptValueToJsonString(sv);
			if(sv.isError()) {
				/// zprava ze skriptu, neco se nepodarilo
				//theApp()->emitLogRequest(QFLog::LOG_ERR, sv.property("message").toString() + "\n" + sv.property("debugInfo").toString());
				theApp()->emitLogRequestPre(QFLog::LOG_ERR, sv.property("message").toString());
				//qfError() << sv.property("message").toString();
			}
			else ret = sv;
		}
		else {
			theApp()->emitLogRequest(QFLog::LOG_ERR, tr("Extension '%1' does not contains function '%2'").arg(extension).arg(fn));
			//qfError() << "Extension" << extension << "does not contains function" << fn;
		}
	}
	return ret;
}
コード例 #17
0
ファイル: receiptsplugin.cpp プロジェクト: arnost00/quickbox
void ReceiptsPlugin::previewReceipt_classic(int card_id)
{
	qfLogFuncFrame() << "card id:" << card_id;
	//qfInfo() << "previewReceipe_classic, card id:" << card_id;
	auto *w = new qf::qmlwidgets::reports::ReportViewWidget();
	w->setPersistentSettingsId("cardPreview");
	w->setWindowTitle(tr("Receipt"));
	w->setReport(manifest()->homeDir() + "/reports/receiptClassic.qml");
	QVariantMap dt = receiptTablesData(card_id);
	for(auto key : dt.keys())
		w->setTableData(key, dt.value(key));
	qff::MainWindow *fwk = qff::MainWindow::frameWork();
	qf::qmlwidgets::dialogs::Dialog dlg(fwk);
	dlg.setCentralWidget(w);
	dlg.exec();
}
コード例 #18
0
ファイル: eventplugin.cpp プロジェクト: mezkov/quickbox
void EventPlugin::editEvent()
{
	qfLogFuncFrame();
	qff::MainWindow *fwk = qff::MainWindow::frameWork();
	qfd::Dialog dlg(fwk);
	dlg.setButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
	EventDialogWidget *event_w = new EventDialogWidget();
	event_w->setEventId(eventName());
	event_w->setEventIdEditable(false);
	event_w->loadParams(eventConfig()->value("event").toMap());
	dlg.setCentralWidget(event_w);
	if(!dlg.exec())
		return;

	eventConfig()->setValue("event", event_w->saveParams());
	eventConfig()->save("event");
}
コード例 #19
0
ファイル: servertreeitem.cpp プロジェクト: Paukert/quickbox
void Connection::close()
{
	qfLogFuncFrame();
	if(!isOpen())
		return;
	QModelIndex ix = model()->object2index(this);
	model()->deleteChildren(ix);
	/*
	QModelIndex ix = model()->object2index(this);
	while(model()->rowCount(ix)) {
		QObject *o = model()->take(model()->index(0, 0, ix));
		qfDebug() << o->objectName();
		delete o;
	}
	*/
	//foreach(QObject *o, children()) delete o;
}
コード例 #20
0
AddLegDialogWidget::AddLegDialogWidget(QWidget *parent)
	: Super(parent)
	, ui(new Ui::AddLegDialogWidget)
{
	qfLogFuncFrame() << objectName();
	ui->setupUi(this);
	setPersistentSettingsId(objectName());
	ui->tblCompetitors->setPersistentSettingsId(ui->tblCompetitors->objectName());
	ui->tblRegistrations->setPersistentSettingsId(ui->tblRegistrations->objectName());

	qf::core::model::SqlTableModel *competitors_model = new qf::core::model::SqlTableModel(this);
	//competitors_model->addColumn("relays.club", tr("Club"));
	competitors_model->addColumn("relayName", tr("Name"));
	competitors_model->addColumn("runs.leg", tr("Leg"));
	competitors_model->addColumn("competitorName", tr("Name"));
	competitors_model->addColumn("registration", tr("Reg"));
	competitors_model->addColumn("licence", tr("Lic"));
	competitors_model->addColumn("competitors.siId", tr("SI"));
	qf::core::sql::QueryBuilder qb;
	qb.select2("runs", "id, relayId, leg")
			.select2("competitors", "id, registration, licence, siId")
			.select2("classes", "name")
			.select2("relays", "classId")
			.select("COALESCE(relays.club, '') || ' ' || COALESCE(relays.name, '') AS relayName")
			.select("COALESCE(lastName, '') || ' ' || COALESCE(firstName, '') AS competitorName")
			.from("runs")
			.join("runs.competitorId", "competitors.id")
			.join("runs.relayId", "relays.id")
			.join("relays.classId", "classes.id")
			.orderBy("competitorName");//.limit(10);
	competitors_model->setQueryBuilder(qb);
	ui->tblCompetitors->setTableModel(competitors_model);
	ui->tblCompetitors->setReadOnly(true);
	competitors_model->reload();

	qf::core::model::SqlTableModel *reg_model = competitorsPlugin()->registrationsModel();
	ui->tblRegistrations->setTableModel(reg_model);
	ui->tblRegistrations->setReadOnly(true);
	connect(reg_model, &qf::core::model::SqlTableModel::reloaded, [this]() {
		ui->tblRegistrations->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents);
	});

	connect(ui->edFilter, &QLineEdit::textChanged, this, &AddLegDialogWidget::onFilterTextChanged);
	connect(ui->tblCompetitors, &qf::qmlwidgets::TableView::doubleClicked, this, &AddLegDialogWidget::onCompetitorSelected);
	connect(ui->tblRegistrations, &qf::qmlwidgets::TableView::doubleClicked, this, &AddLegDialogWidget::onRegistrationSelected);
}
コード例 #21
0
ファイル: eventplugin.cpp プロジェクト: mezkov/quickbox
void EventPlugin::editStage()
{
	qfLogFuncFrame();// << "id:" << id << "mode:" << mode;
	int stage_id = currentStageId();
	if(stage_id < 0)
		return;
	Event::StageWidget *w = new Event::StageWidget();
	w->setWindowTitle(tr("Edit Stage"));
	auto fwk = qf::qmlwidgets::framework::MainWindow::frameWork();
	qfd::Dialog dlg(QDialogButtonBox::Save | QDialogButtonBox::Cancel, fwk);
	dlg.setDefaultButton(QDialogButtonBox::Save);
	dlg.setCentralWidget(w);
	w->load(stage_id);
	if(dlg.exec()) {
		clearStageDataCache();
	}
}
コード例 #22
0
ファイル: table.cpp プロジェクト: arnost00/quickbox
void Table::updateRowCount()
{
	qfLogFuncFrame() << m_cellSize;
	if(!m_cellSize.isValid()) {
		QFontMetrics fm(font(), this);
		qfInfo() << "h:" << fm.height() << "asc:" << fm.ascent() << "desc:" << fm.descent();
		Application *app = Application::instance();
		AppCliOptions *cliopts = app->cliOptions();
		m_cellSize.setHeight(fm.height() * cliopts->fontScale() / 100);
	}
	QSize frame_size = geometry().size();
	m_rowCount = frame_size.height() / m_cellSize.height();
	int rest = frame_size.height() % m_cellSize.height();
	m_cellSize.setHeight(m_cellSize.height() + rest / m_rowCount);
	m_cellSize.setWidth(frame_size.width() / m_columnCount);
	qfDebug() << "new row count:" << m_rowCount << "cell size:" << m_cellSize;
	update();
}
コード例 #23
0
ファイル: table.cpp プロジェクト: arnost00/quickbox
Table::Table(QWidget *parent)
	: Super(parent)
{
	qfLogFuncFrame();
	m_updateRowCountTimer = new QTimer(this);
	m_updateRowCountTimer->setSingleShot(true);
	connect(m_updateRowCountTimer, &QTimer::timeout, this, &Table::updateRowCount);

	m_scrollTimer = new QTimer(this);
	Application *app = Application::instance();
	AppCliOptions *cliopts = app->cliOptions();
	m_columnCount = cliopts->columnCount();
	m_scrollTimer->start(cliopts->refreshTime());
	connect(m_scrollTimer, &QTimer::timeout, [this]() {
		model()->shift();
		update();
	});
}
コード例 #24
0
ファイル: qfstatusbar.cpp プロジェクト: Nechanicky/quickbox
void QFStatusBar::setProgressValue(double val, const QString &label_text)
{
	qfLogFuncFrame() << "val:" << val << "text:" << label_text;
	if(val < 0 || val > 1) hideProgress();
	else {
		progressBar()->setValue(progressBar()->minimum() + (int)((progressBar()->maximum() - progressBar()->minimum()) * val));
		if(progressBar()->isHidden()) {
			progressBar()->show();
			//fProgressBarLabel->show();
		}
	}
	if(label_text.isEmpty()) fProgressBarLabel->hide();
	else {
		fProgressBarLabel->show();
		fProgressBarLabel->setText(label_text);
	}
	QApplication::processEvents();
}
コード例 #25
0
ファイル: eventplugin.cpp プロジェクト: mezkov/quickbox
static bool run_sql_script(qf::core::sql::Query &q, const QStringList &sql_lines)
{
	qfLogFuncFrame();
	for(auto cmd : sql_lines) {
		if(cmd.isEmpty())
			continue;
		if(cmd.startsWith(QLatin1String("--")))
			continue;
		qfDebug() << cmd << ';';
		bool ok = q.exec(cmd);
		if(!ok) {
			qfInfo() << cmd;
			qfError() << q.lastError().text();
			return false;
		}
	}
	return true;
}
コード例 #26
0
ファイル: runstablemodel.cpp プロジェクト: fvacek/quickbox
/*
bool RunsTableModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
{
	qfLogFuncFrame() << "row:" << row << "col:" << column << action << parent;
	Q_UNUSED(action);
	Q_UNUSED(row);
	Q_UNUSED(parent);

	if (!data->hasFormat(MIME_TYPE))
		return false;

	if (column > 0)
		return false;
	qfInfo() << "TRUE";
	return true;
}
*/
bool RunsTableModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
	qfLogFuncFrame() << "row:" << row << "col:" << column << "parent:" << parent;
	if (!canDropMimeData(data, action, row, column, parent))
		return false;

	if (action == Qt::IgnoreAction)
		return true;
	if (!parent.isValid()) {
		// not drop on item
		return false;
	}
	int r1 = QString::fromUtf8(data->data(MIME_TYPE)).toInt();
	int r2 = parent.row();
	qfDebug() << "switch:" << r1 << "and" << r2;
	switchStartTimes(r1, r2);
	return true;
}
コード例 #27
0
ファイル: reportitembreak.cpp プロジェクト: Paukert/quickbox
ReportItem::PrintResult ReportItemBreak::printMetaPaint(ReportItemMetaPaint *out, const ReportItem::Rect &bounding_rect )
{
	qfLogFuncFrame() << "is breaking:" << m_breaking;
	Q_UNUSED(bounding_rect);
	Q_UNUSED(out);
	if(!isVisible()) {
		return PrintResult::createPrintFinished();
	}
	PrintResult ret = PrintResult::createPrintFinished();
	if(!m_breaking) {
		ret = PrintResult::createPrintAgain();
		if(breakType() == BreakType::Page)
			ret.setPageBreak(true);
		else if(breakType() == BreakType::Column)
			ret.setColumnBreak(true);
	}
	m_breaking = !m_breaking;
	return ret;
}
コード例 #28
0
ファイル: mainwindow.cpp プロジェクト: Paukert/quickbox
void MainWindow::onCommOpen(bool checked)
{
	qfLogFuncFrame() << "checked:" << checked;
	if(checked) {
		QSettings settings;
		settings.beginGroup("comm");
		settings.beginGroup("connection");
		QString device = settings.value("device", "/dev/ttyUSB0").toString();
		int baud_rate = settings.value("baudRate", 38400).toInt();
		int data_bits = settings.value("dataBits", 8).toInt();
		int stop_bits = settings.value("stopBits", 1).toInt();
		QString parity = settings.value("parity", "none").toString();
		theApp()->siDriver()->openCommPort(device, baud_rate, data_bits, parity, stop_bits > 1);
		//theApp()->scriptDriver()->callExtensionFunction("onCommConnect", QVariantList() << device);
	}
    else {
        theApp()->siDriver()->closeCommPort();
    }
}
コード例 #29
0
ファイル: classitem.cpp プロジェクト: fvacek/quickbox
void ClassItem::dropEvent(QGraphicsSceneDragDropEvent *event)
{
	qfLogFuncFrame();
	QJsonDocument jsd = QJsonDocument::fromJson(event->mimeData()->text().toUtf8());
	QVariantMap m = jsd.toVariant().toMap();
	Qt::DropAction act = (m.isEmpty())? Qt::IgnoreAction: Qt::MoveAction;
	event->setDropAction(act);
	event->accept();

	int slot1_ix = m.value(QStringLiteral("slotIndex"), -1).toInt();
	int class1_ix = m.value(QStringLiteral("classIndex"), -1).toInt();
	auto dt = data();
	int slot2_ix = dt.startSlotIndex();
	int class2_ix = dt.classIndex();
	if(!m_dropInsertsBefore.toBool())
		class2_ix++;
	qfDebug() << "DROP class:" << slot1_ix << class1_ix;
	ganttItem()->moveClassItem(slot1_ix, class1_ix, slot2_ix, class2_ix);

	m_dropInsertsBefore = QVariant();
	update();
}
コード例 #30
0
ファイル: classeswidget.cpp プロジェクト: pavelkral/quickbox
void ClassesWidget::import_ocad_iofxml()
{
	qfLogFuncFrame();
	QString fn = qfd::FileDialog::getOpenFileName(this, tr("Open file"), QString(), "XML files (*.xml);; All files (*)");
	if(fn.isEmpty())
		return;
	try {
		QFile f(fn);
		if(f.open(QFile::ReadOnly)) {
			QDomDocument xdoc;
			QString err_str; int err_line;
			if(!xdoc.setContent(&f, &err_str, &err_line))
				QF_EXCEPTION(QString("Error parsing xml file '%1' at line: %2").arg(err_str).arg(err_line));

			QDomNodeList xml_courses = xdoc.elementsByTagName(QStringLiteral("Course"));

			QList<CourseDef> defined_courses_list;
			for (int i = 0; i < xml_courses.count(); ++i) {
				QDomElement el_course = xml_courses.at(i).toElement();
				if(el_course.isNull())
					QF_EXCEPTION(QString("Xml file format error: bad element '%1'").arg("Course"));
				CourseDef coursedef;
				QString course_name = element_text(el_course, QStringLiteral("CourseName"));
				course_name.replace(' ', QString());
				course_name.replace(';', '-');
				course_name.replace(',', '-');
				course_name.replace(':', '-');
				course_name.replace('+', '-');
				coursedef.setName(course_name);

				QStringList class_names;
				QDomNodeList xml_classes = el_course.elementsByTagName(QStringLiteral("ClassShortName"));
				for (int j = 0; j < xml_classes.count(); ++j) {
					QString class_name = xml_classes.at(j).toElement().text().trimmed();
					class_names << class_name;
				}
				coursedef.setClasses(class_names);

				QDomElement el_course_variantion = el_course.firstChildElement(QStringLiteral("CourseVariation"));
				if(el_course_variantion.isNull())
					QF_EXCEPTION(QString("Xml file format error: missing element '%1'").arg("CourseVariation"));
				coursedef.setLenght(element_text(el_course_variantion, QStringLiteral("CourseLength")).trimmed().toInt());
				coursedef.setClimb(element_text(el_course_variantion, QStringLiteral("CourseClimb")).trimmed().toInt());

				QMap<int, QVariant> codes;
				QDomNodeList xml_controls = el_course.elementsByTagName(QStringLiteral("CourseControl"));
				for (int j = 0; j < xml_controls.count(); ++j) {
					QDomElement el_control = xml_controls.at(j).toElement();
					int no = element_text(el_control, QStringLiteral("Sequence")).trimmed().toInt();
					if(no <= 0)
						QF_EXCEPTION(QString("Xml file format error: bad sequence number %1 in %2").arg(no).arg(dump_element(el_control)));
					int code = element_text(el_control, QStringLiteral("ControlCode")).trimmed().toInt();
					if(code <= 0)
						QF_EXCEPTION(QString("Xml file format error: bad control code %1 in %2").arg(code).arg(dump_element(el_control)));
					codes[no] = code;
				}
				coursedef.setCodes(codes.values());
				defined_courses_list << coursedef;
			}
			importCourses(defined_courses_list);
		}
	}
	catch (const qf::core::Exception &e) {
		qf::qmlwidgets::framework::MainWindow *fwk = qf::qmlwidgets::framework::MainWindow::frameWork();
		qf::qmlwidgets::dialogs::MessageBox::showException(fwk, e);
	}
}