--- a/homescreenapp/hsdomainmodel/src/hswidgetcomponent.cpp Thu Jun 24 13:11:40 2010 +0100
+++ b/homescreenapp/hsdomainmodel/src/hswidgetcomponent.cpp Fri Jun 25 19:19:22 2010 +0300
@@ -23,16 +23,26 @@
#include "caservice.h"
#include "caquery.h"
+/*!
+ \class HsWidgetComponent
+ \ingroup group_hsdomainmodel
+ \brief Widget component represent a widget package.
+
+ Widget component is accessed through a HsWidgetComponentRegistry. All widget instances from same type
+ are refering to one HsWidgetComponent and can listen component state changes
+
+*/
+
/*!
-
+ Destructor
*/
HsWidgetComponent::~HsWidgetComponent()
{
}
/*!
-
+ Widget component installation path
*/
QString HsWidgetComponent::rootPath() const
{
@@ -40,14 +50,16 @@
}
/*!
-
+ Widget unique identifier
*/
QString HsWidgetComponent::uri() const
{
return mUri;
}
-
+/*!
+ Returns true if widget is available thus it's root path exists
+*/
bool HsWidgetComponent::isAvailable() const
{
bool ret(true);
@@ -57,23 +69,58 @@
return ret;
}
/*!
+ \fn HsWidgetComponent::aboutToUninstall()
+ This signal is emitted before component is uninstalled.
+ System may delete widget instances and release all resources
+ related to component. Component installation will fail, if installer
+ can't remove and install some file if someone has handle to it.
+
+*/
+
+/*!
+ \fn HsWidgetComponent::uninstalled()
+
+ This signal is emitted after component is uninstalled from device.
+*/
+
+/*!
+ \fn HsWidgetComponent::updated()
+
+ This signal is emitted when component is updated.
+*/
+
+/*!
+ \fn HsWidgetComponent::unavailable()
+
+ This signal is emitted when component comes unavailable i.e media is removed.
+*/
+
+/*!
+ \fn HsWidgetComponent::available()
+
+ This signal is emitted when component comes available i.e media is attached.
+*/
+
+
+/*!
+ Constructor
*/
HsWidgetComponent::HsWidgetComponent(const QString &uri, QObject *parent)
: QObject(parent),
mUri(uri),
mState(Available)
{
- resolveRootPath();
+ resolveRootPathAndTranslationFilename();
installTranslator();
}
/*!
-
+ Resolves component's root path and translation file name if any
*/
-void HsWidgetComponent::resolveRootPath()
+void HsWidgetComponent::resolveRootPathAndTranslationFilename()
{
CaQuery query;
query.setEntryTypeNames(QStringList(widgetTypeName()));
@@ -87,11 +134,13 @@
mRootPath = entry->attribute(widgetPathAttributeName());
if (mRootPath.isEmpty() || !QDir(mRootPath).exists()) {
mState = Unavailable;
+ } else {
+ mTranslationFilename = entry->attribute(translationFilename());
}
}
/*!
-
+ Search component's translation dile and installs translator to application
*/
void HsWidgetComponent::installTranslator()
{
@@ -111,29 +160,32 @@
// if it is not in installed,then check z drive
possiblePaths << "z:/resource/qt/translations";
#endif
-
+
for(int i=0; i<possiblePaths.count(); ++i) {
QString candidate = QDir::toNativeSeparators(possiblePaths.at(i));
if (QDir(candidate).exists()) {
- QString fileName(mUri);
- fileName.append("_");
- fileName.append(QLocale::system().name());
+ QString fileName(mTranslationFilename);
+ fileName.append("_");
+ fileName.append(QLocale::system().name());
if (mTranslator.load(fileName, candidate)) {
QCoreApplication::installTranslator(&mTranslator);
- break;
+ break;
}
- }
- }
+ }
+ }
}
/*!
-
+ Unistall translator from application
*/
void HsWidgetComponent::uninstallTranslator()
{
QCoreApplication::removeTranslator(&mTranslator);
}
+/*!
+ Emit aboutToUninstall signal
+*/
void HsWidgetComponent::emitAboutToUninstall()
{
if (mState == Available) {
@@ -141,6 +193,9 @@
emit aboutToUninstall();
}
}
+/*!
+ Emit uninstalled signal
+*/
void HsWidgetComponent::emitUninstalled()
{
if (mState == Uninstalling) {
@@ -148,6 +203,9 @@
emit uninstalled();
}
}
+/*!
+ Emit updated signal
+*/
void HsWidgetComponent::emitUpdated()
{
if (mState == Uninstalling) {
@@ -155,6 +213,9 @@
emit updated();
}
}
+/*!
+ Emit unavailable signal
+*/
void HsWidgetComponent::emitUnavailable()
{
if (mState == Available) {
@@ -162,6 +223,9 @@
emit unavailable();
}
}
+/*!
+ Emit available signal
+*/
void HsWidgetComponent::emitAvailable()
{
if (mState == Unavailable) {