forked from qt-creator/qt-creator
Core: Re-order EditorView functions a bit
More canonical. Also remove two unused slots markers plus a bit code cosmetics. Change-Id: I4015ffecc5cb2f7d0bb7d8e35c4a59c425a42a6d Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -7,11 +7,9 @@
|
||||
#include "editormanager_p.h"
|
||||
#include "documentmodel.h"
|
||||
#include "documentmodel_p.h"
|
||||
#include "../actionmanager/actionmanager.h"
|
||||
#include "../editormanager/ieditor.h"
|
||||
#include "../editortoolbar.h"
|
||||
#include "../findplaceholder.h"
|
||||
#include "../icore.h"
|
||||
#include "../minisplitter.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -22,8 +20,6 @@
|
||||
#include <utils/link.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
@@ -36,10 +32,11 @@
|
||||
#include <QStackedLayout>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
using namespace Utils;
|
||||
|
||||
// ================EditorView====================
|
||||
namespace Core::Internal {
|
||||
|
||||
// EditorView
|
||||
|
||||
EditorView::EditorView(SplitterOrView *parentSplitterOrView, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -225,6 +222,16 @@ void EditorView::setCloseSplitIcon(const QIcon &icon)
|
||||
m_toolBar->setCloseSplitIcon(icon);
|
||||
}
|
||||
|
||||
bool EditorView::canGoForward() const
|
||||
{
|
||||
return m_currentNavigationHistoryPosition < m_navigationHistory.size() - 1;
|
||||
}
|
||||
|
||||
bool EditorView::canGoBack() const
|
||||
{
|
||||
return m_currentNavigationHistoryPosition > 0;
|
||||
}
|
||||
|
||||
void EditorView::updateEditorHistory(IEditor *editor, QList<EditLocation> &history)
|
||||
{
|
||||
if (!editor)
|
||||
@@ -997,3 +1004,5 @@ EditLocation EditLocation::load(const QByteArray &data)
|
||||
stream >> loc.state;
|
||||
return loc;
|
||||
}
|
||||
|
||||
} // Core::Internal
|
||||
|
||||
@@ -7,13 +7,9 @@
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QPointer>
|
||||
#include <QVariant>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QWidget>
|
||||
|
||||
#include <functional>
|
||||
@@ -84,6 +80,21 @@ public:
|
||||
void setCloseSplitEnabled(bool enable);
|
||||
void setCloseSplitIcon(const QIcon &icon);
|
||||
|
||||
bool canGoForward() const;
|
||||
bool canGoBack() const;
|
||||
|
||||
void goBackInNavigationHistory();
|
||||
void goForwardInNavigationHistory();
|
||||
|
||||
void goToEditLocation(const EditLocation &location);
|
||||
|
||||
void addCurrentPositionToNavigationHistory(const QByteArray &saveState = QByteArray());
|
||||
void cutForwardNavigationHistory();
|
||||
|
||||
QList<EditLocation> editorHistory() const { return m_editorHistory; }
|
||||
|
||||
void copyNavigationHistoryFrom(EditorView* other);
|
||||
void updateEditorHistory(IEditor *editor);
|
||||
static void updateEditorHistory(IEditor *editor, QList<EditLocation> &history);
|
||||
|
||||
signals:
|
||||
@@ -112,6 +123,8 @@ private:
|
||||
void updateToolBar(IEditor *editor);
|
||||
void checkProjectLoaded(IEditor *editor);
|
||||
|
||||
void updateCurrentPositionInNavigationHistory();
|
||||
|
||||
SplitterOrView *m_parentSplitterOrView;
|
||||
EditorToolBar *m_toolBar;
|
||||
|
||||
@@ -129,26 +142,6 @@ private:
|
||||
QList<EditLocation> m_navigationHistory;
|
||||
QList<EditLocation> m_editorHistory;
|
||||
int m_currentNavigationHistoryPosition = 0;
|
||||
void updateCurrentPositionInNavigationHistory();
|
||||
|
||||
public:
|
||||
inline bool canGoForward() const { return m_currentNavigationHistoryPosition < m_navigationHistory.size()-1; }
|
||||
inline bool canGoBack() const { return m_currentNavigationHistoryPosition > 0; }
|
||||
|
||||
public slots:
|
||||
void goBackInNavigationHistory();
|
||||
void goForwardInNavigationHistory();
|
||||
|
||||
public:
|
||||
void goToEditLocation(const EditLocation &location);
|
||||
|
||||
void addCurrentPositionToNavigationHistory(const QByteArray &saveState = QByteArray());
|
||||
void cutForwardNavigationHistory();
|
||||
|
||||
inline QList<EditLocation> editorHistory() const { return m_editorHistory; }
|
||||
|
||||
void copyNavigationHistoryFrom(EditorView* other);
|
||||
void updateEditorHistory(IEditor *editor);
|
||||
};
|
||||
|
||||
class SplitterOrView : public QWidget
|
||||
@@ -162,15 +155,15 @@ public:
|
||||
void split(Qt::Orientation orientation, bool activateView = true);
|
||||
void unsplit();
|
||||
|
||||
inline bool isView() const { return m_view != nullptr; }
|
||||
inline bool isSplitter() const { return m_splitter != nullptr; }
|
||||
bool isView() const { return m_view != nullptr; }
|
||||
bool isSplitter() const { return m_splitter != nullptr; }
|
||||
|
||||
inline IEditor *editor() const { return m_view ? m_view->currentEditor() : nullptr; }
|
||||
inline QList<IEditor *> editors() const { return m_view ? m_view->editors() : QList<IEditor*>(); }
|
||||
inline bool hasEditor(IEditor *editor) const { return m_view && m_view->hasEditor(editor); }
|
||||
inline bool hasEditors() const { return m_view && m_view->editorCount() != 0; }
|
||||
inline EditorView *view() const { return m_view; }
|
||||
inline QSplitter *splitter() const { return m_splitter; }
|
||||
IEditor *editor() const { return m_view ? m_view->currentEditor() : nullptr; }
|
||||
QList<IEditor *> editors() const { return m_view ? m_view->editors() : QList<IEditor*>(); }
|
||||
bool hasEditor(IEditor *editor) const { return m_view && m_view->hasEditor(editor); }
|
||||
bool hasEditors() const { return m_view && m_view->editorCount() != 0; }
|
||||
EditorView *view() const { return m_view; }
|
||||
QSplitter *splitter() const { return m_splitter; }
|
||||
QSplitter *takeSplitter();
|
||||
EditorView *takeView();
|
||||
|
||||
@@ -196,5 +189,5 @@ private:
|
||||
QSplitter *m_splitter;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // Internal
|
||||
} // Core
|
||||
|
||||
Reference in New Issue
Block a user