X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2FPluginInterface.h;h=33cd4912383a989a1878aa26a58335ace0896870;hb=d843508b9e84901695a6f72152d5366ebd957ad6;hp=427c3304feeb3b98b8b2ea348e0768c31bf14163;hpb=b62e6b5309eb1954c6ea4e1522767a424d76f15d;p=qtrapids diff --git a/src/plugins/PluginInterface.h b/src/plugins/PluginInterface.h index 427c330..33cd491 100644 --- a/src/plugins/PluginInterface.h +++ b/src/plugins/PluginInterface.h @@ -25,81 +25,57 @@ namespace qtrapids { -<<<<<<< .mine - -// Forward declaration because of co-dependency of classes. -class PluginInterface; - -/** @class PluginHostInterface -* @brief Defines interface for plugins to access the host application. -* A Host is an application that is extended by implementing Plugins, -* that implement the additional functionality -* @note Implementing plugin host should inherit QObject. -*/ -class PluginHostInterface -{ -public: - - /// @brief Sets the plugin GUI element to host application - /// @note It is up to the host application to decide how to manage - /// and show the actual widget. - virtual bool setGui(PluginInterface* from, QWidget* widget) = 0; - - /// @brief Adds additional plugin wigdets to the host application. - /// This functio can be called by the plugin recursively, i.e. when GUI events occur - /// The host application must handle placing the additional widgets. - /// @todo Could we implement this using in a more manageable way, e.g. signal-slot? - virtual void addPluginWidget(PluginInterface* from, QWidget* widget) = 0; - virtual void addToolbar(PluginInterface* from, QWidget* widget) = 0; - virtual void addToolItem(PluginInterface* from, QWidget* widget) = 0; - virtual void addMenu(PluginInterface* from, QWidget* widget) = 0; - virtual void addMenuItem(PluginInterface* from, QWidget* widget) = 0; -}; -======= - >>>>>>> .r31 - <<<<<<< .mine - - ======= - - /** @class PluginHostInterface - * @brief Defines interface for plugins to access the host application. - * A Host is an application that is extended by implementing Plugins, - * that implement the additional functionality - */ - class PluginHostInterface : public QObject -{ -public: - - >>>>>>> .r31 - /// @brief Sets the plugin GUI element to host application - /// @note It is up to the host application to decide how to manage - /// and show the actual widget. - virtual bool setGui(QWidget* widget) = 0; - - /// @brief Adds additional plugin wigdets to the host application. - /// This functio can be called by the plugin recursively, i.e. when GUI events occur - /// The host application must handle placing the additional widgets. - /// @todo Could we implement this using in a more manageable way, e.g. signal-slot? - virtual void addPluginWidget(QWidget* widget) = 0; - virtual void addToolbar() = 0; - virtual void addToolItem() = 0; - virtual void addMenu() = 0; - virtual void addMenuItem() = 0; -}; - - -/** @class PluginInterface - * @brief Defines interface for a plugin instance. - * The host application uses PluginInterface interface for calling the plugins - * that extend the Host functionality -*/ -class PluginInterface : public QObject -{ -public: - /// @brief Initializes the plugin instance. - virtual void initialize(PluginHostInterface* host) = 0; - virtual QWidget* getGui() = 0; -}; + + // Forward declaration because of co-dependency of classes. + class PluginInterface; + + + /** @class PluginHostInterface + * @brief Defines interface for plugins to access the host application. + * A Host is an application that is extended by implementing Plugins, + * that implement the additional functionality + * @note Implementing plugin host should inherit QObject. + */ + class PluginHostInterface { + public: + /// @enum PluginWidgetType Allows plugin host to differentiate actions + /// when passed as parameter to addWidget(). E.g. Popup a dialog or append tab etc. + /// @todo add new types + enum PluginWidgetType { + BASE_WIDGET, + TAB_PAGE, + UNKNOWN + }; + + /// @brief Sets the plugin GUI element to host application + /// @note It is up to the host application to decide how to manage + /// and show the actual widget. + virtual bool setGui(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0; + + /// @brief Adds additional plugin wigdets to the host application. + /// This functio can be called by the plugin recursively, i.e. when GUI events occur + /// The host application must handle placing the additional widgets. + /// @todo Could we implement this using in a more manageable way, e.g. signal-slot? + virtual void addPluginWidget(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0; + virtual void addToolbar(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0; + virtual void addToolItem(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0; + virtual void addMenu(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0; + virtual void addMenuItem(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0; + }; + + + + /** @class PluginInterface + * @brief Defines interface for a plugin instance. + * The host application uses PluginInterface interface for calling the plugins + * that extend the Host functionality + */ + class PluginInterface : public QObject { + public: + /// @brief Initializes the plugin instance. + virtual void initialize(PluginHostInterface* host) = 0; + virtual QWidget* getGui() = 0; + }; } //namespace qtrapids @@ -109,59 +85,59 @@ Q_DECLARE_INTERFACE(qtrapids::PluginInterface, "com.ixonos.qtrapids.PluginInterface/1.0") Q_DECLARE_INTERFACE(qtrapids::PluginHostInterface, "com.ixonos.qtrapids.PluginHostInterface/1.0") - - + + //////////////// EXAMPLE PLUGIN DECLARATION ///////////////////////// // A simple plugin example using the PluginInterface // For more info, see Qt documentation: "How to Create Qt Plugins" // // namespace qtrapids // { -// +// // class MyPlugin : public PluginInterface { // Q_OBJECT // // NOTE: This macro tells Qt which interfaces the plugin implements (i.e. inherits): // Q_INTERFACES(qtrapids::PluginInterface) -// +// // public: // MyPlugin(); // virtual void initialize(PluginHostInterface* host); // virtual QWidget* getGui(); -// +// // // Additional plugin-specific signals and slots. -// signals: +// signals: // void searchResult(QWidget* resultwidget); -// -// private slots: +// +// private slots: // void on_button_clicked(); // void on_result(QWidget* resultWidget); -// +// // private: // }; -// +// // // MyPlugin::MyPlugin(): host_(NULL) {} -// +// // void SearchPlugin::initialize(AbstractPluginHost* host) // { // host_ = host; -// +// // if (host_ != NULL) { // QWidget *pluginWidget = new QWidget; // QVBoxLayout *vbox = new QVBoxLayout; // QPushButton *searchButton = new QPushButton("Search"); // vbox->addWidget(searchButton); // pluginWidget->setLayout(vbox); -// +// // connect(searchButton, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked())); // //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*))); -// -// // Call host interface function to set the plugin GUI. Host handles the setup +// +// // Call host interface function to set the plugin GUI. Host handles the setup // // to it's own policy // host_->setGui(pluginWidget); // } // } -// } // namespace qtrapids +// } // namespace qtrapids // //// NOTE: Remember to export the actual plugin to be visible for Qt: //// Q_EXPORT_PLUGIN2(myplugin, qtrapids::MyPlugin)