src: refactored lib/utility
* removed unused utilityMath * removed some unused functions from utility * moved time related utility functions to TimeStamp * moved path objects from utility to app/paths * moved objects in lib to lib/app * removed duplicate confirm methods in DialogView * moved utilityFile to utility/file * removed uint typedef and replaced with size_t everywhere * removed boost header in utilityUuid
This commit is contained in:
@@ -75,7 +75,7 @@ void QtLineNumberArea::paintEvent(QPaintEvent *event)
|
||||
|
||||
|
||||
QtCodeArea::QtCodeArea(
|
||||
uint startLineNumber,
|
||||
size_t startLineNumber,
|
||||
const std::string& code,
|
||||
std::shared_ptr<SourceLocationFile> locationFile,
|
||||
QtCodeNavigator* navigator,
|
||||
@@ -319,7 +319,7 @@ void QtCodeArea::setIsActiveFile(bool isActiveFile)
|
||||
m_isActiveFile = isActiveFile;
|
||||
}
|
||||
|
||||
uint QtCodeArea::getLineNumberForLocationId(Id locationId) const
|
||||
size_t QtCodeArea::getLineNumberForLocationId(Id locationId) const
|
||||
{
|
||||
for (const Annotation& annotation : m_annotations)
|
||||
{
|
||||
@@ -332,17 +332,17 @@ uint QtCodeArea::getLineNumberForLocationId(Id locationId) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::pair<uint, uint> QtCodeArea::getLineNumbersForLocationId(Id locationId) const
|
||||
std::pair<size_t, size_t> QtCodeArea::getLineNumbersForLocationId(Id locationId) const
|
||||
{
|
||||
for (const Annotation& annotation : m_annotations)
|
||||
{
|
||||
if (annotation.locationId == locationId)
|
||||
{
|
||||
return std::pair<uint, uint>(annotation.startLine, annotation.endLine);
|
||||
return std::pair<size_t, size_t>(annotation.startLine, annotation.endLine);
|
||||
}
|
||||
}
|
||||
|
||||
return std::pair<uint, uint>(0, 0);
|
||||
return std::pair<size_t, size_t>(0, 0);
|
||||
}
|
||||
|
||||
Id QtCodeArea::getLocationIdOfFirstActiveLocation(Id tokenId) const
|
||||
@@ -403,7 +403,7 @@ std::vector<Id> QtCodeArea::getLocationIdsForTokenIds(const std::set<Id>& tokenI
|
||||
|
||||
size_t QtCodeArea::getActiveLocationCount() const
|
||||
{
|
||||
uint count = 0;
|
||||
size_t count = 0;
|
||||
|
||||
for (const Annotation& annotation : m_annotations)
|
||||
{
|
||||
@@ -428,7 +428,7 @@ size_t QtCodeArea::getActiveLocationCount() const
|
||||
return count;
|
||||
}
|
||||
|
||||
QRectF QtCodeArea::getLineRectForLineNumber(uint lineNumber) const
|
||||
QRectF QtCodeArea::getLineRectForLineNumber(size_t lineNumber) const
|
||||
{
|
||||
if (lineNumber < getStartLineNumber())
|
||||
{
|
||||
@@ -680,7 +680,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
|
||||
QScrollBar* scrollbar = horizontalScrollBar();
|
||||
int visibleContentWidth = width() - lineNumberAreaWidth();
|
||||
float deltaPosRatio = float(deltaX) / (visibleContentWidth);
|
||||
scrollbar->setValue(scrollbar->value() - utility::roundToInt(deltaPosRatio * scrollbar->pageStep()));
|
||||
scrollbar->setValue(scrollbar->value() - std::round(deltaPosRatio * scrollbar->pageStep()));
|
||||
}
|
||||
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(event->pos());
|
||||
|
||||
@@ -53,7 +53,7 @@ class QtCodeArea
|
||||
public:
|
||||
|
||||
QtCodeArea(
|
||||
uint startLineNumber,
|
||||
size_t startLineNumber,
|
||||
const std::string& code,
|
||||
std::shared_ptr<SourceLocationFile> locationFile,
|
||||
QtCodeNavigator* navigator,
|
||||
@@ -74,8 +74,8 @@ public:
|
||||
|
||||
void setIsActiveFile(bool isActiveFile);
|
||||
|
||||
uint getLineNumberForLocationId(Id locationId) const;
|
||||
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
|
||||
size_t getLineNumberForLocationId(Id locationId) const;
|
||||
std::pair<size_t, size_t> getLineNumbersForLocationId(Id locationId) const;
|
||||
|
||||
Id getLocationIdOfFirstActiveLocation(Id tokenId) const;
|
||||
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
|
||||
size_t getActiveLocationCount() const;
|
||||
|
||||
QRectF getLineRectForLineNumber(uint lineNumber) const;
|
||||
QRectF getLineRectForLineNumber(size_t lineNumber) const;
|
||||
|
||||
void findScreenMatches(const std::wstring& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches);
|
||||
void clearScreenMatches();
|
||||
|
||||
@@ -28,7 +28,7 @@ void QtCodeField::clearAnnotationColors()
|
||||
}
|
||||
|
||||
QtCodeField::QtCodeField(
|
||||
uint startLineNumber,
|
||||
size_t startLineNumber,
|
||||
const std::string& code,
|
||||
std::shared_ptr<SourceLocationFile> locationFile,
|
||||
bool convertLocationsOnDemand,
|
||||
@@ -128,12 +128,12 @@ QSize QtCodeField::sizeHint() const
|
||||
return QSize(width + 1, height + 5);
|
||||
}
|
||||
|
||||
uint QtCodeField::getStartLineNumber() const
|
||||
size_t QtCodeField::getStartLineNumber() const
|
||||
{
|
||||
return m_startLineNumber;
|
||||
}
|
||||
|
||||
uint QtCodeField::getEndLineNumber() const
|
||||
size_t QtCodeField::getEndLineNumber() const
|
||||
{
|
||||
return m_startLineNumber + blockCount() - 1;
|
||||
}
|
||||
@@ -382,7 +382,7 @@ void QtCodeField::createAnnotations(std::shared_ptr<SourceLocationFile> location
|
||||
m_locationFile = locationFile;
|
||||
m_annotations.clear();
|
||||
|
||||
uint endLineNumber = getEndLineNumber();
|
||||
size_t endLineNumber = getEndLineNumber();
|
||||
std::set<Id> locationIds;
|
||||
|
||||
locationFile->forEachSourceLocation(
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
static void clearAnnotationColors();
|
||||
|
||||
QtCodeField(
|
||||
uint startLineNumber,
|
||||
size_t startLineNumber,
|
||||
const std::string& code,
|
||||
std::shared_ptr<SourceLocationFile> locationFile,
|
||||
bool convertLocationsOnDemand = true,
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
|
||||
virtual QSize sizeHint() const Q_DECL_OVERRIDE;
|
||||
|
||||
uint getStartLineNumber() const;
|
||||
uint getEndLineNumber() const;
|
||||
size_t getStartLineNumber() const;
|
||||
size_t getEndLineNumber() const;
|
||||
|
||||
int totalLineHeight() const;
|
||||
|
||||
@@ -122,7 +122,7 @@ private:
|
||||
void createMultibyteCharacterLocationCache(const QString& code);
|
||||
int getColumnCorrectedForMultibyteCharacters(int line, int column) const;
|
||||
|
||||
const uint m_startLineNumber;
|
||||
const size_t m_startLineNumber;
|
||||
const std::string m_code;
|
||||
|
||||
std::shared_ptr<SourceLocationFile> m_locationFile;
|
||||
|
||||
@@ -126,8 +126,8 @@ QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params)
|
||||
size_t i = 0;
|
||||
while (i < m_snippets.size())
|
||||
{
|
||||
uint start = newSnippet->getStartLineNumber();
|
||||
uint end = newSnippet->getEndLineNumber();
|
||||
size_t start = newSnippet->getStartLineNumber();
|
||||
size_t end = newSnippet->getEndLineNumber();
|
||||
|
||||
QtCodeSnippet* oldSnippet = m_snippets[i];
|
||||
|
||||
@@ -434,7 +434,7 @@ void QtCodeFile::clickedSnippetButton()
|
||||
|
||||
void QtCodeFile::clickedMaximizeButton()
|
||||
{
|
||||
uint lineNumber = 0;
|
||||
size_t lineNumber = 0;
|
||||
Id locationId = 0;
|
||||
|
||||
std::pair<QtCodeSnippet*, Id> snippet = getFirstSnippetWithActiveLocationId(0);
|
||||
|
||||
@@ -158,7 +158,7 @@ void QtCodeFileList::requestFileContent(const FilePath& filePath)
|
||||
getFile(filePath)->requestContent();
|
||||
}
|
||||
|
||||
bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target)
|
||||
bool QtCodeFileList::requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target)
|
||||
{
|
||||
QtCodeFile* file = getFile(filePath);
|
||||
if (!file)
|
||||
@@ -199,12 +199,12 @@ bool QtCodeFileList::requestScroll(const FilePath& filePath, uint lineNumber, Id
|
||||
return true;
|
||||
}
|
||||
|
||||
uint endLineNumber = 0;
|
||||
size_t endLineNumber = 0;
|
||||
if (!lineNumber)
|
||||
{
|
||||
if (locationId)
|
||||
{
|
||||
std::pair<uint, uint> lineNumbers = snippet->getLineNumbersForLocationId(locationId);
|
||||
std::pair<size_t, size_t> lineNumbers = snippet->getLineNumbersForLocationId(locationId);
|
||||
|
||||
lineNumber = lineNumbers.first;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
void updateCodeSnippet(const CodeSnippetParams& params) override;
|
||||
|
||||
void requestFileContent(const FilePath& filePath) override;
|
||||
bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) override;
|
||||
bool requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) override;
|
||||
|
||||
void updateFiles() override;
|
||||
void showContents() override;
|
||||
|
||||
@@ -153,7 +153,7 @@ void QtCodeFileSingle::requestFileContent(const FilePath& filePath)
|
||||
}
|
||||
|
||||
bool QtCodeFileSingle::requestScroll(
|
||||
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target)
|
||||
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target)
|
||||
{
|
||||
FileData file = getFileData(filePath);
|
||||
if (file.area)
|
||||
@@ -171,12 +171,12 @@ bool QtCodeFileSingle::requestScroll(
|
||||
animated = false;
|
||||
}
|
||||
|
||||
uint endLineNumber = 0;
|
||||
size_t endLineNumber = 0;
|
||||
if (!lineNumber)
|
||||
{
|
||||
if (locationId)
|
||||
{
|
||||
std::pair<uint, uint> lineNumbers = m_area->getLineNumbersForLocationId(locationId);
|
||||
std::pair<size_t, size_t> lineNumbers = m_area->getLineNumbersForLocationId(locationId);
|
||||
|
||||
lineNumber = lineNumbers.first;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
void requestFileContent(const FilePath& filePath) override;
|
||||
bool requestScroll(
|
||||
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) override;
|
||||
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) override;
|
||||
|
||||
void updateFiles() override;
|
||||
void showContents() override;
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
virtual void updateCodeSnippet(const CodeSnippetParams& params) = 0;
|
||||
|
||||
virtual void requestFileContent(const FilePath& filePath) = 0;
|
||||
virtual bool requestScroll(const FilePath& filePath, uint lineNumber, Id locationId, bool animated, ScrollTarget target) = 0;
|
||||
virtual bool requestScroll(const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, ScrollTarget target) = 0;
|
||||
|
||||
virtual void updateFiles() = 0;
|
||||
virtual void showContents() = 0;
|
||||
|
||||
@@ -838,7 +838,7 @@ void QtCodeNavigator::scrollToSnippetIfRequested()
|
||||
}
|
||||
|
||||
void QtCodeNavigator::requestScroll(
|
||||
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target)
|
||||
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target)
|
||||
{
|
||||
ScrollRequest req;
|
||||
req.filePath = filePath;
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
void scrollToSnippetIfRequested();
|
||||
|
||||
void requestScroll(
|
||||
const FilePath& filePath, uint lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target);
|
||||
const FilePath& filePath, size_t lineNumber, Id locationId, bool animated, QtCodeNavigateable::ScrollTarget target);
|
||||
|
||||
signals:
|
||||
void scrollRequest();
|
||||
@@ -172,7 +172,7 @@ private:
|
||||
}
|
||||
|
||||
FilePath filePath;
|
||||
uint lineNumber;
|
||||
size_t lineNumber;
|
||||
Id locationId;
|
||||
|
||||
bool animated;
|
||||
|
||||
@@ -40,7 +40,7 @@ QtCodeSnippet* QtCodeSnippet::merged(
|
||||
|
||||
std::string secondCode = second->getCode();
|
||||
int secondCodeStartIndex = 0;
|
||||
for (uint i = second->getStartLineNumber(); i <= first->getEndLineNumber(); i++)
|
||||
for (size_t i = second->getStartLineNumber(); i <= first->getEndLineNumber(); i++)
|
||||
{
|
||||
secondCodeStartIndex = secondCode.find("\n", secondCodeStartIndex) + 1;
|
||||
}
|
||||
@@ -124,12 +124,12 @@ QtCodeArea* QtCodeSnippet::getArea() const
|
||||
return m_codeArea;
|
||||
}
|
||||
|
||||
uint QtCodeSnippet::getStartLineNumber() const
|
||||
size_t QtCodeSnippet::getStartLineNumber() const
|
||||
{
|
||||
return m_codeArea->getStartLineNumber();
|
||||
}
|
||||
|
||||
uint QtCodeSnippet::getEndLineNumber() const
|
||||
size_t QtCodeSnippet::getEndLineNumber() const
|
||||
{
|
||||
return m_codeArea->getEndLineNumber();
|
||||
}
|
||||
@@ -163,12 +163,12 @@ void QtCodeSnippet::setIsActiveFile(bool isActiveFile)
|
||||
m_codeArea->setIsActiveFile(isActiveFile);
|
||||
}
|
||||
|
||||
uint QtCodeSnippet::getLineNumberForLocationId(Id locationId) const
|
||||
size_t QtCodeSnippet::getLineNumberForLocationId(Id locationId) const
|
||||
{
|
||||
return m_codeArea->getLineNumberForLocationId(locationId);
|
||||
}
|
||||
|
||||
std::pair<uint, uint> QtCodeSnippet::getLineNumbersForLocationId(Id locationId) const
|
||||
std::pair<size_t, size_t> QtCodeSnippet::getLineNumbersForLocationId(Id locationId) const
|
||||
{
|
||||
return m_codeArea->getLineNumbersForLocationId(locationId);
|
||||
}
|
||||
@@ -184,7 +184,7 @@ Id QtCodeSnippet::getFirstActiveLocationId(Id tokenId) const
|
||||
return m_codeArea->getLocationIdOfFirstActiveLocation(tokenId);
|
||||
}
|
||||
|
||||
QRectF QtCodeSnippet::getLineRectForLineNumber(uint lineNumber) const
|
||||
QRectF QtCodeSnippet::getLineRectForLineNumber(size_t lineNumber) const
|
||||
{
|
||||
return m_codeArea->getLineRectForLineNumber(lineNumber);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public:
|
||||
QtCodeFile* getFile() const;
|
||||
QtCodeArea* getArea() const;
|
||||
|
||||
uint getStartLineNumber() const;
|
||||
uint getEndLineNumber() const;
|
||||
size_t getStartLineNumber() const;
|
||||
size_t getEndLineNumber() const;
|
||||
|
||||
int lineNumberDigits() const;
|
||||
|
||||
@@ -44,11 +44,11 @@ public:
|
||||
|
||||
void setIsActiveFile(bool isActiveFile);
|
||||
|
||||
uint getLineNumberForLocationId(Id locationId) const;
|
||||
std::pair<uint, uint> getLineNumbersForLocationId(Id locationId) const;
|
||||
size_t getLineNumberForLocationId(Id locationId) const;
|
||||
std::pair<size_t, size_t> getLineNumbersForLocationId(Id locationId) const;
|
||||
|
||||
Id getFirstActiveLocationId(Id tokenId) const;
|
||||
QRectF getLineRectForLineNumber(uint lineNumber) const;
|
||||
QRectF getLineRectForLineNumber(size_t lineNumber) const;
|
||||
|
||||
std::string getCode() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user