Commit 3ad22e33 authored by hjk's avatar hjk
Browse files

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

parents da1492cf 0a48bd87
......@@ -88,6 +88,7 @@ void FileWizardPage::setName(const QString &name)
void FileWizardPage::changeEvent(QEvent *e)
{
QWizardPage::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_d->m_ui.retranslateUi(this);
......
......@@ -113,6 +113,7 @@ void ProjectIntroPage::setDescription(const QString &description)
void ProjectIntroPage::changeEvent(QEvent *e)
{
QWizardPage::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_d->m_ui.retranslateUi(this);
......
......@@ -366,6 +366,7 @@ bool SubmitEditorWidget::hasCheckedFiles() const
void SubmitEditorWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_d->m_ui.retranslateUi(this);
......
......@@ -986,6 +986,7 @@ void MainWindow::removeContextObject(IContext *context)
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
if (e->type() == QEvent::ActivationChange) {
if (isActiveWindow()) {
if (debugMainWindow)
......
......@@ -185,6 +185,7 @@ CPPEditor::CPPEditor(QWidget *parent)
{
setParenthesesMatchingEnabled(true);
setMarksVisible(true);
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
baseTextDocument()->setSyntaxHighlighter(new CppHighlighter);
// new QShortcut(QKeySequence("Ctrl+Alt+M"), this, SLOT(foo()), 0, Qt::WidgetShortcut);
......
......@@ -8,7 +8,6 @@ include(../../qworkbenchplugin.pri)
include(cppeditor_dependencies.pri)
HEADERS += cppplugin.h \
cppeditor.h \
cppeditoractionhandler.h \
cpphighlighter.h \
cpphoverhandler.h \
cppfilewizard.h \
......@@ -16,13 +15,10 @@ HEADERS += cppplugin.h \
cppeditorenums.h \
cppeditor_global.h \
cppclasswizard.h
SOURCES += cppplugin.cpp \
cppeditoractionhandler.cpp \
cppeditor.cpp \
cpphighlighter.cpp \
cpphoverhandler.cpp \
cppfilewizard.cpp \
cppclasswizard.cpp
RESOURCES += cppeditor.qrc
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#include "cppeditoractionhandler.h"
#include "cppeditorconstants.h"
#include "cppeditor.h"
#include <QAction>
using namespace CppEditor::Internal;
CPPEditorActionHandler::CPPEditorActionHandler(const QString &context,
uint optionalActions)
: TextEditor::TextEditorActionHandler(context, optionalActions)
{ }
CPPEditorActionHandler::~CPPEditorActionHandler()
{ }
void CPPEditorActionHandler::createActions()
{
TextEditor::TextEditorActionHandler::createActions();
}
void CPPEditorActionHandler::updateActions(UpdateMode um)
{
TextEditor::TextEditorActionHandler::updateActions(um);
}
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
**************************************************************************/
#ifndef CPPEDITORACTIONHANDLER_H
#define CPPEDITORACTIONHANDLER_H
#include <texteditor/texteditoractionhandler.h>
namespace CppEditor {
namespace Internal {
class CPPEditorActionHandler : public TextEditor::TextEditorActionHandler
{
Q_OBJECT
public:
CPPEditorActionHandler(const QString &context,
uint optionalActions = None);
virtual ~CPPEditorActionHandler();
using TextEditor::TextEditorActionHandler::updateActions;
protected:
virtual void createActions();
virtual void updateActions(UpdateMode um);
};
} // namespace Internal
} // namespace CppEditor
#endif // CPPEDITORACTIONHANDLER_H
......@@ -30,7 +30,6 @@
#include "cppplugin.h"
#include "cppclasswizard.h"
#include "cppeditor.h"
#include "cppeditoractionhandler.h"
#include "cppeditorconstants.h"
#include "cppeditorenums.h"
#include "cppfilewizard.h"
......@@ -47,6 +46,8 @@
#include <texteditor/completionsupport.h>
#include <texteditor/fontsettings.h>
#include <texteditor/storagesettings.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/texteditorplugin.h>
#include <texteditor/texteditorsettings.h>
#include <cpptools/cpptoolsconstants.h>
......@@ -60,9 +61,9 @@ static const char *sourceSuffixKeyC = "CppEditor/SourceSuffix";
using namespace CppEditor::Internal;
//////////////////////////// CppPluginEditorFactory /////////////////////////////
//////////////////////////// CppEditorFactory /////////////////////////////
CppPluginEditorFactory::CppPluginEditorFactory(CppPlugin *owner) :
CppEditorFactory::CppEditorFactory(CppPlugin *owner) :
m_kind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND)),
m_owner(owner)
{
......@@ -77,18 +78,18 @@ CppPluginEditorFactory::CppPluginEditorFactory(CppPlugin *owner) :
QLatin1String("h"));
}
QString CppPluginEditorFactory::kind() const
QString CppEditorFactory::kind() const
{
return m_kind;
}
Core::IFile *CppPluginEditorFactory::open(const QString &fileName)
Core::IFile *CppEditorFactory::open(const QString &fileName)
{
Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, kind());
return iface ? iface->file() : 0;
}
Core::IEditor *CppPluginEditorFactory::createEditor(QWidget *parent)
Core::IEditor *CppEditorFactory::createEditor(QWidget *parent)
{
CPPEditor *editor = new CPPEditor(parent);
editor->setRevisionsVisible(true);
......@@ -97,7 +98,7 @@ Core::IEditor *CppPluginEditorFactory::createEditor(QWidget *parent)
return editor->editableInterface();
}
QStringList CppPluginEditorFactory::mimeTypes() const
QStringList CppEditorFactory::mimeTypes() const
{
return m_mimeTypes;
}
......@@ -128,25 +129,9 @@ CppPlugin *CppPlugin::instance()
void CppPlugin::initializeEditor(CPPEditor *editor)
{
// common actions
m_actionHandler->setupActions(editor);
// settings
TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
editor, SLOT(setFontSettings(TextEditor::FontSettings)));
connect(settings, SIGNAL(tabSettingsChanged(TextEditor::TabSettings)),
editor, SLOT(setTabSettings(TextEditor::TabSettings)));
connect(settings, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
editor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
connect(settings, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)),
editor, SLOT(setDisplaySettings(TextEditor::DisplaySettings)));
// tab settings rely on font settings
editor->setFontSettings(settings->fontSettings());
editor->setTabSettings(settings->tabSettings());
editor->setStorageSettings(settings->storageSettings());
editor->setDisplaySettings(settings->displaySettings());
TextEditor::TextEditorSettings::instance()->initializeEditor(editor);
// auto completion
connect(editor, SIGNAL(requestAutoCompletion(ITextEditable*, bool)),
......@@ -159,7 +144,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/cppeditor/CppEditor.mimetypes.xml"), errorMessage))
return false;
m_factory = new CppPluginEditorFactory(this);
m_factory = new CppEditorFactory(this);
addObject(m_factory);
addAutoReleasedObject(new CppHoverHandler);
......@@ -207,7 +192,7 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
am->actionContainer(CppEditor::Constants::M_CONTEXT)->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
m_actionHandler = new CPPEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
m_actionHandler = new TextEditor::TextEditorActionHandler(CppEditor::Constants::C_CPPEDITOR,
TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll);
......
......@@ -44,8 +44,7 @@ namespace CppEditor {
namespace Internal {
class CPPEditor;
class CPPEditorActionHandler;
class CppPluginEditorFactory;
class CppEditorFactory;
class CppPlugin : public ExtensionSystem::IPlugin
{
......@@ -68,21 +67,21 @@ private slots:
void jumpToDefinition();
private:
friend class CppPluginEditorFactory;
friend class CppEditorFactory;
Core::IEditor *createEditor(QWidget *parent);
static CppPlugin *m_instance;
CPPEditorActionHandler *m_actionHandler;
CppPluginEditorFactory *m_factory;
TextEditor::TextEditorActionHandler *m_actionHandler;
CppEditorFactory *m_factory;
};
class CppPluginEditorFactory : public Core::IEditorFactory
class CppEditorFactory : public Core::IEditorFactory
{
Q_OBJECT
public:
CppPluginEditorFactory(CppPlugin *owner);
CppEditorFactory(CppPlugin *owner);
virtual QStringList mimeTypes() const;
......
......@@ -39,7 +39,7 @@ Manager *ProjectFilesFactory::manager() const
Core::IEditor *ProjectFilesFactory::createEditor(QWidget *parent)
{
ProjectFilesEditor *ed = new ProjectFilesEditor(parent, this, _actionHandler);
ed->initialize();
TextEditor::TextEditorSettings::instance()->initializeEditor(ed);
return ed->editableInterface();
}
......@@ -98,7 +98,7 @@ Core::IEditor *ProjectFilesEditable::duplicate(QWidget *parent)
ProjectFilesEditor *editor = new ProjectFilesEditor(parent,
parentEditor->factory(),
parentEditor->actionHandler());
editor->initialize();
TextEditor::TextEditorSettings::instance()->initializeEditor(editor);
return editor->editableInterface();
}
......@@ -122,16 +122,6 @@ ProjectFilesEditor::ProjectFilesEditor(QWidget *parent, ProjectFilesFactory *fac
ProjectFilesEditor::~ProjectFilesEditor()
{ }
void ProjectFilesEditor::initialize()
{
TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
connect(settings, SIGNAL(fontSettingsChanged(const TextEditor::FontSettings&)),
this, SLOT(setFontSettings(const TextEditor::FontSettings&)));
setFontSettings(settings->fontSettings());
}
ProjectFilesFactory *ProjectFilesEditor::factory() const
{
return _factory;
......
......@@ -64,8 +64,6 @@ public:
TextEditor::TextEditorActionHandler *handler);
virtual ~ProjectFilesEditor();
void initialize();
ProjectFilesFactory *factory() const;
TextEditor::TextEditorActionHandler *actionHandler() const;
......
......@@ -258,6 +258,7 @@ void BranchDialog::slotRemoteBranchActivated(const QModelIndex &i)
void BranchDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
......
......@@ -3,64 +3,68 @@
#include <QtGui/QDialog>
QT_BEGIN_NAMESPACE
class QPushButton;
class QModelIndex;
QT_END_NAMESPACE
namespace Git {
namespace Internal {
namespace Ui {
class BranchDialog;
}
class GitClient;
class LocalBranchModel;
class RemoteBranchModel;
/* Branch dialog: Display a list of local branches at the top
* and remote branches below. Offers to checkout/delete local
* branches.
* TODO: Add new branch (optionally tracking a remote one).
* How to find out that a local branch is a tracking one? */
class BranchDialog : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(BranchDialog)
public:
explicit BranchDialog(QWidget *parent = 0);
bool init(GitClient *client, const QString &workingDirectory, QString *errorMessage);
virtual ~BranchDialog();
protected:
virtual void changeEvent(QEvent *e);
private slots:
void slotEnableButtons();
void slotCheckoutSelectedBranch();
void slotDeleteSelectedBranch();
void slotLocalBranchActivated();
void slotRemoteBranchActivated(const QModelIndex &);
void slotCreateLocalBranch(const QString &branchName);
private:
bool ask(const QString &title, const QString &what, bool defaultButton);
void selectLocalBranch(const QString &b);
int selectedLocalBranchIndex() const;
int selectedRemoteBranchIndex() const;
GitClient *m_client;
Ui::BranchDialog *m_ui;
QPushButton *m_checkoutButton;
QPushButton *m_deleteButton;
LocalBranchModel *m_localModel;
RemoteBranchModel *m_remoteModel;
QString m_repoDirectory;
};
} // namespace Internal
namespace Internal {
namespace Ui {
class BranchDialog;
}
class GitClient;
class LocalBranchModel;
class RemoteBranchModel;
/**
* Branch dialog. Displays a list of local branches at the top and remote
* branches below. Offers to checkout/delete local branches.
*
* TODO: Add new branch (optionally tracking a remote one).
* How to find out that a local branch is a tracking one?
*/
class BranchDialog : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(BranchDialog)
public:
explicit BranchDialog(QWidget *parent = 0);
bool init(GitClient *client, const QString &workingDirectory, QString *errorMessage);
virtual ~BranchDialog();
protected:
virtual void changeEvent(QEvent *e);
private slots:
void slotEnableButtons();
void slotCheckoutSelectedBranch();
void slotDeleteSelectedBranch();
void slotLocalBranchActivated();
void slotRemoteBranchActivated(const QModelIndex &);
void slotCreateLocalBranch(const QString &branchName);
private:
bool ask(const QString &title, const QString &what, bool defaultButton);
void selectLocalBranch(const QString &b);
int selectedLocalBranchIndex() const;
int selectedRemoteBranchIndex() const;
GitClient *m_client;
Ui::BranchDialog *m_ui;
QPushButton *m_checkoutButton;
QPushButton *m_deleteButton;
LocalBranchModel *m_localModel;
RemoteBranchModel *m_remoteModel;
QString m_repoDirectory;
};
} // namespace Internal
} // namespace Git
#endif // BRANCHDIALOG_H
......@@ -78,3 +78,67 @@ bool HelpFindSupport::findStep(const QString &txt, QTextDocument::FindFlags find
QTC_ASSERT(m_centralWidget, return false);
return m_centralWidget->find(txt, findFlags, false);
}
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
: m_viewer(viewer)
{
}
QString HelpViewerFindSupport::currentFindString() const
{
QTC_ASSERT(m_viewer, return QString());
return m_viewer->selectedText();
}
bool HelpViewerFindSupport::findIncremental(const QString &txt, QTextDocument::FindFlags findFlags)
{
QTC_ASSERT(m_viewer, return false);
findFlags &= ~QTextDocument::FindBackward;
return find(txt, findFlags, true);
}
bool HelpViewerFindSupport::findStep(const QString &txt, QTextDocument::FindFlags findFlags)
{
QTC_ASSERT(m_viewer, return false);
return find(txt, findFlags, false);
}
bool HelpViewerFindSupport::find(const QString &txt, QTextDocument::FindFlags findFlags, bool incremental)
{
QTC_ASSERT(m_viewer, return false);
#if !defined(QT_NO_WEBKIT)
Q_UNUSED(incremental);
QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
if (findFlags & QTextDocument::FindBackward)
options |= QWebPage::FindBackward;
if (findFlags & QTextDocument::FindCaseSensitively)
options |= QWebPage::FindCaseSensitively;
return m_viewer->findText(txt, options);
#else
QTextCursor cursor = viewer->textCursor();
QTextDocument *doc = viewer->document();
QTextBrowser *browser = qobject_cast<QTextBrowser*>(viewer);
if (!browser || !doc || cursor.isNull())
return false;
if (incremental)
cursor.setPosition(cursor.selectionStart());
QTextCursor found = doc->find(txt, cursor, findFlags);
if (found.isNull()) {
if ((findFlags&QTextDocument::FindBackward) == 0)
cursor.movePosition(QTextCursor::Start);
else
cursor.movePosition(QTextCursor::End);
found = doc->find(txt, cursor, findFlags);
if (found.isNull()) {
return false;
}
}
if (!found.isNull()) {
viewer->setTextCursor(found);
}
return true;
#endif
}
......@@ -34,6 +34,10 @@
#include <find/ifindsupport.h>
QT_BEGIN_NAMESPACE
class HelpViewer;
QT_END_NAMESPACE
namespace Help {
namespace Internal {
......@@ -65,6 +69,31 @@ private:
CentralWidget *m_centralWidget;
};
class HelpViewerFindSupport : public Find::IFindSupport
{
Q_OBJECT
public:
HelpViewerFindSupport(HelpViewer *viewer);
bool isEnabled() const { return true; }
bool supportsReplace() const { return false; }
void resetIncrementalSearch() {}
void clearResults() {}
QString currentFindString() const;
QString completedFindString() const { return QString(); }
bool findIncremental(const QString &txt, QTextDocument::FindFlags findFlags);
bool findStep(const QString &txt, QTextDocument::FindFlags findFlags);
bool replaceStep(const QString &, const QString &,
QTextDocument::FindFlags ) { return false; }
int replaceAll(const QString &, const QString &,
QTextDocument::FindFlags ) { return 0; }
private:
bool find(const QString &ttf, QTextDocument::FindFlags findFlags, bool incremental);
HelpViewer *m_viewer;
};
} // namespace Internal
} // namespace Help
......
......@@ -373,6 +373,9 @@ void HelpPlugin::createRightPaneSideBar()
rightPaneLayout->addWidget(rightPaneToolBar);
m_helpViewerForSideBar = new HelpViewer(m_helpEngine, 0);