Commit cac7f826 authored by Friedemann Kleint's avatar Friedemann Kleint

Remove static icons, cleanup.

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