summaryrefslogtreecommitdiff
path: root/src/plugins/bookmarks
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-05-02 11:59:37 +0200
committerEike Ziller <eike.ziller@qt.io>2018-05-03 05:19:24 +0000
commiteca2f5da53719a873072d1312040aaf984ad1d91 (patch)
tree7a8b6e61677250eb0e8b636053c4831cead33543 /src/plugins/bookmarks
parent436967ebf062d658b3ac8bb5ab96da83d3ad53d5 (diff)
downloadqt-creator-eca2f5da53719a873072d1312040aaf984ad1d91.tar.gz
Bookmarks: Some general code cleanup
Change-Id: Ibaba24af685d733bc3a488b82f2af5212f7ac35d Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/bookmarks')
-rw-r--r--src/plugins/bookmarks/bookmarkmanager.cpp29
-rw-r--r--src/plugins/bookmarks/bookmarkmanager.h32
-rw-r--r--src/plugins/bookmarks/bookmarksplugin.cpp6
3 files changed, 20 insertions, 47 deletions
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp
index a503e97123..e75664ce45 100644
--- a/src/plugins/bookmarks/bookmarkmanager.cpp
+++ b/src/plugins/bookmarks/bookmarkmanager.cpp
@@ -169,33 +169,6 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
0.7 * textColor.greenF() + 0.3 * backgroundColor.greenF(),
0.7 * textColor.blueF() + 0.3 * backgroundColor.blueF());
painter->setPen(mix);
-//
-// QString directory = index.data(BookmarkManager::Directory).toString();
-// int availableSpace = opt.rect.width() - 12;
-// if (fm.width(directory) > availableSpace) {
-// // We need a shorter directory
-// availableSpace -= fm.width("...");
-//
-// int pos = directory.size();
-// int idx;
-// forever {
-// idx = directory.lastIndexOf("/", pos-1);
-// if (idx == -1) {
-// // Can't happen, this means the string did fit after all?
-// break;
-// }
-// int width = fm.width(directory.mid(idx, pos-idx));
-// if (width > availableSpace) {
-// directory = "..." + directory.mid(pos);
-// break;
-// } else {
-// pos = idx;
-// availableSpace -= width;
-// }
-// }
-// }
-//
-// painter->drawText(3, opt.rect.top() + fm.ascent() + fm.height() + 6, directory);
QString lineText = index.data(BookmarkManager::Note).toString().trimmed();
if (lineText.isEmpty())
@@ -514,7 +487,7 @@ void BookmarkManager::deleteBookmark(Bookmark *bookmark)
Bookmark *BookmarkManager::bookmarkForIndex(const QModelIndex &index) const
{
if (!index.isValid() || index.row() >= m_bookmarksList.size())
- return 0;
+ return nullptr;
return m_bookmarksList.at(index.row());
}
diff --git a/src/plugins/bookmarks/bookmarkmanager.h b/src/plugins/bookmarks/bookmarkmanager.h
index 4021942001..c1cbef10f3 100644
--- a/src/plugins/bookmarks/bookmarkmanager.h
+++ b/src/plugins/bookmarks/bookmarkmanager.h
@@ -51,7 +51,7 @@ class BookmarkManager : public QAbstractItemModel
public:
BookmarkManager();
- ~BookmarkManager();
+ ~BookmarkManager() final;
void updateBookmark(Bookmark *bookmark);
void updateBookmarkFileName(Bookmark *bookmark, const QString &oldFileName);
@@ -63,16 +63,16 @@ public:
State state() const;
// Model stuff
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- QModelIndex parent(const QModelIndex &child) const;
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- Qt::ItemFlags flags(const QModelIndex &index) const;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const final;
+ QModelIndex parent(const QModelIndex &child) const final;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const final;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const final;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const final;
+ Qt::ItemFlags flags(const QModelIndex &index) const final;
- Qt::DropActions supportedDragActions() const;
- QStringList mimeTypes() const;
- QMimeData *mimeData(const QModelIndexList &indexes) const;
+ Qt::DropActions supportedDragActions() const final;
+ QStringList mimeTypes() const final;
+ QMimeData *mimeData(const QModelIndexList &indexes) const final;
// this QItemSelectionModel is shared by all views
QItemSelectionModel *selectionModel() const;
@@ -128,7 +128,7 @@ class BookmarkView : public Utils::ListView
public:
explicit BookmarkView(BookmarkManager *manager);
- ~BookmarkView();
+ ~BookmarkView() final;
QList<QToolButton *> createToolBarWidgets() const;
@@ -140,9 +140,9 @@ protected slots:
void removeAll();
protected:
- void contextMenuEvent(QContextMenuEvent *event);
+ void contextMenuEvent(QContextMenuEvent *event) final;
void removeBookmark(const QModelIndex &index);
- void keyPressEvent(QKeyEvent *event);
+ void keyPressEvent(QKeyEvent *event) final;
private:
Core::IContext *m_bookmarkContext;
@@ -168,11 +168,11 @@ class BookmarkDelegate : public QStyledItemDelegate
Q_OBJECT
public:
- BookmarkDelegate(QObject *parent = 0);
+ BookmarkDelegate(QObject *parent = nullptr);
private:
- void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
- QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
+ 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;
diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp
index 513af772ce..cdc1cd30d1 100644
--- a/src/plugins/bookmarks/bookmarksplugin.cpp
+++ b/src/plugins/bookmarks/bookmarksplugin.cpp
@@ -141,7 +141,7 @@ BookmarksPluginRunData::BookmarksPluginRunData()
editorManagerContext);
mbm->addAction(cmd);
- connect(&m_toggleAction, &QAction::triggered, [this] {
+ connect(&m_toggleAction, &QAction::triggered, this, [this] {
BaseTextEditor *editor = BaseTextEditor::currentTextEditor();
if (editor && !editor->document()->isTemporary())
m_bookmarkManager.toggleBookmark(editor->document()->filePath(), editor->currentLine());
@@ -154,7 +154,7 @@ BookmarksPluginRunData::BookmarksPluginRunData()
connect(&m_docNextAction, &QAction::triggered,
&m_bookmarkManager, &BookmarkManager::nextInDocument);
- connect(&m_editBookmarkAction, &QAction::triggered, [this] {
+ connect(&m_editBookmarkAction, &QAction::triggered, this, [this] {
m_bookmarkManager.editByFileAndLine(m_marginActionFileName, m_marginActionLineNumber);
});
@@ -162,7 +162,7 @@ BookmarksPluginRunData::BookmarksPluginRunData()
this, &BookmarksPluginRunData::updateActions);
updateActions(false, m_bookmarkManager.state());
- connect(&m_bookmarkMarginAction, &QAction::triggered, [this] {
+ connect(&m_bookmarkMarginAction, &QAction::triggered, this, [this] {
m_bookmarkManager.toggleBookmark(m_marginActionFileName, m_marginActionLineNumber);
});