本文整理汇总了C++中PlainTextEditor类的典型用法代码示例。如果您正苦于以下问题:C++ PlainTextEditor类的具体用法?C++ PlainTextEditor怎么用?C++ PlainTextEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlainTextEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlainTextEditor
Core::IEditor *PlainTextEditorEditable::duplicate(QWidget *parent)
{
PlainTextEditor *newEditor = new PlainTextEditor(parent);
newEditor->duplicateFrom(editor());
TextEditorPlugin::instance()->initializeEditor(newEditor);
return newEditor->editableInterface();
}
示例2: wrapLines
void MainUI::wrapLines(bool wrap){
settings->setValue("wrapLines",wrap);
for(int i=0; i<ui->tabWidget->count(); i++){
PlainTextEditor *edit = static_cast<PlainTextEditor*>(ui->tabWidget->widget(i));
edit->setLineWrapMode( wrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
}
}
示例3: check_PlainTextEditor_blockCount
void BlackMilordTests::check_PlainTextEditor_blockCount()
{
PlainTextEditor *editor = Gui::plainTextEditor();
QString testString = "test\ntest";
editor->setPlainText(testString);
QVERIFY(editor->blockCount() == 2);
}
示例4: showLineNumbers
void MainUI::showLineNumbers(bool show){
settings->setValue("showLineNumbers",show);
for(int i=0; i<ui->tabWidget->count(); i++){
PlainTextEditor *edit = static_cast<PlainTextEditor*>(ui->tabWidget->widget(i));
edit->showLineNumbers(show);
}
}
示例5: check_PlainTextEditor_typing
void BlackMilordTests::check_PlainTextEditor_typing()
{
PlainTextEditor *editor = Gui::plainTextEditor();
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
QVERIFY(editor->toPlainText() == "a");
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_B);
QVERIFY(editor->toPlainText() == "ab");
}
示例6: check_PlainTextEditor_visibleBlocks
void BlackMilordTests::check_PlainTextEditor_visibleBlocks()
{
PlainTextEditor *editor = Gui::plainTextEditor();
QString testString = "test\ntest";
editor->setPlainText(testString);
QVERIFY(editor->firstVisibleBlock() == 0);
QVERIFY(editor->lastVisibleBlock() == 1);
}
示例7: currentEditor
void MainUI::openReplace(){
PlainTextEditor *cur = currentEditor();
if(cur==0){ return; }
ui->groupReplace->setVisible(true);
ui->line_find->setText( cur->textCursor().selectedText() );
ui->line_replace->setText("");
ui->line_replace->setFocus();
}
示例8: tabClosed
void MainUI::tabClosed(int tab){
PlainTextEditor *edit = static_cast<PlainTextEditor*>(ui->tabWidget->widget(tab));
if(edit==0){ return; } //should never happen
if(edit->hasChange()){
//Verify if the user wants to lose any unsaved changes
}
ui->tabWidget->removeTab(tab);
edit->deleteLater();
}
示例9: check_PlainTextEditor_setTextgetText
void BlackMilordTests::check_PlainTextEditor_setTextgetText()
{
PlainTextEditor *editor = Gui::plainTextEditor();
QString testString = "test";
editor->setPlainText(testString);
QVERIFY(editor->toPlainText() == testString);
testString = "test\ntest";
editor->setPlainText(testString);
QVERIFY(editor->toPlainText() == testString);
}
示例10: check_PlainTextEditor_getCursorPosition
void BlackMilordTests::check_PlainTextEditor_getCursorPosition()
{
PlainTextEditor *editor = Gui::plainTextEditor();
QVERIFY(editor->getCursorPosition() == 0);
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
QVERIFY(editor->getCursorPosition() == 1);
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_B);
QVERIFY(editor->getCursorPosition() == 2);
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_Enter);
QVERIFY(editor->getCursorPosition() == 3);
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
QVERIFY(editor->getCursorPosition() == 4);
}
示例11: updateTab
void MainUI::updateTab(QString file){
PlainTextEditor *cur = 0;
int index = -1;
for(int i=0; i<ui->tabWidget->count(); i++){
PlainTextEditor *tmp = static_cast<PlainTextEditor*>(ui->tabWidget->widget(i));
if(tmp->currentFile()==file){
cur = tmp;
index = i;
break;
}
}
if(cur==0){ return; } //should never happen
bool changes = cur->hasChange();
//qDebug() << "Update Tab:" << file << cur << changes;
ui->tabWidget->setTabText(index,(changes ? "*" : "") + file.section("/",-1));
ui->actionSave_File->setEnabled(changes);
this->setWindowTitle( ui->tabWidget->tabText( ui->tabWidget->currentIndex() ) );
}
示例12: updateEditorInfoBar
void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
{
PlainTextEditor *editorEditable = qobject_cast<PlainTextEditor *>(editor);
if (editorEditable) {
PlainTextEditorWidget *textEditor = static_cast<PlainTextEditorWidget *>(editorEditable->editorWidget());
if (textEditor->isMissingSyntaxDefinition() &&
!textEditor->ignoreMissingSyntaxDefinition() &&
TextEditorSettings::instance()->highlighterSettings().alertWhenNoDefinition()) {
Core::EditorManager::instance()->showEditorInfoBar(
Constants::INFO_SYNTAX_DEFINITION,
tr("A highlight definition was not found for this file. "
"Would you like to try to find one?"),
tr("Show highlighter options"),
textEditor,
SLOT(acceptMissingSyntaxDefinitionInfo()),
SLOT(ignoreMissingSyntaxDefinitionInfo()));
return;
}
}
Core::EditorManager::instance()->hideEditorInfoBar(Constants::INFO_SYNTAX_DEFINITION);
}
示例13: tr
void MainUI::OpenFile(QString file){
QStringList files;
if(file.isEmpty()){
//Prompt for a file to open
files = QFileDialog::getOpenFileNames(this, tr("Open File(s)"), currentFileDir(), tr("Text Files (*)") );
if(files.isEmpty()){ return; } //cancelled
}else{
files << file;
}
for(int i=0; i<files.length(); i++){
PlainTextEditor *edit = new PlainTextEditor(settings, this);
connect(edit, SIGNAL(FileLoaded(QString)), this, SLOT(updateTab(QString)) );
connect(edit, SIGNAL(UnsavedChanges(QString)), this, SLOT(updateTab(QString)) );
ui->tabWidget->addTab(edit, files[i].section("/",-1));
edit->showLineNumbers(ui->actionLine_Numbers->isChecked());
edit->setLineWrapMode( ui->actionWrap_Lines->isChecked() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
edit->setFocusPolicy(Qt::ClickFocus); //no "tabbing" into this widget
ui->tabWidget->setCurrentWidget(edit);
edit->LoadFile(files[i]);
edit->setFocus();
QApplication::processEvents(); //to catch the fileLoaded() signal
}
}
示例14: check_PlainTextEditor_setCursorPosition
void BlackMilordTests::check_PlainTextEditor_setCursorPosition()
{
PlainTextEditor *editor = Gui::plainTextEditor();
QString testString = "testtest";
editor->setPlainText(testString);
QVERIFY(editor->getCursorPosition() == 8);
editor->setCursorPosition(4);
QVERIFY(editor->getCursorPosition() == 4);
editor->setCursorPosition(0);
QVERIFY(editor->getCursorPosition() == 0);
editor->setCursorPositionToEnd();
QVERIFY(editor->getCursorPosition() == 8);
editor->setCursorPositionToStart();
QVERIFY(editor->getCursorPosition() == 0);
}
示例15: check_PlainTextEditor_redoUndoAvailability
void BlackMilordTests::check_PlainTextEditor_redoUndoAvailability()
{
PlainTextEditor *editor = Gui::plainTextEditor();
QVERIFY(!editor->canRedo());
QVERIFY(!editor->canUndo());
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
QVERIFY(!editor->canRedo());
QVERIFY(editor->canUndo());
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_Enter);
QVERIFY(!editor->canRedo());
QVERIFY(editor->canUndo());
QTest::keyEvent(QTest::Click, editor->asWidget(), Qt::Key_A);
QVERIFY(!editor->canRedo());
QVERIFY(editor->canUndo());
editor->undo();
QVERIFY(editor->canRedo());
QVERIFY(editor->canUndo());
editor->undo();
QVERIFY(editor->canRedo());
QVERIFY(!editor->canUndo());
editor->redo();
QVERIFY(editor->canRedo());
QVERIFY(editor->canUndo());
editor->redo();
QVERIFY(!editor->canRedo());
QVERIFY(editor->canUndo());
}