mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-07 05:15:34 +00:00
jump to line in source text when clicking on an error in error table
This commit is contained in:
parent
6576ac34f6
commit
757f7d895a
4 changed files with 36 additions and 0 deletions
|
@ -77,10 +77,14 @@ CSVWorld::ScriptErrorTable::ScriptErrorTable (const CSMDoc::Document& document,
|
|||
horizontalHeader()->setStretchLastSection (true);
|
||||
verticalHeader()->hide();
|
||||
|
||||
setSelectionMode (QAbstractItemView::NoSelection);
|
||||
|
||||
Compiler::registerExtensions (mExtensions);
|
||||
mContext.setExtensions (&mExtensions);
|
||||
|
||||
setWarningsMode (CSMSettings::UserSettings::instance().settingValue ("script-editor/warnings"));
|
||||
|
||||
connect (this, SIGNAL (cellClicked (int, int)), this, SLOT (cellClicked (int, int)));
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptErrorTable::updateUserSetting (const QString& name, const QStringList& value)
|
||||
|
@ -112,3 +116,9 @@ void CSVWorld::ScriptErrorTable::update (const std::string& source)
|
|||
addMessage (error.what(), CSMDoc::Message::Severity_SeriousError);
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptErrorTable::cellClicked (int row, int column)
|
||||
{
|
||||
int line = item (row, 1)->data (Qt::DisplayRole).toInt();
|
||||
emit highlightError (line-1);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,14 @@ namespace CSVWorld
|
|||
void updateUserSetting (const QString& name, const QStringList& value);
|
||||
|
||||
void update (const std::string& source);
|
||||
|
||||
private slots:
|
||||
|
||||
void cellClicked (int row, int column);
|
||||
|
||||
signals:
|
||||
|
||||
void highlightError (int line);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
|||
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
||||
|
||||
mErrors->update (source.toUtf8().constData());
|
||||
|
||||
connect (mErrors, SIGNAL (highlightError (int)), this, SLOT (highlightError (int)));
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
||||
|
@ -244,3 +246,17 @@ void CSVWorld::ScriptSubView::switchToId (const std::string& id)
|
|||
{
|
||||
switchToRow (mModel->getModelIndex (id, 0).row());
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptSubView::highlightError (int line)
|
||||
{
|
||||
QTextCursor cursor = mEditor->textCursor();
|
||||
|
||||
cursor.movePosition (QTextCursor::Start);
|
||||
if (cursor.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, line))
|
||||
{
|
||||
// cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, column);
|
||||
}
|
||||
|
||||
mEditor->setFocus();
|
||||
mEditor->setTextCursor (cursor);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace CSVWorld
|
|||
void switchToRow (int row);
|
||||
|
||||
void switchToId (const std::string& id);
|
||||
|
||||
void highlightError (int line);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue