- enhancement: auto sort TODO items
This commit is contained in:
parent
da2a7549f1
commit
fde8a868fa
1
NEWS.md
1
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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<PTodoItem> &items=getItems(mIsForProject);
|
||||
beginInsertRows(QModelIndex(),items.count(),items.count());
|
||||
int pos=-1;
|
||||
for (int i=0;i<items.count();i++) {
|
||||
int comp=QString::compare(filename,items[i]->filename);
|
||||
if (comp<0) {
|
||||
pos=i;
|
||||
break;
|
||||
} else if (comp==0) {
|
||||
if (lineNo<items[i]->lineNo) {
|
||||
pos=i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pos<0) {
|
||||
pos=items.count();
|
||||
}
|
||||
beginInsertRows(QModelIndex(),pos,pos);
|
||||
PTodoItem item = std::make_shared<TodoItem>();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
int columnCount(const QModelIndex &parent) const override;
|
||||
bool isForProject() const;
|
||||
void setIsForProject(bool newIsForProject);
|
||||
|
||||
};
|
||||
|
||||
class TodoThread: public QThread
|
||||
|
|
Loading…
Reference in New Issue