Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-8838: <BlackBerry: Implement UI.TableView> #62

Merged
merged 7 commits into from
Jun 5, 2012
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion apidoc/Titanium/UI/TableView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ methods:
summary: Animation properties, only used on iOS.
type: TableViewAnimationProperties
optional: true
platforms: [android, iphone, ipad, mobileweb]

- name: deleteRow
summary: Deletes an existing row.
Expand All @@ -53,6 +54,7 @@ methods:
summary: Animation properties. Only used on iOS.
type: TableViewAnimationProperties
optional: true
platforms: [android, iphone, ipad, mobileweb]

- name: deselectRow
summary: Programmatically deselects a row.
Expand Down Expand Up @@ -82,6 +84,7 @@ methods:
summary: Animation properties. Only used on iOS.
type: TableViewAnimationProperties
optional: true
platforms: [android, iphone, ipad, mobileweb]

- name: insertRowBefore
summary: Inserts a row before another row.
Expand All @@ -103,6 +106,7 @@ methods:
summary: Animation properties. Only used on iOS.
type: TableViewAnimationProperties
optional: true
platforms: [android, iphone, ipad, mobileweb]

- name: scrollToIndex
summary: Scrolls the table view to ensure that the specified row is on screen.
Expand Down Expand Up @@ -150,6 +154,7 @@ methods:
summary: Animation properties. Only used on iOS.
type: TableViewAnimationProperties
optional: true
platforms: [android, iphone, ipad, mobileweb]

- name: selectRow
summary: Programmatically selects a row.
Expand Down Expand Up @@ -187,10 +192,12 @@ methods:
- name: properties
summary: Animation properties. Only used on iOS.
type: TableViewAnimationProperties
platforms: [android, iphone, ipad, mobileweb]

events:
- name: click
summary: Fired when a table row is clicked by the user.
platforms: [android, iphone, ipad, mobileweb]
platforms: [android, iphone, ipad, mobileweb, blackberry]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all the click event properties currently supported? If not the yml needs updating

properties:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be blackberry, instead of 'backberry'.
Also say for method appendRow, since we don't implement it mark platforms as [android, iphone, ipad, mobileweb], and so on for others.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

- name: index
summary: Row index.
Expand Down Expand Up @@ -645,6 +652,7 @@ properties:
- name: footerTitle
summary: Table view footer title.
type: String
platforms: [android, iphone, ipad, mobileweb]

- name: hideSearchOnSelection
summary: Boolean to indicate whether or not the search field should hide on completion.
Expand All @@ -663,14 +671,17 @@ properties:
- name: footerView
summary: Table view footer as a view that will be rendered instead of a label.
type: Titanium.UI.View
platforms: [android, iphone, ipad, mobileweb]

- name: headerTitle
summary: Table view header title.
type: String
platforms: [android, iphone, ipad, mobileweb]

- name: headerView
summary: Table view header as a view that will be rendered instead of a label.
type: Titanium.UI.View
platforms: [android, iphone, ipad, mobileweb]

- name: index
summary: Array of objects (with `title` and `index` properties) to control the table view index.
Expand All @@ -684,10 +695,12 @@ properties:
- name: maxRowHeight
summary: Maximum row height for table view rows.
type: Number
platforms: [android, iphone, ipad, mobileweb]

- name: minRowHeight
summary: Minimum row height for table view rows.
type: Number
platforms: [android, iphone, ipad, mobileweb]

- name: moving
summary: Boolean to control the moveable state of the table view.
Expand All @@ -697,6 +710,7 @@ properties:
- name: rowHeight
summary: Default row height for table view rows.
type: Number
platforms: [android, iphone, ipad, mobileweb]

- name: scrollable
summary: If `true`, the tableview can be scrolled.
Expand All @@ -719,6 +733,7 @@ properties:
summary: Separator color between rows, specified as a hex or named value.
type: String
default: platform-specific default color
platforms: [android, iphone, ipad, mobileweb]

- name: separatorStyle
summary: Separator style constant.
Expand Down
10 changes: 9 additions & 1 deletion blackberry/tibb/NativeContainerObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
#include "NativeContainerObject.h"
#include "NativeObjectFactory.h"
#include <bb/cascades/AbsoluteLayout>
#include <bb/cascades/ActivityIndicator>
#include <bb/cascades/Button>
#include <bb/cascades/Color>
#include <bb/cascades/Container>
#include <bb/cascades/DockLayout>
#include <bb/cascades/DockLayoutProperties>
#include <bb/cascades/ImageView>
#include <bb/cascades/Label>
#include <bb/cascades/ListView>
#include <bb/cascades/ProgressIndicator>
#include <bb/cascades/Slider>
#include <bb/cascades/Stacklayout>
#include <bb/cascades/TextField>
#include <bb/cascades/ActivityIndicator>
#include <bb/cascades/DropDown>
#include <qtgui/QColor>

Expand Down Expand Up @@ -147,6 +148,13 @@ int NativeContainerObject::addChildNativeObject(NativeObject* obj)

}

case N_TYPE_LIST_VIEW:
{
bb::cascades::ListView* listView = (bb::cascades::ListView*) obj->getNativeHandle();
container_->add(listView);
return NATIVE_ERROR_OK;
}

}

return NATIVE_ERROR_NOTSUPPORTED;
Expand Down
70 changes: 67 additions & 3 deletions blackberry/tibb/NativeControlObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,36 @@ int NativeControlObject::setTop(TiObject* obj)
return NATIVE_ERROR_OK;
}

