Commit 3761aff8 authored by dt's avatar dt
Browse files

Merge branch '1.1' of git@scm.dev.nokia.troll.no:creator/mainline into 1.1

parents e6779aae 29a620fa
......@@ -77,5 +77,3 @@ Lots of improvements to
Additional credits go to:
* Martin Aumueller <aumuell@reserv.at> (FakeVim improvements)
* Kris Wong (different patches)
//TODO: this refers to commit c6419ff008bbf1afd2dfa4ed18a09de039cccef6
......@@ -47,7 +47,7 @@ public:
virtual ~IOutputPane() {}
virtual QWidget *outputWidget(QWidget *parent) = 0;
virtual QList<QWidget*> toolBarWidgets(void) const = 0;
virtual QList<QWidget*> toolBarWidgets() const = 0;
virtual QString name() const = 0;
// -1 don't show in statusBar
......
......@@ -48,7 +48,7 @@ public:
~MessageOutputWindow();
QWidget *outputWidget(QWidget *parent);
QList<QWidget*> toolBarWidgets(void) const { return QList<QWidget *>(); }
QList<QWidget*> toolBarWidgets() const { return QList<QWidget *>(); }
QString name() const;
int priorityInStatusBar() const;
......
......@@ -1073,20 +1073,6 @@ void CPPEditor::unCommentSelection()
cursor.endEditBlock();
}
int CPPEditor::endOfNameAtPosition(int pos)
{
if (pos == -1)
pos = position();
QChar chr = characterAt(pos);
// Skip to the start of a name
while (chr.isLetterOrNumber() || chr == QLatin1Char('_'))
chr = characterAt(++pos);
return pos;
}
CPPEditor::Link CPPEditor::linkToSymbol(CPlusPlus::Symbol *symbol)
{
const QString fileName = QString::fromUtf8(symbol->fileName(),
......
......@@ -127,8 +127,6 @@ private:
void createToolBar(CPPEditorEditable *editable);
int endOfNameAtPosition(int pos);
struct Link
{
Link(const QString &fileName = QString(),
......
......@@ -46,7 +46,7 @@ public:
DebuggerOutputWindow(QWidget *parent = 0);
QWidget *outputWidget(QWidget *) { return this; }
QList<QWidget*> toolBarWidgets(void) const { return QList<QWidget *>(); }
QList<QWidget*> toolBarWidgets() const { return QList<QWidget *>(); }
QString name() const { return windowTitle(); }
void visibilityChanged(bool /*visible*/) {}
......
......@@ -72,7 +72,7 @@ void SearchResultTreeItemDelegate::paint(QPainter *painter, const QStyleOptionVi
}
int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyleOptionViewItemV3 &option,
const QModelIndex &index) const
const QModelIndex &index) const
{
static const int lineNumberAreaHorizontalPadding = 4;
const bool isSelected = option.state & QStyle::State_Selected;
......@@ -90,10 +90,10 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle
else if (!(option.state & QStyle::State_Enabled))
cg = QPalette::Disabled;
painter->fillRect(lineNumberAreaRect, QBrush(isSelected?
option.palette.brush(cg, QPalette::Highlight):QBrush(qRgb(230, 230, 230))));
painter->setPen(isSelected?
option.palette.color(cg, QPalette::HighlightedText):Qt::darkGray);
painter->fillRect(lineNumberAreaRect, QBrush(isSelected ?
option.palette.brush(cg, QPalette::Highlight) : QBrush(qRgb(230, 230, 230))));
painter->setPen(isSelected ?
option.palette.color(cg, QPalette::HighlightedText) : Qt::darkGray);
painter->drawText(lineNumberAreaRect.adjusted(0, 0, -lineNumberAreaHorizontalPadding, 0),
Qt::AlignRight, QString::number(lineNumber));
......@@ -101,7 +101,7 @@ int SearchResultTreeItemDelegate::drawLineNumber(QPainter *painter, const QStyle
}
void SearchResultTreeItemDelegate::drawMarker(QPainter *painter, const QModelIndex &index, const QString text,
const QRect &rect) const
const QRect &rect) const
{
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
int searchTermStart = index.model()->data(index, ItemDataRoles::SearchTermStartRole).toInt();
......
......@@ -34,7 +34,7 @@ namespace Find {
namespace Internal {
namespace ItemDataRoles {
enum roles
enum Roles
{
TypeRole = Qt::UserRole,
FileNameRole,
......@@ -49,6 +49,6 @@ enum roles
} // namespace Internal
} // namespace Find
} // namespace itemDataRoles
} // namespace ItemDataRoles
#endif // SEARCHRESULTTREEITEMROLES_H
......@@ -31,7 +31,7 @@
using namespace Find::Internal;
SearchResultTreeItem::SearchResultTreeItem(SearchResultTreeItem::itemType type, const SearchResultTreeItem *parent)
SearchResultTreeItem::SearchResultTreeItem(SearchResultTreeItem::ItemType type, const SearchResultTreeItem *parent)
: m_type(type), m_parent(parent)
{
}
......@@ -41,33 +41,33 @@ SearchResultTreeItem::~SearchResultTreeItem()
clearChildren();
}
void SearchResultTreeItem::clearChildren(void)
void SearchResultTreeItem::clearChildren()
{
qDeleteAll(m_children);
m_children.clear();
}
SearchResultTreeItem::itemType SearchResultTreeItem::getItemType(void) const
SearchResultTreeItem::ItemType SearchResultTreeItem::itemType() const
{
return m_type;
}
int SearchResultTreeItem::getChildrenCount(void) const
int SearchResultTreeItem::childrenCount() const
{
return m_children.count();
}
int SearchResultTreeItem::getRowOfItem(void) const
int SearchResultTreeItem::rowOfItem() const
{
return (m_parent?m_parent->m_children.indexOf(const_cast<SearchResultTreeItem*>(this)):0);
return (m_parent ? m_parent->m_children.indexOf(const_cast<SearchResultTreeItem*>(this)):0);
}
const SearchResultTreeItem* SearchResultTreeItem::getChild(int index) const
const SearchResultTreeItem* SearchResultTreeItem::childAt(int index) const
{
return m_children.at(index);
}
const SearchResultTreeItem *SearchResultTreeItem::getParent(void) const
const SearchResultTreeItem *SearchResultTreeItem::parent() const
{
return m_parent;
}
......@@ -78,8 +78,10 @@ void SearchResultTreeItem::appendChild(SearchResultTreeItem *child)
}
SearchResultTextRow::SearchResultTextRow(int index, int lineNumber,
const QString &rowText, int searchTermStart, int searchTermLength, const SearchResultTreeItem *parent)
: SearchResultTreeItem(resultRow, parent),
const QString &rowText,
int searchTermStart, int searchTermLength,
const SearchResultTreeItem *parent):
SearchResultTreeItem(ResultRow, parent),
m_index(index),
m_lineNumber(lineNumber),
m_rowText(rowText),
......@@ -113,12 +115,13 @@ int SearchResultTextRow::searchTermLength() const
return m_searchTermLength;
}
SearchResultFile::SearchResultFile(const QString &fileName, const SearchResultTreeItem *parent)
: SearchResultTreeItem(resultFile, parent), m_fileName(fileName)
SearchResultFile::SearchResultFile(const QString &fileName, const SearchResultTreeItem *parent):
SearchResultTreeItem(ResultFile, parent),
m_fileName(fileName)
{
}
QString SearchResultFile::getFileName(void) const
QString SearchResultFile::fileName() const
{
return m_fileName;
}
......@@ -126,6 +129,7 @@ QString SearchResultFile::getFileName(void) const
void SearchResultFile::appendResultLine(int index, int lineNumber, const QString &rowText, int searchTermStart,
int searchTermLength)
{
SearchResultTreeItem *child = new SearchResultTextRow(index, lineNumber, rowText, searchTermStart, searchTermLength, this);
SearchResultTreeItem *child = new SearchResultTextRow(index, lineNumber, rowText,
searchTermStart, searchTermLength, this);
appendChild(child);
}
......@@ -42,35 +42,35 @@ class SearchResultTreeItem;
class SearchResultTreeItem
{
public:
enum itemType
enum ItemType
{
root,
resultRow,
resultFile
Root,
ResultRow,
ResultFile
};
SearchResultTreeItem(itemType type = root, const SearchResultTreeItem *parent = NULL);
SearchResultTreeItem(ItemType type = Root, const SearchResultTreeItem *parent = NULL);
virtual ~SearchResultTreeItem();
itemType getItemType() const;
const SearchResultTreeItem *getParent() const;
const SearchResultTreeItem *getChild(int index) const;
ItemType itemType() const;
const SearchResultTreeItem *parent() const;
const SearchResultTreeItem *childAt(int index) const;
void appendChild(SearchResultTreeItem *child);
int getChildrenCount() const;
int getRowOfItem() const;
int childrenCount() const;
int rowOfItem() const;
void clearChildren();
private:
itemType m_type;
ItemType m_type;
const SearchResultTreeItem *m_parent;
QList<SearchResultTreeItem *> m_children;
};
class SearchResultTextRow: public SearchResultTreeItem
class SearchResultTextRow : public SearchResultTreeItem
{
public:
SearchResultTextRow(int index, int lineNumber, const QString &rowText, int searchTermStart,
int searchTermLength, const SearchResultTreeItem *parent);
int searchTermLength, const SearchResultTreeItem *parent);
int index() const;
QString rowText() const;
int lineNumber() const;
......@@ -85,13 +85,13 @@ private:
int m_searchTermLength;
};
class SearchResultFile: public SearchResultTreeItem
class SearchResultFile : public SearchResultTreeItem
{
public:
SearchResultFile(const QString &fileName, const SearchResultTreeItem *parent);
QString getFileName() const;
QString fileName() const;
void appendResultLine(int index, int lineNumber, const QString &rowText, int searchTermStart,
int searchTermLength);
int searchTermLength);
private:
QString m_fileName;
......
......@@ -37,9 +37,11 @@
using namespace Find::Internal;
SearchResultTreeModel::SearchResultTreeModel(QObject *parent)
: QAbstractItemModel(parent), m_lastAppendedResultFile(0)
: QAbstractItemModel(parent)
, m_lastAppendedResultFile(0)
{
m_rootItem = new SearchResultTreeItem();
m_textEditorFont = QFont("Courier");
}
SearchResultTreeModel::~SearchResultTreeModel()
......@@ -47,8 +49,13 @@ SearchResultTreeModel::~SearchResultTreeModel()
delete m_rootItem;
}
void SearchResultTreeModel::setTextEditorFont(const QFont &font)
{
m_textEditorFont = font;
}
QModelIndex SearchResultTreeModel::index(int row, int column,
const QModelIndex &parent) const
const QModelIndex &parent) const
{
if (!hasIndex(row, column, parent))
return QModelIndex();
......@@ -60,7 +67,7 @@ QModelIndex SearchResultTreeModel::index(int row, int column,
else
parentItem = static_cast<const SearchResultTreeItem*>(parent.internalPointer());
const SearchResultTreeItem *childItem = parentItem->getChild(row);
const SearchResultTreeItem *childItem = parentItem->childAt(row);
if (childItem)
return createIndex(row, column, (void *)childItem);
else
......@@ -73,12 +80,12 @@ QModelIndex SearchResultTreeModel::parent(const QModelIndex &index) const
return QModelIndex();
const SearchResultTreeItem *childItem = static_cast<const SearchResultTreeItem*>(index.internalPointer());
const SearchResultTreeItem *parentItem = childItem->getParent();
const SearchResultTreeItem *parentItem = childItem->parent();
if (parentItem == m_rootItem)
return QModelIndex();
return createIndex(parentItem->getRowOfItem(), 0, (void *)parentItem);
return createIndex(parentItem->rowOfItem(), 0, (void *)parentItem);
}
int SearchResultTreeModel::rowCount(const QModelIndex &parent) const
......@@ -93,7 +100,7 @@ int SearchResultTreeModel::rowCount(const QModelIndex &parent) const
else
parentItem = static_cast<const SearchResultTreeItem*>(parent.internalPointer());
return parentItem->getChildrenCount();
return parentItem->childrenCount();
}
int SearchResultTreeModel::columnCount(const QModelIndex &parent) const
......@@ -111,12 +118,12 @@ QVariant SearchResultTreeModel::data(const QModelIndex &index, int role) const
QVariant result;
if (item->getItemType() == SearchResultTreeItem::resultRow)
if (item->itemType() == SearchResultTreeItem::ResultRow)
{
const SearchResultTextRow *row = static_cast<const SearchResultTextRow *>(item);
result = data(row, role);
}
else if (item->getItemType() == SearchResultTreeItem::resultFile)
else if (item->itemType() == SearchResultTreeItem::ResultFile)
{
const SearchResultFile *file = static_cast<const SearchResultFile *>(item);
result = data(file, role);
......@@ -135,7 +142,7 @@ QVariant SearchResultTreeModel::data(const SearchResultTextRow *row, int role) c
result = row->rowText().trimmed();
break;
case Qt::FontRole:
result = QFont("courier");
result = m_textEditorFont;
break;
case ItemDataRoles::ResultLineRole:
case Qt::DisplayRole:
......@@ -158,8 +165,8 @@ QVariant SearchResultTreeModel::data(const SearchResultTextRow *row, int role) c
break;
case ItemDataRoles::FileNameRole:
{
const SearchResultFile *file = dynamic_cast<const SearchResultFile *>(row->getParent());
result = file->getFileName();
const SearchResultFile *file = dynamic_cast<const SearchResultFile *>(row->parent());
result = file->fileName();
break;
}
default:
......@@ -179,22 +186,15 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con
case Qt::BackgroundRole:
result = QColor(qRgb(245, 245, 245));
break;
case Qt::FontRole:
{
QFont font;
font.setPointSize(font.pointSize() + 1);
result = font;
break;
}
case Qt::DisplayRole:
result = file->getFileName() + " (" + QString::number(file->getChildrenCount()) + ")";
result = file->fileName() + " (" + QString::number(file->childrenCount()) + ")";
break;
case ItemDataRoles::FileNameRole:
case Qt::ToolTipRole:
result = file->getFileName();
result = file->fileName();
break;
case ItemDataRoles::ResultLinesCountRole:
result = file->getChildrenCount();
result = file->childrenCount();
break;
case ItemDataRoles::TypeRole:
result = "file";
......@@ -220,20 +220,20 @@ void SearchResultTreeModel::appendResultFile(const QString &fileName)
{
m_lastAppendedResultFile = new SearchResultFile(fileName, m_rootItem);
beginInsertRows(QModelIndex(), m_rootItem->getChildrenCount(), m_rootItem->getChildrenCount());
beginInsertRows(QModelIndex(), m_rootItem->childrenCount(), m_rootItem->childrenCount());
m_rootItem->appendChild(m_lastAppendedResultFile);
endInsertRows();
}
void SearchResultTreeModel::appendResultLine(int index, int lineNumber, const QString &rowText, int searchTermStart,
int searchTermLength)
void SearchResultTreeModel::appendResultLine(int index, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength)
{
if (!m_lastAppendedResultFile)
return;
QModelIndex lastFile(createIndex(m_lastAppendedResultFile->getRowOfItem(), 0, m_lastAppendedResultFile));
QModelIndex lastFile(createIndex(m_lastAppendedResultFile->rowOfItem(), 0, m_lastAppendedResultFile));
beginInsertRows(lastFile, m_lastAppendedResultFile->getChildrenCount(), m_lastAppendedResultFile->getChildrenCount());
beginInsertRows(lastFile, m_lastAppendedResultFile->childrenCount(), m_lastAppendedResultFile->childrenCount());
m_lastAppendedResultFile->appendResultLine(index, lineNumber, rowText, searchTermStart, searchTermLength);
endInsertRows();
......@@ -241,15 +241,15 @@ void SearchResultTreeModel::appendResultLine(int index, int lineNumber, const QS
}
void SearchResultTreeModel::appendResultLine(int index, const QString &fileName, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength)
int searchTermStart, int searchTermLength)
{
if (!m_lastAppendedResultFile || (m_lastAppendedResultFile->getFileName() != fileName))
if (!m_lastAppendedResultFile || (m_lastAppendedResultFile->fileName() != fileName))
appendResultFile(fileName);
appendResultLine(index, lineNumber, rowText, searchTermStart, searchTermLength);
}
void SearchResultTreeModel::clear(void)
void SearchResultTreeModel::clear()
{
m_lastAppendedResultFile = NULL;
m_rootItem->clearChildren();
......
......@@ -31,6 +31,7 @@
#define SEARCHRESULTTREEMODEL_H
#include <QtCore/QAbstractItemModel>
#include <QtGui/QFont>
namespace Find {
namespace Internal {
......@@ -47,8 +48,9 @@ public:
SearchResultTreeModel(QObject *parent = 0);
~SearchResultTreeModel();
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
void setTextEditorFont(const QFont &font);
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;
......@@ -57,25 +59,26 @@ public:
signals:
void jumpToSearchResult(const QString &fileName, int lineNumber,
int searchTermStart, int searchTermLength);
int searchTermStart, int searchTermLength);
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
public slots:
void clear();
void appendResultLine(int index, int lineNumber, const QString &rowText, int searchTermStart,
int searchTermLength);
void appendResultLine(int index, const QString &fileName, int lineNumber, const QString &rowText, int searchTermStart,
int searchTermLength);
void appendResultLine(int index, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength);
void appendResultLine(int index, const QString &fileName, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength);
private:
void appendResultFile(const QString &fileName);
QVariant data(const SearchResultTextRow *row, int role) const;
QVariant data(const SearchResultFile *file, int role) const;
void initializeData(void);
void disposeData(void);
void initializeData();
void disposeData();
SearchResultTreeItem *m_rootItem;
SearchResultFile *m_lastAppendedResultFile;
QFont m_textEditorFont;
};
} // namespace Internal
......
......@@ -37,7 +37,8 @@
using namespace Find::Internal;
SearchResultTreeView::SearchResultTreeView(QWidget *parent)
: QTreeView(parent), m_autoExpandResults(false)
: QTreeView(parent)
, m_autoExpandResults(false)
{
m_model = new SearchResultTreeModel(this);
setModel(m_model);
......@@ -46,7 +47,7 @@ SearchResultTreeView::SearchResultTreeView(QWidget *parent)
setIndentation(14);
header()->hide();
connect (this, SIGNAL(activated(QModelIndex)), this, SLOT(emitJumpToSearchResult(QModelIndex)));
connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(emitJumpToSearchResult(QModelIndex)));
}
void SearchResultTreeView::setAutoExpandResults(bool expand)
......@@ -54,13 +55,18 @@ void SearchResultTreeView::setAutoExpandResults(bool expand)
m_autoExpandResults = expand;
}
void SearchResultTreeView::clear(void)
void SearchResultTreeView::setTextEditorFont(const QFont &font)
{
m_model->setTextEditorFont(font);
}
void SearchResultTreeView::clear()
{
m_model->clear();
}
void SearchResultTreeView::appendResultLine(int index, const QString &fileName, int lineNumber, const QString &rowText,
int searchTermStart, int searchTermLength)
int searchTermStart, int searchTermLength)
{
int rowsBefore = m_model->rowCount();
m_model->appendResultLine(index, fileName, lineNumber, rowText, searchTermStart, searchTermLength);
......
......@@ -44,16 +44,18 @@ class SearchResultTreeView : public QTreeView
public:
SearchResultTreeView(QWidget *parent = 0);
void setAutoExpandResults(bool expand);
void setTextEditorFont(const QFont &font);
signals:
void jumpToSearchResult(int index, const QString &fileName, int lineNumber,
int searchTermStart, int searchTermLength);
int searchTermStart, int searchTermLength);
public slots:
void clear();
void appendResultLine(int index, const QString &fileName, int lineNumber, const QString &lineText,
int searchTermStart, int searchTermLength);
int searchTermStart, int searchTermLength);
private slots:
void emitJumpToSearchResult(const QModelIndex &index);
......
......@@ -82,22 +82,6 @@ SearchResultWindow::~SearchResultWindow()
m_items.clear();
}
bool SearchResultWindow::hasFocus()
{
return m_searchResultTreeView->hasFocus();
}
bool SearchResultWindow::canFocus()
{
return !m_items.isEmpty();
}
void SearchResultWindow::setFocus()
{
if (!m_items.isEmpty())
m_searchResultTreeView->setFocus();
}
void SearchResultWindow::visibilityChanged(bool /*visible*/)
{
}
......@@ -107,7 +91,7 @@ QWidget *SearchResultWindow::outputWidget(QWidget *)
return m_widget;
}
QList<QWidget*> SearchResultWindow::toolBarWidgets(void) const
QList<QWidget*> SearchResultWindow::toolBarWidgets() const
{
return QList<QWidget*>() << m_expandCollapseToolButton;
}
......@@ -120,7 +104,7 @@ void SearchResultWindow::clearContents()
m_items.clear();
}
void SearchResultWindow::showNoMatchesFound(void)
void SearchResultWindow::showNoMatchesFound()
{
m_widget->setCurrentWidget(m_noMatchesFoundDisplay);
}
......@@ -135,6 +119,27 @@ int SearchResultWindow::numberOfResults() const
return m_searchResultTreeView->model()->rowCount();
}
bool SearchResultWindow::hasFocus()
{