logic: Fixed project refresh to acknowledge project state
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
|
||||
QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeNavigator* navigator)
|
||||
: QFrame()
|
||||
, m_updateTitleBarFunctor(std::bind(&QtCodeFile::doUpdateTitleBar, this))
|
||||
, m_navigator(navigator)
|
||||
, m_filePath(filePath)
|
||||
, m_contentRequested(false)
|
||||
@@ -403,6 +402,27 @@ void QtCodeFile::updateSnippets()
|
||||
m_snippets.back()->setProperty("isLast", true);
|
||||
}
|
||||
|
||||
void QtCodeFile::updateTitleBar()
|
||||
{
|
||||
if (isTrial())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// cannot use m_filePath.exists() here since it is only checked when FilePath is constructed.
|
||||
if ((!FileSystem::exists(m_filePath.str())) ||
|
||||
(FileSystem::getLastWriteTime(m_filePath) > m_modificationTime))
|
||||
{
|
||||
m_title->setText(QString(m_filePath.fileName().c_str()) + "*");
|
||||
m_title->setToolTip(QString::fromStdString("out of date: " + m_filePath.str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_title->setText(m_filePath.fileName().c_str());
|
||||
m_title->setToolTip(QString::fromStdString(m_filePath.str()));
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFile::clickedMinimizeButton() const
|
||||
{
|
||||
MessageChangeFileView(
|
||||
@@ -459,11 +479,6 @@ void QtCodeFile::editProject()
|
||||
MessageProjectEdit().dispatch();
|
||||
}
|
||||
|
||||
void QtCodeFile::handleMessage(MessageWindowFocus* message)
|
||||
{
|
||||
updateTitleBar();
|
||||
}
|
||||
|
||||
void QtCodeFile::updateRefCount(int refCount)
|
||||
{
|
||||
if (refCount > 0)
|
||||
@@ -488,29 +503,3 @@ void QtCodeFile::updateRefCount(int refCount)
|
||||
m_referenceCount->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFile::updateTitleBar()
|
||||
{
|
||||
m_updateTitleBarFunctor();
|
||||
}
|
||||
|
||||
void QtCodeFile::doUpdateTitleBar()
|
||||
{
|
||||
if (isTrial())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// cannot use m_filePath.exists() here since it is only checked when FilePath is constructed.
|
||||
if ((!FileSystem::exists(m_filePath.str())) ||
|
||||
(FileSystem::getLastWriteTime(m_filePath) > m_modificationTime))
|
||||
{
|
||||
m_title->setText(QString(m_filePath.fileName().c_str()) + "*");
|
||||
m_title->setToolTip(QString::fromStdString("out of date: " + m_filePath.str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_title->setText(m_filePath.fileName().c_str());
|
||||
m_title->setToolTip(QString::fromStdString(m_filePath.str()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/TimePoint.h"
|
||||
#include "utility/types.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
#include "data/ErrorInfo.h"
|
||||
#include "component/view/helper/CodeSnippetParams.h"
|
||||
@@ -26,7 +23,6 @@ class TokenLocationFile;
|
||||
|
||||
class QtCodeFile
|
||||
: public QFrame
|
||||
, MessageListener<MessageWindowFocus>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -59,6 +55,7 @@ public:
|
||||
|
||||
bool hasSnippets() const;
|
||||
void updateSnippets();
|
||||
void updateTitleBar();
|
||||
|
||||
public slots:
|
||||
void clickedMinimizeButton() const;
|
||||
@@ -71,13 +68,7 @@ private slots:
|
||||
void editProject();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageWindowFocus* message);
|
||||
|
||||
void updateRefCount(int refCount);
|
||||
void updateTitleBar();
|
||||
void doUpdateTitleBar();
|
||||
|
||||
QtThreadedFunctor<> m_updateTitleBarFunctor;
|
||||
|
||||
QtCodeNavigator* m_navigator;
|
||||
|
||||
|
||||
@@ -93,6 +93,14 @@ void QtCodeFileList::showContents()
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileList::onWindowFocus()
|
||||
{
|
||||
for (std::shared_ptr<QtCodeFile> filePtr : m_files)
|
||||
{
|
||||
filePtr->updateTitleBar();
|
||||
}
|
||||
}
|
||||
|
||||
QtCodeFile* QtCodeFileList::getFile(const FilePath filePath)
|
||||
{
|
||||
QtCodeFile* file = nullptr;
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
void updateFiles();
|
||||
void showContents();
|
||||
|
||||
void onWindowFocus();
|
||||
|
||||
QtCodeFile* getFile(const FilePath filePath);
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_switchReferenceFunctor(std::bind(&QtCodeNavigator::doSwitchReference, this, std::placeholders::_1))
|
||||
, m_value(0)
|
||||
, m_refIndex(0)
|
||||
, m_scrollToFile(nullptr)
|
||||
@@ -602,17 +601,29 @@ void QtCodeNavigator::ensureWidgetVisibleAnimated(QWidget *childWidget, QRectF r
|
||||
|
||||
void QtCodeNavigator::handleMessage(MessageCodeReference* message)
|
||||
{
|
||||
m_switchReferenceFunctor(message->type);
|
||||
MessageCodeReference::ReferenceType type = message->type;
|
||||
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
if (type == MessageCodeReference::REFERENCE_PREVIOUS)
|
||||
{
|
||||
previousReference();
|
||||
}
|
||||
else if (type == MessageCodeReference::REFERENCE_NEXT)
|
||||
{
|
||||
nextReference();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtCodeNavigator::doSwitchReference(MessageCodeReference::ReferenceType type)
|
||||
void QtCodeNavigator::handleMessage(MessageWindowFocus* message)
|
||||
{
|
||||
if (type == MessageCodeReference::REFERENCE_PREVIOUS)
|
||||
{
|
||||
previousReference();
|
||||
}
|
||||
else if (type == MessageCodeReference::REFERENCE_NEXT)
|
||||
{
|
||||
nextReference();
|
||||
}
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_list->onWindowFocus();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
@@ -18,6 +19,7 @@ class TokenLocationFile;
|
||||
class QtCodeNavigator
|
||||
: public QWidget
|
||||
, public MessageListener<MessageCodeReference>
|
||||
, public MessageListener<MessageWindowFocus>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -99,9 +101,9 @@ private:
|
||||
void ensureWidgetVisibleAnimated(QWidget *childWidget, QRectF rect);
|
||||
|
||||
void handleMessage(MessageCodeReference* message);
|
||||
void doSwitchReference(MessageCodeReference::ReferenceType type);
|
||||
void handleMessage(MessageWindowFocus* message);
|
||||
|
||||
QtThreadedFunctor<MessageCodeReference::ReferenceType> m_switchReferenceFunctor;
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
QScrollArea* m_scrollArea;
|
||||
QtCodeFileList* m_list;
|
||||
|
||||
Reference in New Issue
Block a user