forked from mirror/openmw-tes3mp
Implemented line and col calculations in scriptsubview
This commit is contained in:
parent
029a86267b
commit
e7a3f059aa
1 changed files with 28 additions and 16 deletions
|
@ -198,16 +198,30 @@ void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
||||||
if (hint.empty())
|
if (hint.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (hint[0]=='l')
|
size_t line = 0, column = 0;
|
||||||
|
std::istringstream stream (hint.c_str()+2);
|
||||||
|
switch(hint[0]){
|
||||||
|
case 'R':
|
||||||
|
case 'r':
|
||||||
{
|
{
|
||||||
std::istringstream stream (hint.c_str()+1);
|
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
||||||
|
QString source = mModel->data (index).toString();
|
||||||
|
size_t pos;
|
||||||
|
stream >> pos >> pos;
|
||||||
|
|
||||||
char ignore;
|
for (size_t i = 0; i <= pos; ++i){
|
||||||
int line;
|
if (source[(unsigned) i] == '\n'){
|
||||||
int column;
|
++line;
|
||||||
|
column = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
column = pos - column - (line > 0 ? 1 : 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'l':
|
||||||
|
stream >> line >> column;
|
||||||
|
}
|
||||||
|
|
||||||
if (stream >> ignore >> line >> column)
|
|
||||||
{
|
|
||||||
QTextCursor cursor = mEditor->textCursor();
|
QTextCursor cursor = mEditor->textCursor();
|
||||||
|
|
||||||
cursor.movePosition (QTextCursor::Start);
|
cursor.movePosition (QTextCursor::Start);
|
||||||
|
@ -216,8 +230,6 @@ void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
||||||
|
|
||||||
mEditor->setFocus();
|
mEditor->setFocus();
|
||||||
mEditor->setTextCursor (cursor);
|
mEditor->setTextCursor (cursor);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::textChanged()
|
void CSVWorld::ScriptSubView::textChanged()
|
||||||
|
|
Loading…
Reference in a new issue