Changeset View
Changeset View
Standalone View
Standalone View
plugins/grepview/grepviewplugin.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | |||||
117 | } | 117 | } | ||
118 | 118 | | |||
119 | void GrepViewPlugin::startSearch(const QString& pattern, const QString& directory, bool show) | 119 | void GrepViewPlugin::startSearch(const QString& pattern, const QString& directory, bool show) | ||
120 | { | 120 | { | ||
121 | m_directory = directory; | 121 | m_directory = directory; | ||
122 | showDialog(false, pattern, show); | 122 | showDialog(false, pattern, show); | ||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | KDevelop::ContextMenuExtension GrepViewPlugin::contextMenuExtension(KDevelop::Context* context) | 125 | KDevelop::ContextMenuExtension GrepViewPlugin::contextMenuExtension(KDevelop::Context* context, QWidget* parent) | ||
126 | { | 126 | { | ||
127 | KDevelop::ContextMenuExtension extension = KDevelop::IPlugin::contextMenuExtension(context); | 127 | KDevelop::ContextMenuExtension extension = KDevelop::IPlugin::contextMenuExtension(context, parent); | ||
128 | if( context->type() == KDevelop::Context::ProjectItemContext ) { | 128 | if( context->type() == KDevelop::Context::ProjectItemContext ) { | ||
129 | KDevelop::ProjectItemContext* ctx = static_cast<KDevelop::ProjectItemContext*>(context); | 129 | KDevelop::ProjectItemContext* ctx = static_cast<KDevelop::ProjectItemContext*>(context); | ||
130 | QList<KDevelop::ProjectBaseItem*> items = ctx->items(); | 130 | QList<KDevelop::ProjectBaseItem*> items = ctx->items(); | ||
131 | // verify if there is only one folder selected | 131 | // verify if there is only one folder selected | ||
132 | if ((items.count() == 1) && (items.first()->folder())) { | 132 | if ((items.count() == 1) && (items.first()->folder())) { | ||
133 | QAction* action = new QAction( i18n( "Find/Replace in This Folder..." ), this ); | 133 | QAction* action = new QAction(i18n("Find/Replace in This Folder..."), parent); | ||
134 | action->setIcon(QIcon::fromTheme(QStringLiteral("edit-find"))); | 134 | action->setIcon(QIcon::fromTheme(QStringLiteral("edit-find"))); | ||
135 | m_contextMenuDirectory = items.at(0)->folder()->path().toLocalFile(); | 135 | m_contextMenuDirectory = items.at(0)->folder()->path().toLocalFile(); | ||
136 | connect( action, &QAction::triggered, this, &GrepViewPlugin::showDialogFromProject); | 136 | connect( action, &QAction::triggered, this, &GrepViewPlugin::showDialogFromProject); | ||
137 | extension.addAction( KDevelop::ContextMenuExtension::ExtensionGroup, action ); | 137 | extension.addAction( KDevelop::ContextMenuExtension::ExtensionGroup, action ); | ||
138 | } | 138 | } | ||
139 | } | 139 | } | ||
140 | 140 | | |||
141 | if ( context->type() == KDevelop::Context::EditorContext ) { | 141 | if ( context->type() == KDevelop::Context::EditorContext ) { | ||
142 | KDevelop::EditorContext* econtext = static_cast<KDevelop::EditorContext*>(context); | 142 | KDevelop::EditorContext* econtext = static_cast<KDevelop::EditorContext*>(context); | ||
143 | if ( econtext->view()->selection() ) { | 143 | if ( econtext->view()->selection() ) { | ||
144 | QAction* action = new QAction(QIcon::fromTheme(QStringLiteral("edit-find")), i18n("&Find/Replace in Files..."), this); | 144 | QAction* action = new QAction(QIcon::fromTheme(QStringLiteral("edit-find")), i18n("&Find/Replace in Files..."), parent); | ||
145 | connect(action, &QAction::triggered, this, &GrepViewPlugin::showDialogFromMenu); | 145 | connect(action, &QAction::triggered, this, &GrepViewPlugin::showDialogFromMenu); | ||
146 | extension.addAction(KDevelop::ContextMenuExtension::ExtensionGroup, action); | 146 | extension.addAction(KDevelop::ContextMenuExtension::ExtensionGroup, action); | ||
147 | } | 147 | } | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | if(context->type() == KDevelop::Context::FileContext) { | 150 | if(context->type() == KDevelop::Context::FileContext) { | ||
151 | KDevelop::FileContext* fcontext = static_cast<KDevelop::FileContext*>(context); | 151 | KDevelop::FileContext* fcontext = static_cast<KDevelop::FileContext*>(context); | ||
152 | // TODO: just stat() or QFileInfo().isDir() for local files? should be faster than mime type checking | 152 | // TODO: just stat() or QFileInfo().isDir() for local files? should be faster than mime type checking | ||
153 | QMimeType mimetype = QMimeDatabase().mimeTypeForUrl(fcontext->urls().at(0)); | 153 | QMimeType mimetype = QMimeDatabase().mimeTypeForUrl(fcontext->urls().at(0)); | ||
154 | static const QMimeType directoryMime = QMimeDatabase().mimeTypeForName(QStringLiteral("inode/directory")); | 154 | static const QMimeType directoryMime = QMimeDatabase().mimeTypeForName(QStringLiteral("inode/directory")); | ||
155 | if (mimetype == directoryMime) { | 155 | if (mimetype == directoryMime) { | ||
156 | QAction* action = new QAction( i18n( "Find/Replace in This Folder..." ), this ); | 156 | QAction* action = new QAction(i18n("Find/Replace in This Folder..."), parent); | ||
157 | action->setIcon(QIcon::fromTheme(QStringLiteral("edit-find"))); | 157 | action->setIcon(QIcon::fromTheme(QStringLiteral("edit-find"))); | ||
158 | m_contextMenuDirectory = fcontext->urls().at(0).toLocalFile(); | 158 | m_contextMenuDirectory = fcontext->urls().at(0).toLocalFile(); | ||
159 | connect( action, &QAction::triggered, this, &GrepViewPlugin::showDialogFromProject); | 159 | connect( action, &QAction::triggered, this, &GrepViewPlugin::showDialogFromProject); | ||
160 | extension.addAction( KDevelop::ContextMenuExtension::ExtensionGroup, action ); | 160 | extension.addAction( KDevelop::ContextMenuExtension::ExtensionGroup, action ); | ||
161 | } | 161 | } | ||
162 | } | 162 | } | ||
163 | return extension; | 163 | return extension; | ||
164 | } | 164 | } | ||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |