Ejemplo n.º 1
0
void RKConsole::tryNextInBatch (bool add_new_line) {
	RK_TRACE (APP);
	if (add_new_line) {
		if (RKSettingsModuleConsole::maxConsoleLines ()) {
			uint c = (uint) doc->numLines();
			setUpdatesEnabled (false);
			for (uint ui = c; ui > RKSettingsModuleConsole::maxConsoleLines (); --ui) {
				editInterface(doc)->removeText (0, 0,0, editInterface(doc)->textLine(0).length());
			}
			setUpdatesEnabled (true);
		}
		editInterface(doc)->insertText (doc->numLines ()-1, 0, prefix);		// somehow, it seems to be safer to do this after removing superfluous lines, than before
		cursorAtTheEnd ();
	}

	if (!commands_batch.isEmpty()) {
		// If we were not finished executing a batch of commands, we execute the next one.
		setCurrentCommand (currentCommand () + commands_batch.first ());
		commands_batch.pop_front ();
		if (!commands_batch.isEmpty ()){
			submitCommand ();
			return;
		}
		// We would put this here if we would want the last line to be executed. We generally don't want this, as there is an empty last item, if there is a newline at the end.
		//TODO: deal with this kind of situation better.
		//commands_batch.erase(commands_batch.begin());
	}

	current_command = 0;
	interrupt_command_action->setEnabled (isBusy ());
}
Ejemplo n.º 2
0
void RKConsole::newOutput (RCommand *, ROutput *output) {
	RK_TRACE (APP);

// TODO: handle different types of output, once we can differentiate between them
//	insertAt (output->output, doc->numLines()-1, paragraphLength (doc->numLines() - 1));
	if (output_continuation) {
		editInterface (doc)->insertText (doc->numLines () -1, editInterface (doc)->lineLength (doc->numLines () -1), output->output);
	} else {
		editInterface (doc)->insertText (doc->numLines () -1, 0, output->output);
	}

	if (RKSettingsModuleConsole::maxConsoleLines ()) {
		uint c = (uint) doc->numLines();
// TODO: WORKAROUND: Somehow, when removing paragraph 0, the QTextEdit scrolls to the top in between (yes, this also happens when using removeParagaph (0)). Since this may happen very often in newOutput, we're a bit sloppy, and only remove lines after a certain threshold (20) is exceeded. When the command is finished, this will be cleaned up automatically.
		if (c > (RKSettingsModuleConsole::maxConsoleLines () + 20)) {
			view->setUpdatesEnabled (false);		// major performance boost while removing lines!
			//TODO : deal with the case when there is already a selection
			selectionInterface (doc)->setSelection (0, 0, c - RKSettingsModuleConsole::maxConsoleLines (), 0);
			selectionInterface (doc)->removeSelectedText ();
			view->setUpdatesEnabled (true);
		}
	}
	cursorAtTheEnd ();
	output_continuation = true;
}
Ejemplo n.º 3
0
void KDataToolPluginView::slotToolActivated( const KDataToolInfo &info, const QString &command )
{

	KDataTool* tool = info.createTool( );
	if ( !tool )
	{
		kdWarning() << "Could not create Tool !" << endl;
		return;
	}

	QString text;
	if ( selectionInterface(m_view->document())->hasSelection() )
		text = selectionInterface(m_view->document())->selection();
	else
		text = m_wordUnderCursor;

	QString mimetype = "text/plain";
	QString datatype = "QString";

	// If unsupported (and if we have a single word indeed), try application/x-singleword
	if ( !info.mimeTypes().contains( mimetype ) && m_singleWord )
		mimetype = "application/x-singleword";
	
	kdDebug() << "Running tool with datatype=" << datatype << " mimetype=" << mimetype << endl;

	QString origText = text;

	if ( tool->run( command, &text, datatype, mimetype) )
	{
		kdDebug() << "Tool ran. Text is now " << text << endl;
		if ( origText != text )
		{
			uint line, col;
			viewCursorInterface(m_view)->cursorPositionReal(&line, &col);
			if ( ! selectionInterface(m_view->document())->hasSelection() )
			{
				KTextEditor::SelectionInterface *si;
				si = KTextEditor::selectionInterface(m_view->document());
				si->setSelection(m_singleWord_line, m_singleWord_start, m_singleWord_line, m_singleWord_end);
			}
		
			// replace selection with 'text'
			selectionInterface(m_view->document())->removeSelectedText();
			viewCursorInterface(m_view)->cursorPositionReal(&line, &col);
			editInterface(m_view->document())->insertText(line, col, text);
			 // fixme: place cursor at the end:
			 /* No idea yet (Joseph Wenninger)
			 for ( uint i = 0; i < text.length(); i++ ) {
				viewCursorInterface(m_view)->cursorRight();
			 } */
		}
	}

	delete tool;
}
void EapQtValidatorPacStorePassword::updateEditor(HbLineEdit* const edit)
{
    qDebug("EapQtValidatorPacStorePassword::updateEditor()");

    Q_ASSERT(edit);

    edit->setMaxLength(EapQtConfigInterfacePrivate::PacPasswordMaxLength);
    edit->setInputMethodHints(Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase
        | Qt::ImhNoPredictiveText);

    // do not set editor class or auto completing since they might leak the pwd
    HbEditorInterface editInterface(edit);
    editInterface.setSmileyTheme(HbSmileyTheme());
}
Ejemplo n.º 5
0
void RKConsole::submitCommand () {
	RK_TRACE (APP);

	QString current_line = currentCommand ();
	QString command = current_line;
	addCommandToHistory (current_line);
	
	if (command_incomplete) {
		command.prepend (incomplete_command + '\n');
	}

	doc->insertText (doc->numLines () - 1, editInterface (doc)->lineLength (doc->numLines () -1), "\n");
	if (!current_line.isEmpty ()) {
		current_command = new RCommand (command, RCommand::User | RCommand::Console, QString::null, this);
		RKGlobals::rInterface ()->issueCommand (current_command);
		interrupt_command_action->setEnabled (true);
	} else {
		tryNextInBatch ();
	}
}
Ejemplo n.º 6
0
void RKConsole::rCommandDone (RCommand *command) {
	RK_TRACE (APP);
	if (command->errorSyntax ()) {
		editInterface(doc)->insertLine(doc->numLines()-1, i18n ("Syntax error\n"));
	}

	if (command->errorIncomplete ()) {
		prefix = iprefix;
		command_incomplete = true;
		incomplete_command = command->command ();
	} else {
		prefix = nprefix;
		command_incomplete = false;
		incomplete_command = QString::null;
	}

	if (output_continuation) doc->insertLine (doc->numLines (), "");
	output_continuation = false;
	commands_history_position = commands_history.constEnd ();
	tryNextInBatch ();
}
QString RKCommandEditorWindow::getText () {
	RK_TRACE (COMMANDEDITOR);
	return editInterface (m_doc)->text ();
}
/*!
 * Page initialization. If view is already loaded, does nothing.
 * @return pointer to widget "occ_add_wlan_01".
 */
HbWidget* WlanWizardPageSsid::initializePage()
{
    OstTraceFunctionEntry0(WLANWIZARDPAGESSID_INITIALIZEPAGE_ENTRY);
    
    OstTrace0(
        TRACE_NORMAL,
        WLANWIZARDPAGESSID_INITIALIZEPAGE,
        "WlanWizardPageSsid::initializePage");

    // It is not possible for this method to be called more than once during
    // wizard lifetime.
    Q_ASSERT(mWidget == NULL);

    bool ok;

    mLoader = new HbDocumentLoader(mWizard->mainWindow());

    mLoader->load(":/docml/occ_add_wlan_01_04.docml", &ok);
    Q_ASSERT(ok);

    // Load orientation
    loadDocmlSection(mWizard->mainWindow()->orientation());

    // Load widgets
    mWidget = qobject_cast<HbWidget*> (mLoader->findWidget(
        "occ_add_wlan_01"));
    Q_ASSERT(mWidget != NULL);

    mLabel = qobject_cast<HbLabel*> (mLoader->findWidget("dialog"));
    Q_ASSERT(mLabel != NULL);

    mSsid = qobject_cast<HbLineEdit*> (mLoader->findWidget("lineEditKey"));
    Q_ASSERT(mSsid != NULL);

    mLabel->setPlainText(hbTrId(
        "txt_occ_dialog_insert_the_name_of_the_new_wlan_net"));

    // Connect orientation signal from the main window to orientation
    // loader.
    ok = connect(mWizard->mainWindow(),
        SIGNAL(orientationChanged(Qt::Orientation)), this,
        SLOT(loadDocmlSection(Qt::Orientation)));
    Q_ASSERT(ok);

    // Connect text change-signal from input dialog to handler function
    ok = connect(mSsid, SIGNAL(textChanged(const QString &)), this,
        SLOT(textChanged(const QString &)));
    Q_ASSERT(ok);

    HbEditorInterface editInterface(mSsid);
    
    editInterface.setInputConstraints(
        HbEditorConstraintAutoCompletingField |
        HbEditorConstraintLatinAlphabetOnly);
    
    editInterface.setSmileyTheme(HbSmileyTheme());
    editInterface.setEditorClass(HbInputEditorClassNetworkName);
    mSsid->setInputMethodHints(
        Qt::ImhNoPredictiveText | Qt::ImhPreferLowercase);
    mSsid->setMaxLength(WlanWizardUtils::SsidMaxLength);

	OstTraceFunctionExit0(WLANWIZARDPAGESSID_INITIALIZEPAGE_EXIT);
	return mWidget;
}
Ejemplo n.º 9
0
void RKConsole::cursorAtTheEnd () {
	RK_TRACE (APP);
	view->setCursorPosition (doc->numLines() -1, editInterface(doc)->lineLength (doc->numLines() -1));
	view->scrollDown ();
}
Ejemplo n.º 10
0
void RKConsole::setCurrentCommand (const QString &command) {
	RK_TRACE (APP);
	editInterface(doc)->removeText (doc->numLines() - 1, 0, doc->numLines() - 1, editInterface(doc)->textLine(doc->numLines() - 1).length());
	editInterface(doc)->insertText (doc->numLines() - 1, 0, prefix + command);
	cursorAtTheEnd ();
}