class browser icons
1
NEWS.md
|
@ -1,4 +1,5 @@
|
|||
Version 0.2
|
||||
- enhancement: class browser syntax colors and icons
|
||||
- enhancement: function tips
|
||||
- enhancement: project support
|
||||
- enhancement: paint color editor use system palette's disabled group color
|
||||
|
|
|
@ -460,7 +460,7 @@ void Editor::focusOutEvent(QFocusEvent *event)
|
|||
this,
|
||||
&SynEdit::invalidate);
|
||||
}
|
||||
pMainWindow->updateClassBrowserForEditor(nullptr);
|
||||
//pMainWindow->updateClassBrowserForEditor(nullptr);
|
||||
pMainWindow->updateEditorActions();
|
||||
pMainWindow->updateStatusbarForLineCol();
|
||||
pMainWindow->updateForStatusbarModeInfo();
|
||||
|
|
|
@ -467,5 +467,24 @@
|
|||
<file>images/associations/obj.ico</file>
|
||||
<file>images/associations/rc.ico</file>
|
||||
<file>images/associations/template.ico</file>
|
||||
<file>images/classparser/class.ico</file>
|
||||
<file>images/classparser/define.ico</file>
|
||||
<file>images/classparser/enum.ico</file>
|
||||
<file>images/classparser/global.ico</file>
|
||||
<file>images/classparser/global_method.ico</file>
|
||||
<file>images/classparser/method_inherited.ico</file>
|
||||
<file>images/classparser/method_inherited_protected.ico</file>
|
||||
<file>images/classparser/method_private.ico</file>
|
||||
<file>images/classparser/method_protected.ico</file>
|
||||
<file>images/classparser/method_public.ico</file>
|
||||
<file>images/classparser/namespace.ico</file>
|
||||
<file>images/classparser/static_method.ico</file>
|
||||
<file>images/classparser/static_var.ico</file>
|
||||
<file>images/classparser/type.ico</file>
|
||||
<file>images/classparser/var_inherited.ico</file>
|
||||
<file>images/classparser/var_inherited_protected.ico</file>
|
||||
<file>images/classparser/var_private.ico</file>
|
||||
<file>images/classparser/var_protected.ico</file>
|
||||
<file>images/classparser/var_public.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.1 KiB |
|
@ -1628,6 +1628,19 @@ void MainWindow::buildContextMenus()
|
|||
mProject->removeFolder(folderNode);
|
||||
mProject->saveOptions();
|
||||
});
|
||||
|
||||
//context menu signal for class browser
|
||||
ui->classBrowser->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->classBrowser,&QWidget::customContextMenuRequested,
|
||||
this, &MainWindow::onClassBrowserContextMenu);
|
||||
mClassBrowser_Sort_By_Type = createActionFor(
|
||||
tr("Sort By Type"),
|
||||
ui->classBrowser);
|
||||
mClassBrowser_Sort_By_Type->setIcon(QIcon(":/icons/images/newlook24/077-sort-type.png"));
|
||||
QAction * mClassBrowser_Sort_By_Name;
|
||||
QAction * mClassBrowser_Show_Inheritance;
|
||||
QAction * mClassBrowser_goto_declaration;
|
||||
QAction * mClassBrowser_goto_definition;
|
||||
}
|
||||
|
||||
void MainWindow::maximizeEditor()
|
||||
|
@ -3433,3 +3446,9 @@ const std::shared_ptr<QHash<StatementKind, QColor> > &MainWindow::statementColor
|
|||
return mStatementColors;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_classBrowser_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -339,6 +339,8 @@ private slots:
|
|||
|
||||
void on_actionProject_Open_In_Terminal_triggered();
|
||||
|
||||
void on_classBrowser_doubleClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
EditorList *mEditorList;
|
||||
|
@ -409,6 +411,12 @@ private:
|
|||
QAction * mProject_Rename_Folder;
|
||||
QAction * mProject_Remove_Folder;
|
||||
|
||||
//actions for class browser
|
||||
QAction * mClassBrowser_Sort_By_Type;
|
||||
QAction * mClassBrowser_Sort_By_Name;
|
||||
QAction * mClassBrowser_Show_Inheritance;
|
||||
QAction * mClassBrowser_goto_declaration;
|
||||
QAction * mClassBrowser_goto_definition;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
|
|
|
@ -10,7 +10,7 @@ ClassBrowserModel::ClassBrowserModel(QObject *parent):QAbstractItemModel(parent)
|
|||
mRoot = new ClassBrowserNode();
|
||||
mRoot->parent = nullptr;
|
||||
mRoot->statement = PStatement();
|
||||
mRoot->childrenFetched = true;
|
||||
// mRoot->childrenFetched = true;
|
||||
mUpdating = false;
|
||||
mUpdateCount = 0;
|
||||
mShowInheritedMembers = false;
|
||||
|
@ -54,14 +54,14 @@ bool ClassBrowserModel::hasChildren(const QModelIndex &parent) const
|
|||
{
|
||||
ClassBrowserNode *parentNode;
|
||||
if (!parent.isValid()) { // top level
|
||||
return mRoot->children.count();
|
||||
return mRoot->children.count()>0;
|
||||
} else {
|
||||
parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
||||
if (parentNode->childrenFetched)
|
||||
return parentNode->children.count();
|
||||
if (parentNode->statement)
|
||||
return !parentNode->statement->children.isEmpty();
|
||||
return false;
|
||||
// if (parentNode->childrenFetched)
|
||||
return parentNode->children.count()>0;
|
||||
// if (parentNode->statement)
|
||||
// return !parentNode->statement->children.isEmpty();
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,37 +81,37 @@ int ClassBrowserModel::columnCount(const QModelIndex&) const
|
|||
return 1;
|
||||
}
|
||||
|
||||
void ClassBrowserModel::fetchMore(const QModelIndex &parent)
|
||||
{
|
||||
if (!parent.isValid()) { // top level
|
||||
return;
|
||||
}
|
||||
//void ClassBrowserModel::fetchMore(const QModelIndex &parent)
|
||||
//{
|
||||
// if (!parent.isValid()) { // top level
|
||||
// return;
|
||||
// }
|
||||
|
||||
ClassBrowserNode *parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
||||
if (!parentNode->childrenFetched) {
|
||||
parentNode->childrenFetched = true;
|
||||
if (parentNode->statement && !parentNode->statement->children.isEmpty()) {
|
||||
filterChildren(parentNode, parentNode->statement->children);
|
||||
beginInsertRows(parent,0,parentNode->children.count());
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
// ClassBrowserNode *parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
||||
// if (!parentNode->childrenFetched) {
|
||||
// parentNode->childrenFetched = true;
|
||||
// if (parentNode->statement && !parentNode->statement->children.isEmpty()) {
|
||||
// filterChildren(parentNode, parentNode->statement->children);
|
||||
// beginInsertRows(parent,0,parentNode->children.count());
|
||||
// endInsertRows();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
bool ClassBrowserModel::canFetchMore(const QModelIndex &parent) const
|
||||
{
|
||||
if (!parent.isValid()) { // top level
|
||||
return false;
|
||||
}
|
||||
ClassBrowserNode *parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
||||
if (!parentNode->childrenFetched) {
|
||||
if (parentNode->statement && !parentNode->statement->children.isEmpty())
|
||||
return true;
|
||||
else
|
||||
parentNode->childrenFetched = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//bool ClassBrowserModel::canFetchMore(const QModelIndex &parent) const
|
||||
//{
|
||||
// if (!parent.isValid()) { // top level
|
||||
// return false;
|
||||
// }
|
||||
// ClassBrowserNode *parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
||||
// if (!parentNode->childrenFetched) {
|
||||
// if (parentNode->statement && !parentNode->statement->children.isEmpty())
|
||||
// return true;
|
||||
// else
|
||||
// parentNode->childrenFetched = true;
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const
|
|||
return QVariant();
|
||||
if (role == Qt::DisplayRole) {
|
||||
if (node->statement) {
|
||||
return node->statement->command;
|
||||
return node->statement->command + node->statement->args;
|
||||
}
|
||||
} else if (role == Qt::ForegroundRole) {
|
||||
if (node->statement) {
|
||||
|
@ -136,6 +136,70 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
return mColors->value(kind,pMainWindow->palette().color(QPalette::Text));
|
||||
}
|
||||
} else if (role == Qt::DecorationRole) {
|
||||
if (node->statement) {
|
||||
PStatement statement = (node->statement);
|
||||
StatementKind kind;
|
||||
if (mParser) {
|
||||
kind = mParser->getKindOfStatement(statement);
|
||||
} else {
|
||||
kind = statement->kind;
|
||||
}
|
||||
switch (kind) {
|
||||
case StatementKind::skTypedef:
|
||||
return QIcon(":/icons/images/classparser/type.ico");
|
||||
case StatementKind::skClass:
|
||||
case StatementKind::skEnumClassType:
|
||||
case StatementKind::skEnumType:
|
||||
return QIcon(":/icons/images/classparser/class.ico");
|
||||
case StatementKind::skNamespace:
|
||||
case StatementKind::skNamespaceAlias:
|
||||
return QIcon(":/icons/images/classparser/namespace.ico");
|
||||
case StatementKind::skPreprocessor:
|
||||
return QIcon(":/icons/images/classparser/define.ico");
|
||||
case StatementKind::skEnum:
|
||||
return QIcon(":/icons/images/classparser/enum.ico");
|
||||
case StatementKind::skFunction:
|
||||
case StatementKind::skConstructor:
|
||||
case StatementKind::skDestructor:
|
||||
if (statement->scope == StatementScope::ssGlobal)
|
||||
return QIcon(":/icons/images/classparser/global_method.ico");
|
||||
if (statement->isInherited) {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
return QIcon(":/icons/images/classparser/method_inherited_protected.ico");
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
return QIcon(":/icons/images/classparser/method_inherited.ico");
|
||||
}
|
||||
} else {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
return QIcon(":/icons/images/classparser/method_protected.ico");
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
return QIcon(":/icons/images/classparser/method_public.ico");
|
||||
} else {
|
||||
return QIcon(":/icons/images/classparser/method_private.ico");
|
||||
}
|
||||
}
|
||||
case StatementKind::skVariable:
|
||||
if (statement->scope == StatementScope::ssGlobal)
|
||||
return QIcon(":/icons/images/classparser/global.ico");
|
||||
if (statement->isInherited) {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
return QIcon(":/icons/images/classparser/var_inherited_protected.ico");
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
return QIcon(":/icons/images/classparser/var_inherited.ico");
|
||||
}
|
||||
} else {
|
||||
if (statement->classScope == StatementClassScope::scsProtected) {
|
||||
return QIcon(":/icons/images/classparser/var_protected.ico");
|
||||
} else if (statement->classScope == StatementClassScope::scsPublic) {
|
||||
return QIcon(":/icons/images/classparser/var_public.ico");
|
||||
} else {
|
||||
return QIcon(":/icons/images/classparser/var_private.ico");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -215,9 +279,10 @@ void ClassBrowserModel::addChild(ClassBrowserNode *node, PStatement statement)
|
|||
PClassBrowserNode newNode = std::make_shared<ClassBrowserNode>();
|
||||
newNode->parent = node;
|
||||
newNode->statement = statement;
|
||||
newNode->childrenFetched = false;
|
||||
// newNode->childrenFetched = false;
|
||||
node->children.append(newNode.get());
|
||||
mNodes.append(newNode);
|
||||
filterChildren(newNode.get(), statement->children);
|
||||
}
|
||||
|
||||
void ClassBrowserModel::addMembers(const QSet<QString> &includedFiles)
|
||||
|
|
|
@ -8,7 +8,7 @@ struct ClassBrowserNode {
|
|||
ClassBrowserNode* parent;
|
||||
PStatement statement;
|
||||
QVector<ClassBrowserNode *> children;
|
||||
bool childrenFetched;
|
||||
// bool childrenFetched;
|
||||
};
|
||||
|
||||
using PClassBrowserNode = std::shared_ptr<ClassBrowserNode>;
|
||||
|
@ -26,8 +26,8 @@ public:
|
|||
bool hasChildren(const QModelIndex &parent) const override;
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
int columnCount(const QModelIndex &parent) const override;
|
||||
void fetchMore(const QModelIndex &parent) override;
|
||||
bool canFetchMore(const QModelIndex &parent) const override;
|
||||
// void fetchMore(const QModelIndex &parent) override;
|
||||
// bool canFetchMore(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
const PCppParser &parser() const;
|
||||
void setParser(const PCppParser &newCppParser);
|
||||
|
@ -59,6 +59,7 @@ private:
|
|||
QString mCurrentFile;
|
||||
bool mShowInheritedMembers;
|
||||
std::shared_ptr<QHash<StatementKind, QColor>> mColors;
|
||||
|
||||
};
|
||||
|
||||
#endif // CLASSBROWSER_H
|
||||
|
|