Пример #1
0
void SqlEditor::actionRun_Explain_triggered()
{
    QString s("explain query plan %1");
    s = s.arg(query());
	emit showSqlResult(s);
    appendHistory(s);
}
Пример #2
0
void QG_CommandWidget::tabPressed() {
    if (actionHandler) {
        QStringList reducedChoice;
        QString typed = leCommand->text();
        QStringList choice;

        // check current command:
        choice = actionHandler->getAvailableCommands();
        if (choice.count()==0) {
            choice = RS_COMMANDS->complete(typed);
        }

        for (QStringList::Iterator it = choice.begin(); it != choice.end(); ++it) {
            if (typed.isEmpty() || (*it).startsWith(typed)) {
                reducedChoice << (*it);
            }
        }

        // command found:
        if (reducedChoice.count()==1) {
            leCommand->setText(reducedChoice.first());
        }
        else if (reducedChoice.count()>0) {
			QString const& proposal = this->getRootCommand(reducedChoice, typed);
            appendHistory(reducedChoice.join(", "));
            leCommand -> setText(proposal);
        }
    }
}
Пример #3
0
void ResultDisplay::refresh()
{
    const QStringList expressions = m_expressions;
    const QStringList results = m_results;
    clear();
    appendHistory(expressions, results);
}
Пример #4
0
void QG_CommandWidget::handleCommand(QString cmd)
{
    cmd = cmd.simplified();
    bool isAction=false;
    if (!cmd.isEmpty()) {
        appendHistory(cmd);
    }

    if (actionHandler) {
        isAction=actionHandler->command(cmd);
    }

    if (!isAction && !(cmd.contains(',') || cmd.at(0)=='@')) {
       appendHistory(tr("Unknown command: %1").arg(cmd));
    }

    leCommand->setText("");
}
Пример #5
0
void SqlEditor::action_Run_SQL_triggered()
{
	if (creator && creator->checkForPending())
	{
		QString sql(query());
		emit showSqlResult(sql);
	    appendHistory(sql);
	}
}
Пример #6
0
void QG_CommandWidget::trigger() {
    QString cmd = leCommand->text();
    bool isAction=false;
    if (cmd=="") {
        cmd="\n";
    } else {
        appendHistory(cmd);
    }

    if (actionHandler!=NULL) {
        isAction=actionHandler->command(cmd);
    }

    if (!isAction && cmd!="\n" && !(cmd.contains(',') || cmd.at(0)=='@')) {
       appendHistory(tr("Unknown command: %1").arg(cmd));
    }

    leCommand->setText("");
}
Пример #7
0
void SqlEditor::action_Run_SQL_triggered()
{
	if (creator && creator->checkForPending())
	{
		QString sql(query());
		emit showSqlResult(sql);
		if (Utils::updateObjectTree(sql)) { emit buildTree(); }
		if (Utils::updateTables(sql)) { emit refreshTable(); }
	    appendHistory(sql);
		creator->buildPragmasTree();
	}
}
Пример #8
0
Файл: main.c Проект: macrat/rusk
void onLoadChange(WebKitWebView *webview, WebKitLoadEvent event, RuskWindow *rusk)
{
	switch(event)
	{
		case WEBKIT_LOAD_STARTED:
			gtk_widget_set_visible(GTK_WIDGET(rusk->progressbar), TRUE);
			break;

		case WEBKIT_LOAD_COMMITTED:
			updateBorder(rusk);
			appendHistory(rusk);
			break;

		case WEBKIT_LOAD_FINISHED:
			gtk_widget_set_visible(GTK_WIDGET(rusk->progressbar), FALSE);
			break;

		default:
			break;
	}
}
Пример #9
0
/*
 *  Constructs a QG_CommandWidget as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 */
