1 /*************************************************************************** 2 robjectbrowser - description 3 ------------------- 4 begin : Thu Aug 19 2004 5 copyright : (C) 2004 - 2016 by Thomas Friedrichsmeier 6 email : thomas.friedrichsmeier@kdemail.net 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 #ifndef ROBJECTBROWSER_H 18 #define ROBJECTBROWSER_H 19 20 #include "rkmdiwindow.h" 21 22 #include <QModelIndex> 23 #include <QFocusEvent> 24 25 #include "rkcommandeditorwindow.h" 26 27 class RKObjectListView; 28 class RKObjectListViewSettings; 29 class QPushButton; 30 class RObject; 31 class RObjectBrowserInternal; 32 33 /** 34 This widget provides a browsable list of all objects in the R workspace 35 36 Note: Most actual functionality is realized in RObjectBrowserInternal, which is created as soon as the RObjectBrowser is shown for the first time. 37 38 @author Thomas Friedrichsmeier 39 */ 40 class RObjectBrowser : public RKMDIWindow { 41 public: 42 RObjectBrowser (QWidget *parent, bool tool_window, const char *name=0); 43 ~RObjectBrowser (); 44 void unlock (); mainBrowser()45 static RObjectBrowser *mainBrowser () { return object_browser; }; 46 /** reimplemented to create the real file browser widget only when the file browser is shown for the first time */ 47 void showEvent (QShowEvent *e) override; 48 private: 49 RObjectBrowserInternal *internal; 50 QWidget *layout_widget; 51 52 bool locked; 53 friend class RKWardMainWindow; 54 static RObjectBrowser *object_browser; 55 void initialize (); 56 }; 57 58 /** 59 Provides most of the functionality of RObjectBrowser 60 61 @author Thomas Friedrichsmeier 62 */ 63 class RObjectBrowserInternal : public QWidget, public RKScriptContextProvider { 64 Q_OBJECT 65 public: 66 explicit RObjectBrowserInternal (QWidget *parent, RObjectBrowser *browser); 67 ~RObjectBrowserInternal (); 68 private slots: 69 void updateButtonClicked (); 70 void contextMenuCallback (RObject *object, bool *suppress); 71 72 void popupEdit (); 73 void popupCopy (); 74 /** essentially like popupCopy, but does not ask for a name */ 75 void popupCopyToGlobalEnv (); 76 void popupView (); 77 void popupDelete (); 78 void popupUnload (); 79 void popupRename (); 80 /** when an object in the list is double clicked, insert its name in the current RKCommandEditor window */ 81 void doubleClicked (const QModelIndex &index); 82 protected: 83 /** reimplemnented from QWidget to make show the globalenv object when activated (other than by mouse click) */ 84 void focusInEvent (QFocusEvent *e) override; 85 void currentHelpContext (QString *symbol, QString *package) override; 86 private: 87 enum PopupActions { 88 Help=0, 89 SearchOnline, 90 Edit, 91 View, 92 Rename, 93 Copy, 94 CopyToGlobalEnv, 95 Delete, 96 Unload, 97 LoadUnloadPackages, 98 ActionCount 99 }; 100 QList<QAction*> actions; 101 102 QPushButton *update_button; 103 RKObjectListView *list_view; 104 }; 105 106 #endif 107