forked from qt-creator/qt-creator
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
This commit is contained in:
@@ -80,7 +80,6 @@ OpenEditorsWidget::OpenEditorsWidget()
|
||||
|
||||
OpenEditorsWidget::~OpenEditorsWidget()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
|
||||
|
||||
@@ -314,6 +314,7 @@ void ManhattanStyle::polish(QWidget *widget)
|
||||
if (qobject_cast<QToolButton*>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2);
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
}
|
||||
else if (qobject_cast<QLineEdit*>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
@@ -325,8 +326,10 @@ void ManhattanStyle::polish(QWidget *widget)
|
||||
widget->setMinimumHeight(StyleHelper::navigationWidgetHeight());
|
||||
else if (qobject_cast<QStatusBar*>(widget))
|
||||
widget->setFixedHeight(StyleHelper::navigationWidgetHeight() + 2);
|
||||
else if (qobject_cast<QComboBox*>(widget))
|
||||
else if (qobject_cast<QComboBox*>(widget)) {
|
||||
widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2);
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,6 +341,8 @@ void ManhattanStyle::unpolish(QWidget *widget)
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
else if (qobject_cast<QToolBar*>(widget))
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
else if (qobject_cast<QComboBox*>(widget))
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,15 +522,12 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
}
|
||||
#ifndef Q_WS_MAC
|
||||
else if (option->state & State_Enabled &&
|
||||
option->state & State_MouseOver) {
|
||||
else if (option->state & State_Enabled &&
|
||||
option->state & State_MouseOver) {
|
||||
QColor lighter(255, 255, 255, 35);
|
||||
painter->fillRect(rect, lighter);
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -676,11 +678,11 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
imagePainter.setBrush(option->palette.mid().color());
|
||||
imagePainter.setPen(option->palette.mid().color());
|
||||
} else {
|
||||
QColor shadow(0, 0, 0, 50);
|
||||
QColor shadow(0, 0, 0, 100);
|
||||
imagePainter.translate(0, 1);
|
||||
imagePainter.setPen(shadow);
|
||||
imagePainter.setBrush(shadow);
|
||||
QColor foreGround(255, 255, 255, 220);
|
||||
QColor foreGround(255, 255, 255, 210);
|
||||
imagePainter.drawPolygon(a);
|
||||
imagePainter.translate(0, -1);
|
||||
imagePainter.setPen(foreGround);
|
||||
@@ -1018,17 +1020,21 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
||||
|
||||
// Draw tool button
|
||||
QLinearGradient grad(option->rect.topRight(), option->rect.bottomRight());
|
||||
grad.setColorAt(0, Qt::transparent);
|
||||
grad.setColorAt(0.4, QColor(255, 255, 255, 30));
|
||||
grad.setColorAt(1, Qt::transparent);
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 20));
|
||||
grad.setColorAt(0.4, QColor(255, 255, 255, 60));
|
||||
grad.setColorAt(0.7, QColor(255, 255, 255, 50));
|
||||
grad.setColorAt(1, QColor(255, 255, 255, 40));
|
||||
painter->setPen(QPen(grad, 0));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
grad.setColorAt(0, Qt::transparent);
|
||||
grad.setColorAt(0.4, QColor(0, 0, 0, 30));
|
||||
grad.setColorAt(1, Qt::transparent);
|
||||
grad.setColorAt(0, QColor(0, 0, 0, 20));
|
||||
grad.setColorAt(0.4, QColor(0, 0, 0, 70));
|
||||
grad.setColorAt(0.7, QColor(0, 0, 0, 70));
|
||||
grad.setColorAt(1, QColor(0, 0, 0, 40));
|
||||
painter->setPen(QPen(grad, 0));
|
||||
painter->drawLine(rect.topRight() - QPoint(1,0), rect.bottomRight() - QPoint(1,0));
|
||||
drawPrimitive(PE_PanelButtonTool, option, painter, widget);
|
||||
QStyleOption toolbutton = *option;
|
||||
toolbutton.rect.adjust(0, 0, -2, 0);
|
||||
drawPrimitive(PE_PanelButtonTool, &toolbutton, painter, widget);
|
||||
|
||||
// Draw arrow
|
||||
int menuButtonWidth = 12;
|
||||
@@ -1042,11 +1048,14 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
||||
QStyleOption arrowOpt = *option;
|
||||
arrowOpt.rect = arrowRect;
|
||||
QPalette pal = option->palette;
|
||||
pal.setBrush(QPalette::All, QPalette::ButtonText, StyleHelper::panelTextColor());
|
||||
arrowOpt.palette = pal;
|
||||
|
||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
|
||||
if (styleHint(SH_ComboBox_Popup, option, widget)) {
|
||||
arrowOpt.rect.translate(0, -3);
|
||||
drawPrimitive(PE_IndicatorArrowUp, &arrowOpt, painter, widget);
|
||||
arrowOpt.rect.translate(0, 6);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
} else {
|
||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -593,8 +593,6 @@ Symbol *CPPEditor::findDefinition(Symbol *symbol)
|
||||
{
|
||||
if (symbol->isFunction())
|
||||
return 0; // symbol is a function definition.
|
||||
else if (! symbol->type())
|
||||
return 0;
|
||||
|
||||
Function *funTy = symbol->type()->asFunctionType();
|
||||
if (! funTy)
|
||||
|
||||
@@ -165,6 +165,9 @@ static QString buildHelpId(const FullySpecifiedType &type,
|
||||
}
|
||||
}
|
||||
|
||||
if (! name)
|
||||
return QString();
|
||||
|
||||
Overview overview;
|
||||
overview.setShowArgumentNames(false);
|
||||
overview.setShowReturnTypes(false);
|
||||
|
||||
@@ -200,7 +200,7 @@ FunctionArgumentWidget::FunctionArgumentWidget()
|
||||
setParent(m_popupFrame);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(this);
|
||||
layout->setMargin(0);
|
||||
m_popupFrame->setLayout(layout);
|
||||
@@ -578,8 +578,6 @@ bool CppCodeCompletion::completeFunction(FullySpecifiedType exprTy,
|
||||
QSet<QString> signatures;
|
||||
foreach (TypeOfExpression::Result p, resolvedTypes) {
|
||||
FullySpecifiedType ty = p.first;
|
||||
if (! ty)
|
||||
continue;
|
||||
if (Function *fun = ty->asFunctionType()) {
|
||||
if (TextEditor::CompletionItem item = toCompletionItem(fun)) {
|
||||
QString signature;
|
||||
@@ -602,7 +600,7 @@ bool CppCodeCompletion::completeFunction(FullySpecifiedType exprTy,
|
||||
bool CppCodeCompletion::completeMember(const QList<TypeOfExpression::Result> &results,
|
||||
const LookupContext &context)
|
||||
{
|
||||
if (results.isEmpty() || ! results.first().first)
|
||||
if (results.isEmpty())
|
||||
return false;
|
||||
|
||||
TypeOfExpression::Result result = results.first();
|
||||
@@ -898,10 +896,7 @@ bool CppCodeCompletion::completeConstructors(Class *klass)
|
||||
|
||||
for (unsigned i = 0; i < klass->memberCount(); ++i) {
|
||||
Symbol *member = klass->memberAt(i);
|
||||
FullySpecifiedType memberTy = member->type();
|
||||
if (! memberTy)
|
||||
continue;
|
||||
else if (! memberTy->isFunctionType())
|
||||
if (! member->type()->isFunctionType())
|
||||
continue;
|
||||
else if (! member->identity())
|
||||
continue;
|
||||
@@ -935,12 +930,8 @@ bool CppCodeCompletion::completeQtMethod(CPlusPlus::FullySpecifiedType,
|
||||
QSet<QString> signatures;
|
||||
foreach (TypeOfExpression::Result p, results) {
|
||||
FullySpecifiedType ty = p.first;
|
||||
if (! ty)
|
||||
continue;
|
||||
|
||||
if (ReferenceType *refTy = ty->asReferenceType())
|
||||
ty = refTy->elementType();
|
||||
|
||||
if (PointerType *ptrTy = ty->asPointerType())
|
||||
ty = ptrTy->elementType();
|
||||
else
|
||||
@@ -1125,15 +1116,13 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
|
||||
extraChars += QLatin1Char('(');
|
||||
|
||||
// If the function takes no arguments, automatically place the closing parenthesis
|
||||
if (function->argumentCount() == 0 || (function->argumentCount() == 1 &&
|
||||
function->argumentAt(0)->type() &&
|
||||
if (function->argumentCount() == 0 || (function->argumentCount() == 1 &&
|
||||
function->argumentAt(0)->type()->isVoidType())) {
|
||||
extraChars += QLatin1Char(')');
|
||||
|
||||
// If the function doesn't return anything, automatically place the semicolon,
|
||||
// unless we're doing a scope completion (then it might be function definition).
|
||||
FullySpecifiedType retTy = function->returnType();
|
||||
if (retTy && retTy->isVoidType() && m_completionOperator != T_COLON_COLON) {
|
||||
if (function->returnType()->isVoidType() && m_completionOperator != T_COLON_COLON) {
|
||||
extraChars += QLatin1Char(';');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QMutexLocker>
|
||||
#include <QtCore/QTime>
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace CppTools::Internal;
|
||||
@@ -454,6 +455,12 @@ CppModelManager::CppModelManager(QObject *parent)
|
||||
ProjectExplorer::SessionManager *session = m_projectExplorer->session();
|
||||
QTC_ASSERT(session, return);
|
||||
|
||||
m_updateEditorSelectionsTimer = new QTimer(this);
|
||||
m_updateEditorSelectionsTimer->setInterval(500);
|
||||
m_updateEditorSelectionsTimer->setSingleShot(true);
|
||||
connect(m_updateEditorSelectionsTimer, SIGNAL(timeout()),
|
||||
this, SLOT(updateEditorSelections()));
|
||||
|
||||
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
||||
this, SLOT(onProjectAdded(ProjectExplorer::Project*)));
|
||||
|
||||
@@ -717,8 +724,8 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
|
||||
continue;
|
||||
else if (lines.contains(m.line()))
|
||||
continue;
|
||||
else if (lines.size() == MAX_SELECTION_COUNT)
|
||||
break; // we're done.
|
||||
//else if (lines.size() == MAX_SELECTION_COUNT)
|
||||
//break; // we're done.
|
||||
|
||||
lines.insert(m.line());
|
||||
|
||||
@@ -740,12 +747,42 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
|
||||
sel.cursor = c;
|
||||
selections.append(sel);
|
||||
}
|
||||
ed->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection, selections);
|
||||
|
||||
QList<Editor> todo;
|
||||
foreach (Editor e, todo) {
|
||||
if (e.widget != ed)
|
||||
todo.append(e);
|
||||
}
|
||||
|
||||
Editor e;
|
||||
e.widget = ed;
|
||||
e.selections = selections;
|
||||
todo.append(e);
|
||||
m_todo = todo;
|
||||
postEditorUpdate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CppModelManager::postEditorUpdate()
|
||||
{
|
||||
m_updateEditorSelectionsTimer->start(500);
|
||||
}
|
||||
|
||||
void CppModelManager::updateEditorSelections()
|
||||
{
|
||||
foreach (Editor ed, m_todo) {
|
||||
if (! ed.widget)
|
||||
continue;
|
||||
|
||||
ed.widget->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection,
|
||||
ed.selections);
|
||||
}
|
||||
|
||||
m_todo.clear();
|
||||
}
|
||||
|
||||
void CppModelManager::onProjectAdded(ProjectExplorer::Project *)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include <QMap>
|
||||
#include <QFutureInterface>
|
||||
#include <QMutex>
|
||||
#include <QTimer>
|
||||
#include <QTextEdit>
|
||||
|
||||
namespace Core {
|
||||
class ICore;
|
||||
@@ -49,6 +51,7 @@ class IEditor;
|
||||
|
||||
namespace TextEditor {
|
||||
class ITextEditor;
|
||||
class BaseTextEditor;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -86,6 +89,9 @@ public:
|
||||
|
||||
void emitDocumentUpdated(CPlusPlus::Document::Ptr doc);
|
||||
|
||||
void stopEditorSelectionsUpdate()
|
||||
{ m_updateEditorSelectionsTimer->stop(); }
|
||||
|
||||
Q_SIGNALS:
|
||||
void projectPathChanged(const QString &projectPath);
|
||||
|
||||
@@ -102,6 +108,8 @@ private Q_SLOTS:
|
||||
void onAboutToRemoveProject(ProjectExplorer::Project *project);
|
||||
void onSessionUnloaded();
|
||||
void onProjectAdded(ProjectExplorer::Project *project);
|
||||
void postEditorUpdate();
|
||||
void updateEditorSelections();
|
||||
|
||||
private:
|
||||
QMap<QString, QByteArray> buildWorkingCopyList();
|
||||
@@ -163,6 +171,15 @@ private:
|
||||
enum {
|
||||
MAX_SELECTION_COUNT = 5
|
||||
};
|
||||
|
||||
struct Editor {
|
||||
QPointer<TextEditor::BaseTextEditor> widget;
|
||||
QList<QTextEdit::ExtraSelection> selections;
|
||||
};
|
||||
|
||||
QList<Editor> m_todo;
|
||||
|
||||
QTimer *m_updateEditorSelectionsTimer;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "cppmodelmanager.h"
|
||||
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
@@ -68,12 +69,14 @@ void CppEditorSupport::setTextEditor(TextEditor::ITextEditor *textEditor)
|
||||
updateDocument();
|
||||
}
|
||||
|
||||
QString CppEditorSupport::contents() const
|
||||
QString CppEditorSupport::contents()
|
||||
{
|
||||
if (! _textEditor)
|
||||
return QString();
|
||||
else if (! _cachedContents.isEmpty())
|
||||
_cachedContents = _textEditor->contents();
|
||||
|
||||
return _textEditor->contents();
|
||||
return _cachedContents;
|
||||
}
|
||||
|
||||
int CppEditorSupport::updateDocumentInterval() const
|
||||
@@ -83,7 +86,20 @@ void CppEditorSupport::setUpdateDocumentInterval(int updateDocumentInterval)
|
||||
{ _updateDocumentInterval = updateDocumentInterval; }
|
||||
|
||||
void CppEditorSupport::updateDocument()
|
||||
{ _updateDocumentTimer->start(_updateDocumentInterval); }
|
||||
{
|
||||
if (TextEditor::BaseTextEditor *edit = qobject_cast<TextEditor::BaseTextEditor*>(_textEditor->widget())) {
|
||||
const QList<QTextEdit::ExtraSelection> selections =
|
||||
edit->extraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection);
|
||||
|
||||
if (! selections.isEmpty())
|
||||
edit->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection,
|
||||
QList<QTextEdit::ExtraSelection>());
|
||||
|
||||
_modelManager->stopEditorSelectionsUpdate();
|
||||
}
|
||||
|
||||
_updateDocumentTimer->start(_updateDocumentInterval);
|
||||
}
|
||||
|
||||
void CppEditorSupport::updateDocumentNow()
|
||||
{
|
||||
@@ -91,7 +107,9 @@ void CppEditorSupport::updateDocumentNow()
|
||||
_updateDocumentTimer->start(_updateDocumentInterval);
|
||||
} else {
|
||||
_updateDocumentTimer->stop();
|
||||
|
||||
QStringList sourceFiles(_textEditor->file()->fileName());
|
||||
_cachedContents = _textEditor->contents();
|
||||
_documentParser = _modelManager->refreshSourceFiles(sourceFiles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
int updateDocumentInterval() const;
|
||||
void setUpdateDocumentInterval(int updateDocumentInterval);
|
||||
|
||||
QString contents() const;
|
||||
QString contents();
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateDocument();
|
||||
@@ -79,6 +79,7 @@ private:
|
||||
QTimer *_updateDocumentTimer;
|
||||
int _updateDocumentInterval;
|
||||
QFuture<void> _documentParser;
|
||||
QString _cachedContents;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user