Commit cac7f826 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Remove static icons, cleanup.

Use constructor initialization, const.
parent f4163b8b
...@@ -35,21 +35,20 @@ ...@@ -35,21 +35,20 @@
using namespace Bookmarks::Internal; using namespace Bookmarks::Internal;
const QIcon Bookmark::m_bookmarkIcon = QIcon(":/bookmarks/images/bookmark.png"); Bookmark::Bookmark(const QString& fileName, int lineNumber, BookmarkManager *manager) :
BaseTextMark(fileName, lineNumber),
Bookmark::Bookmark(const QString& fileName, int lineNumber, BookmarkManager *manager) m_manager(manager),
: BaseTextMark(fileName, lineNumber), m_manager(manager) m_fileInfo(fileName),
m_fileName(fileName),
m_onlyFile(m_fileInfo.fileName()),
m_path(m_fileInfo.path()),
m_lineNumber(lineNumber)
{ {
m_fileName = fileName;
m_fileInfo.setFile(fileName);
m_onlyFile = m_fileInfo.fileName();
m_path = m_fileInfo.path();
m_lineNumber= lineNumber;
} }
QIcon Bookmark::icon() const QIcon Bookmark::icon() const
{ {
return m_bookmarkIcon; return m_manager->bookmarkIcon();
} }
void Bookmark::removedFromEditor() void Bookmark::removedFromEditor()
......
...@@ -64,16 +64,13 @@ public: ...@@ -64,16 +64,13 @@ public:
inline int lineNumber() const { return m_lineNumber; } inline int lineNumber() const { return m_lineNumber; }
private: private:
static const QIcon m_bookmarkIcon;
BookmarkManager *m_manager; BookmarkManager *m_manager;
int m_lineNumber; const QFileInfo m_fileInfo;
QString m_name; const QString m_fileName;
QString m_fileName; const QString m_onlyFile;
QString m_onlyFile; const QString m_path;
QString m_path;
QString m_lineText; QString m_lineText;
QFileInfo m_fileInfo; int m_lineNumber;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -202,16 +202,16 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti ...@@ -202,16 +202,16 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
painter->restore(); painter->restore();
} }
BookmarkView::BookmarkView(QWidget *parent) BookmarkView::BookmarkView(QWidget *parent) :
: QListView(parent) QListView(parent),
m_bookmarkContext(new BookmarkContext(this)),
m_manager(0)
{ {
setWindowTitle(tr("Bookmarks")); setWindowTitle(tr("Bookmarks"));
setWindowIcon(QIcon(":/bookmarks/images/bookmark.png"));
connect(this, SIGNAL(clicked(const QModelIndex &)), connect(this, SIGNAL(clicked(const QModelIndex &)),
this, SLOT(gotoBookmark(const QModelIndex &))); this, SLOT(gotoBookmark(const QModelIndex &)));
m_bookmarkContext = new BookmarkContext(this);
ICore::instance()->addContextObject(m_bookmarkContext); ICore::instance()->addContextObject(m_bookmarkContext);
setItemDelegate(new BookmarkDelegate(this)); setItemDelegate(new BookmarkDelegate(this));
...@@ -317,11 +317,10 @@ QWidget *BookmarkContext::widget() ...@@ -317,11 +317,10 @@ QWidget *BookmarkContext::widget()
// BookmarkManager // BookmarkManager
//// ////
BookmarkManager::BookmarkManager() BookmarkManager::BookmarkManager() :
: m_bookmarkIcon(QIcon(QLatin1String(":/bookmarks/images/bookmark.png"))) m_bookmarkIcon(QLatin1String(":/bookmarks/images/bookmark.png")),
m_selectionModel(new QItemSelectionModel(this, this))
{ {
m_selectionModel = new QItemSelectionModel(this, this);
connect(Core::ICore::instance(), SIGNAL(contextChanged(Core::IContext*)), connect(Core::ICore::instance(), SIGNAL(contextChanged(Core::IContext*)),
this, SLOT(updateActionStatus())); this, SLOT(updateActionStatus()));
......
...@@ -66,6 +66,9 @@ class BookmarkManager : public QAbstractItemModel ...@@ -66,6 +66,9 @@ class BookmarkManager : public QAbstractItemModel
public: public:
BookmarkManager(); BookmarkManager();
~BookmarkManager(); ~BookmarkManager();
QIcon bookmarkIcon() const { return m_bookmarkIcon; }
void updateBookmark(Bookmark *bookmark); void updateBookmark(Bookmark *bookmark);
void removeBookmark(Bookmark *bookmark); // Does not remove the mark void removeBookmark(Bookmark *bookmark); // Does not remove the mark
void removeAllBookmarks(); void removeAllBookmarks();
...@@ -127,7 +130,7 @@ private: ...@@ -127,7 +130,7 @@ private:
DirectoryFileBookmarksMap m_bookmarksMap; DirectoryFileBookmarksMap m_bookmarksMap;
QIcon m_bookmarkIcon; const QIcon m_bookmarkIcon;
QList<Bookmark *> m_bookmarksList; QList<Bookmark *> m_bookmarksList;
QItemSelectionModel *m_selectionModel; QItemSelectionModel *m_selectionModel;
......
...@@ -89,8 +89,8 @@ GenericProjectWizard::~GenericProjectWizard() ...@@ -89,8 +89,8 @@ GenericProjectWizard::~GenericProjectWizard()
Core::BaseFileWizardParameters GenericProjectWizard::parameters() Core::BaseFileWizardParameters GenericProjectWizard::parameters()
{ {
static Core::BaseFileWizardParameters parameters(ProjectWizard); Core::BaseFileWizardParameters parameters(ProjectWizard);
parameters.setIcon(QIcon(":/wizards/images/console.png")); parameters.setIcon(QIcon(QLatin1String(":/wizards/images/console.png")));
parameters.setDisplayName(tr("Import of Makefile-based Project")); parameters.setDisplayName(tr("Import of Makefile-based Project"));
parameters.setId(QLatin1String("Z.Makefile")); parameters.setId(QLatin1String("Z.Makefile"));
parameters.setDescription(tr("Creates a generic project, supporting any build system.")); parameters.setDescription(tr("Creates a generic project, supporting any build system."));
......
...@@ -603,14 +603,13 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const ...@@ -603,14 +603,13 @@ Qt::ItemFlags BookmarkModel::flags(const QModelIndex &index) const
// #pragma mark -- BookmarkManager // #pragma mark -- BookmarkManager
BookmarkManager::BookmarkManager(QHelpEngineCore* _helpEngine) BookmarkManager::BookmarkManager(QHelpEngineCore* _helpEngine) :
: treeModel(new BookmarkModel(0, 1, this)) m_folderIcon(QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon)),
, listModel(new BookmarkModel(0, 1, this)) m_bookmarkIcon(QLatin1String(":/help/images/bookmark.png")),
, helpEngine(_helpEngine) treeModel(new BookmarkModel(0, 1, this)),
listModel(new BookmarkModel(0, 1, this)),
helpEngine(_helpEngine)
{ {
bookmarkIcon = QIcon(QLatin1String(":/help/images/bookmark.png"));
folderIcon = QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon);
connect(treeModel, SIGNAL(itemChanged(QStandardItem*)), this, connect(treeModel, SIGNAL(itemChanged(QStandardItem*)), this,
SLOT(itemChanged(QStandardItem*))); SLOT(itemChanged(QStandardItem*)));
} }
...@@ -660,7 +659,7 @@ QModelIndex BookmarkManager::addNewFolder(const QModelIndex& index) ...@@ -660,7 +659,7 @@ QModelIndex BookmarkManager::addNewFolder(const QModelIndex& index)
{ {
QStandardItem *item = new QStandardItem(uniqueFolderName()); QStandardItem *item = new QStandardItem(uniqueFolderName());
item->setEditable(false); item->setEditable(false);
item->setIcon(folderIcon); item->setIcon(m_folderIcon);
item->setData(false, Qt::UserRole + 11); item->setData(false, Qt::UserRole + 11);
item->setData(QLatin1String("Folder"), Qt::UserRole + 10); item->setData(QLatin1String("Folder"), Qt::UserRole + 10);
item->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon)); item->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirClosedIcon));
...@@ -716,7 +715,7 @@ void BookmarkManager::addNewBookmark(const QModelIndex& index, ...@@ -716,7 +715,7 @@ void BookmarkManager::addNewBookmark(const QModelIndex& index,
{ {
QStandardItem *item = new QStandardItem(name); QStandardItem *item = new QStandardItem(name);
item->setEditable(false); item->setEditable(false);
item->setIcon(bookmarkIcon); item->setIcon(m_bookmarkIcon);
item->setData(false, Qt::UserRole + 11); item->setData(false, Qt::UserRole + 11);
item->setData(url, Qt::UserRole + 10); item->setData(url, Qt::UserRole + 10);
...@@ -782,10 +781,10 @@ void BookmarkManager::setupBookmarkModels() ...@@ -782,10 +781,10 @@ void BookmarkManager::setupBookmarkModels()
} }
if (type != QLatin1String("Folder")) { if (type != QLatin1String("Folder")) {
item->setIcon(bookmarkIcon); item->setIcon(m_bookmarkIcon);
listModel->appendRow(item->clone()); listModel->appendRow(item->clone());
} else { } else {
item->setIcon(folderIcon); item->setIcon(m_folderIcon);
} }
} }
} }
......
...@@ -182,9 +182,10 @@ private: ...@@ -182,9 +182,10 @@ private:
const qint32 depth) const; const qint32 depth) const;
private: private:
const QIcon m_folderIcon;
const QIcon m_bookmarkIcon;
QString oldText; QString oldText;
QIcon folderIcon;
QIcon bookmarkIcon;
BookmarkModel *treeModel; BookmarkModel *treeModel;
BookmarkModel *listModel; BookmarkModel *listModel;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment