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 <coreplugin/session.h>
|
||||||
|
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/icon.h>
|
#include <utils/icon.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/dropsupport.h>
|
#include <utils/dropsupport.h>
|
||||||
#include <utils/utilsicons.h>
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QDir>
|
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@@ -43,10 +42,21 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace Bookmarks::Internal {
|
namespace Bookmarks::Internal {
|
||||||
|
|
||||||
BookmarkDelegate::BookmarkDelegate(QObject *parent)
|
class BookmarkDelegate : public QStyledItemDelegate
|
||||||
: QStyledItemDelegate(parent)
|
|
||||||
{
|
{
|
||||||
}
|
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
|
QSize BookmarkDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
@@ -159,6 +169,31 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||||||
painter->restore();
|
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) :
|
BookmarkView::BookmarkView(BookmarkManager *manager) :
|
||||||
m_bookmarkContext(new IContext(this)),
|
m_bookmarkContext(new IContext(this)),
|
||||||
m_manager(manager)
|
m_manager(manager)
|
||||||
|
@@ -99,29 +99,6 @@ private:
|
|||||||
QItemSelectionModel *m_selectionModel;
|
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
|
class BookmarkViewFactory : public Core::INavigationWidgetFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -133,18 +110,4 @@ private:
|
|||||||
BookmarkManager *m_manager;
|
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
|
} // Bookmarks::Internal
|
||||||
|
@@ -20,7 +20,6 @@
|
|||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
Reference in New Issue
Block a user