[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [homerun/plugin] /: Create HOMERUN_EXPORT_SOURCE helper macro
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2012-09-14 14:18:09
Message-ID: 20120914141809.505ECA60CD () git ! kde ! org
[Download RAW message or body]
Git commit 5209910bf39cfecffa72a3d1ce82561f7c2452bb by Aurélien Gâteau.
Committed on 13/09/2012 at 18:08.
Pushed by gateau into branch 'plugin'.
Create HOMERUN_EXPORT_SOURCE helper macro
M +3 -0 lib/abstractsource.h
M +7 -5 plugins/helloworld/helloworld.cpp
http://commits.kde.org/homerun/5209910bf39cfecffa72a3d1ce82561f7c2452bb
diff --git a/lib/abstractsource.h b/lib/abstractsource.h
index dd82992..91d27dc 100644
--- a/lib/abstractsource.h
+++ b/lib/abstractsource.h
@@ -73,5 +73,8 @@ public:
}
};
+#define HOMERUN_EXPORT_SOURCE(libName, className) \
+ K_PLUGIN_FACTORY(factory, registerPlugin<className>();) \
+ K_EXPORT_PLUGIN(factory("homerun_source_" #libName))
#endif /* ABSTRACTSOURCE_H */
diff --git a/plugins/helloworld/helloworld.cpp b/plugins/helloworld/helloworld.cpp
index bc2207b..42577a0 100644
--- a/plugins/helloworld/helloworld.cpp
+++ b/plugins/helloworld/helloworld.cpp
@@ -31,11 +31,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// KDE
#include <KDebug>
+#include <KLocale>
#include <KPluginFactory>
typedef SimpleSource<HelloWorldModel> HelloWorldSource;
-K_PLUGIN_FACTORY(HelloWorldFactory, registerPlugin<HelloWorldSource>();)
-K_EXPORT_PLUGIN(HelloWorldFactory("homerun_source_helloworld"))
+// First argument is the library name without the "homerun_source_" prefix
+// Second argument is the class name of the source
+HOMERUN_EXPORT_SOURCE(helloworld, HelloWorldSource)
HelloWorldModel::HelloWorldModel()
{
@@ -49,12 +51,12 @@ HelloWorldModel::HelloWorldModel()
QStandardItem *item;
item = new QStandardItem;
- item->setText("Hello");
+ item->setText(i18n("Hello"));
item->setData("face-smile", Qt::DecorationRole);
appendRow(item);
item = new QStandardItem;
- item->setText("World");
+ item->setText(i18n("World"));
item->setData("network-defaultroute", Qt::DecorationRole);
appendRow(item);
}
@@ -69,7 +71,7 @@ bool HelloWorldModel::trigger(int row)
QString HelloWorldModel::name() const
{
- return "Hello World";
+ return i18n("Hello World");
}
int HelloWorldModel::count() const
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic