Files
Sourcetrail/src/lib_gui/qt/element/QtCodeSnippet.h
T
Eberhard Graether 2bdc9b19a2 ui: Added single file mode to code view
* Added navigation to top of code view for iterating references and switching between list and single file mode
* current file name and reference count is shown on top in single file mode
* refactored scrolling to location or line via request system
* added parameters animated and toTop to scrolling system
* refactored class hierarchy and removed unused stuff in list mode
2017-01-09 00:48:20 +01:00

77 lines
1.5 KiB
C++

#ifndef QT_CODE_SNIPPET_H
#define QT_CODE_SNIPPET_H
#include <vector>
#include <memory>
#include <QFrame>
#include "utility/types.h"
#include "qt/element/QtCodeArea.h"
#include "component/view/helper/CodeSnippetParams.h"
class QBoxLayout;
class QPushButton;
class QtCodeFile;
class QtCodeNavigator;
class TokenLocationFile;
class QtCodeSnippet
: public QFrame
{
Q_OBJECT
public:
static std::shared_ptr<QtCodeSnippet> merged(
QtCodeSnippet* a, QtCodeSnippet* b, QtCodeNavigator* navigator, QtCodeFile* file);
QtCodeSnippet(const CodeSnippetParams& params, QtCodeNavigator* navigator, QtCodeFile* file);
virtual ~QtCodeSnippet();
QtCodeFile* getFile() const;
QtCodeArea* getArea() const;
uint getStartLineNumber() const;
uint getEndLineNumber() const;
int lineNumberDigits() const;
void updateLineNumberAreaWidthForDigits(int digits);
void updateContent();
void setIsActiveFile(bool isActiveFile);
uint getLineNumberForLocationId(Id locationId) const;
uint getStartLineNumberOfFirstActiveLocationOfTokenId(Id tokenId) const;
QRectF getLineRectForLineNumber(uint lineNumber) const;
std::string getCode() const;
private slots:
void clickedTitle();
void clickedFooter();
private:
QPushButton* createScopeLine(QBoxLayout* layout);
void updateDots();
QtCodeNavigator* m_navigator;
QtCodeFile* m_file;
Id m_titleId;
std::string m_titleString;
Id m_footerId;
std::string m_footerString;
std::vector<QPushButton*> m_dots;
QPushButton* m_title;
QPushButton* m_footer;
std::shared_ptr<QtCodeArea> m_codeArea;
};
#endif // QT_CODE_SNIPPET_H