logic: Don't show line numbers for summary
This commit is contained in:
@@ -37,6 +37,8 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
|||||||
statsSnippet.startLineNumber = 1;
|
statsSnippet.startLineNumber = 1;
|
||||||
statsSnippet.endLineNumber = 1;
|
statsSnippet.endLineNumber = 1;
|
||||||
|
|
||||||
|
statsSnippet.reduced = true;
|
||||||
|
|
||||||
statsSnippet.locationFile = std::make_shared<TokenLocationFile>(FilePath());
|
statsSnippet.locationFile = std::make_shared<TokenLocationFile>(FilePath());
|
||||||
statsSnippet.locationFile->isWholeCopy = true;
|
statsSnippet.locationFile->isWholeCopy = true;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ CodeSnippetParams::CodeSnippetParams()
|
|||||||
, isActive(false)
|
, isActive(false)
|
||||||
, isDeclaration(false)
|
, isDeclaration(false)
|
||||||
, isCollapsed(false)
|
, isCollapsed(false)
|
||||||
|
, reduced(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ struct CodeSnippetParams
|
|||||||
bool isActive;
|
bool isActive;
|
||||||
bool isDeclaration;
|
bool isDeclaration;
|
||||||
bool isCollapsed;
|
bool isCollapsed;
|
||||||
|
|
||||||
|
bool reduced;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CODE_SNIPPET_PARAMS_H
|
#endif // CODE_SNIPPET_PARAMS_H
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ QtCodeArea::QtCodeArea(
|
|||||||
, m_setIDECursorPositionAction(nullptr)
|
, m_setIDECursorPositionAction(nullptr)
|
||||||
, m_eventPosition(0, 0)
|
, m_eventPosition(0, 0)
|
||||||
, m_isActiveFile(false)
|
, m_isActiveFile(false)
|
||||||
|
, m_lineNumbersHidden(false)
|
||||||
{
|
{
|
||||||
setObjectName("code_area");
|
setObjectName("code_area");
|
||||||
setReadOnly(true);
|
setReadOnly(true);
|
||||||
@@ -116,7 +117,7 @@ QtCodeArea::QtCodeArea(
|
|||||||
annotateText();
|
annotateText();
|
||||||
|
|
||||||
m_digits = lineNumberDigits();
|
m_digits = lineNumberDigits();
|
||||||
updateLineNumberAreaWidth(0);
|
updateLineNumberAreaWidth();
|
||||||
|
|
||||||
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
|
connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
|
||||||
connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
|
connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
|
||||||
@@ -221,13 +222,18 @@ int QtCodeArea::lineNumberDigits() const
|
|||||||
|
|
||||||
int QtCodeArea::lineNumberAreaWidth() const
|
int QtCodeArea::lineNumberAreaWidth() const
|
||||||
{
|
{
|
||||||
return fontMetrics().width(QLatin1Char('9')) * m_digits + 30;
|
if (!m_lineNumbersHidden)
|
||||||
|
{
|
||||||
|
return fontMetrics().width(QLatin1Char('9')) * m_digits + 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeArea::updateLineNumberAreaWidthForDigits(int digits)
|
void QtCodeArea::updateLineNumberAreaWidthForDigits(int digits)
|
||||||
{
|
{
|
||||||
m_digits = digits;
|
m_digits = digits;
|
||||||
updateLineNumberAreaWidth(0);
|
updateLineNumberAreaWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeArea::updateContent()
|
void QtCodeArea::updateContent()
|
||||||
@@ -279,6 +285,12 @@ std::string QtCodeArea::getCode() const
|
|||||||
return m_code;
|
return m_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeArea::hideLineNumbers()
|
||||||
|
{
|
||||||
|
m_lineNumberArea->hide();
|
||||||
|
m_lineNumbersHidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
void QtCodeArea::resizeEvent(QResizeEvent *e)
|
void QtCodeArea::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
QPlainTextEdit::resizeEvent(e);
|
QPlainTextEdit::resizeEvent(e);
|
||||||
@@ -529,7 +541,7 @@ void QtCodeArea::updateLineNumberArea(const QRect &rect, int dy)
|
|||||||
|
|
||||||
if (rect.contains(viewport()->rect()))
|
if (rect.contains(viewport()->rect()))
|
||||||
{
|
{
|
||||||
updateLineNumberAreaWidth(0);
|
updateLineNumberAreaWidth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ public:
|
|||||||
|
|
||||||
std::string getCode() const;
|
std::string getCode() const;
|
||||||
|
|
||||||
|
void hideLineNumbers();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
|
||||||
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
|
||||||
@@ -102,7 +104,7 @@ protected:
|
|||||||
virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
|
virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateLineNumberAreaWidth(int newBlockCount);
|
void updateLineNumberAreaWidth(int newBlockCount = 0);
|
||||||
void updateLineNumberArea(const QRect&, int);
|
void updateLineNumberArea(const QRect&, int);
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
void setIDECursorPosition();
|
void setIDECursorPosition();
|
||||||
@@ -177,6 +179,7 @@ private:
|
|||||||
// the position where the context menu is opened needs to be stored]
|
// the position where the context menu is opened needs to be stored]
|
||||||
|
|
||||||
bool m_isActiveFile;
|
bool m_isActiveFile;
|
||||||
|
bool m_lineNumbersHidden;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_CODE_AREA_H
|
#endif // QT_CODE_AREA_H
|
||||||
|
|||||||
@@ -60,11 +60,6 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent)
|
|||||||
|
|
||||||
titleLayout->addWidget(m_title);
|
titleLayout->addWidget(m_title);
|
||||||
|
|
||||||
if (m_title->text().size() == 0)
|
|
||||||
{
|
|
||||||
m_title->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_titleBar->setMinimumHeight(m_title->height() + 4);
|
m_titleBar->setMinimumHeight(m_title->height() + 4);
|
||||||
|
|
||||||
m_referenceCount = new QLabel(this);
|
m_referenceCount = new QLabel(this);
|
||||||
@@ -149,6 +144,11 @@ void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
|||||||
|
|
||||||
std::shared_ptr<QtCodeSnippet> snippet(new QtCodeSnippet(params, this));
|
std::shared_ptr<QtCodeSnippet> snippet(new QtCodeSnippet(params, this));
|
||||||
|
|
||||||
|
if (params.reduced)
|
||||||
|
{
|
||||||
|
m_title->hide();
|
||||||
|
}
|
||||||
|
|
||||||
m_snippetLayout->addWidget(snippet.get());
|
m_snippetLayout->addWidget(snippet.get());
|
||||||
|
|
||||||
if (params.locationFile->isWholeCopy)
|
if (params.locationFile->isWholeCopy)
|
||||||
@@ -172,7 +172,7 @@ void QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
|||||||
|
|
||||||
m_snippets.push_back(snippet);
|
m_snippets.push_back(snippet);
|
||||||
|
|
||||||
updateSnippets();
|
setSnippets();
|
||||||
updateRefCount(params.refCount);
|
updateRefCount(params.refCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params)
|
|||||||
m_snippetLayout->insertWidget(i, snippet.get());
|
m_snippetLayout->insertWidget(i, snippet.get());
|
||||||
m_snippets.insert(m_snippets.begin() + i, snippet);
|
m_snippets.insert(m_snippets.begin() + i, snippet);
|
||||||
|
|
||||||
updateSnippets();
|
setSnippets();
|
||||||
updateRefCount(params.refCount);
|
updateRefCount(params.refCount);
|
||||||
|
|
||||||
return snippet.get();
|
return snippet.get();
|
||||||
@@ -270,6 +270,8 @@ bool QtCodeFile::isCollapsedActiveFile() const
|
|||||||
|
|
||||||
void QtCodeFile::updateContent()
|
void QtCodeFile::updateContent()
|
||||||
{
|
{
|
||||||
|
updateSnippets();
|
||||||
|
|
||||||
for (std::shared_ptr<QtCodeSnippet> snippet : m_snippets)
|
for (std::shared_ptr<QtCodeSnippet> snippet : m_snippets)
|
||||||
{
|
{
|
||||||
snippet->updateContent();
|
snippet->updateContent();
|
||||||
@@ -425,13 +427,13 @@ bool QtCodeFile::hasSnippets() const
|
|||||||
return m_snippets.size() > 0;
|
return m_snippets.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::handleMessage(MessageWindowFocus* message)
|
|
||||||
{
|
|
||||||
updateTitleBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeFile::updateSnippets()
|
void QtCodeFile::updateSnippets()
|
||||||
{
|
{
|
||||||
|
if (m_snippets.size() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int maxDigits = 1;
|
int maxDigits = 1;
|
||||||
for (std::shared_ptr<QtCodeSnippet> snippet : m_snippets)
|
for (std::shared_ptr<QtCodeSnippet> snippet : m_snippets)
|
||||||
{
|
{
|
||||||
@@ -448,8 +450,11 @@ void QtCodeFile::updateSnippets()
|
|||||||
|
|
||||||
m_snippets.front()->setProperty("isFirst", true);
|
m_snippets.front()->setProperty("isFirst", true);
|
||||||
m_snippets.back()->setProperty("isLast", true);
|
m_snippets.back()->setProperty("isLast", true);
|
||||||
|
}
|
||||||
|
|
||||||
setSnippets();
|
void QtCodeFile::handleMessage(MessageWindowFocus* message)
|
||||||
|
{
|
||||||
|
updateTitleBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::updateRefCount(int refCount)
|
void QtCodeFile::updateRefCount(int refCount)
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public:
|
|||||||
void requestSnippets() const;
|
void requestSnippets() const;
|
||||||
bool hasSnippets() const;
|
bool hasSnippets() const;
|
||||||
|
|
||||||
|
void updateSnippets();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clickedMinimizeButton() const;
|
void clickedMinimizeButton() const;
|
||||||
void clickedSnippetButton() const;
|
void clickedSnippetButton() const;
|
||||||
@@ -71,7 +73,6 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
virtual void handleMessage(MessageWindowFocus* message);
|
virtual void handleMessage(MessageWindowFocus* message);
|
||||||
|
|
||||||
void updateSnippets();
|
|
||||||
void updateRefCount(int refCount);
|
void updateRefCount(int refCount);
|
||||||
void updateTitleBar();
|
void updateTitleBar();
|
||||||
void doUpdateTitleBar();
|
void doUpdateTitleBar();
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ void QtCodeFileList::addCodeSnippet(
|
|||||||
{
|
{
|
||||||
file->addCodeSnippet(params);
|
file->addCodeSnippet(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
file->setModificationTime(params.modificationTime);
|
file->setModificationTime(params.modificationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +174,14 @@ void QtCodeFileList::setFileMaximized(const FilePath path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeFileList::updateFiles()
|
||||||
|
{
|
||||||
|
for (std::shared_ptr<QtCodeFile> file: m_files)
|
||||||
|
{
|
||||||
|
file->updateContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QtCodeFileList::showContents()
|
void QtCodeFileList::showContents()
|
||||||
{
|
{
|
||||||
for (std::shared_ptr<QtCodeFile> filePtr : m_files)
|
for (std::shared_ptr<QtCodeFile> filePtr : m_files)
|
||||||
@@ -261,14 +270,6 @@ QtCodeSnippet* QtCodeFileList::getFirstActiveSnippet() const
|
|||||||
return snippet;
|
return snippet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileList::updateFiles()
|
|
||||||
{
|
|
||||||
for (std::shared_ptr<QtCodeFile> file: m_files)
|
|
||||||
{
|
|
||||||
file->updateContent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeFileList::expandActiveSnippetFile(bool scrollTo)
|
void QtCodeFileList::expandActiveSnippetFile(bool scrollTo)
|
||||||
{
|
{
|
||||||
for (std::shared_ptr<QtCodeFile> file: m_files)
|
for (std::shared_ptr<QtCodeFile> file: m_files)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
void setFileSnippets(const FilePath path);
|
void setFileSnippets(const FilePath path);
|
||||||
void setFileMaximized(const FilePath path);
|
void setFileMaximized(const FilePath path);
|
||||||
|
|
||||||
|
void updateFiles();
|
||||||
void showContents();
|
void showContents();
|
||||||
void scrollToValue(int value);
|
void scrollToValue(int value);
|
||||||
void scrollToActiveFileIfRequested();
|
void scrollToActiveFileIfRequested();
|
||||||
@@ -69,8 +70,6 @@ private:
|
|||||||
QtCodeFile* getFile(const FilePath filePath);
|
QtCodeFile* getFile(const FilePath filePath);
|
||||||
QtCodeSnippet* getFirstActiveSnippet() const;
|
QtCodeSnippet* getFirstActiveSnippet() const;
|
||||||
|
|
||||||
void updateFiles();
|
|
||||||
|
|
||||||
void expandActiveSnippetFile(bool scrollTo);
|
void expandActiveSnippetFile(bool scrollTo);
|
||||||
void ensureWidgetVisibleAnimated(QWidget *childWidget, QRectF rect);
|
void ensureWidgetVisibleAnimated(QWidget *childWidget, QRectF rect);
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,10 @@ QtCodeSnippet::QtCodeSnippet(const CodeSnippetParams& params, QtCodeFile* file)
|
|||||||
connect(m_footer, SIGNAL(clicked()), this, SLOT(clickedFooter()));
|
connect(m_footer, SIGNAL(clicked()), this, SLOT(clickedFooter()));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateDots();
|
if (params.reduced)
|
||||||
|
{
|
||||||
|
m_codeArea->hideLineNumbers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtCodeSnippet::~QtCodeSnippet()
|
QtCodeSnippet::~QtCodeSnippet()
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_widget->updateFiles();
|
||||||
|
|
||||||
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
|
setStyleSheet(); // so property "isLast" of QtCodeSnippet is computed correctly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user