ui: switch to single file mode with snippet maximize
* switch back to snippet view with snippet button in file title bar * use new title bar widget in single view as well * restore view mode on undo, store current view mode for every message id (added id to message) * treat view mode switch as adapt message on undo stack * fixed crash after snippet expansion * fixed hatching in file title not shown
This commit is contained in:
@@ -94,48 +94,49 @@
|
|||||||
padding-bottom: 7px;
|
padding-bottom: 7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_widget {
|
#title_bar, #title_bar_single {
|
||||||
background-color: <color:code/file/background>;
|
background-color: <color:code/file/background>;
|
||||||
|
font-size: <setting:font_size>px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#title_bar[hovering=false] {
|
||||||
border-top-left-radius: 7px;
|
border-top-left-radius: 7px;
|
||||||
border-top-right-radius: 7px;
|
border-top-right-radius: 7px;
|
||||||
font-size: <setting:font_size>px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_widget[hovering=true] {
|
#title_bar_single {
|
||||||
border-top-left-radius: 0px;
|
background-color: <color:code/file/background>;
|
||||||
border-top-right-radius: 0px;
|
padding-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_label, #single_file_title_bar #file_title {
|
#title_button {
|
||||||
background-color: <color:code/file/title/normal>;
|
background-color: <color:code/file/title/normal>;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
color: <color:code/file/title/text>;
|
color: <color:code/file/title/text>;
|
||||||
font-size: <setting:font_size>px;
|
font-size: <setting:font_size>px;
|
||||||
padding: 2px 4px;
|
padding: 2px 4px;
|
||||||
}
|
|
||||||
|
|
||||||
#title_label {
|
|
||||||
margin: 1px 8px;
|
margin: 1px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#single_file_title_bar #file_title {
|
#title_bar_single #title_button {
|
||||||
margin: 3px 8px;
|
margin: 3px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_label:hover, #single_file_title_bar #file_title:hover {
|
#title_button:hover {
|
||||||
background-color: <color:code/file/title/hover>;
|
background-color: <color:code/file/title/hover>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_label:pressed, #single_file_title_bar #file_title:pressed {
|
#title_button:pressed {
|
||||||
background-color: <color:code/file/title/press>;
|
background-color: <color:code/file/title/press>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_label[complete=false], #single_file_title_bar #file_title[complete=false] {
|
#title_button[complete=false] {
|
||||||
border: 1px solid <color:code/file/title/border>;
|
border: 1px solid <color:code/file/title/border>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#references_label, #single_file_title_bar #references_label {
|
#references_label {
|
||||||
background-color: <color:code/file/ref_count/background>;
|
background-color: <color:code/file/ref_count/background>;
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
@@ -189,7 +190,7 @@
|
|||||||
selection-background-color: <color:code/snippet/selection/background>;
|
selection-background-color: <color:code/snippet/selection/background>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_widget #file_button {
|
#title_bar #file_button, #title_bar_single #file_button {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
@@ -197,15 +198,10 @@
|
|||||||
max-width: 16px;
|
max-width: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#title_widget #file_button:enabled {
|
#title_bar #file_button:enabled, #title_bar_single #file_button:enabled {
|
||||||
border-image: url(<setting:gui_path>code_view/images/button_background.png);
|
border-image: url(<setting:gui_path>code_view/images/button_background.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
#single_file_title_bar {
|
|
||||||
background-color: <color:code/file/background>;
|
|
||||||
padding-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#last_scroll_bar {
|
#last_scroll_bar {
|
||||||
background-color: <color:code/snippet/background>;
|
background-color: <color:code/snippet/background>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,6 +454,7 @@ add_files(
|
|||||||
utility/messaging/type/MessageZoom.h
|
utility/messaging/type/MessageZoom.h
|
||||||
|
|
||||||
utility/messaging/Message.h
|
utility/messaging/Message.h
|
||||||
|
utility/messaging/MessageBase.cpp
|
||||||
utility/messaging/MessageBase.h
|
utility/messaging/MessageBase.h
|
||||||
utility/messaging/MessageFilter.h
|
utility/messaging/MessageFilter.h
|
||||||
utility/messaging/MessageInterruptTasksCounter.cpp
|
utility/messaging/MessageInterruptTasksCounter.cpp
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ void ActivationController::handleMessage(MessageActivateFile* message)
|
|||||||
MessageChangeFileView msg(
|
MessageChangeFileView msg(
|
||||||
message->filePath,
|
message->filePath,
|
||||||
MessageChangeFileView::FILE_MAXIMIZED,
|
MessageChangeFileView::FILE_MAXIMIZED,
|
||||||
|
MessageChangeFileView::VIEW_CURRENT,
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ void CodeController::handleMessage(MessageActivateAll* message)
|
|||||||
{
|
{
|
||||||
TRACE("code all");
|
TRACE("code all");
|
||||||
|
|
||||||
|
saveOrRestoreViewMode(message);
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
Project* currentProject = Application::getInstance()->getCurrentProject().get();
|
Project* currentProject = Application::getInstance()->getCurrentProject().get();
|
||||||
@@ -107,6 +108,8 @@ void CodeController::handleMessage(MessageActivateTokens* message)
|
|||||||
{
|
{
|
||||||
TRACE("code activate");
|
TRACE("code activate");
|
||||||
|
|
||||||
|
saveOrRestoreViewMode(message);
|
||||||
|
|
||||||
CodeView* view = getView();
|
CodeView* view = getView();
|
||||||
|
|
||||||
CodeView::CodeParams params;
|
CodeView::CodeParams params;
|
||||||
@@ -180,6 +183,8 @@ void CodeController::handleMessage(MessageActivateTrailEdge* message)
|
|||||||
{
|
{
|
||||||
TRACE("trail edge activate");
|
TRACE("trail edge activate");
|
||||||
|
|
||||||
|
saveOrRestoreViewMode(message);
|
||||||
|
|
||||||
CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION);
|
CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION);
|
||||||
getView()->scrollTo(scrollParams);
|
getView()->scrollTo(scrollParams);
|
||||||
|
|
||||||
@@ -197,14 +202,6 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
|||||||
{
|
{
|
||||||
TRACE("code change file");
|
TRACE("code change file");
|
||||||
|
|
||||||
if (!m_collection)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeView* view = getView();
|
|
||||||
bool inListMode = view->isInListMode();
|
|
||||||
|
|
||||||
CodeView::FileState state;
|
CodeView::FileState state;
|
||||||
switch (message->state)
|
switch (message->state)
|
||||||
{
|
{
|
||||||
@@ -219,13 +216,15 @@ void CodeController::handleMessage(MessageChangeFileView* message)
|
|||||||
case MessageChangeFileView::FILE_MAXIMIZED:
|
case MessageChangeFileView::FILE_MAXIMIZED:
|
||||||
state = CodeView::FILE_MAXIMIZED;
|
state = CodeView::FILE_MAXIMIZED;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MessageChangeFileView::FILE_DEFAULT_FOR_MODE:
|
|
||||||
state = inListMode ? CodeView::FILE_SNIPPETS : CodeView::FILE_MAXIMIZED;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message->needsData)
|
CodeView* view = getView();
|
||||||
|
if (message->viewMode != MessageChangeFileView::VIEW_CURRENT)
|
||||||
|
{
|
||||||
|
view->setMode(message->viewMode == MessageChangeFileView::VIEW_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message->needsData && !message->filePath.empty())
|
||||||
{
|
{
|
||||||
CodeView::CodeParams params;
|
CodeView::CodeParams params;
|
||||||
view->showCodeSnippets(getSnippetsForFileWithState(message->filePath, state, !message->showErrors), params);
|
view->showCodeSnippets(getSnippetsForFileWithState(message->filePath, state, !message->showErrors), params);
|
||||||
@@ -302,6 +301,8 @@ void CodeController::handleMessage(MessageShowErrors* message)
|
|||||||
{
|
{
|
||||||
TRACE("code errors");
|
TRACE("code errors");
|
||||||
|
|
||||||
|
saveOrRestoreViewMode(message);
|
||||||
|
|
||||||
CodeView* view = getView();
|
CodeView* view = getView();
|
||||||
if (!view->showsErrors() || !message->errorId)
|
if (!view->showsErrors() || !message->errorId)
|
||||||
{
|
{
|
||||||
@@ -337,6 +338,8 @@ void CodeController::handleMessage(MessageSearchFullText* message)
|
|||||||
{
|
{
|
||||||
TRACE("code fulltext");
|
TRACE("code fulltext");
|
||||||
|
|
||||||
|
saveOrRestoreViewMode(message);
|
||||||
|
|
||||||
m_collection = m_storageAccess->getFullTextSearchLocations(message->searchTerm, message->caseSensitive);
|
m_collection = m_storageAccess->getFullTextSearchLocations(message->searchTerm, message->caseSensitive);
|
||||||
|
|
||||||
CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION);
|
CodeView::ScrollParams scrollParams(CodeView::ScrollParams::SCROLL_TO_DEFINITION);
|
||||||
@@ -892,3 +895,19 @@ void CodeController::addActiveSourceLocations(std::shared_ptr<SourceLocationFile
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeController::saveOrRestoreViewMode(MessageBase* message)
|
||||||
|
{
|
||||||
|
if (message->isReplayed())
|
||||||
|
{
|
||||||
|
auto it = m_messageIdToViewModeMap.find(message->getId());
|
||||||
|
if (it != m_messageIdToViewModeMap.end())
|
||||||
|
{
|
||||||
|
getView()->setMode(it->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_messageIdToViewModeMap.emplace(message->getId(), getView()->isInListMode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -100,8 +100,12 @@ private:
|
|||||||
void addModificationTimes(std::vector<CodeSnippetParams>& snippets) const;
|
void addModificationTimes(std::vector<CodeSnippetParams>& snippets) const;
|
||||||
void addActiveSourceLocations(std::shared_ptr<SourceLocationFile> locationFile) const;
|
void addActiveSourceLocations(std::shared_ptr<SourceLocationFile> locationFile) const;
|
||||||
|
|
||||||
|
void saveOrRestoreViewMode(MessageBase* message);
|
||||||
|
|
||||||
StorageAccess* m_storageAccess;
|
StorageAccess* m_storageAccess;
|
||||||
mutable std::shared_ptr<SourceLocationCollection> m_collection;
|
mutable std::shared_ptr<SourceLocationCollection> m_collection;
|
||||||
|
|
||||||
|
std::map<Id, bool> m_messageIdToViewModeMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CODE_CONTROLLER_H
|
#endif // CODE_CONTROLLER_H
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ void UndoRedoController::handleMessage(MessageActivateTrailEdge* message)
|
|||||||
|
|
||||||
void UndoRedoController::handleMessage(MessageChangeFileView* message)
|
void UndoRedoController::handleMessage(MessageChangeFileView* message)
|
||||||
{
|
{
|
||||||
Command command(std::make_shared<MessageChangeFileView>(*message), Command::ORDER_VIEW);
|
Command command(std::make_shared<MessageChangeFileView>(*message),
|
||||||
|
message->switchesViewMode ? Command::ORDER_ADAPT : Command::ORDER_VIEW);
|
||||||
processCommand(command);
|
processCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ public:
|
|||||||
virtual void showContents() = 0;
|
virtual void showContents() = 0;
|
||||||
|
|
||||||
virtual bool isInListMode() const = 0;
|
virtual bool isInListMode() const = 0;
|
||||||
|
virtual void setMode(bool listMode) = 0;
|
||||||
|
|
||||||
virtual bool hasSingleFileCached(const FilePath& filePath) const = 0;
|
virtual bool hasSingleFileCached(const FilePath& filePath) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#include "utility/messaging/MessageBase.h"
|
||||||
|
|
||||||
|
Id MessageBase::s_nextId = 1;
|
||||||
@@ -4,11 +4,14 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include "utility/types.h"
|
||||||
|
|
||||||
class MessageBase
|
class MessageBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MessageBase()
|
MessageBase()
|
||||||
: m_isParallel(false)
|
: m_id(s_nextId++)
|
||||||
|
, m_isParallel(false)
|
||||||
, m_isReplayed(false)
|
, m_isReplayed(false)
|
||||||
, m_sendAsTask(true)
|
, m_sendAsTask(true)
|
||||||
, m_keepContent(false)
|
, m_keepContent(false)
|
||||||
@@ -24,6 +27,11 @@ public:
|
|||||||
virtual std::string getType() const = 0;
|
virtual std::string getType() const = 0;
|
||||||
virtual void dispatch() = 0;
|
virtual void dispatch() = 0;
|
||||||
|
|
||||||
|
Id getId() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
bool sendAsTask() const
|
bool sendAsTask() const
|
||||||
{
|
{
|
||||||
return m_sendAsTask;
|
return m_sendAsTask;
|
||||||
@@ -95,6 +103,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static size_t s_nextId;
|
||||||
|
|
||||||
|
Id m_id;
|
||||||
|
|
||||||
bool m_isParallel;
|
bool m_isParallel;
|
||||||
bool m_isReplayed;
|
bool m_isReplayed;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
#include "utility/messaging/MessageListenerBase.h"
|
#include "utility/messaging/MessageListenerBase.h"
|
||||||
|
|
||||||
uint MessageListenerBase::s_nextId = 0;
|
Id MessageListenerBase::s_nextId = 1;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint getId() const
|
Id getId() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
@@ -57,9 +57,9 @@ private:
|
|||||||
virtual std::string doGetType() const = 0;
|
virtual std::string doGetType() const = 0;
|
||||||
virtual void doHandleMessageBase(MessageBase*) = 0;
|
virtual void doHandleMessageBase(MessageBase*) = 0;
|
||||||
|
|
||||||
static uint s_nextId;
|
static Id s_nextId;
|
||||||
|
|
||||||
uint m_id;
|
Id m_id;
|
||||||
bool m_alive;
|
bool m_alive;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,12 +64,12 @@ void MessageQueue::unregisterListener(MessageListenerBase* listener)
|
|||||||
LOG_ERROR("Listener was not found");
|
LOG_ERROR("Listener was not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageListenerBase* MessageQueue::getListenerById(const uint id) const
|
MessageListenerBase* MessageQueue::getListenerById(Id listenerId) const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_listenersMutex);
|
std::lock_guard<std::mutex> lock(m_listenersMutex);
|
||||||
for (size_t i = 0; i < m_listeners.size(); i++)
|
for (size_t i = 0; i < m_listeners.size(); i++)
|
||||||
{
|
{
|
||||||
if (m_listeners[i]->getId() == id)
|
if (m_listeners[i]->getId() == listenerId)
|
||||||
{
|
{
|
||||||
return m_listeners[i];
|
return m_listeners[i];
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ void MessageQueue::sendMessageAsTask(std::shared_ptr<MessageBase> message, bool
|
|||||||
|
|
||||||
if (listener->getType() == message->getType())
|
if (listener->getType() == message->getType())
|
||||||
{
|
{
|
||||||
uint listenerId = listener->getId();
|
Id listenerId = listener->getId();
|
||||||
taskGroup->addTask(std::make_shared<TaskLambda>(
|
taskGroup->addTask(std::make_shared<TaskLambda>(
|
||||||
[listenerId, message]()
|
[listenerId, message]()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
void registerListener(MessageListenerBase* listener);
|
void registerListener(MessageListenerBase* listener);
|
||||||
void unregisterListener(MessageListenerBase* listener);
|
void unregisterListener(MessageListenerBase* listener);
|
||||||
|
|
||||||
MessageListenerBase* getListenerById(const uint id) const;
|
MessageListenerBase* getListenerById(Id listenerId) const;
|
||||||
|
|
||||||
void addMessageFilter(std::shared_ptr<MessageFilter> filter);
|
void addMessageFilter(std::shared_ptr<MessageFilter> filter);
|
||||||
|
|
||||||
|
|||||||
@@ -12,20 +12,30 @@ public:
|
|||||||
{
|
{
|
||||||
FILE_MINIMIZED,
|
FILE_MINIMIZED,
|
||||||
FILE_SNIPPETS,
|
FILE_SNIPPETS,
|
||||||
FILE_MAXIMIZED,
|
FILE_MAXIMIZED
|
||||||
FILE_DEFAULT_FOR_MODE
|
};
|
||||||
|
|
||||||
|
enum ViewMode
|
||||||
|
{
|
||||||
|
VIEW_LIST,
|
||||||
|
VIEW_SINGLE,
|
||||||
|
VIEW_CURRENT
|
||||||
};
|
};
|
||||||
|
|
||||||
MessageChangeFileView(
|
MessageChangeFileView(
|
||||||
const FilePath& filePath,
|
const FilePath& filePath,
|
||||||
FileState state,
|
FileState state,
|
||||||
|
ViewMode viewMode,
|
||||||
bool needsData,
|
bool needsData,
|
||||||
bool showErrors
|
bool showErrors,
|
||||||
|
bool switchesViewMode = false
|
||||||
)
|
)
|
||||||
: filePath(filePath)
|
: filePath(filePath)
|
||||||
, state(state)
|
, state(state)
|
||||||
|
, viewMode(viewMode)
|
||||||
, needsData(needsData)
|
, needsData(needsData)
|
||||||
, showErrors(showErrors)
|
, showErrors(showErrors)
|
||||||
|
, switchesViewMode(switchesViewMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +51,13 @@ public:
|
|||||||
case FILE_MINIMIZED: os << "minimize"; break;
|
case FILE_MINIMIZED: os << "minimize"; break;
|
||||||
case FILE_SNIPPETS: os << "snippets"; break;
|
case FILE_SNIPPETS: os << "snippets"; break;
|
||||||
case FILE_MAXIMIZED: os << "maximize"; break;
|
case FILE_MAXIMIZED: os << "maximize"; break;
|
||||||
case FILE_DEFAULT_FOR_MODE: os << "default"; break;
|
}
|
||||||
|
|
||||||
|
switch (viewMode)
|
||||||
|
{
|
||||||
|
case VIEW_LIST: os << ", list"; break;
|
||||||
|
case VIEW_SINGLE: os << ", single"; break;
|
||||||
|
case VIEW_CURRENT: os << ", current"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsData)
|
if (needsData)
|
||||||
@@ -50,11 +66,12 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath filePath;
|
const FilePath filePath;
|
||||||
FileState state;
|
const FileState state;
|
||||||
|
const ViewMode viewMode;
|
||||||
bool needsData;
|
const bool needsData;
|
||||||
bool showErrors;
|
const bool showErrors;
|
||||||
|
const bool switchesViewMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_CHANGE_FILE_VIEW_H
|
#endif // MESSAGE_CHANGE_FILE_VIEW_H
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ Id QtCodeArea::getLocationIdOfFirstActiveScopeLocation(Id tokenId) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint QtCodeArea::getActiveLocationCount() const
|
size_t QtCodeArea::getActiveLocationCount() const
|
||||||
{
|
{
|
||||||
uint count = 0;
|
uint count = 0;
|
||||||
|
|
||||||
@@ -359,6 +359,18 @@ uint QtCodeArea::getActiveLocationCount() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!count)
|
||||||
|
{
|
||||||
|
for (const Annotation& annotation : m_annotations)
|
||||||
|
{
|
||||||
|
if (annotation.locationType == LocationType::LOCATION_FULLTEXT_SEARCH ||
|
||||||
|
annotation.locationType == LocationType::LOCATION_ERROR)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
Id getLocationIdOfFirstActiveLocation(Id tokenId) const;
|
Id getLocationIdOfFirstActiveLocation(Id tokenId) const;
|
||||||
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
|
Id getLocationIdOfFirstActiveScopeLocation(Id tokenId) const;
|
||||||
|
|
||||||
uint getActiveLocationCount() const;
|
size_t getActiveLocationCount() const;
|
||||||
|
|
||||||
QRectF getLineRectForLineNumber(uint lineNumber) const;
|
QRectF getLineRectForLineNumber(uint lineNumber) const;
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ QtCodeSnippet* QtCodeFile::addCodeSnippet(const CodeSnippetParams& params)
|
|||||||
m_fileSnippet->setIsActiveFile(true);
|
m_fileSnippet->setIsActiveFile(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMaximized();
|
setSnippets();
|
||||||
if (params.refCount != -1)
|
if (params.refCount != -1)
|
||||||
{
|
{
|
||||||
updateRefCount(0);
|
updateRefCount(0);
|
||||||
@@ -140,6 +140,7 @@ QtCodeSnippet* QtCodeFile::insertCodeSnippet(const CodeSnippetParams& params)
|
|||||||
}
|
}
|
||||||
else if (s->getStartLineNumber() < start || s->getEndLineNumber() > end)
|
else if (s->getStartLineNumber() < start || s->getEndLineNumber() > end)
|
||||||
{
|
{
|
||||||
|
m_navigator->clearSnippetReferences();
|
||||||
snippet = QtCodeSnippet::merged(snippet.get(), s.get(), m_navigator, this);
|
snippet = QtCodeSnippet::merged(snippet.get(), s.get(), m_navigator, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,7 +257,25 @@ void QtCodeFile::requestContent()
|
|||||||
|
|
||||||
bool needsData = (state == MessageChangeFileView::FILE_MAXIMIZED) ? (getFileSnippet() == nullptr) : (m_snippets.size() == 0);
|
bool needsData = (state == MessageChangeFileView::FILE_MAXIMIZED) ? (getFileSnippet() == nullptr) : (m_snippets.size() == 0);
|
||||||
|
|
||||||
MessageChangeFileView(m_filePath, state, needsData, m_navigator->hasErrors()).dispatch();
|
MessageChangeFileView(m_filePath, state, MessageChangeFileView::VIEW_LIST, needsData, m_navigator->hasErrors()).dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtCodeFile::requestWholeFileContent()
|
||||||
|
{
|
||||||
|
if (!getFileSnippet())
|
||||||
|
{
|
||||||
|
MessageChangeFileView(
|
||||||
|
m_filePath,
|
||||||
|
MessageChangeFileView::FILE_MAXIMIZED,
|
||||||
|
MessageChangeFileView::VIEW_LIST,
|
||||||
|
true,
|
||||||
|
m_navigator->hasErrors()
|
||||||
|
).dispatch();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setSnippets();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::updateContent()
|
void QtCodeFile::updateContent()
|
||||||
@@ -299,21 +318,28 @@ void QtCodeFile::setMinimized()
|
|||||||
m_fileSnippet->hide();
|
m_fileSnippet->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_titleBar->setMinimized(!m_isWholeFile);
|
m_titleBar->setMinimized();
|
||||||
|
|
||||||
setStyleSheet("#code_file { padding-bottom: 0; } #code_file #title_widget { border-radius: 7px; }");
|
setStyleSheet("#code_file { padding-bottom: 0; } #code_file #title_bar { border-radius: 7px; }");
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::setSnippets()
|
void QtCodeFile::setSnippets()
|
||||||
{
|
{
|
||||||
for (const std::shared_ptr<QtCodeSnippet>& snippet : m_snippets)
|
|
||||||
{
|
|
||||||
snippet->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_fileSnippet)
|
if (m_fileSnippet)
|
||||||
{
|
{
|
||||||
m_fileSnippet->hide();
|
m_fileSnippet->show();
|
||||||
|
|
||||||
|
for (const std::shared_ptr<QtCodeSnippet>& snippet : m_snippets)
|
||||||
|
{
|
||||||
|
snippet->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (const std::shared_ptr<QtCodeSnippet>& snippet : m_snippets)
|
||||||
|
{
|
||||||
|
snippet->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_titleBar->setSnippets();
|
m_titleBar->setSnippets();
|
||||||
@@ -323,19 +349,7 @@ void QtCodeFile::setSnippets()
|
|||||||
|
|
||||||
void QtCodeFile::setMaximized()
|
void QtCodeFile::setMaximized()
|
||||||
{
|
{
|
||||||
for (const std::shared_ptr<QtCodeSnippet>& snippet : m_snippets)
|
setSnippets();
|
||||||
{
|
|
||||||
snippet->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_fileSnippet)
|
|
||||||
{
|
|
||||||
m_fileSnippet->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_titleBar->setMaximized(!m_isWholeFile);
|
|
||||||
|
|
||||||
setStyleSheet("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtCodeFile::hasSnippets() const
|
bool QtCodeFile::hasSnippets() const
|
||||||
@@ -396,18 +410,12 @@ void QtCodeFile::findScreenMatches(const std::string& query, std::vector<std::pa
|
|||||||
|
|
||||||
void QtCodeFile::clickedMinimizeButton()
|
void QtCodeFile::clickedMinimizeButton()
|
||||||
{
|
{
|
||||||
// overview stats
|
|
||||||
if (m_filePath.empty())
|
|
||||||
{
|
|
||||||
setMinimized();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_navigator->requestScroll(m_filePath, 0, 0, false, QtCodeNavigateable::SCROLL_VISIBLE);
|
m_navigator->requestScroll(m_filePath, 0, 0, false, QtCodeNavigateable::SCROLL_VISIBLE);
|
||||||
|
|
||||||
MessageChangeFileView(
|
MessageChangeFileView(
|
||||||
m_filePath,
|
m_filePath,
|
||||||
MessageChangeFileView::FILE_MINIMIZED,
|
MessageChangeFileView::FILE_MINIMIZED,
|
||||||
|
MessageChangeFileView::VIEW_LIST,
|
||||||
false,
|
false,
|
||||||
m_navigator->hasErrors()
|
m_navigator->hasErrors()
|
||||||
).dispatch();
|
).dispatch();
|
||||||
@@ -420,55 +428,41 @@ void QtCodeFile::clickedSnippetButton()
|
|||||||
MessageChangeFileView(
|
MessageChangeFileView(
|
||||||
m_filePath,
|
m_filePath,
|
||||||
MessageChangeFileView::FILE_SNIPPETS,
|
MessageChangeFileView::FILE_SNIPPETS,
|
||||||
!m_snippets.size(),
|
MessageChangeFileView::VIEW_LIST,
|
||||||
|
isCollapsed(),
|
||||||
m_navigator->hasErrors()
|
m_navigator->hasErrors()
|
||||||
).dispatch();
|
).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::clickedMaximizeButton()
|
void QtCodeFile::clickedMaximizeButton()
|
||||||
{
|
{
|
||||||
// overview stats
|
uint firstLineNumber = 1;
|
||||||
if (m_filePath.empty())
|
std::vector<QtCodeSnippet*> snippets = getVisibleSnippets();
|
||||||
|
if (snippets.size())
|
||||||
{
|
{
|
||||||
setMaximized();
|
firstLineNumber = snippets[0]->getStartLineNumber();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
m_navigator->requestScroll(m_filePath, firstLineNumber, 0, false, QtCodeNavigateable::SCROLL_CENTER);
|
||||||
m_navigator->requestScroll(m_filePath, 0, 0, false, QtCodeNavigateable::SCROLL_VISIBLE);
|
|
||||||
|
|
||||||
MessageChangeFileView(
|
MessageChangeFileView(
|
||||||
m_filePath,
|
m_filePath,
|
||||||
MessageChangeFileView::FILE_MAXIMIZED,
|
MessageChangeFileView::FILE_MAXIMIZED,
|
||||||
!getFileSnippet(),
|
MessageChangeFileView::VIEW_SINGLE,
|
||||||
m_navigator->hasErrors()
|
true, // TODO: check if data is really needed
|
||||||
|
m_navigator->hasErrors(),
|
||||||
|
true
|
||||||
).dispatch();
|
).dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::updateRefCount(int refCount)
|
void QtCodeFile::updateRefCount(int refCount)
|
||||||
{
|
{
|
||||||
if (refCount > 0 && !m_isWholeFile)
|
if (m_isWholeFile)
|
||||||
{
|
{
|
||||||
bool hasErrors = m_navigator->hasErrors();
|
refCount = 0;
|
||||||
|
|
||||||
QString label = hasErrors ? "error" : "reference";
|
|
||||||
if (refCount > 1)
|
|
||||||
{
|
|
||||||
label += "s";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasErrors)
|
|
||||||
{
|
|
||||||
size_t fatalErrorCount = m_navigator->getFatalErrorCountForFile(m_filePath);
|
|
||||||
if (fatalErrorCount > 0)
|
|
||||||
{
|
|
||||||
label += " (" + QString::number(fatalErrorCount) + " fatal)";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_titleBar->setRefString(QString::number(refCount) + " " + label);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_titleBar->setRefString("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasErrors = m_navigator->hasErrors();
|
||||||
|
size_t fatalErrorCount = hasErrors ? m_navigator->getFatalErrorCountForFile(m_filePath) : 0;
|
||||||
|
|
||||||
|
m_titleBar->updateRefCount(refCount, hasErrors, fatalErrorCount);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
bool isCollapsed() const;
|
bool isCollapsed() const;
|
||||||
|
|
||||||
void requestContent();
|
void requestContent();
|
||||||
|
void requestWholeFileContent();
|
||||||
void updateContent();
|
void updateContent();
|
||||||
|
|
||||||
void setWholeFile(bool isWholeFile, int refCount);
|
void setWholeFile(bool isWholeFile, int refCount);
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ void QtCodeFileList::clear()
|
|||||||
m_files.clear();
|
m_files.clear();
|
||||||
m_scrollArea->verticalScrollBar()->setValue(0);
|
m_scrollArea->verticalScrollBar()->setValue(0);
|
||||||
|
|
||||||
|
clearSnippetTitleAndScrollBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtCodeFileList::clearSnippetTitleAndScrollBar()
|
||||||
|
{
|
||||||
updateFirstSnippetTitleBar(nullptr);
|
updateFirstSnippetTitleBar(nullptr);
|
||||||
updateLastSnippetScrollBar(nullptr);
|
updateLastSnippetScrollBar(nullptr);
|
||||||
}
|
}
|
||||||
@@ -221,6 +226,7 @@ void QtCodeFileList::showContents()
|
|||||||
{
|
{
|
||||||
for (QtCodeFile* file : m_files)
|
for (QtCodeFile* file : m_files)
|
||||||
{
|
{
|
||||||
|
file->updateTitleBar();
|
||||||
file->show();
|
file->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,17 +254,55 @@ void QtCodeFileList::findScreenMatches(const std::string& query, std::vector<std
|
|||||||
|
|
||||||
void QtCodeFileList::setFileMinimized(const FilePath path)
|
void QtCodeFileList::setFileMinimized(const FilePath path)
|
||||||
{
|
{
|
||||||
getFile(path)->setMinimized();
|
if (path.empty())
|
||||||
|
{
|
||||||
|
if (m_files.size())
|
||||||
|
{
|
||||||
|
m_files[0]->setMinimized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getFile(path)->setMinimized();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileList::setFileSnippets(const FilePath path)
|
void QtCodeFileList::setFileSnippets(const FilePath path)
|
||||||
{
|
{
|
||||||
getFile(path)->setSnippets();
|
if (path.empty())
|
||||||
|
{
|
||||||
|
if (m_files.size())
|
||||||
|
{
|
||||||
|
m_files[0]->setSnippets();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getFile(path)->setSnippets();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileList::setFileMaximized(const FilePath path)
|
void QtCodeFileList::setFileMaximized(const FilePath path)
|
||||||
{
|
{
|
||||||
getFile(path)->setMaximized();
|
if (path.empty())
|
||||||
|
{
|
||||||
|
if (m_files.size())
|
||||||
|
{
|
||||||
|
m_files[0]->setMaximized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getFile(path)->setMaximized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtCodeFileList::maximizeFirstFile()
|
||||||
|
{
|
||||||
|
if (m_files.size())
|
||||||
|
{
|
||||||
|
m_files[0]->clickedMaximizeButton();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationId(Id tokenId) const
|
std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationId(Id tokenId) const
|
||||||
@@ -284,9 +328,7 @@ std::pair<QtCodeSnippet*, Id> QtCodeFileList::getFirstSnippetWithActiveLocationI
|
|||||||
|
|
||||||
void QtCodeFileList::resizeEvent(QResizeEvent* event)
|
void QtCodeFileList::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
updateFirstSnippetTitleBar(nullptr);
|
clearSnippetTitleAndScrollBar();
|
||||||
updateLastSnippetScrollBar(nullptr);
|
|
||||||
|
|
||||||
updateSnippetTitleAndScrollBar();
|
updateSnippetTitleAndScrollBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ public:
|
|||||||
virtual ~QtCodeFileList();
|
virtual ~QtCodeFileList();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
void clearSnippetTitleAndScrollBar();
|
||||||
|
|
||||||
QtCodeFile* getFile(const FilePath filePath);
|
QtCodeFile* getFile(const FilePath filePath);
|
||||||
void addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimeStamp modificationTime, bool isComplete);
|
void addFile(const FilePath& filePath, bool isWholeFile, int refCount, TimeStamp modificationTime, bool isComplete);
|
||||||
@@ -49,6 +50,8 @@ public:
|
|||||||
void setFileSnippets(const FilePath path);
|
void setFileSnippets(const FilePath path);
|
||||||
void setFileMaximized(const FilePath path);
|
void setFileMaximized(const FilePath path);
|
||||||
|
|
||||||
|
void maximizeFirstFile();
|
||||||
|
|
||||||
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
|
std::pair<QtCodeSnippet*, Id> getFirstSnippetWithActiveLocationId(Id tokenId) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "data/location/SourceLocationFile.h"
|
#include "data/location/SourceLocationFile.h"
|
||||||
#include "qt/element/QtCodeArea.h"
|
#include "qt/element/QtCodeArea.h"
|
||||||
|
#include "qt/element/QtCodeFileTitleBar.h"
|
||||||
#include "qt/element/QtCodeFileTitleButton.h"
|
#include "qt/element/QtCodeFileTitleButton.h"
|
||||||
#include "qt/element/QtCodeNavigator.h"
|
#include "qt/element/QtCodeNavigator.h"
|
||||||
#include "qt/utility/utilityQt.h"
|
#include "qt/utility/utilityQt.h"
|
||||||
@@ -28,35 +29,11 @@ QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
|
|||||||
layout()->setContentsMargins(0, 0, 0, 0);
|
layout()->setContentsMargins(0, 0, 0, 0);
|
||||||
layout()->setSpacing(0);
|
layout()->setSpacing(0);
|
||||||
|
|
||||||
{
|
m_titleBar = new QtCodeFileTitleBar(this, false, true);
|
||||||
QWidget* titleBar = new QWidget();
|
m_titleBar->setObjectName("title_bar_single");
|
||||||
titleBar->setObjectName("single_file_title_bar");
|
layout()->addWidget(m_titleBar);
|
||||||
|
|
||||||
QHBoxLayout* titleLayout = new QHBoxLayout();
|
connect(m_titleBar, &QtCodeFileTitleBar::snippet, this, &QtCodeFileSingle::clickedSnippetButton);
|
||||||
titleLayout->setSpacing(0);
|
|
||||||
titleLayout->setMargin(0);
|
|
||||||
|
|
||||||
m_title = new QtCodeFileTitleButton();
|
|
||||||
m_title->setObjectName("file_title");
|
|
||||||
titleLayout->addWidget(m_title);
|
|
||||||
|
|
||||||
m_title->hide();
|
|
||||||
|
|
||||||
m_referenceCount = new QLabel();
|
|
||||||
m_referenceCount->setObjectName("references_label");
|
|
||||||
m_referenceCount->hide();
|
|
||||||
titleLayout->addWidget(m_referenceCount);
|
|
||||||
|
|
||||||
QPushButton* filler = new QPushButton();
|
|
||||||
filler->setObjectName("file_title");
|
|
||||||
filler->setEnabled(false);
|
|
||||||
titleLayout->addWidget(filler);
|
|
||||||
|
|
||||||
titleLayout->addStretch();
|
|
||||||
|
|
||||||
titleBar->setLayout(titleLayout);
|
|
||||||
layout()->addWidget(titleBar);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_areaWrapper = new QWidget();
|
m_areaWrapper = new QWidget();
|
||||||
m_areaWrapper->setObjectName("code_file_single");
|
m_areaWrapper->setObjectName("code_file_single");
|
||||||
@@ -160,7 +137,8 @@ void QtCodeFileSingle::requestFileContent(const FilePath& filePath)
|
|||||||
|
|
||||||
MessageChangeFileView(
|
MessageChangeFileView(
|
||||||
filePath,
|
filePath,
|
||||||
MessageChangeFileView::FILE_DEFAULT_FOR_MODE,
|
MessageChangeFileView::FILE_MAXIMIZED,
|
||||||
|
MessageChangeFileView::VIEW_SINGLE,
|
||||||
true,
|
true,
|
||||||
m_navigator->hasErrors()
|
m_navigator->hasErrors()
|
||||||
).dispatch();
|
).dispatch();
|
||||||
@@ -228,12 +206,13 @@ void QtCodeFileSingle::showContents()
|
|||||||
if (m_area)
|
if (m_area)
|
||||||
{
|
{
|
||||||
m_area->show();
|
m_area->show();
|
||||||
|
updateRefCount(m_area->getActiveLocationCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileSingle::onWindowFocus()
|
void QtCodeFileSingle::onWindowFocus()
|
||||||
{
|
{
|
||||||
m_title->updateTexts();
|
m_titleBar->getTitleButton()->updateTexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileSingle::findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
void QtCodeFileSingle::findScreenMatches(const std::string& query, std::vector<std::pair<QtCodeArea*, Id>>* screenMatches)
|
||||||
@@ -270,6 +249,20 @@ Id QtCodeFileSingle::getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) con
|
|||||||
return m_area->getLocationIdOfFirstActiveLocation(tokenId);
|
return m_area->getLocationIdOfFirstActiveLocation(tokenId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeFileSingle::clickedSnippetButton()
|
||||||
|
{
|
||||||
|
m_navigator->requestScroll(m_currentFilePath, 0, 0, false, QtCodeNavigateable::SCROLL_TOP);
|
||||||
|
|
||||||
|
MessageChangeFileView(
|
||||||
|
m_currentFilePath,
|
||||||
|
MessageChangeFileView::FILE_SNIPPETS,
|
||||||
|
MessageChangeFileView::VIEW_LIST,
|
||||||
|
true, // TODO: check if data is really needed
|
||||||
|
m_navigator->hasErrors(),
|
||||||
|
true
|
||||||
|
).dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
QtCodeFileSingle::FileData QtCodeFileSingle::getFileData(const FilePath& filePath) const
|
QtCodeFileSingle::FileData QtCodeFileSingle::getFileData(const FilePath& filePath) const
|
||||||
{
|
{
|
||||||
std::map<FilePath, FileData>::const_iterator it = m_fileDatas.find(filePath);
|
std::map<FilePath, FileData>::const_iterator it = m_fileDatas.find(filePath);
|
||||||
@@ -285,11 +278,6 @@ void QtCodeFileSingle::setFileData(const FileData& file)
|
|||||||
{
|
{
|
||||||
if (file.area == m_area)
|
if (file.area == m_area)
|
||||||
{
|
{
|
||||||
if (m_area)
|
|
||||||
{
|
|
||||||
updateRefCount(m_area->getActiveLocationCount());
|
|
||||||
m_area->updateContent();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +290,7 @@ void QtCodeFileSingle::setFileData(const FileData& file)
|
|||||||
|
|
||||||
m_areaWrapper->layout()->takeAt(0);
|
m_areaWrapper->layout()->takeAt(0);
|
||||||
|
|
||||||
|
QtCodeFileTitleButton* titleButton = m_titleBar->getTitleButton();
|
||||||
if (file.area)
|
if (file.area)
|
||||||
{
|
{
|
||||||
m_area = file.area;
|
m_area = file.area;
|
||||||
@@ -310,54 +299,40 @@ void QtCodeFileSingle::setFileData(const FileData& file)
|
|||||||
m_area->updateContent();
|
m_area->updateContent();
|
||||||
|
|
||||||
m_currentFilePath = file.filePath;
|
m_currentFilePath = file.filePath;
|
||||||
|
m_titleBar->setMaximized();
|
||||||
|
|
||||||
if (file.title.size())
|
if (file.title.size())
|
||||||
{
|
{
|
||||||
m_title->setProject(file.title);
|
titleButton->setProject(file.title);
|
||||||
m_title->setIsComplete(true);
|
titleButton->setIsComplete(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_title->setFilePath(file.filePath);
|
titleButton->setFilePath(file.filePath);
|
||||||
m_title->setModificationTime(file.modificationTime);
|
titleButton->setModificationTime(file.modificationTime);
|
||||||
m_title->setIsComplete(file.isComplete);
|
titleButton->setIsComplete(file.isComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRefCount(m_area->getActiveLocationCount());
|
updateRefCount(m_area->getActiveLocationCount());
|
||||||
|
|
||||||
m_title->show();
|
titleButton->updateTexts();
|
||||||
|
titleButton->show();
|
||||||
m_area->show();
|
m_area->show();
|
||||||
|
|
||||||
m_scrollRequested = false;
|
m_scrollRequested = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_title->hide();
|
titleButton->hide();
|
||||||
updateRefCount(0);
|
updateRefCount(0);
|
||||||
|
m_titleBar->setSnippets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileSingle::updateRefCount(int refCount)
|
void QtCodeFileSingle::updateRefCount(int refCount)
|
||||||
{
|
{
|
||||||
if (refCount > 0)
|
bool hasErrors = m_navigator->hasErrors();
|
||||||
{
|
size_t fatalErrorCount = hasErrors ? m_navigator->getFatalErrorCountForFile(m_currentFilePath) : 0;
|
||||||
QString label = m_navigator->hasErrors() ? "error" : "reference";
|
|
||||||
if (refCount > 1)
|
|
||||||
{
|
|
||||||
label += "s";
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t fatalErrorCount = m_navigator->getFatalErrorCountForFile(m_currentFilePath);
|
m_titleBar->updateRefCount(refCount, hasErrors, fatalErrorCount);
|
||||||
if (fatalErrorCount > 0)
|
|
||||||
{
|
|
||||||
label += " (" + QString::number(fatalErrorCount) + " fatal)";
|
|
||||||
}
|
|
||||||
|
|
||||||
m_referenceCount->setText(QString::number(refCount) + " " + label);
|
|
||||||
m_referenceCount->show();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_referenceCount->hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
class QLabel;
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QtCodeArea;
|
class QtCodeArea;
|
||||||
class QtCodeFileTitleButton;
|
class QtCodeFileTitleBar;
|
||||||
class QtCodeNavigator;
|
class QtCodeNavigator;
|
||||||
|
|
||||||
class QtCodeFileSingle
|
class QtCodeFileSingle
|
||||||
@@ -52,6 +52,9 @@ public:
|
|||||||
|
|
||||||
Id getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const;
|
Id getLocationIdOfFirstActiveLocationOfTokenId(Id tokenId) const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void clickedSnippetButton();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct FileData
|
struct FileData
|
||||||
{
|
{
|
||||||
@@ -73,8 +76,7 @@ private:
|
|||||||
QWidget* m_areaWrapper;
|
QWidget* m_areaWrapper;
|
||||||
FilePath m_currentFilePath;
|
FilePath m_currentFilePath;
|
||||||
|
|
||||||
QtCodeFileTitleButton* m_title;
|
QtCodeFileTitleBar* m_titleBar;
|
||||||
QLabel* m_referenceCount;
|
|
||||||
|
|
||||||
QtCodeArea* m_area;
|
QtCodeArea* m_area;
|
||||||
std::map<FilePath, FileData> m_fileDatas;
|
std::map<FilePath, FileData> m_fileDatas;
|
||||||
|
|||||||
@@ -6,13 +6,20 @@
|
|||||||
|
|
||||||
#include "utility/ResourcePaths.h"
|
#include "utility/ResourcePaths.h"
|
||||||
|
|
||||||
QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering)
|
QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering, bool isSingle)
|
||||||
: QtHoverButton(parent)
|
: QtHoverButton(parent)
|
||||||
{
|
{
|
||||||
setObjectName("title_widget");
|
setObjectName("title_bar");
|
||||||
setProperty("hovering", isHovering);
|
setProperty("hovering", isHovering);
|
||||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||||
|
|
||||||
|
if (!isSingle)
|
||||||
|
{
|
||||||
|
connect(this, &QPushButton::clicked, this, &QtCodeFileTitleBar::clickedTitleBar);
|
||||||
|
connect(this, &QtHoverButton::hoveredIn, this, &QtCodeFileTitleBar::enteredTitleBar);
|
||||||
|
connect(this, &QtHoverButton::hoveredOut, this, &QtCodeFileTitleBar::leftTitleBar);
|
||||||
|
}
|
||||||
|
|
||||||
QHBoxLayout* titleLayout = new QHBoxLayout();
|
QHBoxLayout* titleLayout = new QHBoxLayout();
|
||||||
titleLayout->setMargin(0);
|
titleLayout->setMargin(0);
|
||||||
titleLayout->setSpacing(0);
|
titleLayout->setSpacing(0);
|
||||||
@@ -20,7 +27,11 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering)
|
|||||||
setLayout(titleLayout);
|
setLayout(titleLayout);
|
||||||
|
|
||||||
m_titleButton = new QtCodeFileTitleButton(this);
|
m_titleButton = new QtCodeFileTitleButton(this);
|
||||||
|
QSizePolicy policy = m_titleButton->sizePolicy();
|
||||||
|
policy.setRetainSizeWhenHidden(true);
|
||||||
|
m_titleButton->setSizePolicy(policy);
|
||||||
titleLayout->addWidget(m_titleButton);
|
titleLayout->addWidget(m_titleButton);
|
||||||
|
|
||||||
setMinimumHeight(m_titleButton->height() + 4);
|
setMinimumHeight(m_titleButton->height() + 4);
|
||||||
|
|
||||||
m_referenceCount = new QLabel(this);
|
m_referenceCount = new QLabel(this);
|
||||||
@@ -31,58 +42,51 @@ QtCodeFileTitleBar::QtCodeFileTitleBar(QWidget* parent, bool isHovering)
|
|||||||
titleLayout->addStretch(3);
|
titleLayout->addStretch(3);
|
||||||
|
|
||||||
std::string imageDir = ResourcePaths::getGuiPath().str() + "code_view/images/";
|
std::string imageDir = ResourcePaths::getGuiPath().str() + "code_view/images/";
|
||||||
|
QColor inactiveColor(0x5E, 0x5D, 0x5D);
|
||||||
|
|
||||||
m_minimizeButton = new QtIconStateButton(this);
|
m_minimizeButton = new QtIconStateButton(this);
|
||||||
m_minimizeButton->addState(QtIconStateButton::STATE_DEFAULT, (imageDir + "minimize_active.png").c_str());
|
m_minimizeButton->addState(QtIconStateButton::STATE_DEFAULT, (imageDir + "minimize_active.png").c_str());
|
||||||
// m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "minimize_inactive.png").c_str(), "#5E5D5D");
|
m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "minimize_inactive.png").c_str(), inactiveColor);
|
||||||
m_minimizeButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "minimize_inactive.png").c_str(), QColor(0x5E, 0x5D, 0x5D));
|
|
||||||
m_minimizeButton->addState(QtIconStateButton::STATE_DISABLED, (imageDir + "minimize_inactive.png").c_str());
|
m_minimizeButton->addState(QtIconStateButton::STATE_DISABLED, (imageDir + "minimize_inactive.png").c_str());
|
||||||
m_minimizeButton->setIconSize(QSize(16, 16));
|
|
||||||
m_minimizeButton->setObjectName("file_button");
|
|
||||||
m_minimizeButton->setToolTip("minimize");
|
m_minimizeButton->setToolTip("minimize");
|
||||||
titleLayout->addWidget(m_minimizeButton);
|
|
||||||
|
|
||||||
m_snippetButton = new QtIconStateButton(this);
|
m_snippetButton = new QtIconStateButton(this);
|
||||||
m_snippetButton->addState(QtIconStateButton::STATE_DEFAULT, (imageDir + "snippet_active.png").c_str());
|
m_snippetButton->addState(QtIconStateButton::STATE_DEFAULT, (imageDir + "snippet_active.png").c_str());
|
||||||
// m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "snippet_inactive.png").c_str(), "#5E5D5D");
|
m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "snippet_inactive.png").c_str(), inactiveColor);
|
||||||
m_snippetButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "snippet_inactive.png").c_str(), QColor(0x5E, 0x5D, 0x5D));
|
|
||||||
m_snippetButton->addState(QtIconStateButton::STATE_DISABLED, (imageDir + "snippet_inactive.png").c_str());
|
m_snippetButton->addState(QtIconStateButton::STATE_DISABLED, (imageDir + "snippet_inactive.png").c_str());
|
||||||
m_snippetButton->setIconSize(QSize(16, 16));
|
|
||||||
m_snippetButton->setObjectName("file_button");
|
|
||||||
m_snippetButton->setToolTip("show snippets");
|
m_snippetButton->setToolTip("show snippets");
|
||||||
titleLayout->addWidget(m_snippetButton);
|
|
||||||
|
|
||||||
m_maximizeButton = new QtIconStateButton(this);
|
m_maximizeButton = new QtIconStateButton(this);
|
||||||
m_maximizeButton->addState(QtIconStateButton::STATE_DEFAULT, (imageDir + "maximize_active.png").c_str());
|
m_maximizeButton->addState(QtIconStateButton::STATE_DEFAULT, (imageDir + "maximize_active.png").c_str());
|
||||||
// m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "maximize_inactive.png").c_str(), "#5E5D5D");
|
m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "maximize_inactive.png").c_str(), inactiveColor);
|
||||||
m_maximizeButton->addState(QtIconStateButton::STATE_HOVERED, (imageDir + "maximize_inactive.png").c_str(), QColor(0x5E, 0x5D, 0x5D));
|
|
||||||
m_maximizeButton->addState(QtIconStateButton::STATE_DISABLED, (imageDir + "maximize_inactive.png").c_str());
|
m_maximizeButton->addState(QtIconStateButton::STATE_DISABLED, (imageDir + "maximize_inactive.png").c_str());
|
||||||
m_maximizeButton->setIconSize(QSize(16, 16));
|
|
||||||
m_maximizeButton->setObjectName("file_button");
|
|
||||||
m_maximizeButton->setToolTip("maximize");
|
m_maximizeButton->setToolTip("maximize");
|
||||||
titleLayout->addWidget(m_maximizeButton);
|
|
||||||
|
|
||||||
titleLayout->addSpacing(3);
|
for (QtIconStateButton* button : { m_minimizeButton, m_snippetButton, m_maximizeButton })
|
||||||
|
{
|
||||||
|
button->setIconSize(QSize(16, 16));
|
||||||
|
button->setObjectName("file_button");
|
||||||
|
button->setEnabled(false);
|
||||||
|
titleLayout->addWidget(button);
|
||||||
|
|
||||||
connect(this, &QPushButton::clicked, this, &QtCodeFileTitleBar::clickedTitleBar);
|
if (!isSingle)
|
||||||
connect(this, &QtHoverButton::hoveredIn, this, &QtCodeFileTitleBar::enteredTitleBar);
|
{
|
||||||
connect(this, &QtHoverButton::hoveredOut, this, &QtCodeFileTitleBar::leftTitleBar);
|
connect(button, &QtIconStateButton::hoveredIn, this, &QtCodeFileTitleBar::leftTitleBar);
|
||||||
|
connect(button, &QtIconStateButton::hoveredOut, this, &QtCodeFileTitleBar::enteredTitleBar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connect(m_minimizeButton, &QtIconStateButton::hoveredIn, this, &QtCodeFileTitleBar::leftTitleBar);
|
|
||||||
connect(m_minimizeButton, &QtIconStateButton::hoveredOut, this, &QtCodeFileTitleBar::enteredTitleBar);
|
|
||||||
connect(m_minimizeButton, &QtIconStateButton::clicked, this, &QtCodeFileTitleBar::clickedMinimizeButton);
|
connect(m_minimizeButton, &QtIconStateButton::clicked, this, &QtCodeFileTitleBar::clickedMinimizeButton);
|
||||||
|
|
||||||
connect(m_snippetButton, &QtIconStateButton::hoveredIn, this, &QtCodeFileTitleBar::leftTitleBar);
|
|
||||||
connect(m_snippetButton, &QtIconStateButton::hoveredOut, this, &QtCodeFileTitleBar::enteredTitleBar);
|
|
||||||
connect(m_snippetButton, &QtIconStateButton::clicked, this, &QtCodeFileTitleBar::clickedSnippetButton);
|
connect(m_snippetButton, &QtIconStateButton::clicked, this, &QtCodeFileTitleBar::clickedSnippetButton);
|
||||||
|
|
||||||
connect(m_maximizeButton, &QtIconStateButton::hoveredIn, this, &QtCodeFileTitleBar::leftTitleBar);
|
|
||||||
connect(m_maximizeButton, &QtIconStateButton::hoveredOut, this, &QtCodeFileTitleBar::enteredTitleBar);
|
|
||||||
connect(m_maximizeButton, &QtIconStateButton::clicked, this, &QtCodeFileTitleBar::clickedMaximizeButton);
|
connect(m_maximizeButton, &QtIconStateButton::clicked, this, &QtCodeFileTitleBar::clickedMaximizeButton);
|
||||||
|
|
||||||
m_minimizeButton->setEnabled(false);
|
if (isSingle)
|
||||||
m_snippetButton->setEnabled(false);
|
{
|
||||||
m_maximizeButton->setEnabled(false);
|
m_minimizeButton->hide();
|
||||||
|
m_maximizeButton->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
titleLayout->addSpacing(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtCodeFileTitleButton* QtCodeFileTitleBar::getTitleButton() const
|
QtCodeFileTitleButton* QtCodeFileTitleBar::getTitleButton() const
|
||||||
@@ -90,11 +94,26 @@ QtCodeFileTitleButton* QtCodeFileTitleBar::getTitleButton() const
|
|||||||
return m_titleButton;
|
return m_titleButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileTitleBar::setRefString(const QString& refString)
|
void QtCodeFileTitleBar::updateRefCount(int refCount, bool hasErrors, size_t fatalErrorCount)
|
||||||
{
|
{
|
||||||
if (refString.size())
|
if (refCount > 0)
|
||||||
{
|
{
|
||||||
m_referenceCount->setText(refString);
|
QString label = hasErrors ? "error" : "reference";
|
||||||
|
if (refCount > 1)
|
||||||
|
{
|
||||||
|
label += "s";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fatalErrorCount > 0)
|
||||||
|
{
|
||||||
|
label += " (" + QString::number(fatalErrorCount) + " fatal)";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString text = QString::number(refCount) + " " + label;
|
||||||
|
if (text != m_referenceCount->text())
|
||||||
|
{
|
||||||
|
m_referenceCount->setText(text);
|
||||||
|
}
|
||||||
m_referenceCount->show();
|
m_referenceCount->show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -103,10 +122,10 @@ void QtCodeFileTitleBar::setRefString(const QString& refString)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileTitleBar::setMinimized(bool hasSnippets)
|
void QtCodeFileTitleBar::setMinimized()
|
||||||
{
|
{
|
||||||
m_minimizeButton->setEnabled(false);
|
m_minimizeButton->setEnabled(false);
|
||||||
m_snippetButton->setEnabled(hasSnippets);
|
m_snippetButton->setEnabled(true);
|
||||||
m_maximizeButton->setEnabled(true);
|
m_maximizeButton->setEnabled(true);
|
||||||
|
|
||||||
m_minimizeButton->hoverOut();
|
m_minimizeButton->hoverOut();
|
||||||
@@ -125,10 +144,10 @@ void QtCodeFileTitleBar::setSnippets()
|
|||||||
m_maximizeButton->hoverOut();
|
m_maximizeButton->hoverOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileTitleBar::setMaximized(bool hasSnippets)
|
void QtCodeFileTitleBar::setMaximized()
|
||||||
{
|
{
|
||||||
m_minimizeButton->setEnabled(true);
|
m_minimizeButton->setEnabled(false);
|
||||||
m_snippetButton->setEnabled(hasSnippets);
|
m_snippetButton->setEnabled(true);
|
||||||
m_maximizeButton->setEnabled(false);
|
m_maximizeButton->setEnabled(false);
|
||||||
|
|
||||||
m_minimizeButton->hoverOut();
|
m_minimizeButton->hoverOut();
|
||||||
@@ -140,7 +159,16 @@ void QtCodeFileTitleBar::updateFromOther(const QtCodeFileTitleBar* other)
|
|||||||
{
|
{
|
||||||
m_titleButton->updateFromOther(other->getTitleButton());
|
m_titleButton->updateFromOther(other->getTitleButton());
|
||||||
|
|
||||||
setRefString(other->m_referenceCount->text());
|
QString refString = other->m_referenceCount->text();
|
||||||
|
if (refString.size())
|
||||||
|
{
|
||||||
|
m_referenceCount->setText(refString);
|
||||||
|
m_referenceCount->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_referenceCount->hide();
|
||||||
|
}
|
||||||
|
|
||||||
m_minimizeButton->setEnabled(other->m_minimizeButton->isEnabled());
|
m_minimizeButton->setEnabled(other->m_minimizeButton->isEnabled());
|
||||||
m_snippetButton->setEnabled(other->m_snippetButton->isEnabled());
|
m_snippetButton->setEnabled(other->m_snippetButton->isEnabled());
|
||||||
|
|||||||
@@ -19,15 +19,15 @@ signals:
|
|||||||
void maximize();
|
void maximize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtCodeFileTitleBar(QWidget* parent = nullptr, bool isHovering = false);
|
QtCodeFileTitleBar(QWidget* parent = nullptr, bool isHovering = false, bool isSingle = false);
|
||||||
|
|
||||||
QtCodeFileTitleButton* getTitleButton() const;
|
QtCodeFileTitleButton* getTitleButton() const;
|
||||||
|
|
||||||
void setRefString(const QString& refString);
|
void updateRefCount(int refCount, bool hasErrors, size_t fatalErrorCount);
|
||||||
|
|
||||||
void setMinimized(bool hasSnippets);
|
void setMinimized();
|
||||||
void setSnippets();
|
void setSnippets();
|
||||||
void setMaximized(bool hasSnippets);
|
void setMaximized();
|
||||||
|
|
||||||
void updateFromOther(const QtCodeFileTitleBar* other);
|
void updateFromOther(const QtCodeFileTitleBar* other);
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
|
|||||||
: QPushButton(parent)
|
: QPushButton(parent)
|
||||||
, m_isComplete(true)
|
, m_isComplete(true)
|
||||||
{
|
{
|
||||||
setObjectName("title_label");
|
setObjectName("title_button");
|
||||||
minimumSizeHint(); // force font loading
|
minimumSizeHint(); // force font loading
|
||||||
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||||
|
|
||||||
@@ -35,18 +35,16 @@ void QtCodeFileTitleButton::setFilePath(const FilePath& filePath)
|
|||||||
{
|
{
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
|
|
||||||
|
if (m_filePath.empty())
|
||||||
|
{
|
||||||
|
std::string text = ResourcePaths::getGuiPath().str() + "code_view/images/file.png";
|
||||||
|
setIcon(utility::colorizePixmap(
|
||||||
|
QPixmap(text.c_str()),
|
||||||
|
ColorScheme::getInstance()->getColor("code/file/title/icon").c_str()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
m_filePath = filePath;
|
m_filePath = filePath;
|
||||||
setText("");
|
|
||||||
|
|
||||||
setText(filePath.fileName().c_str());
|
|
||||||
setToolTip(filePath.str().c_str());
|
|
||||||
|
|
||||||
std::string text = ResourcePaths::getGuiPath().str() + "code_view/images/file.png";
|
|
||||||
|
|
||||||
setIcon(utility::colorizePixmap(
|
|
||||||
QPixmap(text.c_str()),
|
|
||||||
ColorScheme::getInstance()->getColor("code/file/title/icon").c_str()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileTitleButton::setModificationTime(const TimeStamp modificationTime)
|
void QtCodeFileTitleButton::setModificationTime(const TimeStamp modificationTime)
|
||||||
@@ -54,7 +52,6 @@ void QtCodeFileTitleButton::setModificationTime(const TimeStamp modificationTime
|
|||||||
if (modificationTime.isValid())
|
if (modificationTime.isValid())
|
||||||
{
|
{
|
||||||
m_modificationTime = modificationTime;
|
m_modificationTime = modificationTime;
|
||||||
updateTexts();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,25 +72,24 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete)
|
|||||||
);
|
);
|
||||||
|
|
||||||
setStyleSheet((
|
setStyleSheet((
|
||||||
"#title_label, #file_title { background-image: url(" + hatchingFilePath.str() + "); }"
|
"#title_button { background-image: url(" + hatchingFilePath.str() + "); }"
|
||||||
).c_str());
|
).c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setStyleSheet("");
|
setStyleSheet("");
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTexts();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileTitleButton::setProject(const std::string& name)
|
void QtCodeFileTitleButton::setProject(const std::string& name)
|
||||||
{
|
{
|
||||||
setText(name.c_str());
|
|
||||||
m_filePath = FilePath();
|
m_filePath = FilePath();
|
||||||
|
|
||||||
std::string text = ResourcePaths::getGuiPath().str() + "code_view/images/edit.png";
|
setText(name.c_str());
|
||||||
setToolTip("edit project");
|
setToolTip("edit project");
|
||||||
|
|
||||||
|
std::string text = ResourcePaths::getGuiPath().str() + "code_view/images/edit.png";
|
||||||
|
|
||||||
setIcon(utility::colorizePixmap(
|
setIcon(utility::colorizePixmap(
|
||||||
QPixmap(text.c_str()),
|
QPixmap(text.c_str()),
|
||||||
ColorScheme::getInstance()->getColor("code/file/title/icon").c_str()
|
ColorScheme::getInstance()->getColor("code/file/title/icon").c_str()
|
||||||
@@ -139,6 +135,7 @@ void QtCodeFileTitleButton::updateFromOther(const QtCodeFileTitleButton* other)
|
|||||||
|
|
||||||
setModificationTime(other->m_modificationTime);
|
setModificationTime(other->m_modificationTime);
|
||||||
setIsComplete(other->m_isComplete);
|
setIsComplete(other->m_isComplete);
|
||||||
|
updateTexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFileTitleButton::contextMenuEvent(QContextMenuEvent* event)
|
void QtCodeFileTitleButton::contextMenuEvent(QContextMenuEvent* event)
|
||||||
|
|||||||
@@ -43,15 +43,10 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated(
|
|||||||
switch (target)
|
switch (target)
|
||||||
{
|
{
|
||||||
case SCROLL_VISIBLE:
|
case SCROLL_VISIBLE:
|
||||||
if (focusRect.top() < visibleRect.top())
|
if (focusRect.top() > visibleRect.top() && focusRect.bottom() < visibleRect.bottom())
|
||||||
{
|
{
|
||||||
value = focusRect.top() - visibleRect.top() - 20;
|
return;
|
||||||
}
|
}
|
||||||
else if (focusRect.bottom() > visibleRect.bottom())
|
|
||||||
{
|
|
||||||
value = focusRect.bottom() - visibleRect.bottom() + 20;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SCROLL_CENTER:
|
case SCROLL_CENTER:
|
||||||
value = focusRect.center().y() - visibleRect.center().y();
|
value = focusRect.center().y() - visibleRect.center().y();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_mode(MODE_NONE)
|
, m_mode(MODE_NONE)
|
||||||
|
, m_oldMode(MODE_NONE)
|
||||||
, m_activeTokenId(0)
|
, m_activeTokenId(0)
|
||||||
, m_value(0)
|
, m_value(0)
|
||||||
, m_refIndex(0)
|
, m_refIndex(0)
|
||||||
@@ -104,14 +105,8 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
|||||||
m_single = new QtCodeFileSingle(this);
|
m_single = new QtCodeFileSingle(this);
|
||||||
layout->addWidget(m_single);
|
layout->addWidget(m_single);
|
||||||
|
|
||||||
if (ApplicationSettings::getInstance()->getCodeViewModeSingle())
|
setMode(ApplicationSettings::getInstance()->getCodeViewModeSingle() ? MODE_SINGLE : MODE_LIST);
|
||||||
{
|
showContents();
|
||||||
setModeSingle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setModeList();
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshStyle();
|
refreshStyle();
|
||||||
|
|
||||||
@@ -259,6 +254,25 @@ void QtCodeNavigator::clearCaches()
|
|||||||
m_single->clearCache();
|
m_single->clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeNavigator::clearSnippetReferences()
|
||||||
|
{
|
||||||
|
m_list->clearSnippetTitleAndScrollBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtCodeNavigator::setMode(Mode mode)
|
||||||
|
{
|
||||||
|
m_mode = mode;
|
||||||
|
|
||||||
|
if (mode == MODE_LIST)
|
||||||
|
{
|
||||||
|
m_current = m_list;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_current = m_single;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::set<Id>& QtCodeNavigator::getCurrentActiveTokenIds() const
|
const std::set<Id>& QtCodeNavigator::getCurrentActiveTokenIds() const
|
||||||
{
|
{
|
||||||
return m_currentActiveTokenIds;
|
return m_currentActiveTokenIds;
|
||||||
@@ -504,10 +518,41 @@ void QtCodeNavigator::setFileMaximized(const FilePath path)
|
|||||||
void QtCodeNavigator::updateFiles()
|
void QtCodeNavigator::updateFiles()
|
||||||
{
|
{
|
||||||
m_current->updateFiles();
|
m_current->updateFiles();
|
||||||
|
updateRefLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::showContents()
|
void QtCodeNavigator::showContents()
|
||||||
{
|
{
|
||||||
|
if (m_oldMode != m_mode)
|
||||||
|
{
|
||||||
|
m_listButton->setChecked(m_mode == MODE_LIST);
|
||||||
|
m_fileButton->setChecked(m_mode == MODE_SINGLE);
|
||||||
|
|
||||||
|
switch (m_mode)
|
||||||
|
{
|
||||||
|
case MODE_SINGLE:
|
||||||
|
m_list->hide();
|
||||||
|
m_single->show();
|
||||||
|
m_separatorLine->hide();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MODE_LIST:
|
||||||
|
m_single->hide();
|
||||||
|
m_list->show();
|
||||||
|
m_separatorLine->show();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
LOG_ERROR("Wrong mode set in code navigator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplicationSettings::getInstance()->setCodeViewModeSingle(m_mode == MODE_SINGLE);
|
||||||
|
ApplicationSettings::getInstance()->save();
|
||||||
|
|
||||||
|
m_oldMode = m_mode;
|
||||||
|
}
|
||||||
|
|
||||||
m_current->showContents();
|
m_current->showContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,7 +760,7 @@ void QtCodeNavigator::requestScroll(
|
|||||||
// std::cout << "scroll request: " << req.filePath.str() << " " << req.lineNumber << " " << req.locationId;
|
// std::cout << "scroll request: " << req.filePath.str() << " " << req.lineNumber << " " << req.locationId;
|
||||||
// std::cout << " " << req.animated << " " << req.target << std::endl;
|
// std::cout << " " << req.animated << " " << req.target << std::endl;
|
||||||
|
|
||||||
if ((!m_scrollRequest.lineNumber || !m_scrollRequest.locationId) && !req.filePath.empty())
|
if ((!m_scrollRequest.lineNumber && !m_scrollRequest.locationId) && !req.filePath.empty())
|
||||||
{
|
{
|
||||||
m_scrollRequest = req;
|
m_scrollRequest = req;
|
||||||
}
|
}
|
||||||
@@ -802,50 +847,12 @@ void QtCodeNavigator::nextReference(bool fromUI)
|
|||||||
|
|
||||||
void QtCodeNavigator::setModeList()
|
void QtCodeNavigator::setModeList()
|
||||||
{
|
{
|
||||||
setMode(MODE_LIST);
|
m_single->clickedSnippetButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::setModeSingle()
|
void QtCodeNavigator::setModeSingle()
|
||||||
{
|
{
|
||||||
setMode(MODE_SINGLE);
|
m_list->maximizeFirstFile();
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeNavigator::setMode(Mode mode)
|
|
||||||
{
|
|
||||||
m_listButton->setChecked(mode == MODE_LIST);
|
|
||||||
m_fileButton->setChecked(mode == MODE_SINGLE);
|
|
||||||
|
|
||||||
if (m_mode == mode)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_mode = mode;
|
|
||||||
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case MODE_SINGLE:
|
|
||||||
m_list->hide();
|
|
||||||
m_single->show();
|
|
||||||
m_separatorLine->hide();
|
|
||||||
m_current = m_single;
|
|
||||||
break;
|
|
||||||
case MODE_LIST:
|
|
||||||
m_single->hide();
|
|
||||||
m_list->show();
|
|
||||||
m_separatorLine->show();
|
|
||||||
m_current = m_list;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG_ERROR("Wrong mode set in code navigator");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationSettings::getInstance()->setCodeViewModeSingle(m_mode == MODE_SINGLE);
|
|
||||||
ApplicationSettings::getInstance()->save();
|
|
||||||
|
|
||||||
scrollToDefinition(false, false);
|
|
||||||
showContents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeNavigator::showCurrentReference(bool fromUI)
|
void QtCodeNavigator::showCurrentReference(bool fromUI)
|
||||||
@@ -903,16 +910,23 @@ void QtCodeNavigator::handleMessage(MessageFinishedParsing* message)
|
|||||||
|
|
||||||
void QtCodeNavigator::handleMessage(MessageShowReference* message)
|
void QtCodeNavigator::handleMessage(MessageShowReference* message)
|
||||||
{
|
{
|
||||||
m_refIndex = message->refIndex;
|
size_t refIndex = message->refIndex;
|
||||||
|
bool replayed = message->isReplayed();
|
||||||
|
|
||||||
m_onQtThread(
|
m_onQtThread(
|
||||||
[=]()
|
[=]()
|
||||||
{
|
{
|
||||||
|
m_refIndex = refIndex;
|
||||||
|
|
||||||
if (m_refIndex > 0)
|
if (m_refIndex > 0)
|
||||||
{
|
{
|
||||||
const Reference& ref = m_references[m_refIndex - 1];
|
const Reference& ref = m_references[m_refIndex - 1];
|
||||||
setCurrentActiveLocationIds(std::vector<Id>(1, ref.locationId));
|
setCurrentActiveLocationIds(std::vector<Id>(1, ref.locationId));
|
||||||
updateFiles();
|
|
||||||
|
if (!replayed)
|
||||||
|
{
|
||||||
|
updateFiles();
|
||||||
|
}
|
||||||
|
|
||||||
requestScroll(ref.filePath, 0, ref.locationId, true, QtCodeNavigateable::SCROLL_CENTER);
|
requestScroll(ref.filePath, 0, ref.locationId, true, QtCodeNavigateable::SCROLL_CENTER);
|
||||||
emit scrollRequest();
|
emit scrollRequest();
|
||||||
@@ -923,7 +937,10 @@ void QtCodeNavigator::handleMessage(MessageShowReference* message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRefLabel();
|
if (!replayed)
|
||||||
|
{
|
||||||
|
updateRefLabel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ class QtCodeNavigator
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum Mode
|
||||||
|
{
|
||||||
|
MODE_NONE,
|
||||||
|
MODE_LIST,
|
||||||
|
MODE_SINGLE
|
||||||
|
};
|
||||||
|
|
||||||
QtCodeNavigator(QWidget* parent = nullptr);
|
QtCodeNavigator(QWidget* parent = nullptr);
|
||||||
virtual ~QtCodeNavigator();
|
virtual ~QtCodeNavigator();
|
||||||
|
|
||||||
@@ -43,6 +50,9 @@ public:
|
|||||||
void clearCodeSnippets();
|
void clearCodeSnippets();
|
||||||
void clearFile();
|
void clearFile();
|
||||||
void clearCaches();
|
void clearCaches();
|
||||||
|
void clearSnippetReferences();
|
||||||
|
|
||||||
|
void setMode(Mode mode);
|
||||||
|
|
||||||
const std::set<Id>& getCurrentActiveTokenIds() const;
|
const std::set<Id>& getCurrentActiveTokenIds() const;
|
||||||
void setCurrentActiveTokenIds(const std::vector<Id>& currentActiveTokenIds);
|
void setCurrentActiveTokenIds(const std::vector<Id>& currentActiveTokenIds);
|
||||||
@@ -114,15 +124,6 @@ private slots:
|
|||||||
void setModeSingle();
|
void setModeSingle();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum Mode
|
|
||||||
{
|
|
||||||
MODE_NONE,
|
|
||||||
MODE_LIST,
|
|
||||||
MODE_SINGLE
|
|
||||||
};
|
|
||||||
|
|
||||||
void setMode(Mode mode);
|
|
||||||
|
|
||||||
struct Reference
|
struct Reference
|
||||||
{
|
{
|
||||||
Reference()
|
Reference()
|
||||||
@@ -172,6 +173,7 @@ private:
|
|||||||
QtCodeFileSingle* m_single;
|
QtCodeFileSingle* m_single;
|
||||||
|
|
||||||
Mode m_mode;
|
Mode m_mode;
|
||||||
|
Mode m_oldMode;
|
||||||
|
|
||||||
std::set<Id> m_currentActiveTokenIds;
|
std::set<Id> m_currentActiveTokenIds;
|
||||||
std::set<Id> m_currentActiveLocationIds;
|
std::set<Id> m_currentActiveLocationIds;
|
||||||
|
|||||||
@@ -200,10 +200,10 @@ void QtCodeSnippet::clickedTitle()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getFile()->clickedMaximizeButton();
|
getFile()->requestWholeFileContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_navigator->requestScroll(getFile()->getFilePath(), getStartLineNumber(), 0, true, QtCodeNavigateable::SCROLL_CENTER);
|
m_navigator->requestScroll(getFile()->getFilePath(), getStartLineNumber(), 0, true, QtCodeNavigateable::SCROLL_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeSnippet::clickedFooter()
|
void QtCodeSnippet::clickedFooter()
|
||||||
|
|||||||
@@ -146,10 +146,9 @@ void QtCodeView::showCodeSnippets(const std::vector<CodeSnippetParams>& snippets
|
|||||||
m_widget->addedFiles();
|
m_widget->addedFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_widget->updateFiles();
|
|
||||||
|
|
||||||
if (params.showContents)
|
if (params.showContents)
|
||||||
{
|
{
|
||||||
|
m_widget->updateFiles();
|
||||||
m_widget->showContents();
|
m_widget->showContents();
|
||||||
performScroll();
|
performScroll();
|
||||||
}
|
}
|
||||||
@@ -231,6 +230,7 @@ void QtCodeView::showContents()
|
|||||||
m_onQtThread([=]()
|
m_onQtThread([=]()
|
||||||
{
|
{
|
||||||
TRACE("show contents");
|
TRACE("show contents");
|
||||||
|
m_widget->updateFiles();
|
||||||
m_widget->showContents();
|
m_widget->showContents();
|
||||||
performScroll();
|
performScroll();
|
||||||
});
|
});
|
||||||
@@ -241,6 +241,19 @@ bool QtCodeView::isInListMode() const
|
|||||||
return m_widget->isInListMode();
|
return m_widget->isInListMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeView::setMode(bool listMode)
|
||||||
|
{
|
||||||
|
if (isInListMode() == listMode)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_onQtThread([=]()
|
||||||
|
{
|
||||||
|
m_widget->setMode(listMode ? QtCodeNavigator::MODE_LIST : QtCodeNavigator::MODE_SINGLE);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
bool QtCodeView::hasSingleFileCached(const FilePath& filePath) const
|
bool QtCodeView::hasSingleFileCached(const FilePath& filePath) const
|
||||||
{
|
{
|
||||||
return m_widget->hasSingleFileCached(filePath);
|
return m_widget->hasSingleFileCached(filePath);
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ public:
|
|||||||
virtual void showContents();
|
virtual void showContents();
|
||||||
|
|
||||||
virtual bool isInListMode() const;
|
virtual bool isInListMode() const;
|
||||||
|
virtual void setMode(bool listMode);
|
||||||
|
|
||||||
virtual bool hasSingleFileCached(const FilePath& filePath) const;
|
virtual bool hasSingleFileCached(const FilePath& filePath) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user