QG_CommandWidget::QG_CommandWidget(QWidget* parent, const char* name, Qt::WindowFlags fl)
    : QWidget(parent, fl)
    , actionHandler(nullptr)
{
    setObjectName(name);
    setupUi(this);
    connect(leCommand, SIGNAL(command(QString)), this, SLOT(handleCommand(QString)));
    connect(leCommand, SIGNAL(escape()), this, SLOT(escape()));
    connect(leCommand, SIGNAL(focusOut()), this, SLOT(setNormalMode()));
    connect(leCommand, SIGNAL(focusIn()), this, SLOT(setCommandMode()));
    connect(leCommand, SIGNAL(tabPressed()), this, SLOT(tabPressed()));
    connect(leCommand, SIGNAL(clearCommandsHistory()), teHistory, SLOT(clear()));
    connect(leCommand, SIGNAL(message(QString)), this, SLOT(appendHistory(QString)));
    connect(leCommand, &QG_CommandEdit::keycode, this, &QG_CommandWidget::handleKeycode);

    auto a1 = new QAction(QObject::tr("Keycode Mode"), this);
    a1->setObjectName("keycode_action");
    a1->setCheckable(true);
    connect(a1, &QAction::toggled, this, &QG_CommandWidget::setKeycodeMode);
    options_button->addAction(a1);

    QSettings settings;
    if (settings.value("Widgets/KeycodeMode", false).toBool())
    {
        leCommand->keycode_mode = true;
        a1->setChecked(true);
    }

    auto a2 = new QAction(QObject::tr("Load Command File"), this);
    connect(a2, &QAction::triggered, this, &QG_CommandWidget::chooseCommandFile);
    options_button->addAction(a2);

    auto a3 = new QAction(QObject::tr("Paste Multiple Commands"), this);
    connect(a3, &QAction::triggered, leCommand, &QG_CommandEdit::modifiedPaste);
    options_button->addAction(a3);

    options_button->setStyleSheet("QToolButton::menu-indicator { image: none; }");
}
Пример #10
0
bool IOMarket::moveOfferToHistory(uint32_t offerId, MarketOfferState_t state)
{
	const int32_t marketOfferDuration = g_config.getNumber(ConfigManager::MARKET_OFFER_DURATION);

	Database& db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `player_id`, `sale`, `itemtype`, `amount`, `price`, `created` FROM `market_offers` WHERE `id` = " << offerId;

	DBResult_ptr result = db.storeQuery(query.str());
	if (!result) {
		return false;
	}

	query.str(std::string());
	query << "DELETE FROM `market_offers` WHERE `id` = " << offerId;
	if (!db.executeQuery(query.str())) {
		return false;
	}

	appendHistory(result->getNumber<uint32_t>("player_id"), static_cast<MarketAction_t>(result->getNumber<uint16_t>("sale")), result->getNumber<uint16_t>("itemtype"), result->getNumber<uint16_t>("amount"), result->getNumber<uint32_t>("price"), result->getNumber<uint32_t>("created") + marketOfferDuration, state);
	return true;
}
Пример #11
0
void IOMarket::moveOfferToHistory(uint32_t offerId, MarketOfferState_t state)
{
	Database* db = Database::getInstance();
	DBQuery query;
	query << "SELECT `player_id`, `sale`, `itemtype`, `amount`, `price`, `created` FROM `market_offers` WHERE `id` = " << offerId << " AND `world_id` = " 
		<< g_config.getNumber(ConfigManager::WORLD_ID) << ";";

	DBResult* result;
	if(!(result = db->storeQuery(query.str())))
		return;

	query.str("");
	query << "DELETE FROM `market_offers` WHERE `id` = " << offerId << " AND `world_id` = " << g_config.getNumber(ConfigManager::WORLD_ID) << ";";
	if(!db->query(query.str()))
	{
		result->free();
		return;
	}

	appendHistory(result->getDataInt("player_id"), (MarketAction_t)result->getDataInt("sale"), result->getDataInt("itemtype"), result->getDataInt("amount"),
		result->getDataInt("price"), result->getDataInt("created") + g_config.getNumber(ConfigManager::MARKET_OFFER_DURATION), state);
	result->free();
}
Пример #12
0
void IOMarket::moveOfferToHistory(uint32_t offerId, MarketOfferState_t state)
{
	const int32_t marketOfferDuration = g_config.getNumber(ConfigManager::MARKET_OFFER_DURATION);

	Database* db = Database::getInstance();

	std::ostringstream query;
	query << "SELECT `player_id`, `sale`, `itemtype`, `amount`, `price`, `created` FROM `market_offers` WHERE `id` = " << offerId;

	DBResult* result = db->storeQuery(query.str());
	if (!result) {
		return;
	}

	query.str("");
	query << "DELETE FROM `market_offers` WHERE `id` = " << offerId;
	if (!db->executeQuery(query.str())) {
		db->freeResult(result);
		return;
	}

	appendHistory(result->getDataInt("player_id"), (MarketAction_t)result->getDataInt("sale"), result->getDataInt("itemtype"), result->getDataInt("amount"), result->getDataInt("price"), result->getDataInt("created") + marketOfferDuration, state);
	db->freeResult(result);
}
Пример #13
0
bool CmdPromptInput::eventFilter(QObject* obj, QEvent* event)
{
    if(event->type() == QEvent::KeyPress)
    {
        QKeyEvent* pressedKey = (QKeyEvent*)event;

        //NOTE: These shortcuts need to be caught since QLineEdit uses them
        if(pressedKey->matches(QKeySequence::Cut))
        {
            pressedKey->accept();
            emit cutPressed();
            return true;
        }
        else if(pressedKey->matches(QKeySequence::Copy))
        {
            pressedKey->accept();
            emit copyPressed();
            return true;
        }
        else if(pressedKey->matches(QKeySequence::Paste))
        {
            pressedKey->accept();
            emit pastePressed();
            return true;
        }
        else if(pressedKey->matches(QKeySequence::SelectAll))
        {
            pressedKey->accept();
            emit selectAllPressed();
            return true;
        }
        else if(pressedKey->matches(QKeySequence::Undo))
        {
            pressedKey->accept();
            emit undoPressed();
            return true;
        }
        else if(pressedKey->matches(QKeySequence::Redo))
        {
            pressedKey->accept();
            emit redoPressed();
            return true;
        }

        int key = pressedKey->key();
        switch(key)
        {
            case Qt::Key_Enter:
            case Qt::Key_Return:
            case Qt::Key_Space:
                pressedKey->accept();
                processInput(QChar(key));
                return true;
                break;
            case Qt::Key_Delete:
                pressedKey->accept();
                emit deletePressed();
                return true;
                break;
            case Qt::Key_Tab:
                pressedKey->accept();
                emit tabPressed();
                return true;
                break;
            case Qt::Key_Escape:
                pressedKey->accept();
                prefix = "Command: ";
                clear();
                emit appendHistory(curText + tr("*Cancel*"));
                emit escapePressed();
                return true;
                break;
            case Qt::Key_F1:
                pressedKey->accept();
                emit F1Pressed();
                return true;
                break;
            case Qt::Key_F2:
                pressedKey->accept();
                emit F2Pressed();
                return true;
                break;
            case Qt::Key_F3:
                pressedKey->accept();
                emit F3Pressed();
                return true;
                break;
            case Qt::Key_F4:
                pressedKey->accept();
                emit F4Pressed();
                return true;
                break;
            case Qt::Key_F5:
                emit F5Pressed();
                pressedKey->accept();
                return true;
                break;
            case Qt::Key_F6:
                pressedKey->accept();
                emit F6Pressed();
                return true;
                break;
            case Qt::Key_F7:
                pressedKey->accept();
                emit F7Pressed();
                return true;
                break;
            case Qt::Key_F8:
                pressedKey->accept();
                emit F8Pressed();
                return true;
                break;
            case Qt::Key_F9:
                pressedKey->accept();
                emit F9Pressed();
                return true;
                break;
            case Qt::Key_F10:
                pressedKey->accept();
                emit F10Pressed();
                return true;
                break;
            case Qt::Key_F11:
                pressedKey->accept();
                emit F11Pressed();
                return true;
                break;
            case Qt::Key_F12:
                pressedKey->accept();
                emit F12Pressed();
                return true;
                break;
            default:
                pressedKey->ignore();
        }
    }
    return QObject::eventFilter(obj, event);
}
Пример #14
0
void CmdPromptInput::processInput(const QChar& rapidChar)
{
    qDebug("CmdPromptInput::processInput");

    updateCurrentText(curText);

    QString cmdtxt(curText);
    cmdtxt.replace(0, prefix.length(), "");
    if(!rapidFireEnabled) cmdtxt = cmdtxt.toLower();

    if(cmdActive)
    {
        if(rapidFireEnabled)
        {
            if(rapidChar == Qt::Key_Enter || rapidChar == Qt::Key_Return)
            {
                emit appendHistory(curText);
                emit runCommand(curCmd, "RAPID_ENTER");
                curText.clear();
                clear();
                return;
            }
            else if(rapidChar == Qt::Key_Space)
            {
                updateCurrentText(curText + " ");
                emit runCommand(curCmd, cmdtxt + " ");
                return;
            }
            else
            {
                emit runCommand(curCmd, cmdtxt);
                return;
            }
        }
        else
        {
            emit appendHistory(curText);
            emit runCommand(curCmd, cmdtxt);
        }
    }
    else
    {
        if(aliasHash->contains(cmdtxt))
        {
            cmdActive = true;
            lastCmd = curCmd;
            curCmd = aliasHash->value(cmdtxt);
            emit appendHistory(curText);
            emit startCommand(curCmd);
        }
        else if(cmdtxt.isEmpty())
        {
            cmdActive = true;
            emit appendHistory(curText);
            //Rerun the last successful command
            emit startCommand(lastCmd);
        }
        else
        {
            emit appendHistory(curText + " Unknown command \"" + cmdtxt + "\". Press F1 for help.");
        }
    }

    if(!rapidFireEnabled)
        clear();
}
Пример #15
0
void SqlEditor::actionRun_as_Script_triggered()
{
	if ((!creator) || !(creator->checkForPending())) { return; }
	SqlQueryModel * model = 0;
	bool rebuildTree = false;
	bool updateTable = false;
	m_scriptCancelled = false;
	toSQLParse::editorTokenizer tokens(ui.sqlTextEdit);
	int cpos, cline;
	ui.sqlTextEdit->getCursorPosition(&cline, &cpos);

	QProgressDialog * dialog =
		new QProgressDialog(tr("Executing all statements"),
			tr("Cancel"), 0, ui.sqlTextEdit->lines(), this);
	connect(dialog, SIGNAL(canceled()), this, SLOT(scriptCancelled()));

	int line;
	int pos;
	bool ignore = true;

	QSqlQuery query(QSqlDatabase::database(SESSION_NAME));
	QString sql;
	bool isError = false;

	emit sqlScriptStart();
	emit showSqlScriptResult("-- " + tr("Script started"));
	do {
		line = tokens.line();
		pos = tokens.offset();
		dialog->setValue(line);
		qApp->processEvents();
		if (m_scriptCancelled)
			break;
		toSQLParse::parseStatement(tokens);

		if (ignore && (tokens.line() > cline ||
				  (tokens.line() == cline &&
				  tokens.offset() >= cpos)))
		{
			ignore = false;
			cline = line;
			cpos = pos;
		}

		if (tokens.line() < ui.sqlTextEdit->lines() && !ignore)
		{
			sql = prepareExec(tokens, line, pos);
			emit showSqlScriptResult(sql);
			SqlQueryModel * mdl = new SqlQueryModel(creator);
			mdl->setQuery(sql, QSqlDatabase::database(SESSION_NAME));
            appendHistory(sql);
			if (mdl->lastError().isValid())
			{
				emit showSqlScriptResult(
					"-- " + tr("Error: %1.").arg(mdl->lastError().text()));
				int com = QMessageBox::question(this, tr("Run as Script"),
						tr("This script contains the following error:\n")
						+ mdl->lastError().text()
						+ tr("\nAt line: %1").arg(line),
						QMessageBox::Ignore, QMessageBox::Abort);
				if (com == QMessageBox::Abort)
				{
					scriptCancelled();
					isError = true;
					break;
				}
			}
			else
			{
				if (Utils::updateObjectTree(sql)) { rebuildTree = true; }
				if (Utils::updateTables(sql)) { updateTable = true; }
				emit showSqlScriptResult("-- " + tr("No error"));
				if (mdl->rowCount() > 0) { model = mdl; }
				else delete mdl;
			}
			emit showSqlScriptResult("--");
		}
	}
	while (tokens.line() < ui.sqlTextEdit->lines());

	delete dialog;
	ui.sqlTextEdit->setSelection(cline, cpos, tokens.line(), tokens.offset());
	if (!isError)
		emit showSqlScriptResult("-- " + tr("Script finished"));
	if (rebuildTree) { emit buildTree(); }
	if (updateTable) { emit refreshTable(); }
	if (model)
	{
		creator->setTableModel(model);
	}
	creator->buildPragmasTree();
}