PROP_SETTER(setLeft)
int NativeControlObject::setLeft(TiObject* obj)
{
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setValue)
int NativeControlObject::setValue(TiObject* obj)
{
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setWidth)
int NativeControlObject::setWidth(TiObject* obj)
{
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setHeight)
int NativeControlObject::setHeight(TiObject* obj)
{
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setData)
int NativeControlObject::setData(TiObject* obj)
{
return NATIVE_ERROR_NOTSUPPORTED;
}

PROP_SETTER(setVisible)
int NativeControlObject::setVisible(TiObject* obj)
{
Expand Down Expand Up @@ -196,15 +220,15 @@ static vector<NATIVE_PROPSET_CALLBACK> initFunctionMap()
vect[N_PROP_ELLIPSIZE] = NULL;
vect[N_PROP_FOCUSABLE] = NULL;
vect[N_PROP_FONT] = NULL;
vect[N_PROP_HEIGHT] = NULL;
vect[N_PROP_HEIGHT] = PROP_SETTING_FUNCTION(setHeight);
vect[N_PROP_HIGHLIGHTED_COLOR] = NULL;
vect[N_PROP_HINT_TEXT] = NULL;
vect[N_PROP_HTML] = NULL;
vect[N_PROP_IMAGE] = PROP_SETTING_FUNCTION(setImage);
vect[N_PROP_KEEP_SCREEN_ON] = NULL;
vect[N_PROP_LABEL] = PROP_SETTING_FUNCTION(setLabel);
vect[N_PROP_LAYOUT] = NULL;
vect[N_PROP_LEFT] = NULL;
vect[N_PROP_LEFT] = PROP_SETTING_FUNCTION(setLeft);
vect[N_PROP_MAX] = PROP_SETTING_FUNCTION(setMax);
vect[N_PROP_MIN] = PROP_SETTING_FUNCTION(setMin);
vect[N_PROP_MINIMUM_FONT_SIZE] = NULL;
Expand All @@ -225,9 +249,10 @@ static vector<NATIVE_PROPSET_CALLBACK> initFunctionMap()
vect[N_PROP_TRANSFORM] = NULL;
vect[N_PROP_VALUE] = PROP_SETTING_FUNCTION(setValue);
vect[N_PROP_VISIBLE] = PROP_SETTING_FUNCTION(setVisible);
vect[N_PROP_WIDTH] = NULL;
vect[N_PROP_WIDTH] = PROP_SETTING_FUNCTION(setWidth);
vect[N_PROP_WORD_WRAP] = NULL;
vect[N_PROP_ZINDEX] = NULL;
vect[N_PROP_DATA] = PROP_SETTING_FUNCTION(setData);
return vect;
}

Expand Down Expand Up @@ -337,3 +362,42 @@ int NativeControlObject::getStringArray(TiObject* obj, QVector<QString>& value)
}
return NATIVE_ERROR_OK;
}

int NativeControlObject::getDictionaryData(TiObject* obj, multimap<QString, QString>& dictionary)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use a QMultiMap?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to QVector, because it needs to keep the order of elements

{
Handle<Value> value = obj->getValue();
if (value.IsEmpty() || (!value->IsArray()))
{
return NATIVE_ERROR_INVALID_ARG;
}

Handle<Array> array = Handle<Array>::Cast(value);
uint32_t length = array->Length();
//traverse through the dictionary elements
for (uint32_t i = 0; i < length; ++i)
{
Local<Value> el = array->Get(i);
if (el->IsObject())
{
Local<Array> propAr = el->ToObject()->GetPropertyNames();
uint32_t arLenght = propAr->Length();
for (uint32_t j = 0; j < arLenght; ++j)
{
Handle<String> propString = Handle < String > ::Cast(propAr->Get(j));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove spaces in Handle < String > ::

String::Utf8Value propNameUTF(propString);
QString key = *propNameUTF;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the explicit fromUtf8 function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Local<Value> propValue = el->ToObject()->Get(propString);
Local<String> valueStr = propValue->ToString();
String::Utf8Value valueUTF(valueStr);
QString val = *valueUTF;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

dictionary.insert(std::make_pair(key, val));
}
}
else
{
//if the element of the dictionary is not object, it means dictionary contains invalid data
return NATIVE_ERROR_INVALID_ARG;
}
}
return NATIVE_ERROR_OK;
}
7 changes: 7 additions & 0 deletions blackberry/tibb/NativeControlObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ class NativeControlObject : public NativeObject
virtual int setText(TiObject* obj);
virtual int setTextAlign(TiObject* obj);
virtual int setTop(TiObject* obj);
virtual int setLeft(TiObject* obj);
virtual int setTitle(TiObject* obj);
virtual int setValue(TiObject* obj);
virtual int setVisible(TiObject* obj);
virtual int setWidth(TiObject* obj);
virtual int setHeight(TiObject* obj);
virtual int setData(TiObject* obj);
virtual int setOptions(TiObject* obj);
virtual int setSelectedIndex(TiObject* obj);
virtual int setImage(TiObject* obj);
Expand All @@ -45,6 +49,9 @@ class NativeControlObject : public NativeObject
static int getFloat(TiObject* obj, float* value);
static int getInteger(TiObject* obj, int* value);
static int getStringArray(TiObject* obj, QVector<QString>& value);
//obtain java script dictionary object and keep it in the multimap
static int getDictionaryData(TiObject* obj, std::multimap<QString, QString>& dictionary);

protected:
NativeControlObject();
virtual ~NativeControlObject();
Expand Down