JNIEXPORT void JNICALL Java_io_realm_internal_TableView_nativePivot(
    JNIEnv *env, jobject, jlong dataTablePtr, jlong stringCol, jlong intCol, jint operation, jlong resultTablePtr)
{

    try {
        TV(dataTablePtr)->sync_if_needed();
        TableView* dataTable = TV(dataTablePtr);
        Table* resultTable = TBL(resultTablePtr);
        Table::AggrType pivotOp;
        switch (operation) {
        case 0:
            pivotOp = Table::aggr_count;
            break;
        case 1:
            pivotOp = Table::aggr_sum;
            break;
        case 2:
            pivotOp = Table::aggr_avg;
            break;
        case 3:
            pivotOp = Table::aggr_min;
            break;
        case 4:
            pivotOp = Table::aggr_max;
            break;
        default:
            ThrowException(env, UnsupportedOperation, "No pivot operation specified.");
            return;
        }
        dataTable->aggregate(S(stringCol), S(intCol), pivotOp, *resultTable);
    } CATCH_STD()
}
static int lua_cocos2dx_TableView_setDataSource(lua_State* L)
{
    if (nullptr == L)
        return 0;

    int argc = 0;
    TableView* self = nullptr;

#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
    if (!tolua_isusertype(L,1,"cc.TableView",0,&tolua_err)) goto tolua_lerror;
#endif

    self = (TableView*)  tolua_tousertype(L,1,0);

#if COCOS2D_DEBUG >= 1
    if (nullptr == self)
    {
        tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_TableView_setDataSource'\n", nullptr);
        return 0;
    }
#endif

    argc = lua_gettop(L) - 1;

    if (0 == argc)
    {
        LUA_TableViewDataSource* dataSource = new (std::nothrow) LUA_TableViewDataSource();
        if (nullptr == dataSource)
            return 0;

        __Dictionary* userDict = static_cast<__Dictionary*>(self->getUserObject());
        if (nullptr == userDict)
        {
            userDict = new __Dictionary();
            if (NULL == userDict)
                return 0;

            self->setUserObject(userDict);
            userDict->release();
        }

        userDict->setObject(dataSource, KEY_TABLEVIEW_DATA_SOURCE);

        self->setDataSource(dataSource);

        dataSource->release();

        return 0;
    }

    luaL_error(L, "'setDataSource' function of TableView wrong number of arguments: %d, was expecting %d\n", argc, 0);
    return 0;

#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(L,"#ferror in function 'setDataSource'.",&tolua_err);
    return 0;
#endif
}
Beispiel #3
0
// on "init" you need to initialize your instance
bool TableViewTest::init()
{
    if ( !TestCase::init() )
    {
        return false;
    }

	Size winSize = Director::getInstance()->getWinSize();

    TableView* tableView = TableView::create(this, Size(250, 60));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Vec2(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, Size(60, 250));
	tableView->setDirection(ScrollView::Direction::VERTICAL);
	tableView->setPosition(Vec2(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	this->addChild(tableView);
	tableView->reloadData();

    return true;
}
// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::getInstance()->getWinSize();

    TableView* tableView = TableView::create(this, Size(250, 60));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Point(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, Size(60, 250));
	tableView->setDirection(ScrollView::Direction::VERTICAL);
	tableView->setPosition(Point(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(Point::ZERO);
	addChild(menuBack);

    return true;
}
Beispiel #5
0
bool
TableModel::setData(const QModelIndex &index,
                    const QVariant &value,
                    int role)
{
    if ( !index.isValid() ) {
        return false;
    }

    TableItem *itm = item(index);
    if (itm) {
        itm->setData(role, value);

        return true;
    }

    // don't create dummy table items for empty values
    if ( !value.isValid() ) {
        return false;
    }

    TableView *view = qobject_cast<TableView*>( QObject::parent() );
    if (!view) {
        return false;
    }

    itm = createItem();
    itm->setData(role, value);
    view->setItem(index.row(), index.column(), itm);

    return true;
}
// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::sharedDirector()->getWinSize();

    TableView* tableView = TableView::create(this, CCSizeMake(250, 60));
    tableView->setDirection(kScrollViewDirectionHorizontal);
    tableView->setPosition(ccp(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, CCSizeMake(60, 250));
	tableView->setDirection(kScrollViewDirectionVertical);
	tableView->setPosition(ccp(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(kTableViewFillTopDown);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(PointZero);
	addChild(menuBack);

    return true;
}
Beispiel #7
0
//显示选中的难度相对应的排名
void RankScene::showRank(Ref* pSender, Control::EventType controlEvent)
{

	SimpleAudioEngine::getInstance()->playEffect(music_click);

	int news = 3001;
	ControlButton* bt;
	for (int i = 3001; i <= 3003; i++)
	{
		bt = (ControlButton *)this->getChildByTag(i);
		if (bt == pSender)
		{
			news = i;
			break;
		}
	}
	if (news == selected) return;

	//放大选择难度
	this->getChildByTag(selected)->setScale(1.0f);
	this->getChildByTag(news)->setScale(1.1f);
	selected = news;

	//选择难度
	if (selected == 3001)		opt = "easy"; //简单
	else if (selected == 3002)	opt = "normal"; //普通
	else if (selected == 3003)	opt = "hard"; //困难

	//获取排名 CCTbaleView , tag = 3005
	TableView *tb = (TableView *)this->getChildByTag(3005);
	tb->reloadData();
}
Beispiel #8
0
bool SceneRule::init()
{
    if (!Layer::init()) {
        return false;
    }
    
    auto bg = KUtil::addSprite(this, KUtil::getPath(F_BG, "bg_3.png"), Point(HALF_WIDTH, 0), ANCHOR_CENTER_DOWN, 0);
    bg->setScale(KUtil::getScale(FULL_WIDTH, FULL_HEIGHT, bg->getContentSize(), true));
    
    Size size = Size(FULL_WIDTH-20, FULL_HEIGHT-160-10);
    auto tbg = GameTool::addTextBg(this, size, Point(10, 160), ANCHOR_LEFT_DOWN, 10);
    
    detailLabel = KUtil::addLabelConfig(tbg, DETAIL_POINT_MATCH, KUtil::getPath(F_FONT, "luoliti.ttf"), 30, Point(10, 10), Color4B(0, 0, 0, 255), ANCHOR_LEFT_DOWN, 10, Size(size.width-20, size.height-20), TextHAlignment::LEFT, TextVAlignment::TOP);
    
    Vector<MenuItem *> itemArray;
    
    GameTool::addBtn2(&itemArray, "返回", 32, Point(FULL_WIDTH-5, FULL_HEIGHT-5), ANCHOR_RIGHT_UP, CC_CALLBACK_1(SceneRule::callbackBack, this));
    
    KUtil::addMenu(this, &itemArray, 30);
    
    listQAKind.pushBack(QAKind::create(QAKIND_POINT_MATCH, "普通赛规则"));
    listQAKind.pushBack(QAKind::create(QAKIND_HUNDRED_MATCH, "冲百赛规则"));
    listQAKind.pushBack(QAKind::create(QAKIND_BIGTWO_RULE, "锄大地规则"));
    
    cellHeight = 160;
    cellWidth = 250;
    TableView* tableView = TableView::create(this, Size(FULL_WIDTH, cellHeight));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Point(0, 0));
    tableView->setDelegate(this);
    this->addChild(tableView, 100);
    tableView->reloadData();
    
    return true;
}
Beispiel #9
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    TableView w;
    w.initializetablewidget();
    w.show();
//+++++++++++++++++++++this is  main from the hash function
    return a.exec();
}
Beispiel #10
0
/** LuaStackSize TableView::currentIndex(lua_State *L)
 * include/mimas/TableView.h:93
 */
static int TableView_currentIndex(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    return self->currentIndex(L);
  } catch (std::exception &e) {
    lua_pushfstring(L, "currentIndex: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "currentIndex: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #11
0
/** QVariant QObject::property(const char *name)
 * bind/QObject.h:9
 */
static int TableView_property(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    const char *name = dub_checkstring(L, 2);
    return pushVariantInLua(L, self->property(name));
  } catch (std::exception &e) {
    lua_pushfstring(L, "property: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "property: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #12
0
	Table<LabelType> predict(const TableView<DataType> &samples) {
		std::vector<LabelType> predictions(samples.rowsNumber());

		#pragma omp parallel for
		for (size_t i = 0; i < samples.rowsNumber(); ++i) {
			predictions[i] = predict(samples[i]);
		}

		return Table<LabelType> (baseLabels.columnsNames(),
								 std::make_move_iterator(predictions.begin()),
								 std::make_move_iterator(predictions.end()));
	}
Beispiel #13
0
/** void QTableView::scrollToTop()
 * bind/QTableView.h:14
 */
static int TableView_scrollToTop(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    self->scrollToTop();
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "scrollToTop: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "scrollToTop: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #14
0
/** void QWidget::activateWindow()
 * bind/QWidget.h:35
 */
static int TableView_activateWindow(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    self->activateWindow();
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "activateWindow: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "activateWindow: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #15
0
/** QString QWidget::windowTitle()
 * bind/QWidget.h:40
 */
static int TableView_windowTitle(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    lua_pushstring(L, self->windowTitle().toUtf8());
    return 1;
  } catch (std::exception &e) {
    lua_pushfstring(L, "windowTitle: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "windowTitle: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #16
0
/** bool QWidget::isFullScreen()
 * bind/QWidget.h:36
 */
static int TableView_isFullScreen(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    lua_pushboolean(L, self->isFullScreen());
    return 1;
  } catch (std::exception &e) {
    lua_pushfstring(L, "isFullScreen: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "isFullScreen: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #17
0
/** int QWidget::height()
 * bind/QWidget.h:15
 */
static int TableView_height(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    lua_pushnumber(L, self->height());
    return 1;
  } catch (std::exception &e) {
    lua_pushfstring(L, "height: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "height: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #18
0
/** void QWidget::setFocus()
 * bind/QWidget.h:20
 */
static int TableView_setFocus(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    self->setFocus(Qt::OtherFocusReason);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setFocus: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setFocus: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #19
0
/** void QTableView::resizeColumnsToContents()
 * bind/QTableView.h:17
 */
static int TableView_resizeColumnsToContents(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    self->resizeColumnsToContents();
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "resizeColumnsToContents: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "resizeColumnsToContents: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #20
0
/** void QWidget::setStyleSheet(const char *text)
 * bind/QWidget.h:52
 */
static int TableView_setStyleSheet(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    const char *text = dub_checkstring(L, 2);
    self->setStyleSheet(text);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setStyleSheet: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setStyleSheet: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #21
0
/** void QWidget::setStyle(const char *text)
 * bind/QWidget.h:51
 */
static int TableView_setStyle(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    const char *text = dub_checkstring(L, 2);
    self->setStyleSheet(QString("%1 { %2 }").arg(self->metaObject()->className()).arg(text));
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setStyle: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setStyle: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #22
0
/** void QWidget::addAction(Action *action)
 * bind/QWidget.h:37
 */
static int TableView_addAction(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    Action *action = *((Action **)dub_checksdata(L, 2, "mimas.Action"));
    self->addAction(action);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "addAction: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "addAction: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #23
0
/** void QTableView::setModel(DataSource *model)
 * bind/QTableView.h:12
 */
static int TableView_setModel(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    DataSource *model = *((DataSource **)dub_checksdata(L, 2, "mimas.DataSource"));
    self->setModel(model);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setModel: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setModel: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #24
0
/** void QWidget::setFocusPolicy(int policy)
 * bind/QWidget.h:21
 */
static int TableView_setFocusPolicy(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    int policy = dub_checkint(L, 2);
    self->setFocusPolicy((Qt::FocusPolicy)policy);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setFocusPolicy: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setFocusPolicy: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #25
0
/** void QWidget::setParent(QWidget *parent)
 * bind/QWidget.h:16
 */
static int TableView_setParent(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    QWidget *parent = *((QWidget **)dub_checksdata(L, 2, "mimas.QWidget"));
    self->setParent(parent);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setParent: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setParent: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #26
0
/** void TableView::setEditTriggers(int triggers)
 * include/mimas/TableView.h:79
 */
static int TableView_setEditTriggers(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    int triggers = dub_checkint(L, 2);
    self->setEditTriggers(triggers);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setEditTriggers: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setEditTriggers: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #27
0
/** QString QObject::objectName() const
 * bind/QObject.h:7
 */
static int TableView_objectName(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    QByteArray str_(self->objectName().toUtf8());
    lua_pushlstring(L, str_.constData(), str_.size());
    return 1;
  } catch (std::exception &e) {
    lua_pushfstring(L, "objectName: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "objectName: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #28
0
/** void QWidget::setMouseTracking(bool enable)
 * bind/QWidget.h:28
 */
static int TableView_setMouseTracking(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    bool enable = dub_checkboolean(L, 2);
    self->setMouseTracking(enable);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setMouseTracking: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setMouseTracking: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #29
0
/** virtual void TableView::selectColumn(int row)
 * include/mimas/TableView.h:89
 */
static int TableView_selectColumn(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    int row = dub_checkint(L, 2);
    self->selectColumn(row);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "selectColumn: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "selectColumn: Unknown exception");
  }
  return dub_error(L);
}
Beispiel #30
0
	double operator () (const TableView<Label> &positive, const TableView<Label> &negative) {
		std::unordered_set<Label> labels;

		std::unordered_map<Label, size_t> positiveLabelCount;
		for (const auto &label : positive) {
			++positiveLabelCount[label];
			labels.insert(label);
		}

		std::unordered_map<Label, size_t> negativeLabelCount;
		for (const auto &label : negative) {
			++negativeLabelCount[label];
			labels.insert(label);
		}

		size_t samplesNumber = positive.rowsNumber() + negative.rowsNumber();
		double entropy = 0;
		double positivePart = positive.rowsNumber() * 1.0 / samplesNumber;
		double negativePart = negative.rowsNumber() * 1.0 / samplesNumber;

		for (const auto &label : labels) {
			size_t positiveClassSize = positiveLabelCount[label];
			size_t negativeClassSize = negativeLabelCount[label];
			size_t classSize = positiveClassSize + negativeClassSize;

			entropy += h(classSize * 1.0 / samplesNumber);
			if (positive.rowsNumber()) {
				entropy -= positivePart * h(positiveClassSize * 1.0 / positive.rowsNumber());
			}
			if (negative.rowsNumber()) {
				entropy -= negativePart * h(negativeClassSize * 1.0 / negative.rowsNumber());
			}
		}
		return entropy;
	}