mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
consider column when jumping to error in source text
This commit is contained in:
parent
0abd29a3b4
commit
f665919046
4 changed files with 20 additions and 15 deletions
|
@ -18,7 +18,8 @@ void CSVWorld::ScriptErrorTable::report (const std::string& message, const Compi
|
||||||
stream << message << " (" << loc.mLiteral << ")";
|
stream << message << " (" << loc.mLiteral << ")";
|
||||||
|
|
||||||
addMessage (stream.str(), type==Compiler::ErrorHandler::WarningMessage ?
|
addMessage (stream.str(), type==Compiler::ErrorHandler::WarningMessage ?
|
||||||
CSMDoc::Message::Severity_Warning : CSMDoc::Message::Severity_Error, loc.mLine);
|
CSMDoc::Message::Severity_Warning : CSMDoc::Message::Severity_Error,
|
||||||
|
loc.mLine, loc.mColumn-loc.mLiteral.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptErrorTable::report (const std::string& message, Type type)
|
void CSVWorld::ScriptErrorTable::report (const std::string& message, Type type)
|
||||||
|
@ -28,7 +29,7 @@ void CSVWorld::ScriptErrorTable::report (const std::string& message, Type type)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptErrorTable::addMessage (const std::string& message,
|
void CSVWorld::ScriptErrorTable::addMessage (const std::string& message,
|
||||||
CSMDoc::Message::Severity severity, int line)
|
CSMDoc::Message::Severity severity, int line, int column)
|
||||||
{
|
{
|
||||||
int row = rowCount();
|
int row = rowCount();
|
||||||
|
|
||||||
|
@ -45,13 +46,16 @@ void CSVWorld::ScriptErrorTable::addMessage (const std::string& message,
|
||||||
lineItem->setData (Qt::DisplayRole, line+1);
|
lineItem->setData (Qt::DisplayRole, line+1);
|
||||||
lineItem->setFlags (lineItem->flags() ^ Qt::ItemIsEditable);
|
lineItem->setFlags (lineItem->flags() ^ Qt::ItemIsEditable);
|
||||||
setItem (row, 1, lineItem);
|
setItem (row, 1, lineItem);
|
||||||
|
|
||||||
|
QTableWidgetItem *columnItem = new QTableWidgetItem;
|
||||||
|
columnItem->setData (Qt::DisplayRole, column);
|
||||||
|
columnItem->setFlags (columnItem->flags() ^ Qt::ItemIsEditable);
|
||||||
|
setItem (row, 3, columnItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
QTableWidgetItem *messageItem = new QTableWidgetItem (QString::fromUtf8 (message.c_str()));
|
QTableWidgetItem *messageItem = new QTableWidgetItem (QString::fromUtf8 (message.c_str()));
|
||||||
messageItem->setFlags (messageItem->flags() ^ Qt::ItemIsEditable);
|
messageItem->setFlags (messageItem->flags() ^ Qt::ItemIsEditable);
|
||||||
setItem (row, 2, messageItem);
|
setItem (row, 2, messageItem);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptErrorTable::setWarningsMode (const QString& value)
|
void CSVWorld::ScriptErrorTable::setWarningsMode (const QString& value)
|
||||||
|
@ -67,7 +71,7 @@ void CSVWorld::ScriptErrorTable::setWarningsMode (const QString& value)
|
||||||
CSVWorld::ScriptErrorTable::ScriptErrorTable (const CSMDoc::Document& document, QWidget *parent)
|
CSVWorld::ScriptErrorTable::ScriptErrorTable (const CSMDoc::Document& document, QWidget *parent)
|
||||||
: QTableWidget (parent), mContext (document.getData())
|
: QTableWidget (parent), mContext (document.getData())
|
||||||
{
|
{
|
||||||
setColumnCount (3);
|
setColumnCount (4);
|
||||||
|
|
||||||
QStringList headers;
|
QStringList headers;
|
||||||
headers << "Severity" << "Line" << "Description";
|
headers << "Severity" << "Line" << "Description";
|
||||||
|
@ -76,6 +80,7 @@ CSVWorld::ScriptErrorTable::ScriptErrorTable (const CSMDoc::Document& document,
|
||||||
horizontalHeader()->setResizeMode (1, QHeaderView::ResizeToContents);
|
horizontalHeader()->setResizeMode (1, QHeaderView::ResizeToContents);
|
||||||
horizontalHeader()->setStretchLastSection (true);
|
horizontalHeader()->setStretchLastSection (true);
|
||||||
verticalHeader()->hide();
|
verticalHeader()->hide();
|
||||||
|
setColumnHidden (3, true);
|
||||||
|
|
||||||
setSelectionMode (QAbstractItemView::NoSelection);
|
setSelectionMode (QAbstractItemView::NoSelection);
|
||||||
|
|
||||||
|
@ -119,6 +124,7 @@ void CSVWorld::ScriptErrorTable::update (const std::string& source)
|
||||||
|
|
||||||
void CSVWorld::ScriptErrorTable::cellClicked (int row, int column)
|
void CSVWorld::ScriptErrorTable::cellClicked (int row, int column)
|
||||||
{
|
{
|
||||||
int line = item (row, 1)->data (Qt::DisplayRole).toInt();
|
int scriptLine = item (row, 1)->data (Qt::DisplayRole).toInt();
|
||||||
emit highlightError (line-1);
|
int scriptColumn = item (row, 3)->data (Qt::DisplayRole).toInt();
|
||||||
|
emit highlightError (scriptLine-1, scriptColumn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace CSVWorld
|
||||||
///< Report a file related error
|
///< Report a file related error
|
||||||
|
|
||||||
void addMessage (const std::string& message, CSMDoc::Message::Severity severity,
|
void addMessage (const std::string& message, CSMDoc::Message::Severity severity,
|
||||||
int line = -1);
|
int line = -1, int column = -1);
|
||||||
|
|
||||||
void setWarningsMode (const QString& value);
|
void setWarningsMode (const QString& value);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void highlightError (int line);
|
void highlightError (int line, int column);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,8 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
|
|
||||||
mErrors->update (source.toUtf8().constData());
|
mErrors->update (source.toUtf8().constData());
|
||||||
|
|
||||||
connect (mErrors, SIGNAL (highlightError (int)), this, SLOT (highlightError (int)));
|
connect (mErrors, SIGNAL (highlightError (int, int)),
|
||||||
|
this, SLOT (highlightError (int, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
||||||
|
@ -247,15 +248,13 @@ void CSVWorld::ScriptSubView::switchToId (const std::string& id)
|
||||||
switchToRow (mModel->getModelIndex (id, 0).row());
|
switchToRow (mModel->getModelIndex (id, 0).row());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::highlightError (int line)
|
void CSVWorld::ScriptSubView::highlightError (int line, int column)
|
||||||
{
|
{
|
||||||
QTextCursor cursor = mEditor->textCursor();
|
QTextCursor cursor = mEditor->textCursor();
|
||||||
|
|
||||||
cursor.movePosition (QTextCursor::Start);
|
cursor.movePosition (QTextCursor::Start);
|
||||||
if (cursor.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, line))
|
if (cursor.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, line))
|
||||||
{
|
cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, column);
|
||||||
// cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, column);
|
|
||||||
}
|
|
||||||
|
|
||||||
mEditor->setFocus();
|
mEditor->setFocus();
|
||||||
mEditor->setTextCursor (cursor);
|
mEditor->setTextCursor (cursor);
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
void switchToId (const std::string& id);
|
void switchToId (const std::string& id);
|
||||||
|
|
||||||
void highlightError (int line);
|
void highlightError (int line, int column);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue