diff --git a/NEWS.md b/NEWS.md index 0d2e07a7..7454e423 100644 --- a/NEWS.md +++ b/NEWS.md @@ -32,6 +32,7 @@ Red Panda C++ Version 2.0 - change: Don't generate localized filename when new header/add file in the project view - fix: Restore project's original compiler set if user choose 'No' in the confirm project compiler set change dialog. - fix: Encoding info in the status bar not correctly updated when save a new file + - enhancement: auto sort TODO items Red Panda C++ Version 1.5 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 9e6c11a4..31bdf428 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -4565,7 +4565,6 @@ void MainWindow::onTodoFound(const QString& filename, int lineNo, int ch, const void MainWindow::onTodoParseFinished() { - } void MainWindow::prepareProjectForCompile() @@ -6284,6 +6283,7 @@ void MainWindow::on_actionNew_Project_triggered() } mProject->saveAll(); updateProjectView(); + mTodoParser->parseFiles(mProject->unitFiles()); scanActiveProject(true); Editor* editor = mEditorList->getEditor(); updateClassBrowserForEditor(editor); diff --git a/RedPandaIDE/todoparser.cpp b/RedPandaIDE/todoparser.cpp index 43534079..90443bef 100644 --- a/RedPandaIDE/todoparser.cpp +++ b/RedPandaIDE/todoparser.cpp @@ -143,6 +143,7 @@ void TodoThread::doParseFile(const QString &filename, QSynedit::PHighlighter hig pos+highlighter->getTokenPos(), lines[i].trimmed() ); + break; } } highlighter->next(); @@ -168,13 +169,29 @@ TodoModel::TodoModel(QObject *parent) : QAbstractListModel(parent) void TodoModel::addItem(const QString &filename, int lineNo, int ch, const QString &line) { QList &items=getItems(mIsForProject); - beginInsertRows(QModelIndex(),items.count(),items.count()); + int pos=-1; + for (int i=0;ifilename); + if (comp<0) { + pos=i; + break; + } else if (comp==0) { + if (lineNolineNo) { + pos=i; + break; + } + } + } + if (pos<0) { + pos=items.count(); + } + beginInsertRows(QModelIndex(),pos,pos); PTodoItem item = std::make_shared(); item->filename = filename; item->lineNo = lineNo; item->ch = ch; item->line = line; - items.append(item); + items.insert(pos,item); endInsertRows(); } @@ -259,8 +276,6 @@ QVariant TodoModel::data(const QModelIndex &index, int role) const case 1: return item->lineNo; case 2: - return item->ch; - case 3: return item->line; } } @@ -276,8 +291,6 @@ QVariant TodoModel::headerData(int section, Qt::Orientation orientation, int rol case 1: return tr("Line"); case 2: - return tr("Column"); - case 3: return tr("Content"); } } @@ -286,5 +299,5 @@ QVariant TodoModel::headerData(int section, Qt::Orientation orientation, int rol int TodoModel::columnCount(const QModelIndex &) const { - return 4; + return 3; } diff --git a/RedPandaIDE/todoparser.h b/RedPandaIDE/todoparser.h index bf8980a7..d44570a0 100644 --- a/RedPandaIDE/todoparser.h +++ b/RedPandaIDE/todoparser.h @@ -59,6 +59,7 @@ public: int columnCount(const QModelIndex &parent) const override; bool isForProject() const; void setIsForProject(bool newIsForProject); + }; class TodoThread: public QThread