- feature: search panel's context menu
- feature: handle double click on backtrace view - feature: handle double click on breakpoints view
This commit is contained in:
parent
e4d57d5989
commit
ca9f144444
|
@ -1541,6 +1541,13 @@ const QList<PBreakpoint> &BreakpointModel::breakpoints() const
|
|||
return mList;
|
||||
}
|
||||
|
||||
PBreakpoint BreakpointModel::breakpoint(int index) const
|
||||
{
|
||||
if (index<0 && index>=mList.count())
|
||||
return PBreakpoint();
|
||||
return mList[index];
|
||||
}
|
||||
|
||||
|
||||
BacktraceModel::BacktraceModel(QObject *parent):QAbstractTableModel(parent)
|
||||
{
|
||||
|
@ -1627,6 +1634,14 @@ const QList<PTrace> &BacktraceModel::backtraces() const
|
|||
return mList;
|
||||
}
|
||||
|
||||
PTrace BacktraceModel::backtrace(int index) const
|
||||
{
|
||||
if (index>=0 && index < mList.count()){
|
||||
return mList[index];
|
||||
}
|
||||
return PTrace();
|
||||
}
|
||||
|
||||
WatchModel::WatchModel(QObject *parent):QAbstractItemModel(parent)
|
||||
{
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ public:
|
|||
void removeBreakpoint(int index);
|
||||
PBreakpoint setBreakPointCondition(int index, const QString& condition);
|
||||
const QList<PBreakpoint>& breakpoints() const;
|
||||
PBreakpoint breakpoint(int index) const;
|
||||
private:
|
||||
QList<PBreakpoint> mList;
|
||||
};
|
||||
|
@ -127,6 +128,7 @@ public:
|
|||
void clear();
|
||||
void removeTrace(int index);
|
||||
const QList<PTrace>& backtraces() const;
|
||||
PTrace backtrace(int index) const;
|
||||
private:
|
||||
QList<PTrace> mList;
|
||||
};
|
||||
|
|
|
@ -904,18 +904,18 @@ void Editor::copyAsHTML()
|
|||
QGuiApplication::clipboard()->setMimeData(mimeData);
|
||||
}
|
||||
|
||||
void Editor::setCaretPosition(int line, int col)
|
||||
void Editor::setCaretPosition(int line, int aChar)
|
||||
{
|
||||
this->uncollapseAroundLine(line);
|
||||
this->setCaretXYCentered(true,BufferCoord{col,line});
|
||||
this->setCaretXYCentered(true,BufferCoord{aChar,line});
|
||||
}
|
||||
|
||||
void Editor::setCaretPositionAndActivate(int line, int col)
|
||||
void Editor::setCaretPositionAndActivate(int line, int aChar)
|
||||
{
|
||||
this->uncollapseAroundLine(line);
|
||||
if (!this->hasFocus())
|
||||
this->activate();
|
||||
this->setCaretXYCentered(true,BufferCoord{col,line});
|
||||
this->setCaretXYCentered(true,BufferCoord{aChar,line});
|
||||
}
|
||||
|
||||
void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueType errorType, const QString &hint)
|
||||
|
|
|
@ -119,8 +119,8 @@ public:
|
|||
void copyToClipboard() override;
|
||||
void cutToClipboard() override;
|
||||
void copyAsHTML();
|
||||
void setCaretPosition(int line,int col);
|
||||
void setCaretPositionAndActivate(int line,int col);
|
||||
void setCaretPosition(int line,int aChar);
|
||||
void setCaretPositionAndActivate(int line,int aChar);
|
||||
|
||||
void addSyntaxIssues(int line, int startChar, int endChar, CompileIssueType errorType, const QString& hint);
|
||||
void clearSyntaxIssues();
|
||||
|
|
|
@ -1161,7 +1161,6 @@ void MainWindow::buildContextMenus()
|
|||
QKeySequence("Ctrl+Shift+C"));
|
||||
connect(mTableIssuesCopyAllAction,&QAction::triggered,
|
||||
[this](){
|
||||
qDebug()<<"Copy all";
|
||||
QClipboard* clipboard=QGuiApplication::clipboard();
|
||||
QMimeData * mimeData = new QMimeData();
|
||||
mimeData->setText(ui->tableIssues->toTxt());
|
||||
|
@ -1177,6 +1176,28 @@ void MainWindow::buildContextMenus()
|
|||
ui->tableIssues->clearIssues();
|
||||
});
|
||||
|
||||
//context menu signal for search view
|
||||
ui->searchHistoryPanel->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->searchHistoryPanel, &QWidget::customContextMenuRequested,
|
||||
this, &MainWindow::onSearchViewContextMenu);
|
||||
mSearchViewClearAction = createActionFor(
|
||||
tr("Remove this search"),
|
||||
ui->searchHistoryPanel);
|
||||
connect(mSearchViewClearAction, &QAction::triggered,
|
||||
[this](){
|
||||
int index = ui->cbSearchHistory->currentIndex();
|
||||
if (index>=0) {
|
||||
mSearchResultModel.removeSearchResults(index);
|
||||
}
|
||||
});
|
||||
mSearchViewClearAllAction = createActionFor(
|
||||
tr("Clear all searches"),
|
||||
ui->searchHistoryPanel);
|
||||
connect(mSearchViewClearAllAction,&QAction::triggered,
|
||||
[this]() {
|
||||
mSearchResultModel.clear();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::maximizeEditor()
|
||||
|
@ -1269,6 +1290,14 @@ void MainWindow::onTableIssuesContextMenu(const QPoint &pos)
|
|||
menu.exec(ui->tableIssues->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void MainWindow::onSearchViewContextMenu(const QPoint &pos)
|
||||
{
|
||||
QMenu menu(this);
|
||||
menu.addAction(mSearchViewClearAction);
|
||||
menu.addAction(mSearchViewClearAllAction);
|
||||
menu.exec(ui->searchHistoryPanel->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void MainWindow::onEditorContextMenu(const QPoint &pos)
|
||||
{
|
||||
Editor * editor = mEditorList->getEditor();
|
||||
|
@ -2438,3 +2467,41 @@ void MainWindow::on_actionFile_Properties_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_searchView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
QString filename;
|
||||
int line;
|
||||
int start;
|
||||
if (mSearchResultTreeModel->getItemFileAndLineChar(
|
||||
index,filename,line,start)) {
|
||||
Editor *e = mEditorList->getEditorByFilename(filename);
|
||||
if (e) {
|
||||
e->setCaretPositionAndActivate(line,start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_tblStackTrace_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
PTrace trace = mDebugger->backtraceModel()->backtrace(index.row());
|
||||
if (trace) {
|
||||
Editor *e = mEditorList->getEditorByFilename(trace->filename);
|
||||
if (e) {
|
||||
e->setCaretPositionAndActivate(trace->line,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_tblBreakpoints_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
PBreakpoint breakpoint = mDebugger->breakpointModel()->breakpoint(index.row());
|
||||
if (breakpoint) {
|
||||
Editor * e = mEditorList->getEditorByFilename(breakpoint->filename);
|
||||
if (e) {
|
||||
e->setCaretPositionAndActivate(breakpoint->line,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ private slots:
|
|||
|
||||
void onWatchViewContextMenu(const QPoint& pos);
|
||||
void onTableIssuesContextMenu(const QPoint& pos);
|
||||
void onSearchViewContextMenu(const QPoint& pos);
|
||||
|
||||
void on_actionNew_triggered();
|
||||
|
||||
|
@ -289,6 +290,12 @@ private slots:
|
|||
|
||||
void on_actionFile_Properties_triggered();
|
||||
|
||||
void on_searchView_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_tblStackTrace_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void on_tblBreakpoints_doubleClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
EditorList *mEditorList;
|
||||
|
@ -339,6 +346,10 @@ private:
|
|||
QAction * mTableIssuesCopyAllAction;
|
||||
QAction * mTableIssuesClearAction;
|
||||
|
||||
//actions for search result view
|
||||
QAction * mSearchViewClearAction;
|
||||
QAction * mSearchViewClearAllAction;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
|
|
@ -255,7 +255,7 @@
|
|||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabIssues">
|
||||
<attribute name="icon">
|
||||
|
@ -467,7 +467,7 @@
|
|||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabDebugConsole">
|
||||
<attribute name="title">
|
||||
|
@ -760,7 +760,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>946</width>
|
||||
<height>25</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
@ -111,6 +111,12 @@ void SearchResultModel::clear()
|
|||
emit modelChanged();
|
||||
}
|
||||
|
||||
void SearchResultModel::removeSearchResults(int index)
|
||||
{
|
||||
mSearchResults.removeAt(index);
|
||||
emit modelChanged();
|
||||
}
|
||||
|
||||
SearchResultTreeModel::SearchResultTreeModel(SearchResultModel *model, QObject *parent):
|
||||
QAbstractItemModel(parent),
|
||||
mSearchResultModel(model)
|
||||
|
@ -216,6 +222,34 @@ SearchResultModel *SearchResultTreeModel::searchResultModel() const
|
|||
return mSearchResultModel;
|
||||
}
|
||||
|
||||
bool SearchResultTreeModel::getItemFileAndLineChar(const QModelIndex &index, QString &filename, int &line, int &startChar)
|
||||
{
|
||||
if (!index.isValid()){
|
||||
return false;
|
||||
}
|
||||
SearchResultTreeItem *item = static_cast<SearchResultTreeItem *>(index.internalPointer());
|
||||
if (!item)
|
||||
return false;
|
||||
|
||||
PSearchResults results = mSearchResultModel->currentResults();
|
||||
|
||||
if (!results ) {
|
||||
// This is nothing this function is supposed to handle
|
||||
return false;
|
||||
}
|
||||
|
||||
SearchResultTreeItem *parent = item->parent;
|
||||
if (parent==nullptr) { //is filename
|
||||
return false;
|
||||
} else {
|
||||
filename = parent->filename;
|
||||
line = item->line;
|
||||
startChar = item->start;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SearchResultTreeModel::onResultModelChanged()
|
||||
{
|
||||
beginResetModel();
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
PSearchResults currentResults();
|
||||
void setCurrentIndex(int index);
|
||||
void clear();
|
||||
void removeSearchResults(int index);
|
||||
signals:
|
||||
void modelChanged();
|
||||
void currentChanged(int index);
|
||||
|
@ -92,6 +93,11 @@ public:
|
|||
int columnCount(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
SearchResultModel *searchResultModel() const;
|
||||
bool getItemFileAndLineChar(
|
||||
const QModelIndex&index,
|
||||
QString& filename,
|
||||
int& line,
|
||||
int& startChar);
|
||||
public slots:
|
||||
void onResultModelChanged();
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue