Changeset View
Changeset View
Standalone View
Standalone View
plugins/projectmanagerview/projectmanagerviewplugin.cpp
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | |||||
189 | } | 189 | } | ||
190 | 190 | | |||
191 | void ProjectManagerViewPlugin::unload() | 191 | void ProjectManagerViewPlugin::unload() | ||
192 | { | 192 | { | ||
193 | qCDebug(PLUGIN_PROJECTMANAGERVIEW) << "unloading manager view"; | 193 | qCDebug(PLUGIN_PROJECTMANAGERVIEW) << "unloading manager view"; | ||
194 | core()->uiController()->removeToolView(d->factory); | 194 | core()->uiController()->removeToolView(d->factory); | ||
195 | } | 195 | } | ||
196 | 196 | | |||
197 | ContextMenuExtension ProjectManagerViewPlugin::contextMenuExtension( KDevelop::Context* context ) | 197 | ContextMenuExtension ProjectManagerViewPlugin::contextMenuExtension(KDevelop::Context* context, QWidget* parent) | ||
198 | { | 198 | { | ||
199 | if( context->type() != KDevelop::Context::ProjectItemContext ) | 199 | if( context->type() != KDevelop::Context::ProjectItemContext ) | ||
200 | return IPlugin::contextMenuExtension( context ); | 200 | return IPlugin::contextMenuExtension(context, parent); | ||
201 | 201 | | |||
202 | KDevelop::ProjectItemContext* ctx = static_cast<KDevelop::ProjectItemContext*>(context); | 202 | KDevelop::ProjectItemContext* ctx = static_cast<KDevelop::ProjectItemContext*>(context); | ||
203 | QList<KDevelop::ProjectBaseItem*> items = ctx->items(); | 203 | QList<KDevelop::ProjectBaseItem*> items = ctx->items(); | ||
204 | 204 | | |||
205 | d->ctxProjectItemList.clear(); | 205 | d->ctxProjectItemList.clear(); | ||
206 | 206 | | |||
207 | if( items.isEmpty() ) | 207 | if( items.isEmpty() ) | ||
208 | return IPlugin::contextMenuExtension( context ); | 208 | return IPlugin::contextMenuExtension(context, parent); | ||
209 | 209 | | |||
210 | //TODO: also needs: removeTarget, removeFileFromTarget, runTargetsFromContextMenu | 210 | //TODO: also needs: removeTarget, removeFileFromTarget, runTargetsFromContextMenu | ||
211 | ContextMenuExtension menuExt; | 211 | ContextMenuExtension menuExt; | ||
212 | bool needsCreateFile = true; | 212 | bool needsCreateFile = true; | ||
213 | bool needsCreateFolder = true; | 213 | bool needsCreateFolder = true; | ||
214 | bool needsCloseProjects = true; | 214 | bool needsCloseProjects = true; | ||
215 | bool needsBuildItems = true; | 215 | bool needsBuildItems = true; | ||
216 | bool needsFolderItems = true; | 216 | bool needsFolderItems = true; | ||
Show All 21 Lines | 227 | foreach( ProjectBaseItem* item, items ) { | |||
238 | //needsRemove if items are limited to non-top-level folders or files that don't belong to targets | 238 | //needsRemove if items are limited to non-top-level folders or files that don't belong to targets | ||
239 | needsRemoveAndRename &= (item->folder() && item->parent()) || (item->file() && !item->parent()->target()); | 239 | needsRemoveAndRename &= (item->folder() && item->parent()) || (item->file() && !item->parent()->target()); | ||
240 | 240 | | |||
241 | //needsRemoveTargets if items are limited to file items with target parents | 241 | //needsRemoveTargets if items are limited to file items with target parents | ||
242 | needsRemoveTargetFiles &= (item->file() && item->parent()->target()); | 242 | needsRemoveTargetFiles &= (item->file() && item->parent()->target()); | ||
243 | } | 243 | } | ||
244 | 244 | | |||
245 | if ( needsCreateFile ) { | 245 | if ( needsCreateFile ) { | ||
246 | QAction* action = new QAction( i18n( "Create &File..." ), this ); | 246 | QAction* action = new QAction(i18n("Create &File..."), parent); | ||
247 | action->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); | 247 | action->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); | ||
248 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::createFileFromContextMenu ); | 248 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::createFileFromContextMenu ); | ||
249 | menuExt.addAction( ContextMenuExtension::FileGroup, action ); | 249 | menuExt.addAction( ContextMenuExtension::FileGroup, action ); | ||
250 | } | 250 | } | ||
251 | if ( needsCreateFolder ) { | 251 | if ( needsCreateFolder ) { | ||
252 | QAction* action = new QAction( i18n( "Create F&older..." ), this ); | 252 | QAction* action = new QAction(i18n("Create F&older..."), parent); | ||
253 | action->setIcon(QIcon::fromTheme(QStringLiteral("folder-new"))); | 253 | action->setIcon(QIcon::fromTheme(QStringLiteral("folder-new"))); | ||
254 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::createFolderFromContextMenu ); | 254 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::createFolderFromContextMenu ); | ||
255 | menuExt.addAction( ContextMenuExtension::FileGroup, action ); | 255 | menuExt.addAction( ContextMenuExtension::FileGroup, action ); | ||
256 | } | 256 | } | ||
257 | 257 | | |||
258 | if ( needsBuildItems ) { | 258 | if ( needsBuildItems ) { | ||
259 | QAction* action = new QAction( i18nc( "@action", "&Build" ), this ); | 259 | QAction* action = new QAction(i18nc("@action", "&Build"), parent); | ||
260 | action->setIcon(QIcon::fromTheme(QStringLiteral("run-build"))); | 260 | action->setIcon(QIcon::fromTheme(QStringLiteral("run-build"))); | ||
261 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::buildItemsFromContextMenu ); | 261 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::buildItemsFromContextMenu ); | ||
262 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | 262 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | ||
263 | action = new QAction( i18nc( "@action", "&Install" ), this ); | 263 | action = new QAction(i18nc("@action", "&Install"), parent); | ||
264 | action->setIcon(QIcon::fromTheme(QStringLiteral("run-build-install"))); | 264 | action->setIcon(QIcon::fromTheme(QStringLiteral("run-build-install"))); | ||
265 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::installItemsFromContextMenu ); | 265 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::installItemsFromContextMenu ); | ||
266 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | 266 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | ||
267 | action = new QAction( i18nc( "@action", "&Clean" ), this ); | 267 | action = new QAction(i18nc("@action", "&Clean"), parent); | ||
268 | action->setIcon(QIcon::fromTheme(QStringLiteral("run-build-clean"))); | 268 | action->setIcon(QIcon::fromTheme(QStringLiteral("run-build-clean"))); | ||
269 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::cleanItemsFromContextMenu ); | 269 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::cleanItemsFromContextMenu ); | ||
270 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | 270 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | ||
271 | action = new QAction( i18n( "&Add to Build Set" ), this ); | 271 | action = new QAction(i18n("&Add to Build Set"), parent); | ||
272 | action->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); | 272 | action->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); | ||
273 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::addItemsFromContextMenuToBuildset ); | 273 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::addItemsFromContextMenuToBuildset ); | ||
274 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | 274 | menuExt.addAction( ContextMenuExtension::BuildGroup, action ); | ||
275 | } | 275 | } | ||
276 | 276 | | |||
277 | if ( needsCloseProjects ) { | 277 | if ( needsCloseProjects ) { | ||
278 | QAction* close = new QAction( i18np( "C&lose Project", "Close Projects", items.count() ), this ); | 278 | QAction* close = new QAction(i18np("C&lose Project", "Close Projects", items.count()), parent); | ||
279 | close->setIcon(QIcon::fromTheme(QStringLiteral("project-development-close"))); | 279 | close->setIcon(QIcon::fromTheme(QStringLiteral("project-development-close"))); | ||
280 | connect( close, &QAction::triggered, this, &ProjectManagerViewPlugin::closeProjects ); | 280 | connect( close, &QAction::triggered, this, &ProjectManagerViewPlugin::closeProjects ); | ||
281 | menuExt.addAction( ContextMenuExtension::ProjectGroup, close ); | 281 | menuExt.addAction( ContextMenuExtension::ProjectGroup, close ); | ||
282 | } | 282 | } | ||
283 | if ( needsFolderItems ) { | 283 | if ( needsFolderItems ) { | ||
284 | QAction* action = new QAction( i18n( "&Reload" ), this ); | 284 | QAction* action = new QAction(i18n("&Reload"), parent); | ||
285 | action->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); | 285 | action->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); | ||
286 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::reloadFromContextMenu ); | 286 | connect( action, &QAction::triggered, this, &ProjectManagerViewPlugin::reloadFromContextMenu ); | ||
287 | menuExt.addAction( ContextMenuExtension::FileGroup, action ); | 287 | menuExt.addAction( ContextMenuExtension::FileGroup, action ); | ||
288 | } | 288 | } | ||
289 | if ( needsRemoveAndRename ) { | 289 | if ( needsRemoveAndRename ) { | ||
290 | QAction* remove = new QAction( i18n( "Remo&ve" ), this ); | 290 | QAction* remove = new QAction(i18n("Remo&ve"), parent); | ||
291 | remove->setIcon(QIcon::fromTheme(QStringLiteral("user-trash"))); | 291 | remove->setIcon(QIcon::fromTheme(QStringLiteral("user-trash"))); | ||
292 | connect( remove, &QAction::triggered, this, &ProjectManagerViewPlugin::removeFromContextMenu ); | 292 | connect( remove, &QAction::triggered, this, &ProjectManagerViewPlugin::removeFromContextMenu ); | ||
293 | menuExt.addAction( ContextMenuExtension::FileGroup, remove ); | 293 | menuExt.addAction( ContextMenuExtension::FileGroup, remove ); | ||
294 | QAction* rename = new QAction( i18n( "Re&name..." ), this ); | 294 | QAction* rename = new QAction(i18n("Re&name..."), parent); | ||
295 | rename->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); | 295 | rename->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); | ||
296 | connect( rename, &QAction::triggered, this, &ProjectManagerViewPlugin::renameItemFromContextMenu ); | 296 | connect( rename, &QAction::triggered, this, &ProjectManagerViewPlugin::renameItemFromContextMenu ); | ||
297 | menuExt.addAction( ContextMenuExtension::FileGroup, rename ); | 297 | menuExt.addAction( ContextMenuExtension::FileGroup, rename ); | ||
298 | } | 298 | } | ||
299 | if ( needsRemoveTargetFiles ) { | 299 | if ( needsRemoveTargetFiles ) { | ||
300 | QAction* remove = new QAction( i18n( "Remove From &Target" ), this ); | 300 | QAction* remove = new QAction(i18n("Remove From &Target"), parent); | ||
301 | remove->setIcon(QIcon::fromTheme(QStringLiteral("user-trash"))); | 301 | remove->setIcon(QIcon::fromTheme(QStringLiteral("user-trash"))); | ||
302 | connect( remove, &QAction::triggered, this, &ProjectManagerViewPlugin::removeTargetFilesFromContextMenu ); | 302 | connect( remove, &QAction::triggered, this, &ProjectManagerViewPlugin::removeTargetFilesFromContextMenu ); | ||
303 | menuExt.addAction( ContextMenuExtension::FileGroup, remove ); | 303 | menuExt.addAction( ContextMenuExtension::FileGroup, remove ); | ||
304 | } | 304 | } | ||
305 | 305 | | |||
306 | { | 306 | { | ||
307 | QAction* copy = KStandardAction::copy(this, SLOT(copyFromContextMenu()), this); | 307 | QAction* copy = KStandardAction::copy(this, SLOT(copyFromContextMenu()), parent); | ||
308 | copy->setShortcutContext(Qt::WidgetShortcut); | 308 | copy->setShortcutContext(Qt::WidgetShortcut); | ||
309 | menuExt.addAction( ContextMenuExtension::FileGroup, copy ); | 309 | menuExt.addAction( ContextMenuExtension::FileGroup, copy ); | ||
310 | } | 310 | } | ||
311 | if (needsPaste) { | 311 | if (needsPaste) { | ||
312 | QAction* paste = KStandardAction::paste(this, SLOT(pasteFromContextMenu()), this); | 312 | QAction* paste = KStandardAction::paste(this, SLOT(pasteFromContextMenu()), parent); | ||
313 | paste->setShortcutContext(Qt::WidgetShortcut); | 313 | paste->setShortcutContext(Qt::WidgetShortcut); | ||
314 | menuExt.addAction( ContextMenuExtension::FileGroup, paste ); | 314 | menuExt.addAction( ContextMenuExtension::FileGroup, paste ); | ||
315 | } | 315 | } | ||
316 | 316 | | |||
317 | return menuExt; | 317 | return menuExt; | ||
318 | } | 318 | } | ||
319 | 319 | | |||
320 | void ProjectManagerViewPlugin::closeProjects() | 320 | void ProjectManagerViewPlugin::closeProjects() | ||
▲ Show 20 Lines • Show All 424 Lines • Show Last 20 Lines |