forked from qt-creator/qt-creator
Header cleaning mainly in find/cpaster.
This commit is contained in:
@@ -38,6 +38,9 @@
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/messageoutputwindow.h>
|
||||
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
using namespace CodePaster;
|
||||
using namespace Core;
|
||||
|
||||
|
||||
@@ -32,10 +32,13 @@
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
#include <QtGui/QListWidget>
|
||||
#include <QtNetwork/QHttp>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QListWidget;
|
||||
class QNetworkReply;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CodePaster {
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <QtGui/QGroupBox>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
|
||||
@@ -30,14 +30,8 @@
|
||||
#ifndef CODEPASTERSETTINGSPAGE_H
|
||||
#define CODEPASTERSETTINGSPAGE_H
|
||||
|
||||
#include "ui_settingspage.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -36,16 +36,15 @@
|
||||
#include "codepasterprotocol.h"
|
||||
#include "pastebindotcomprotocol.h"
|
||||
#include "pastebindotcaprotocol.h"
|
||||
#include "settingspage.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/messageoutputwindow.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <texteditor/itexteditor.h>
|
||||
|
||||
@@ -55,9 +54,7 @@
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QListWidget>
|
||||
|
||||
using namespace CodePaster;
|
||||
using namespace Core;
|
||||
|
||||
@@ -30,22 +30,18 @@
|
||||
#ifndef CODEPASTERPLUGIN_H
|
||||
#define CODEPASTERPLUGIN_H
|
||||
|
||||
#include "settingspage.h"
|
||||
#include "protocol.h"
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
#include <coreplugin/icorelistener.h>
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QListWidget;
|
||||
class QAction;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CodePaster {
|
||||
class Protocol;
|
||||
|
||||
namespace CodePaster {
|
||||
class SettingsPage;
|
||||
class CustomFetcher;
|
||||
class CustomPoster;
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "pastebindotcaprotocol.h"
|
||||
#include "cgi.h"
|
||||
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
PasteBinDotCaProtocol::PasteBinDotCaProtocol()
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "protocol.h"
|
||||
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtNetwork/QHttp>
|
||||
|
||||
class PasteBinDotCaProtocol : public Protocol
|
||||
|
||||
@@ -29,16 +29,10 @@
|
||||
|
||||
#include "pastebindotcomprotocol.h"
|
||||
#include "pastebindotcomsettings.h"
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/messageoutputwindow.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtNetwork/QHttp>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "protocol.h"
|
||||
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QtNetwork/QHttp>
|
||||
|
||||
class PasteBinDotComSettings;
|
||||
|
||||
@@ -29,11 +29,12 @@
|
||||
|
||||
#include "pasteview.h"
|
||||
|
||||
#include <QFontMetrics>
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QScrollBar>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QByteArray>
|
||||
|
||||
class ColumnIndicatorTextEdit : public QTextEdit
|
||||
{
|
||||
|
||||
@@ -30,17 +30,16 @@
|
||||
#ifndef PASTEVIEW_H
|
||||
#define PASTEVIEW_H
|
||||
|
||||
#include "splitter.h"
|
||||
#include "ui_pasteview.h"
|
||||
#include "splitter.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QByteArray>
|
||||
#include <QtGui/QDialog>
|
||||
|
||||
class PasteView : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PasteView(QWidget *parent);
|
||||
explicit PasteView(QWidget *parent);
|
||||
~PasteView();
|
||||
|
||||
int show(const QString &user, const QString &description, const QString &comment,
|
||||
|
||||
@@ -30,13 +30,8 @@
|
||||
#ifndef PROTOCOL_H
|
||||
#define PROTOCOL_H
|
||||
|
||||
#include "settingspage.h"
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QListWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
|
||||
@@ -739,11 +739,11 @@ void FakeVimPluginPrivate::windowCommand(int key)
|
||||
|
||||
void FakeVimPluginPrivate::find(bool reverse)
|
||||
{
|
||||
if (Find::Internal::FindPlugin *plugin = Find::Internal::FindPlugin::instance()) {
|
||||
if (Find::FindPlugin *plugin = Find::FindPlugin::instance()) {
|
||||
plugin->setUseFakeVim(true);
|
||||
plugin->openFindToolBar(reverse
|
||||
? Find::Internal::FindPlugin::FindBackward
|
||||
: Find::Internal::FindPlugin::FindForward);
|
||||
? Find::FindPlugin::FindBackward
|
||||
: Find::FindPlugin::FindForward);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,8 +847,8 @@ void FakeVimPluginPrivate::setUseFakeVim(const QVariant &value)
|
||||
{
|
||||
//qDebug() << "SET USE FAKEVIM" << value;
|
||||
bool on = value.toBool();
|
||||
if (Find::Internal::FindPlugin::instance())
|
||||
Find::Internal::FindPlugin::instance()->setUseFakeVim(on);
|
||||
if (Find::FindPlugin::instance())
|
||||
Find::FindPlugin::instance()->setUseFakeVim(on);
|
||||
if (on) {
|
||||
Core::EditorManager::instance()->showEditorStatusBar(
|
||||
QLatin1String(Constants::MINI_BUFFER),
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Find;
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "ifindsupport.h"
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
namespace Find {
|
||||
namespace Internal {
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "findtoolbar.h"
|
||||
#include "findtoolwindow.h"
|
||||
#include "searchresultwindow.h"
|
||||
#include "ifindfilter.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -46,6 +47,8 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QStringListModel>
|
||||
#include <QtGui/QAction>
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtCore/QSettings>
|
||||
@@ -70,43 +73,64 @@ namespace {
|
||||
const int MAX_COMPLETIONS = 50;
|
||||
}
|
||||
|
||||
using namespace Find;
|
||||
using namespace Find::Internal;
|
||||
namespace Find {
|
||||
|
||||
FindPlugin *FindPlugin::m_instance = 0;
|
||||
struct FindPluginPrivate {
|
||||
explicit FindPluginPrivate(FindPlugin *q);
|
||||
|
||||
FindPlugin::FindPlugin()
|
||||
: m_currentDocumentFind(0),
|
||||
m_findToolBar(0),
|
||||
m_findDialog(0),
|
||||
m_findCompletionModel(new QStringListModel(this)),
|
||||
m_replaceCompletionModel(new QStringListModel(this))
|
||||
//variables
|
||||
static FindPlugin *m_instance;
|
||||
|
||||
QHash<IFindFilter *, QAction *> m_filterActions;
|
||||
|
||||
Internal::CurrentDocumentFind *m_currentDocumentFind;
|
||||
Internal::FindToolBar *m_findToolBar;
|
||||
Internal::FindToolWindow *m_findDialog;
|
||||
QTextDocument::FindFlags m_findFlags;
|
||||
QStringListModel *m_findCompletionModel;
|
||||
QStringListModel *m_replaceCompletionModel;
|
||||
QStringList m_findCompletions;
|
||||
QStringList m_replaceCompletions;
|
||||
QAction *m_openFindDialog;
|
||||
};
|
||||
|
||||
FindPluginPrivate::FindPluginPrivate(FindPlugin *q) :
|
||||
m_currentDocumentFind(0), m_findToolBar(0), m_findDialog(0),
|
||||
m_findCompletionModel(new QStringListModel(q)),
|
||||
m_replaceCompletionModel(new QStringListModel(q))
|
||||
{
|
||||
QTC_ASSERT(!m_instance, return);
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
FindPlugin *FindPluginPrivate::m_instance = 0;
|
||||
|
||||
FindPlugin::FindPlugin() : d(new FindPluginPrivate(this))
|
||||
{
|
||||
QTC_ASSERT(!FindPluginPrivate::m_instance, return);
|
||||
FindPluginPrivate::m_instance = this;
|
||||
}
|
||||
|
||||
FindPlugin::~FindPlugin()
|
||||
{
|
||||
m_instance = 0;
|
||||
delete m_currentDocumentFind;
|
||||
delete m_findToolBar;
|
||||
delete m_findDialog;
|
||||
FindPluginPrivate::m_instance = 0;
|
||||
delete d->m_currentDocumentFind;
|
||||
delete d->m_findToolBar;
|
||||
delete d->m_findDialog;
|
||||
delete d;
|
||||
}
|
||||
|
||||
FindPlugin *FindPlugin::instance()
|
||||
{
|
||||
return m_instance;
|
||||
return FindPluginPrivate::m_instance;
|
||||
}
|
||||
|
||||
bool FindPlugin::initialize(const QStringList &, QString *)
|
||||
{
|
||||
setupMenu();
|
||||
|
||||
m_currentDocumentFind = new CurrentDocumentFind;
|
||||
d->m_currentDocumentFind = new Internal::CurrentDocumentFind;
|
||||
|
||||
m_findToolBar = new FindToolBar(this, m_currentDocumentFind);
|
||||
m_findDialog = new FindToolWindow(this);
|
||||
d->m_findToolBar = new Internal::FindToolBar(this, d->m_currentDocumentFind);
|
||||
d->m_findDialog = new Internal::FindToolWindow(this);
|
||||
SearchResultWindow *searchResultWindow = new SearchResultWindow;
|
||||
addAutoReleasedObject(searchResultWindow);
|
||||
return true;
|
||||
@@ -120,27 +144,27 @@ void FindPlugin::extensionsInitialized()
|
||||
|
||||
void FindPlugin::shutdown()
|
||||
{
|
||||
m_findToolBar->setVisible(false);
|
||||
m_findToolBar->setParent(0);
|
||||
m_currentDocumentFind->removeConnections();
|
||||
d->m_findToolBar->setVisible(false);
|
||||
d->m_findToolBar->setParent(0);
|
||||
d->m_currentDocumentFind->removeConnections();
|
||||
writeSettings();
|
||||
}
|
||||
|
||||
void FindPlugin::filterChanged()
|
||||
{
|
||||
IFindFilter *changedFilter = qobject_cast<IFindFilter *>(sender());
|
||||
QAction *action = m_filterActions.value(changedFilter);
|
||||
QAction *action = d->m_filterActions.value(changedFilter);
|
||||
QTC_ASSERT(changedFilter, return);
|
||||
QTC_ASSERT(action, return);
|
||||
action->setEnabled(changedFilter->isEnabled());
|
||||
bool haveEnabledFilters = false;
|
||||
foreach (IFindFilter *filter, m_filterActions.keys()) {
|
||||
foreach (IFindFilter *filter, d->m_filterActions.keys()) {
|
||||
if (filter->isEnabled()) {
|
||||
haveEnabledFilters = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||
}
|
||||
|
||||
void FindPlugin::openFindFilter()
|
||||
@@ -148,12 +172,12 @@ void FindPlugin::openFindFilter()
|
||||
QAction *action = qobject_cast<QAction*>(sender());
|
||||
QTC_ASSERT(action, return);
|
||||
IFindFilter *filter = action->data().value<IFindFilter *>();
|
||||
if (m_currentDocumentFind->candidateIsEnabled())
|
||||
m_currentDocumentFind->acceptCandidate();
|
||||
QString currentFindString = (m_currentDocumentFind->isEnabled() ? m_currentDocumentFind->currentFindString() : "");
|
||||
if (d->m_currentDocumentFind->candidateIsEnabled())
|
||||
d->m_currentDocumentFind->acceptCandidate();
|
||||
QString currentFindString = (d->m_currentDocumentFind->isEnabled() ? d->m_currentDocumentFind->currentFindString() : "");
|
||||
if (!currentFindString.isEmpty())
|
||||
m_findDialog->setFindText(currentFindString);
|
||||
m_findDialog->open(filter);
|
||||
d->m_findDialog->setFindText(currentFindString);
|
||||
d->m_findDialog->open(filter);
|
||||
}
|
||||
|
||||
void FindPlugin::setupMenu()
|
||||
@@ -182,11 +206,11 @@ void FindPlugin::setupMenu()
|
||||
Core::ActionContainer *mfindadvanced = am->createMenu(Constants::M_FIND_ADVANCED);
|
||||
mfindadvanced->menu()->setTitle(tr("Advanced Find"));
|
||||
mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS);
|
||||
m_openFindDialog = new QAction(tr("Open Advanced Find..."), this);
|
||||
cmd = am->registerAction(m_openFindDialog, QLatin1String("Find.Dialog"), globalcontext);
|
||||
d->m_openFindDialog = new QAction(tr("Open Advanced Find..."), this);
|
||||
cmd = am->registerAction(d->m_openFindDialog, QLatin1String("Find.Dialog"), globalcontext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F")));
|
||||
mfindadvanced->addAction(cmd);
|
||||
connect(m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter()));
|
||||
connect(d->m_openFindDialog, SIGNAL(triggered()), this, SLOT(openFindFilter()));
|
||||
}
|
||||
|
||||
void FindPlugin::setupFilterMenuItems()
|
||||
@@ -198,10 +222,10 @@ void FindPlugin::setupFilterMenuItems()
|
||||
QList<int> globalcontext = QList<int>() << Core::Constants::C_GLOBAL_ID;
|
||||
|
||||
Core::ActionContainer *mfindadvanced = am->actionContainer(Constants::M_FIND_ADVANCED);
|
||||
m_filterActions.clear();
|
||||
d->m_filterActions.clear();
|
||||
bool haveEnabledFilters = false;
|
||||
foreach (IFindFilter *filter, findInterfaces) {
|
||||
QAction *action = new QAction(QString(" %1").arg(filter->name()), this);
|
||||
QAction *action = new QAction(QLatin1String(" ") + filter->name(), this);
|
||||
bool isEnabled = filter->isEnabled();
|
||||
if (isEnabled)
|
||||
haveEnabledFilters = true;
|
||||
@@ -210,17 +234,17 @@ void FindPlugin::setupFilterMenuItems()
|
||||
cmd = am->registerAction(action, QLatin1String("FindFilter.")+filter->id(), globalcontext);
|
||||
cmd->setDefaultKeySequence(filter->defaultShortcut());
|
||||
mfindadvanced->addAction(cmd);
|
||||
m_filterActions.insert(filter, action);
|
||||
d->m_filterActions.insert(filter, action);
|
||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(openFindFilter()));
|
||||
connect(filter, SIGNAL(changed()), this, SLOT(filterChanged()));
|
||||
}
|
||||
m_findDialog->setFindFilters(findInterfaces);
|
||||
m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||
d->m_findDialog->setFindFilters(findInterfaces);
|
||||
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||
}
|
||||
|
||||
QTextDocument::FindFlags FindPlugin::findFlags() const
|
||||
{
|
||||
return m_findFlags;
|
||||
return d->m_findFlags;
|
||||
}
|
||||
|
||||
void FindPlugin::setCaseSensitive(bool sensitive)
|
||||
@@ -244,30 +268,30 @@ void FindPlugin::setFindFlag(QTextDocument::FindFlag flag, bool enabled)
|
||||
if ((hasFlag && enabled) || (!hasFlag && !enabled))
|
||||
return;
|
||||
if (enabled)
|
||||
m_findFlags |= flag;
|
||||
d->m_findFlags |= flag;
|
||||
else
|
||||
m_findFlags &= ~flag;
|
||||
d->m_findFlags &= ~flag;
|
||||
if (flag != QTextDocument::FindBackward)
|
||||
emit findFlagsChanged();
|
||||
}
|
||||
|
||||
bool FindPlugin::hasFindFlag(QTextDocument::FindFlag flag)
|
||||
{
|
||||
return m_findFlags & flag;
|
||||
return d->m_findFlags & flag;
|
||||
}
|
||||
|
||||
void FindPlugin::writeSettings()
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("Find");
|
||||
settings->setValue("Backward", QVariant((m_findFlags & QTextDocument::FindBackward) != 0));
|
||||
settings->setValue("CaseSensitively", QVariant((m_findFlags & QTextDocument::FindCaseSensitively) != 0));
|
||||
settings->setValue("WholeWords", QVariant((m_findFlags & QTextDocument::FindWholeWords) != 0));
|
||||
settings->setValue("FindStrings", m_findCompletions);
|
||||
settings->setValue("ReplaceStrings", m_replaceCompletions);
|
||||
settings->setValue("Backward", QVariant((d->m_findFlags & QTextDocument::FindBackward) != 0));
|
||||
settings->setValue("CaseSensitively", QVariant((d->m_findFlags & QTextDocument::FindCaseSensitively) != 0));
|
||||
settings->setValue("WholeWords", QVariant((d->m_findFlags & QTextDocument::FindWholeWords) != 0));
|
||||
settings->setValue("FindStrings", d->m_findCompletions);
|
||||
settings->setValue("ReplaceStrings", d->m_replaceCompletions);
|
||||
settings->endGroup();
|
||||
m_findToolBar->writeSettings();
|
||||
m_findDialog->writeSettings();
|
||||
d->m_findToolBar->writeSettings();
|
||||
d->m_findDialog->writeSettings();
|
||||
}
|
||||
|
||||
void FindPlugin::readSettings()
|
||||
@@ -279,24 +303,24 @@ void FindPlugin::readSettings()
|
||||
setCaseSensitive(settings->value("CaseSensitively", false).toBool());
|
||||
setWholeWord(settings->value("WholeWords", false).toBool());
|
||||
blockSignals(block);
|
||||
m_findCompletions = settings->value("FindStrings").toStringList();
|
||||
m_replaceCompletions = settings->value("ReplaceStrings").toStringList();
|
||||
m_findCompletionModel->setStringList(m_findCompletions);
|
||||
m_replaceCompletionModel->setStringList(m_replaceCompletions);
|
||||
d->m_findCompletions = settings->value("FindStrings").toStringList();
|
||||
d->m_replaceCompletions = settings->value("ReplaceStrings").toStringList();
|
||||
d->m_findCompletionModel->setStringList(d->m_findCompletions);
|
||||
d->m_replaceCompletionModel->setStringList(d->m_replaceCompletions);
|
||||
settings->endGroup();
|
||||
m_findToolBar->readSettings();
|
||||
m_findDialog->readSettings();
|
||||
d->m_findToolBar->readSettings();
|
||||
d->m_findDialog->readSettings();
|
||||
emit findFlagsChanged(); // would have been done in the setXXX methods above
|
||||
}
|
||||
|
||||
void FindPlugin::updateFindCompletion(const QString &text)
|
||||
{
|
||||
updateCompletion(text, m_findCompletions, m_findCompletionModel);
|
||||
updateCompletion(text, d->m_findCompletions, d->m_findCompletionModel);
|
||||
}
|
||||
|
||||
void FindPlugin::updateReplaceCompletion(const QString &text)
|
||||
{
|
||||
updateCompletion(text, m_replaceCompletions, m_replaceCompletionModel);
|
||||
updateCompletion(text, d->m_replaceCompletions, d->m_replaceCompletionModel);
|
||||
}
|
||||
|
||||
void FindPlugin::updateCompletion(const QString &text, QStringList &completions, QStringListModel *model)
|
||||
@@ -312,16 +336,29 @@ void FindPlugin::updateCompletion(const QString &text, QStringList &completions,
|
||||
|
||||
void FindPlugin::setUseFakeVim(bool on)
|
||||
{
|
||||
if (m_findToolBar)
|
||||
m_findToolBar->setUseFakeVim(on);
|
||||
if (d->m_findToolBar)
|
||||
d->m_findToolBar->setUseFakeVim(on);
|
||||
}
|
||||
|
||||
void FindPlugin::openFindToolBar(FindDirection direction)
|
||||
{
|
||||
if (m_findToolBar) {
|
||||
m_findToolBar->setBackward(direction == FindBackward);
|
||||
m_findToolBar->openFindToolBar();
|
||||
if (d->m_findToolBar) {
|
||||
d->m_findToolBar->setBackward(direction == FindBackward);
|
||||
d->m_findToolBar->openFindToolBar();
|
||||
}
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(FindPlugin)
|
||||
QStringListModel *FindPlugin::findCompletionModel() const
|
||||
{
|
||||
return d->m_findCompletionModel;
|
||||
}
|
||||
|
||||
QStringListModel *FindPlugin::replaceCompletionModel() const
|
||||
{
|
||||
return d->m_replaceCompletionModel;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Find
|
||||
|
||||
Q_EXPORT_PLUGIN(Find::FindPlugin)
|
||||
|
||||
@@ -30,22 +30,25 @@
|
||||
#ifndef FINDPLUGIN_H
|
||||
#define FINDPLUGIN_H
|
||||
|
||||
#include "ifindfilter.h"
|
||||
#include "find_global.h"
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QTextDocument>
|
||||
#include <QtGui/QStringListModel>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QStringListModel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Find {
|
||||
namespace Internal {
|
||||
class IFindFilter;
|
||||
struct FindPluginPrivate;
|
||||
|
||||
namespace Internal {
|
||||
class FindToolBar;
|
||||
class FindToolWindow;
|
||||
class CurrentDocumentFind;
|
||||
} // namespace Internal
|
||||
|
||||
class FIND_EXPORT FindPlugin : public ExtensionSystem::IPlugin
|
||||
{
|
||||
@@ -69,8 +72,8 @@ public:
|
||||
QTextDocument::FindFlags findFlags() const;
|
||||
void updateFindCompletion(const QString &text);
|
||||
void updateReplaceCompletion(const QString &text);
|
||||
QStringListModel *findCompletionModel() { return m_findCompletionModel; }
|
||||
QStringListModel *replaceCompletionModel() { return m_replaceCompletionModel; }
|
||||
QStringListModel *findCompletionModel() const;
|
||||
QStringListModel *replaceCompletionModel() const;
|
||||
void setUseFakeVim(bool on);
|
||||
void openFindToolBar(FindDirection direction);
|
||||
|
||||
@@ -96,22 +99,9 @@ private:
|
||||
void readSettings();
|
||||
|
||||
//variables
|
||||
static FindPlugin *m_instance;
|
||||
|
||||
QHash<IFindFilter *, QAction *> m_filterActions;
|
||||
|
||||
CurrentDocumentFind *m_currentDocumentFind;
|
||||
FindToolBar *m_findToolBar;
|
||||
FindToolWindow *m_findDialog;
|
||||
QTextDocument::FindFlags m_findFlags;
|
||||
QStringListModel *m_findCompletionModel;
|
||||
QStringListModel *m_replaceCompletionModel;
|
||||
QStringList m_findCompletions;
|
||||
QStringList m_replaceCompletions;
|
||||
QAction *m_openFindDialog;
|
||||
FindPluginPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Find
|
||||
|
||||
#endif // FINDPLUGIN_H
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
@@ -51,6 +54,7 @@
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPixmapCache>
|
||||
#include <QtGui/QStringListModel>
|
||||
|
||||
Q_DECLARE_METATYPE(QStringList)
|
||||
Q_DECLARE_METATYPE(Find::IFindFilter*)
|
||||
|
||||
@@ -31,29 +31,27 @@
|
||||
#define FINDTOOLBAR_H
|
||||
|
||||
#include "ui_findwidget.h"
|
||||
#include "ifindfilter.h"
|
||||
#include "currentdocumentfind.h"
|
||||
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
|
||||
#include <QtGui/QStringListModel>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QLabel>
|
||||
namespace Core {
|
||||
class FindToolBarPlaceHolder;
|
||||
}
|
||||
|
||||
namespace Find {
|
||||
namespace Internal {
|
||||
|
||||
class FindPlugin;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class FindToolBar : public Utils::StyledBar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind);
|
||||
explicit FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumentFind);
|
||||
~FindToolBar();
|
||||
|
||||
void readSettings();
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QStringListModel>
|
||||
#include <QtGui/QCompleter>
|
||||
|
||||
using namespace Find;
|
||||
using namespace Find::Internal;
|
||||
|
||||
@@ -34,20 +34,20 @@
|
||||
#include "ifindfilter.h"
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QCompleter>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QCompleter)
|
||||
|
||||
namespace Find {
|
||||
namespace Internal {
|
||||
|
||||
class FindPlugin;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class FindToolWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FindToolWindow(FindPlugin *plugin);
|
||||
explicit FindToolWindow(FindPlugin *plugin);
|
||||
~FindToolWindow();
|
||||
|
||||
void setFindFilters(const QList<IFindFilter *> &filters);
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
FindPlugin *m_plugin;
|
||||
QList<IFindFilter *> m_filters;
|
||||
QCompleter *m_findCompleter;
|
||||
QList<QWidget *> m_configWidgets;
|
||||
QWidgetList m_configWidgets;
|
||||
IFindFilter *m_currentFilter;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
#ifndef SEARCHRESULTTREEITEMS_H
|
||||
#define SEARCHRESULTTREEITEMS_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/qnamespace.h>
|
||||
|
||||
namespace Find {
|
||||
namespace Internal {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "searchresulttreeitemdelegate.h"
|
||||
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QKeyEvent>
|
||||
|
||||
using namespace Find::Internal;
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#define SEARCHRESULTTREEVIEW_H
|
||||
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QKeyEvent>
|
||||
|
||||
namespace Find {
|
||||
namespace Internal {
|
||||
@@ -43,7 +42,7 @@ class SearchResultTreeView : public QTreeView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SearchResultTreeView(QWidget *parent = 0);
|
||||
explicit SearchResultTreeView(QWidget *parent = 0);
|
||||
|
||||
void setAutoExpandResults(bool expand);
|
||||
void setTextEditorFont(const QFont &font);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "searchresultwindow.h"
|
||||
#include "searchresulttreemodel.h"
|
||||
#include "searchresulttreeitems.h"
|
||||
#include "searchresulttreeview.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -43,53 +44,72 @@
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QStackedWidget>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QFont>
|
||||
|
||||
using namespace Find;
|
||||
using namespace Find::Internal;
|
||||
|
||||
static const QString SETTINGSKEYSECTIONNAME("SearchResults");
|
||||
static const QString SETTINGSKEYEXPANDRESULTS("ExpandResults");
|
||||
static const char SETTINGSKEYSECTIONNAME[] = "SearchResults";
|
||||
static const char SETTINGSKEYEXPANDRESULTS[] = "ExpandResults";
|
||||
|
||||
|
||||
SearchResultWindow::SearchResultWindow()
|
||||
: m_currentSearch(0),
|
||||
m_isShowingReplaceUI(false),
|
||||
m_focusReplaceEdit(false)
|
||||
namespace Find {
|
||||
|
||||
struct SearchResultWindowPrivate {
|
||||
SearchResultWindowPrivate();
|
||||
|
||||
Internal::SearchResultTreeView *m_searchResultTreeView;
|
||||
QListWidget *m_noMatchesFoundDisplay;
|
||||
QToolButton *m_expandCollapseToolButton;
|
||||
QLabel *m_replaceLabel;
|
||||
QLineEdit *m_replaceTextEdit;
|
||||
QToolButton *m_replaceButton;
|
||||
static const bool m_initiallyExpand = false;
|
||||
QStackedWidget *m_widget;
|
||||
SearchResult *m_currentSearch;
|
||||
QList<SearchResultItem> m_items;
|
||||
bool m_isShowingReplaceUI;
|
||||
bool m_focusReplaceEdit;
|
||||
};
|
||||
|
||||
SearchResultWindowPrivate::SearchResultWindowPrivate()
|
||||
: m_currentSearch(0), m_isShowingReplaceUI(false), m_focusReplaceEdit(false)
|
||||
{
|
||||
m_widget = new QStackedWidget;
|
||||
m_widget->setWindowTitle(name());
|
||||
}
|
||||
|
||||
m_searchResultTreeView = new SearchResultTreeView(m_widget);
|
||||
m_searchResultTreeView->setFrameStyle(QFrame::NoFrame);
|
||||
m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
m_widget->addWidget(m_searchResultTreeView);
|
||||
SearchResultWindow::SearchResultWindow() : d(new SearchResultWindowPrivate)
|
||||
{
|
||||
d->m_widget = new QStackedWidget;
|
||||
d->m_widget->setWindowTitle(name());
|
||||
|
||||
m_noMatchesFoundDisplay = new QListWidget(m_widget);
|
||||
m_noMatchesFoundDisplay->addItem(tr("No matches found!"));
|
||||
m_noMatchesFoundDisplay->setFrameStyle(QFrame::NoFrame);
|
||||
m_widget->addWidget(m_noMatchesFoundDisplay);
|
||||
d->m_searchResultTreeView = new Internal::SearchResultTreeView(d->m_widget);
|
||||
d->m_searchResultTreeView->setFrameStyle(QFrame::NoFrame);
|
||||
d->m_searchResultTreeView->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
d->m_widget->addWidget(d->m_searchResultTreeView);
|
||||
|
||||
m_expandCollapseToolButton = new QToolButton(m_widget);
|
||||
m_expandCollapseToolButton->setAutoRaise(true);
|
||||
m_expandCollapseToolButton->setCheckable(true);
|
||||
m_expandCollapseToolButton->setIcon(QIcon(":/find/images/expand.png"));
|
||||
m_expandCollapseToolButton->setToolTip(tr("Expand All"));
|
||||
d->m_noMatchesFoundDisplay = new QListWidget(d->m_widget);
|
||||
d->m_noMatchesFoundDisplay->addItem(tr("No matches found!"));
|
||||
d->m_noMatchesFoundDisplay->setFrameStyle(QFrame::NoFrame);
|
||||
d->m_widget->addWidget(d->m_noMatchesFoundDisplay);
|
||||
|
||||
m_replaceLabel = new QLabel(tr("Replace with:"), m_widget);
|
||||
m_replaceLabel->setContentsMargins(12, 0, 5, 0);
|
||||
m_replaceTextEdit = new QLineEdit(m_widget);
|
||||
m_replaceButton = new QToolButton(m_widget);
|
||||
m_replaceButton->setToolTip(tr("Replace all occurrences"));
|
||||
m_replaceButton->setText(tr("Replace"));
|
||||
m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
||||
m_replaceButton->setAutoRaise(true);
|
||||
m_replaceTextEdit->setTabOrder(m_replaceTextEdit, m_searchResultTreeView);
|
||||
d->m_expandCollapseToolButton = new QToolButton(d->m_widget);
|
||||
d->m_expandCollapseToolButton->setAutoRaise(true);
|
||||
d->m_expandCollapseToolButton->setCheckable(true);
|
||||
d->m_expandCollapseToolButton->setIcon(QIcon(":/find/images/expand.png"));
|
||||
d->m_expandCollapseToolButton->setToolTip(tr("Expand All"));
|
||||
|
||||
connect(m_searchResultTreeView, SIGNAL(jumpToSearchResult(int,bool)),
|
||||
d->m_replaceLabel = new QLabel(tr("Replace with:"), d->m_widget);
|
||||
d->m_replaceLabel->setContentsMargins(12, 0, 5, 0);
|
||||
d->m_replaceTextEdit = new QLineEdit(d->m_widget);
|
||||
d->m_replaceButton = new QToolButton(d->m_widget);
|
||||
d->m_replaceButton->setToolTip(tr("Replace all occurrences"));
|
||||
d->m_replaceButton->setText(tr("Replace"));
|
||||
d->m_replaceButton->setToolButtonStyle(Qt::ToolButtonTextOnly);
|
||||
d->m_replaceButton->setAutoRaise(true);
|
||||
d->m_replaceTextEdit->setTabOrder(d->m_replaceTextEdit, d->m_searchResultTreeView);
|
||||
|
||||
connect(d->m_searchResultTreeView, SIGNAL(jumpToSearchResult(int,bool)),
|
||||
this, SLOT(handleJumpToSearchResult(int,bool)));
|
||||
connect(m_expandCollapseToolButton, SIGNAL(toggled(bool)), this, SLOT(handleExpandCollapseToolButton(bool)));
|
||||
connect(m_replaceTextEdit, SIGNAL(returnPressed()), this, SLOT(handleReplaceButton()));
|
||||
connect(m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton()));
|
||||
connect(d->m_expandCollapseToolButton, SIGNAL(toggled(bool)), this, SLOT(handleExpandCollapseToolButton(bool)));
|
||||
connect(d->m_replaceTextEdit, SIGNAL(returnPressed()), this, SLOT(handleReplaceButton()));
|
||||
connect(d->m_replaceButton, SIGNAL(clicked()), this, SLOT(handleReplaceButton()));
|
||||
|
||||
readSettings();
|
||||
setShowReplaceUI(false);
|
||||
@@ -98,55 +118,56 @@ SearchResultWindow::SearchResultWindow()
|
||||
SearchResultWindow::~SearchResultWindow()
|
||||
{
|
||||
writeSettings();
|
||||
delete m_currentSearch;
|
||||
m_currentSearch = 0;
|
||||
delete m_widget;
|
||||
m_widget = 0;
|
||||
m_items.clear();
|
||||
delete d->m_currentSearch;
|
||||
d->m_currentSearch = 0;
|
||||
delete d->m_widget;
|
||||
d->m_widget = 0;
|
||||
d->m_items.clear();
|
||||
delete d;
|
||||
}
|
||||
|
||||
void SearchResultWindow::setTextToReplace(const QString &textToReplace)
|
||||
{
|
||||
m_replaceTextEdit->setText(textToReplace);
|
||||
d->m_replaceTextEdit->setText(textToReplace);
|
||||
}
|
||||
|
||||
QString SearchResultWindow::textToReplace() const
|
||||
{
|
||||
return m_replaceTextEdit->text();
|
||||
return d->m_replaceTextEdit->text();
|
||||
}
|
||||
|
||||
void SearchResultWindow::setShowReplaceUI(bool show)
|
||||
{
|
||||
m_searchResultTreeView->model()->setShowReplaceUI(show);
|
||||
m_replaceLabel->setVisible(show);
|
||||
m_replaceTextEdit->setVisible(show);
|
||||
m_replaceButton->setVisible(show);
|
||||
m_isShowingReplaceUI = show;
|
||||
d->m_searchResultTreeView->model()->setShowReplaceUI(show);
|
||||
d->m_replaceLabel->setVisible(show);
|
||||
d->m_replaceTextEdit->setVisible(show);
|
||||
d->m_replaceButton->setVisible(show);
|
||||
d->m_isShowingReplaceUI = show;
|
||||
}
|
||||
|
||||
void SearchResultWindow::handleReplaceButton()
|
||||
{
|
||||
QTC_ASSERT(m_currentSearch, return);
|
||||
QTC_ASSERT(d->m_currentSearch, return);
|
||||
// check if button is actually enabled, because this is also triggered
|
||||
// by pressing return in replace line edit
|
||||
if (m_replaceButton->isEnabled())
|
||||
m_currentSearch->replaceButtonClicked(m_replaceTextEdit->text(), checkedItems());
|
||||
if (d->m_replaceButton->isEnabled())
|
||||
d->m_currentSearch->replaceButtonClicked(d->m_replaceTextEdit->text(), checkedItems());
|
||||
}
|
||||
|
||||
QList<SearchResultItem> SearchResultWindow::checkedItems() const
|
||||
{
|
||||
QList<SearchResultItem> result;
|
||||
SearchResultTreeModel *model = m_searchResultTreeView->model();
|
||||
Internal::SearchResultTreeModel *model = d->m_searchResultTreeView->model();
|
||||
const int fileCount = model->rowCount(QModelIndex());
|
||||
for (int i = 0; i < fileCount; ++i) {
|
||||
QModelIndex fileIndex = model->index(i, 0, QModelIndex());
|
||||
SearchResultFile *fileItem = static_cast<SearchResultFile *>(fileIndex.internalPointer());
|
||||
Internal::SearchResultFile *fileItem = static_cast<Internal::SearchResultFile *>(fileIndex.internalPointer());
|
||||
Q_ASSERT(fileItem != 0);
|
||||
for (int rowIndex = 0; rowIndex < fileItem->childrenCount(); ++rowIndex) {
|
||||
QModelIndex textIndex = model->index(rowIndex, 0, fileIndex);
|
||||
SearchResultTextRow *rowItem = static_cast<SearchResultTextRow *>(textIndex.internalPointer());
|
||||
Internal::SearchResultTextRow *rowItem = static_cast<Internal::SearchResultTextRow *>(textIndex.internalPointer());
|
||||
if (rowItem->checkState())
|
||||
result << m_items.at(rowItem->index());
|
||||
result << d->m_items.at(rowItem->index());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -158,27 +179,27 @@ void SearchResultWindow::visibilityChanged(bool /*visible*/)
|
||||
|
||||
QWidget *SearchResultWindow::outputWidget(QWidget *)
|
||||
{
|
||||
return m_widget;
|
||||
return d->m_widget;
|
||||
}
|
||||
|
||||
QList<QWidget*> SearchResultWindow::toolBarWidgets() const
|
||||
{
|
||||
return QList<QWidget*>() << m_expandCollapseToolButton << m_replaceLabel << m_replaceTextEdit << m_replaceButton;
|
||||
return QList<QWidget*>() << d->m_expandCollapseToolButton << d->m_replaceLabel << d->m_replaceTextEdit << d->m_replaceButton;
|
||||
}
|
||||
|
||||
SearchResult *SearchResultWindow::startNewSearch(SearchMode searchOrSearchAndReplace)
|
||||
{
|
||||
clearContents();
|
||||
setShowReplaceUI(searchOrSearchAndReplace != SearchOnly);
|
||||
delete m_currentSearch;
|
||||
m_currentSearch = new SearchResult;
|
||||
return m_currentSearch;
|
||||
delete d->m_currentSearch;
|
||||
d->m_currentSearch = new SearchResult;
|
||||
return d->m_currentSearch;
|
||||
}
|
||||
|
||||
void SearchResultWindow::finishSearch()
|
||||
{
|
||||
if (m_items.count()) {
|
||||
m_replaceButton->setEnabled(true);
|
||||
if (d->m_items.count()) {
|
||||
d->m_replaceButton->setEnabled(true);
|
||||
} else {
|
||||
showNoMatchesFound();
|
||||
}
|
||||
@@ -186,55 +207,55 @@ void SearchResultWindow::finishSearch()
|
||||
|
||||
void SearchResultWindow::clearContents()
|
||||
{
|
||||
m_replaceTextEdit->setEnabled(false);
|
||||
m_replaceButton->setEnabled(false);
|
||||
m_replaceTextEdit->clear();
|
||||
m_searchResultTreeView->clear();
|
||||
m_items.clear();
|
||||
m_widget->setCurrentWidget(m_searchResultTreeView);
|
||||
d->m_replaceTextEdit->setEnabled(false);
|
||||
d->m_replaceButton->setEnabled(false);
|
||||
d->m_replaceTextEdit->clear();
|
||||
d->m_searchResultTreeView->clear();
|
||||
d->m_items.clear();
|
||||
d->m_widget->setCurrentWidget(d->m_searchResultTreeView);
|
||||
navigateStateChanged();
|
||||
}
|
||||
|
||||
void SearchResultWindow::showNoMatchesFound()
|
||||
{
|
||||
m_replaceTextEdit->setEnabled(false);
|
||||
m_replaceButton->setEnabled(false);
|
||||
m_widget->setCurrentWidget(m_noMatchesFoundDisplay);
|
||||
d->m_replaceTextEdit->setEnabled(false);
|
||||
d->m_replaceButton->setEnabled(false);
|
||||
d->m_widget->setCurrentWidget(d->m_noMatchesFoundDisplay);
|
||||
}
|
||||
|
||||
bool SearchResultWindow::isEmpty() const
|
||||
{
|
||||
return (m_searchResultTreeView->model()->rowCount() < 1);
|
||||
return (d->m_searchResultTreeView->model()->rowCount() < 1);
|
||||
}
|
||||
|
||||
int SearchResultWindow::numberOfResults() const
|
||||
{
|
||||
return m_items.count();
|
||||
return d->m_items.count();
|
||||
}
|
||||
|
||||
bool SearchResultWindow::hasFocus()
|
||||
{
|
||||
return m_searchResultTreeView->hasFocus() || (m_isShowingReplaceUI && m_replaceTextEdit->hasFocus());
|
||||
return d->m_searchResultTreeView->hasFocus() || (d->m_isShowingReplaceUI && d->m_replaceTextEdit->hasFocus());
|
||||
}
|
||||
|
||||
bool SearchResultWindow::canFocus()
|
||||
{
|
||||
return !m_items.isEmpty();
|
||||
return !d->m_items.isEmpty();
|
||||
}
|
||||
|
||||
void SearchResultWindow::setFocus()
|
||||
{
|
||||
if (!m_items.isEmpty()) {
|
||||
if (!m_isShowingReplaceUI) {
|
||||
m_searchResultTreeView->setFocus();
|
||||
if (!d->m_items.isEmpty()) {
|
||||
if (!d->m_isShowingReplaceUI) {
|
||||
d->m_searchResultTreeView->setFocus();
|
||||
} else {
|
||||
if (!m_widget->focusWidget()
|
||||
|| m_widget->focusWidget() == m_replaceTextEdit
|
||||
|| m_focusReplaceEdit) {
|
||||
m_replaceTextEdit->setFocus();
|
||||
m_replaceTextEdit->selectAll();
|
||||
if (!d->m_widget->focusWidget()
|
||||
|| d->m_widget->focusWidget() == d->m_replaceTextEdit
|
||||
|| d->m_focusReplaceEdit) {
|
||||
d->m_replaceTextEdit->setFocus();
|
||||
d->m_replaceTextEdit->selectAll();
|
||||
} else {
|
||||
m_searchResultTreeView->setFocus();
|
||||
d->m_searchResultTreeView->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,21 +263,21 @@ void SearchResultWindow::setFocus()
|
||||
|
||||
void SearchResultWindow::setTextEditorFont(const QFont &font)
|
||||
{
|
||||
m_searchResultTreeView->setTextEditorFont(font);
|
||||
d->m_searchResultTreeView->setTextEditorFont(font);
|
||||
}
|
||||
|
||||
void SearchResultWindow::handleJumpToSearchResult(int index, bool /* checked */)
|
||||
{
|
||||
QTC_ASSERT(m_currentSearch, return);
|
||||
m_currentSearch->activated(m_items.at(index));
|
||||
QTC_ASSERT(d->m_currentSearch, return);
|
||||
d->m_currentSearch->activated(d->m_items.at(index));
|
||||
}
|
||||
|
||||
void SearchResultWindow::addResult(const QString &fileName, int lineNumber, const QString &rowText,
|
||||
int searchTermStart, int searchTermLength, const QVariant &userData)
|
||||
{
|
||||
//qDebug()<<"###"<<fileName;
|
||||
m_widget->setCurrentWidget(m_searchResultTreeView);
|
||||
int index = m_items.size();
|
||||
d->m_widget->setCurrentWidget(d->m_searchResultTreeView);
|
||||
int index = d->m_items.size();
|
||||
SearchResultItem item;
|
||||
item.fileName = fileName;
|
||||
item.lineNumber = lineNumber;
|
||||
@@ -265,34 +286,34 @@ void SearchResultWindow::addResult(const QString &fileName, int lineNumber, cons
|
||||
item.searchTermLength = searchTermLength;
|
||||
item.userData = userData;
|
||||
item.index = index;
|
||||
m_items.append(item);
|
||||
m_searchResultTreeView->appendResultLine(index, fileName, lineNumber, rowText, searchTermStart, searchTermLength);
|
||||
d->m_items.append(item);
|
||||
d->m_searchResultTreeView->appendResultLine(index, fileName, lineNumber, rowText, searchTermStart, searchTermLength);
|
||||
if (index == 0) {
|
||||
m_replaceTextEdit->setEnabled(true);
|
||||
d->m_replaceTextEdit->setEnabled(true);
|
||||
// We didn't have an item before, set the focus to the search widget
|
||||
m_focusReplaceEdit = true;
|
||||
d->m_focusReplaceEdit = true;
|
||||
setFocus();
|
||||
m_focusReplaceEdit = false;
|
||||
m_searchResultTreeView->selectionModel()->select(m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select);
|
||||
d->m_focusReplaceEdit = false;
|
||||
d->m_searchResultTreeView->selectionModel()->select(d->m_searchResultTreeView->model()->index(0, 0, QModelIndex()), QItemSelectionModel::Select);
|
||||
emit navigateStateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void SearchResultWindow::handleExpandCollapseToolButton(bool checked)
|
||||
{
|
||||
m_searchResultTreeView->setAutoExpandResults(checked);
|
||||
d->m_searchResultTreeView->setAutoExpandResults(checked);
|
||||
if (checked)
|
||||
m_searchResultTreeView->expandAll();
|
||||
d->m_searchResultTreeView->expandAll();
|
||||
else
|
||||
m_searchResultTreeView->collapseAll();
|
||||
d->m_searchResultTreeView->collapseAll();
|
||||
}
|
||||
|
||||
void SearchResultWindow::readSettings()
|
||||
{
|
||||
QSettings *s = Core::ICore::instance()->settings();
|
||||
if (s) {
|
||||
s->beginGroup(SETTINGSKEYSECTIONNAME);
|
||||
m_expandCollapseToolButton->setChecked(s->value(SETTINGSKEYEXPANDRESULTS, m_initiallyExpand).toBool());
|
||||
s->beginGroup(QLatin1String(SETTINGSKEYSECTIONNAME));
|
||||
d->m_expandCollapseToolButton->setChecked(s->value(QLatin1String(SETTINGSKEYEXPANDRESULTS), d->m_initiallyExpand).toBool());
|
||||
s->endGroup();
|
||||
}
|
||||
}
|
||||
@@ -301,8 +322,8 @@ void SearchResultWindow::writeSettings()
|
||||
{
|
||||
QSettings *s = Core::ICore::instance()->settings();
|
||||
if (s) {
|
||||
s->beginGroup(SETTINGSKEYSECTIONNAME);
|
||||
s->setValue(SETTINGSKEYEXPANDRESULTS, m_expandCollapseToolButton->isChecked());
|
||||
s->beginGroup(QLatin1String(SETTINGSKEYSECTIONNAME));
|
||||
s->setValue(QLatin1String(SETTINGSKEYEXPANDRESULTS), d->m_expandCollapseToolButton->isChecked());
|
||||
s->endGroup();
|
||||
}
|
||||
}
|
||||
@@ -314,32 +335,32 @@ int SearchResultWindow::priorityInStatusBar() const
|
||||
|
||||
bool SearchResultWindow::canNext()
|
||||
{
|
||||
return m_items.count() > 0;
|
||||
return d->m_items.count() > 0;
|
||||
}
|
||||
|
||||
bool SearchResultWindow::canPrevious()
|
||||
{
|
||||
return m_items.count() > 0;
|
||||
return d->m_items.count() > 0;
|
||||
}
|
||||
|
||||
void SearchResultWindow::goToNext()
|
||||
{
|
||||
if (m_items.count() == 0)
|
||||
if (d->m_items.count() == 0)
|
||||
return;
|
||||
QModelIndex idx = m_searchResultTreeView->model()->next(m_searchResultTreeView->currentIndex());
|
||||
QModelIndex idx = d->m_searchResultTreeView->model()->next(d->m_searchResultTreeView->currentIndex());
|
||||
if (idx.isValid()) {
|
||||
m_searchResultTreeView->setCurrentIndex(idx);
|
||||
m_searchResultTreeView->emitJumpToSearchResult(idx);
|
||||
d->m_searchResultTreeView->setCurrentIndex(idx);
|
||||
d->m_searchResultTreeView->emitJumpToSearchResult(idx);
|
||||
}
|
||||
}
|
||||
void SearchResultWindow::goToPrev()
|
||||
{
|
||||
if (!m_searchResultTreeView->model()->rowCount())
|
||||
if (!d->m_searchResultTreeView->model()->rowCount())
|
||||
return;
|
||||
QModelIndex idx = m_searchResultTreeView->model()->prev(m_searchResultTreeView->currentIndex());
|
||||
QModelIndex idx = d->m_searchResultTreeView->model()->prev(d->m_searchResultTreeView->currentIndex());
|
||||
if (idx.isValid()) {
|
||||
m_searchResultTreeView->setCurrentIndex(idx);
|
||||
m_searchResultTreeView->emitJumpToSearchResult(idx);
|
||||
d->m_searchResultTreeView->setCurrentIndex(idx);
|
||||
d->m_searchResultTreeView->emitJumpToSearchResult(idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,3 +368,6 @@ bool SearchResultWindow::canNavigate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Find
|
||||
|
||||
|
||||
@@ -31,20 +31,19 @@
|
||||
#define SEARCHRESULTWINDOW_H
|
||||
|
||||
#include "find_global.h"
|
||||
#include "searchresulttreeview.h"
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
#include <coreplugin/ioutputpane.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QStackedWidget;
|
||||
class QListWidget;
|
||||
class QToolButton;
|
||||
class QLabel;
|
||||
class QFont;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Find {
|
||||
|
||||
namespace Internal {
|
||||
class SearchResultTreeView;
|
||||
}
|
||||
class SearchResultWindow;
|
||||
|
||||
struct FIND_EXPORT SearchResultItem
|
||||
@@ -70,6 +69,7 @@ signals:
|
||||
friend class SearchResultWindow;
|
||||
};
|
||||
|
||||
struct SearchResultWindowPrivate;
|
||||
class FIND_EXPORT SearchResultWindow : public Core::IOutputPane
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
};
|
||||
|
||||
SearchResultWindow();
|
||||
~SearchResultWindow();
|
||||
virtual ~SearchResultWindow();
|
||||
|
||||
QWidget *outputWidget(QWidget *);
|
||||
QList<QWidget*> toolBarWidgets() const;
|
||||
@@ -127,18 +127,7 @@ private:
|
||||
void writeSettings();
|
||||
QList<SearchResultItem> checkedItems() const;
|
||||
|
||||
Internal::SearchResultTreeView *m_searchResultTreeView;
|
||||
QListWidget *m_noMatchesFoundDisplay;
|
||||
QToolButton *m_expandCollapseToolButton;
|
||||
QLabel *m_replaceLabel;
|
||||
QLineEdit *m_replaceTextEdit;
|
||||
QToolButton *m_replaceButton;
|
||||
static const bool m_initiallyExpand = false;
|
||||
QStackedWidget *m_widget;
|
||||
SearchResult *m_currentSearch;
|
||||
QList<SearchResultItem> m_items;
|
||||
bool m_isShowingReplaceUI;
|
||||
bool m_focusReplaceEdit;
|
||||
SearchResultWindowPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Find
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
#include "locator_global.h"
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
namespace Locator {
|
||||
|
||||
@@ -51,6 +50,10 @@ protected:
|
||||
virtual void updateFiles();
|
||||
void generateFileNames();
|
||||
|
||||
inline QStringList &files() { return m_files; }
|
||||
inline const QStringList &files() const { return m_files; }
|
||||
|
||||
private:
|
||||
QStringList m_files;
|
||||
QStringList m_fileNames;
|
||||
QStringList m_previousResultPaths;
|
||||
|
||||
@@ -58,7 +58,7 @@ QByteArray DirectoryFilter::saveState() const
|
||||
out << m_filters;
|
||||
out << shortcutString();
|
||||
out << isIncludedByDefault();
|
||||
out << m_files;
|
||||
out << files();
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ bool DirectoryFilter::restoreState(const QByteArray &state)
|
||||
in >> m_filters;
|
||||
in >> shortcut;
|
||||
in >> defaultFilter;
|
||||
in >> m_files;
|
||||
in >> files();
|
||||
|
||||
setShortcutString(shortcut);
|
||||
setIncludedByDefault(defaultFilter);
|
||||
@@ -184,14 +184,14 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
|
||||
future.setProgressRange(0, MAX);
|
||||
if (m_directories.count() < 1) {
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_files.clear();
|
||||
files().clear();
|
||||
generateFileNames();
|
||||
future.setProgressValueAndText(MAX, tr("%1 filter update: 0 files").arg(m_name));
|
||||
return;
|
||||
}
|
||||
int progress = 0;
|
||||
int MAX_PER = MAX;
|
||||
QStringList files;
|
||||
QStringList filesFound;
|
||||
QStack<QDir> dirs;
|
||||
QStack<int> progressValues;
|
||||
QStack<bool> processedValues;
|
||||
@@ -209,7 +209,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
|
||||
while (!dirs.isEmpty() && !future.isCanceled()) {
|
||||
if (future.isProgressUpdateNeeded()) {
|
||||
future.setProgressValueAndText(progress,
|
||||
tr("%1 filter update: %n files", 0, files.size()).arg(m_name));
|
||||
tr("%1 filter update: %n files", 0, filesFound.size()).arg(m_name));
|
||||
}
|
||||
QDir dir = dirs.pop();
|
||||
int dirProgressMax = progressValues.pop();
|
||||
@@ -225,7 +225,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
|
||||
QDir::Files|QDir::Hidden,
|
||||
QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
|
||||
foreach (const QString &file, fileEntries)
|
||||
files.append(dir.path()+ QLatin1Char('/') +file);
|
||||
filesFound.append(dir.path()+ QLatin1Char('/') +file);
|
||||
progress += dirProgressMax;
|
||||
} else {
|
||||
int subProgress = dirProgressMax/(subDirs.size()+1);
|
||||
@@ -246,7 +246,7 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future)
|
||||
|
||||
if (!future.isCanceled()) {
|
||||
QMutexLocker locker(&m_lock);
|
||||
m_files = files;
|
||||
files() = filesFound;
|
||||
generateFileNames();
|
||||
future.setProgressValue(MAX);
|
||||
} else {
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QFutureInterface>
|
||||
#include <QtCore/QMutex>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QDialog>
|
||||
|
||||
namespace Locator {
|
||||
namespace Internal {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "filesystemfilter.h"
|
||||
#include "locatorwidget.h"
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
|
||||
|
||||
@@ -33,13 +33,15 @@
|
||||
#include "ilocatorfilter.h"
|
||||
#include "ui_filesystemfilter.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QFutureInterface>
|
||||
|
||||
namespace Core {
|
||||
class EditorManager;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
namespace Internal {
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ QT_END_NAMESPACE
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QContextMenuEvent>
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include "locatorplugin.h"
|
||||
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -59,7 +58,7 @@ class LocatorWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LocatorWidget(LocatorPlugin *qop);
|
||||
explicit LocatorWidget(LocatorPlugin *qop);
|
||||
|
||||
void updateFilterList();
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
|
||||
#include "opendocumentsfilter.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::IEditor*);
|
||||
|
||||
using namespace Core;
|
||||
|
||||
@@ -32,15 +32,16 @@
|
||||
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QFutureInterface>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
namespace Core {
|
||||
class EditorManager;
|
||||
}
|
||||
|
||||
namespace Locator {
|
||||
namespace Internal {
|
||||
@@ -50,7 +51,7 @@ class OpenDocumentsFilter : public Locator::ILocatorFilter
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OpenDocumentsFilter(Core::EditorManager *editorManager);
|
||||
explicit OpenDocumentsFilter(Core::EditorManager *editorManager);
|
||||
QString displayName() const { return tr("Open documents"); }
|
||||
QString id() const { return "Open documents"; }
|
||||
Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::Medium; }
|
||||
|
||||
@@ -58,13 +58,13 @@ void AllProjectsFilter::updateFiles()
|
||||
if (m_filesUpToDate)
|
||||
return;
|
||||
m_filesUpToDate = true;
|
||||
m_files.clear();
|
||||
files().clear();
|
||||
SessionManager *session = m_projectExplorer->session();
|
||||
if (!session)
|
||||
return;
|
||||
foreach (Project *project, session->projects())
|
||||
m_files += project->files(Project::AllFiles);
|
||||
qSort(m_files);
|
||||
files().append(project->files(Project::AllFiles));
|
||||
qSort(files());
|
||||
generateFileNames();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,11 +63,11 @@ void CurrentProjectFilter::updateFiles()
|
||||
if (m_filesUpToDate)
|
||||
return;
|
||||
m_filesUpToDate = true;
|
||||
m_files.clear();
|
||||
files().clear();
|
||||
if (!m_project)
|
||||
return;
|
||||
m_files = m_project->files(Project::AllFiles);
|
||||
qSort(m_files);
|
||||
files() = m_project->files(Project::AllFiles);
|
||||
qSort(files());
|
||||
generateFileNames();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtCore/QPointer>
|
||||
|
||||
namespace SharedTools {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "rssfetcher.h"
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QtGui/QTreeWidgetItem>
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef COMMUNITYWELCOMEPAGEWIDGET_H
|
||||
#define COMMUNITYWELCOMEPAGEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
namespace Welcome {
|
||||
namespace Internal {
|
||||
@@ -46,7 +46,7 @@ class CommunityWelcomePageWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CommunityWelcomePageWidget(QWidget *parent = 0);
|
||||
explicit CommunityWelcomePageWidget(QWidget *parent = 0);
|
||||
~CommunityWelcomePageWidget();
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#ifndef RSSFETCHER_H
|
||||
#define RSSFETCHER_H
|
||||
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
#include <QtNetwork/QNetworkAccessManager>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QNetworkReply;
|
||||
class QUrl;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Welcome {
|
||||
@@ -45,7 +45,7 @@ class RSSFetcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RSSFetcher(int maxItems, QObject *parent = 0);
|
||||
explicit RSSFetcher(int maxItems, QObject *parent = 0);
|
||||
|
||||
signals:
|
||||
void newsItemReady(const QString& title, const QString& desciption, const QString& url);
|
||||
|
||||
Reference in New Issue
Block a user