logic: Codeview Snippet order
Sorting the Snippets in. the Codeview. Active Token first then declaration, filename and extension
This commit is contained in:
@@ -4,10 +4,11 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "qt/element/QtCodeSnippet.h"
|
||||
#include "utility/FileSystem.h"
|
||||
|
||||
QtCodeFile::QtCodeFile(const std::string& fileName, QWidget *parent)
|
||||
QtCodeFile::QtCodeFile(const std::string& filePath, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_fileName(fileName)
|
||||
, m_filePath(filePath)
|
||||
, m_showMaximizeButton(true)
|
||||
{
|
||||
setObjectName("code_file");
|
||||
@@ -18,10 +19,10 @@ QtCodeFile::QtCodeFile(const std::string& fileName, QWidget *parent)
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
|
||||
QLabel* label = new QLabel(fileName.c_str(), this);
|
||||
QLabel* label = new QLabel(FileSystem::fileName(filePath).c_str(), this);
|
||||
label->setObjectName("title_label");
|
||||
label->minimumSizeHint(); // force font loading
|
||||
label->setFixedWidth(label->fontMetrics().width(fileName.c_str()) + 32);
|
||||
label->setFixedWidth(label->fontMetrics().width(FileSystem::fileName(filePath).c_str()) + 32);
|
||||
label->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
|
||||
layout->addWidget(label);
|
||||
}
|
||||
@@ -30,9 +31,9 @@ QtCodeFile::~QtCodeFile()
|
||||
{
|
||||
}
|
||||
|
||||
const std::string& QtCodeFile::getFileName() const
|
||||
std::string QtCodeFile::getFileName() const
|
||||
{
|
||||
return m_fileName;
|
||||
return FileSystem::fileName(m_filePath);
|
||||
}
|
||||
|
||||
void QtCodeFile::addCodeSnippet(
|
||||
|
||||
@@ -15,10 +15,10 @@ class TokenLocationFile;
|
||||
class QtCodeFile : public QWidget
|
||||
{
|
||||
public:
|
||||
QtCodeFile(const std::string& fileName, QWidget *parent = 0);
|
||||
QtCodeFile(const std::string& filePath, QWidget *parent = 0);
|
||||
virtual ~QtCodeFile();
|
||||
|
||||
const std::string& getFileName() const;
|
||||
std::string getFileName() const;
|
||||
|
||||
void addCodeSnippet(
|
||||
uint startLineNumber,
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<QtCodeSnippet> > m_snippets;
|
||||
const std::string m_fileName;
|
||||
const std::string m_filePath;
|
||||
bool m_showMaximizeButton;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void QtCodeFileList::addCodeSnippet(
|
||||
|
||||
if (!file)
|
||||
{
|
||||
std::shared_ptr<QtCodeFile> filePtr = std::make_shared<QtCodeFile>(fileName, this);
|
||||
std::shared_ptr<QtCodeFile> filePtr = std::make_shared<QtCodeFile>(locationFile.getFilePath(), this);
|
||||
m_files.push_back(filePtr);
|
||||
|
||||
file = filePtr.get();
|
||||
|
||||
@@ -67,7 +67,7 @@ void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
|
||||
m_windows.push_back(ptr);
|
||||
|
||||
ptr->setShowMaximizeButton(false);
|
||||
ptr->addCodeSnippet(1, params.code, params.locationFile, params.activeTokenIds);
|
||||
ptr->addCodeSnippet(1, params.code, params.locationFile, m_activeTokenIds);
|
||||
|
||||
ptr->setWindowTitle(FileSystem::fileName(params.locationFile.getFilePath()).c_str());
|
||||
ptr->show();
|
||||
@@ -81,12 +81,12 @@ void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
|
||||
|
||||
void QtCodeView::doAddCodeSnippet(const CodeSnippetParams& params)
|
||||
{
|
||||
m_widget->addCodeSnippet(params.startLineNumber, params.code, params.locationFile, params.activeTokenIds);
|
||||
m_widget->addCodeSnippet(params.startLineNumber, params.code, params.locationFile, m_activeTokenIds);
|
||||
|
||||
clearClosedWindows();
|
||||
for (std::shared_ptr<QtCodeFileList> window: m_windows)
|
||||
{
|
||||
window->setActiveTokenIds(params.activeTokenIds);
|
||||
window->setActiveTokenIds(m_activeTokenIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,11 @@ void QtCodeView::setStyleSheet(QWidget* widget) const
|
||||
widget->setStyleSheet(TextAccess::createFromFile("data/gui/code_view/code_view.css")->getText().c_str());
|
||||
}
|
||||
|
||||
void QtCodeView::setActiveTokenIds(std::vector<Id> ids)
|
||||
{
|
||||
m_activeTokenIds = ids;
|
||||
}
|
||||
|
||||
void QtCodeView::clearClosedWindows()
|
||||
{
|
||||
for (size_t i = 0; i < m_windows.size(); i++)
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
std::shared_ptr<QtCodeFileList> createQtCodeFileList() const;
|
||||
|
||||
void setStyleSheet(QWidget* widget) const;
|
||||
|
||||
void setActiveTokenIds(std::vector<Id> ids);
|
||||
void clearClosedWindows();
|
||||
|
||||
QtThreadedFunctor<> m_refreshViewFunctor;
|
||||
@@ -47,6 +47,7 @@ private:
|
||||
|
||||
std::shared_ptr<QtCodeFileList> m_widget;
|
||||
std::vector<std::shared_ptr<QtCodeFileList>> m_windows;
|
||||
std::vector<Id> m_activeTokenIds;
|
||||
};
|
||||
|
||||
# endif // QT_CODE_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user