forked from qt-creator/qt-creator
BookMarks: Hide some BookMarkManager implementation details
Change-Id: Icfc2ca62fb66ff6be6f1f07bbe3e99b35b4c146b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -15,20 +15,19 @@
|
||||
#include <coreplugin/session.h>
|
||||
|
||||
#include <texteditor/texteditor.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/icon.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/checkablemessagebox.h>
|
||||
#include <utils/theme/theme.h>
|
||||
#include <utils/dropsupport.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QDebug>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFormLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
@@ -43,10 +42,21 @@ using namespace Utils;
|
||||
|
||||
namespace Bookmarks::Internal {
|
||||
|
||||
BookmarkDelegate::BookmarkDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
class BookmarkDelegate : public QStyledItemDelegate
|
||||
{
|
||||
}
|
||||
public:
|
||||
BookmarkDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{}
|
||||
|
||||
private:
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const final;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const final;
|
||||
void generateGradientPixmap(int width, int height, const QColor &color, bool selected) const;
|
||||
|
||||
mutable QPixmap m_normalPixmap;
|
||||
mutable QPixmap m_selectedPixmap;
|
||||
};
|
||||
|
||||
QSize BookmarkDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
@@ -159,6 +169,31 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
// BookmarkView
|
||||
|
||||
class BookmarkView final : public Utils::ListView
|
||||
{
|
||||
public:
|
||||
explicit BookmarkView(BookmarkManager *manager);
|
||||
|
||||
QList<QToolButton *> createToolBarWidgets();
|
||||
|
||||
void gotoBookmark(const QModelIndex &index);
|
||||
|
||||
void removeFromContextMenu();
|
||||
void removeAll();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *event) final;
|
||||
void removeBookmark(const QModelIndex &index);
|
||||
void keyPressEvent(QKeyEvent *event) final;
|
||||
|
||||
private:
|
||||
Core::IContext *m_bookmarkContext;
|
||||
QModelIndex m_contextMenuIndex;
|
||||
BookmarkManager *m_manager;
|
||||
};
|
||||
|
||||
BookmarkView::BookmarkView(BookmarkManager *manager) :
|
||||
m_bookmarkContext(new IContext(this)),
|
||||
m_manager(manager)
|
||||
|
@@ -99,29 +99,6 @@ private:
|
||||
QItemSelectionModel *m_selectionModel;
|
||||
};
|
||||
|
||||
class BookmarkView final : public Utils::ListView
|
||||
{
|
||||
public:
|
||||
explicit BookmarkView(BookmarkManager *manager);
|
||||
|
||||
QList<QToolButton *> createToolBarWidgets();
|
||||
|
||||
void gotoBookmark(const QModelIndex &index);
|
||||
|
||||
void removeFromContextMenu();
|
||||
void removeAll();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QContextMenuEvent *event) final;
|
||||
void removeBookmark(const QModelIndex &index);
|
||||
void keyPressEvent(QKeyEvent *event) final;
|
||||
|
||||
private:
|
||||
Core::IContext *m_bookmarkContext;
|
||||
QModelIndex m_contextMenuIndex;
|
||||
BookmarkManager *m_manager;
|
||||
};
|
||||
|
||||
class BookmarkViewFactory : public Core::INavigationWidgetFactory
|
||||
{
|
||||
public:
|
||||
@@ -133,18 +110,4 @@ private:
|
||||
BookmarkManager *m_manager;
|
||||
};
|
||||
|
||||
class BookmarkDelegate : public QStyledItemDelegate
|
||||
{
|
||||
public:
|
||||
BookmarkDelegate(QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const final;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const final;
|
||||
void generateGradientPixmap(int width, int height, const QColor &color, bool selected) const;
|
||||
|
||||
mutable QPixmap m_normalPixmap;
|
||||
mutable QPixmap m_selectedPixmap;
|
||||
};
|
||||
|
||||
} // Bookmarks::Internal
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QMenu>
|
||||
|
Reference in New Issue
Block a user