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
This commit is contained in:
@@ -90,7 +90,7 @@ std::shared_ptr<Application> Application::s_instance;
|
||||
|
||||
Application::Application(bool withGUI)
|
||||
: m_hasGUI(withGUI)
|
||||
, m_isInTrial(false)
|
||||
, m_isInTrial(true)
|
||||
{
|
||||
LicenseChecker::createInstance();
|
||||
}
|
||||
|
||||
@@ -166,6 +166,11 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
{
|
||||
TRACE("code change file");
|
||||
|
||||
if (!m_collection)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CodeView* view = getView();
|
||||
|
||||
switch (message->state)
|
||||
@@ -177,8 +182,18 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
case MessageChangeFileView::FILE_SNIPPETS:
|
||||
if (message->needsData)
|
||||
{
|
||||
view->addCodeSnippets(getSnippetsForFile(
|
||||
m_collection->getTokenLocationFileByPath(message->filePath), !message->showErrors), false);
|
||||
std::shared_ptr<TokenLocationFile> file = m_collection->getTokenLocationFileByPath(message->filePath);
|
||||
if (!file)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (message->showErrors)
|
||||
{
|
||||
file->isWholeCopy = false;
|
||||
}
|
||||
|
||||
view->addCodeSnippets(getSnippetsForFile(file, !message->showErrors), false);
|
||||
}
|
||||
view->setFileState(message->filePath, CodeView::FILE_SNIPPETS);
|
||||
break;
|
||||
@@ -198,6 +213,10 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
if (message->showErrors)
|
||||
{
|
||||
params.locationFile = m_collection->getTokenLocationFileByPath(message->filePath);
|
||||
if (!params.locationFile)
|
||||
{
|
||||
return;
|
||||
}
|
||||
params.locationFile->isWholeCopy = true;
|
||||
}
|
||||
else
|
||||
@@ -221,6 +240,7 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
||||
|
||||
getView()->addCodeSnippets(std::vector<CodeSnippetParams>(1, params), false);
|
||||
}
|
||||
|
||||
view->setFileState(message->filePath, CodeView::FILE_MAXIMIZED);
|
||||
break;
|
||||
}
|
||||
@@ -256,7 +276,7 @@ void CodeController::handleMessage(MessageFocusOut* message)
|
||||
|
||||
void CodeController::handleMessage(MessageCodeViewExpandedInitialFiles* message)
|
||||
{
|
||||
if (m_scrollToDefinition)
|
||||
if (m_scrollToDefinition || (message && message->scrollToDefinition))
|
||||
{
|
||||
getView()->scrollToDefinition();
|
||||
m_scrollToDefinition = false;
|
||||
@@ -264,7 +284,7 @@ void CodeController::handleMessage(MessageCodeViewExpandedInitialFiles* message)
|
||||
|
||||
if (m_scrollToValue != -1)
|
||||
{
|
||||
getView()->scrollToValue(m_scrollToValue);
|
||||
getView()->scrollToValue(m_scrollToValue, m_scrollInListMode);
|
||||
m_scrollToValue = -1;
|
||||
}
|
||||
}
|
||||
@@ -294,6 +314,7 @@ void CodeController::handleMessage(MessageScrollCode* message)
|
||||
if (message->isReplayed())
|
||||
{
|
||||
m_scrollToValue = message->value;
|
||||
m_scrollInListMode = message->inListMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ private:
|
||||
|
||||
bool m_scrollToDefinition;
|
||||
int m_scrollToValue;
|
||||
bool m_scrollInListMode;
|
||||
};
|
||||
|
||||
#endif // CODE_CONTROLLER_H
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
|
||||
virtual void showContents() = 0;
|
||||
|
||||
virtual void scrollToValue(int value) = 0;
|
||||
virtual void scrollToValue(int value, bool inListMode) = 0;
|
||||
virtual void scrollToLine(const FilePath filePath, unsigned int line) = 0;
|
||||
virtual void scrollToDefinition() = 0;
|
||||
|
||||
|
||||
@@ -301,6 +301,16 @@ void ApplicationSettings::setCodeSnippetExpandRange(int range)
|
||||
setValue<int>("code/snippet/expand_range", range);
|
||||
}
|
||||
|
||||
bool ApplicationSettings::getCodeViewModeSingle() const
|
||||
{
|
||||
return getValue<bool>("code/view_mode_single", false);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setCodeViewModeSingle(bool enabled)
|
||||
{
|
||||
setValue<bool>("code/view_mode_single", enabled);
|
||||
}
|
||||
|
||||
std::vector<FilePath> ApplicationSettings::getRecentProjects() const
|
||||
{
|
||||
std::vector<FilePath> recentProjects;
|
||||
|
||||
@@ -91,6 +91,9 @@ public:
|
||||
int getCodeSnippetExpandRange() const;
|
||||
void setCodeSnippetExpandRange(int range);
|
||||
|
||||
bool getCodeViewModeSingle() const;
|
||||
void setCodeViewModeSingle(bool enabled);
|
||||
|
||||
// user
|
||||
std::vector<FilePath> getRecentProjects() const;
|
||||
bool setRecentProjects(const std::vector<FilePath>& recentProjects);
|
||||
|
||||
@@ -7,7 +7,8 @@ class MessageCodeViewExpandedInitialFiles
|
||||
: public Message<MessageCodeViewExpandedInitialFiles>
|
||||
{
|
||||
public:
|
||||
MessageCodeViewExpandedInitialFiles()
|
||||
MessageCodeViewExpandedInitialFiles(bool scrollToDefinition)
|
||||
: scrollToDefinition(scrollToDefinition)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -15,6 +16,8 @@ public:
|
||||
{
|
||||
return "MessageCodeViewExpandedInitialFiles";
|
||||
}
|
||||
|
||||
bool scrollToDefinition;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_CODE_VIEW_EXPANDED_INITIAL_FILES_H
|
||||
|
||||
@@ -7,8 +7,9 @@ class MessageScrollCode
|
||||
: public Message<MessageScrollCode>
|
||||
{
|
||||
public:
|
||||
MessageScrollCode(int value)
|
||||
MessageScrollCode(int value, bool inListMode)
|
||||
: value(value)
|
||||
, inListMode(inListMode)
|
||||
{
|
||||
setIsLogged(false);
|
||||
}
|
||||
@@ -19,6 +20,7 @@ public:
|
||||
}
|
||||
|
||||
int value;
|
||||
bool inListMode;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SCROLL_CODE_H
|
||||
|
||||
Reference in New Issue
Block a user