Example #1
0
void GameScene::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent){
    CCPoint pos = pTouch->getLocationInView();
    pos = CCDirector::sharedDirector()->convertToGL(pos);
    
    if (lastPressedItem >= 0 && lastPressedItem == Utils::buttonHitTest(pos, buttonArray)) {
        AniButton *btn = (AniButton*)buttonArray->objectAtIndex(lastPressedItem);
        btn->click();
        clickItem(btn->getAniButtonBid());
    }
}
Example #2
0
void FavoriteMenu::load(QMenu *menu, bool download)
{
    //一旦クリア
    menu->clear();

    QAction *action;
    QByteArray data;
    QFile file(FAVORITE_DOWNLOAD_FILE);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
    }else{
        QTextStream in(&file);
        in.setCodec("UTF-8");
        while(!in.atEnd()){
            data.append(in.readLine());
        }
        file.close();

        QJsonDocument json = QJsonDocument::fromJson(data);
        QJsonArray array = json.object().value("root").toArray();
        //フォルダ
        for(int i=0; i<array.count(); i++){
            //アイテム
            if(TO_VALUE(array.at(i), "array").isArray()){
                addItem(menu, TO_ARRAY(array.at(i)));
            }else{
//            qDebug() << "title:" << TO_STRING(array->at(i), KEY_TITLE);
                action = menu->addAction(TO_STRING(array.at(i), KEY_TITLE), this, SLOT(clickItem()));
                action->setData(TO_STRING(array.at(i), KEY_URL));
            }
        }

        //現状のデータの日付を保存
        m_currentLoadedFavDataDate = QDate::fromString(json.object().value("serial").toString().left(8), "yyyyMMdd");
//        qDebug() << json.object().value("serial").toString().left(8);
//        qDebug() << "serial=" << serial << "," << serial.toJulianDay();
//        qDebug() << "today =" << QDate::currentDate() << "," << QDate::currentDate().toJulianDay();

    }

    //ユーザー登録ぶん
    QSettings settings(FAV_FILE_NAME, FAV_FILE_FORMAT);
    settings.beginGroup(QStringLiteral(FAV_USER));
    QHash<QString, QVariant> list = settings.value(QStringLiteral(FAV_USER_BOOKMARK)).toHash();
    foreach (const QString &key, list.keys()) {
        action = menu->addAction(list.value(key).toString(), this, SLOT(clickItem()));
        action->setData(key);
    }
    settings.endGroup();


    //お気に入りをダウンロード
    if(download){
        updateFromInternet();
    }
}
Example #3
0
void ListView::contentsMouseReleaseEvent(QMouseEvent *e)
{
#if QT_VERSION < 300
    m_mousePressPos = QPoint(0, 0);
#endif
    QListView::contentsMouseReleaseEvent(e);
    if (m_pressedItem){
        QListViewItem *item = m_pressedItem;
        m_pressedItem = NULL;
        item->repaint();
        QListViewItem *citem = itemAt(contentsToViewport(e->pos()));
        if (item == citem)
            emit clickItem(item);
    }
}
int PerButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QPushButton::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: clickItem((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 1: showItem(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Example #5
0
bool FavoriteMenu::addItem(QMenu *parent, const QJsonArray &array)
{
    QMenu *me;
    QAction *action;

    if(array.count() < 2)
        return false;

    //フォルダ
//    qDebug() << "folder:" << TO_STRING(array->at(0), KEY_TITLE) << " - " << array->count();
    me = parent->addMenu(TO_STRING(array.at(0), KEY_TITLE));
    for(int i=1; i<array.count(); i++){
        //アイテム
        if(TO_VALUE(array.at(i), "array").isArray()){
            addItem(me, TO_ARRAY(array.at(i)));
        }else{
//            qDebug() << "title:" << TO_STRING(array->at(i), KEY_TITLE);
            action = me->addAction(TO_STRING(array.at(i), KEY_TITLE), this, SLOT(clickItem()));
            action->setData(TO_STRING(array.at(i), KEY_URL));
        }
    }

    return true;
}
Example #6
0
void MenuSystem::handleMouseClick(int x, int y) {
	if (!_editingDescription) {
		ItemID id = findItemAt(x, y);
		clickItem(id);
	}
}
Example #7
0
void MyListWidget::mousePressEvent( QMouseEvent * event  ) {
    QPoint pos = event->pos();
    QPersistentModelIndex index = indexAt(pos);

    QString path = index.data(ROLE_ITEM_PATH).toString();
    if(event->button() != Qt::LeftButton){
        QPoint globalPos = QWidget::mapToGlobal(pos);
        emit showOptionsMenu(path,globalPos);
        //emit pressed(index);
        return;

    }

    //Later...
    //if(event->button() == Qt::RightButton){ }

    QRect containingRect = this->geometry();
    containingRect.setHeight(UI_DEFAULT_ITEM_HEIGHT);
    containingRect.moveTop(0);

    QRect pinRect = IconDelegate::getPinItemRect(containingRect);
    QListWidgetItem*  listWidgetItem = item(index.row());

    QPoint localPos = pos;
    localPos.setY(pos.y() % UI_DEFAULT_ITEM_HEIGHT);

    if(pinRect.contains(localPos)){
        CatItem pinItem(addPrefix(OPERATION_PREFIX,PIN_OPERATION_NAME));

        if(!(listWidgetItem->data((ROLE_ITEM_PINNED)).toBool())){
            listWidgetItem->setData((ROLE_ITEM_PINNED),true);
        } else {listWidgetItem->setData((ROLE_ITEM_PINNED),false);}

        //emit listItemAction(path, pinItem);
        //frickin signal not going through
        gMainWidget->operateOnItem(path,pinItem);
        return;
    }

    QRect childRect = IconDelegate::getChildArrowRect(containingRect);
    if(childRect.contains(pos)){
        listWidgetItem->setSelected(true);
        setCurrentRow(index.row());
        CatItem clickItem(addPrefix(OPERATION_PREFIX,GOTO_CHILD_OPERATION));
        gMainWidget->operateOnItem(path,clickItem);
        return;
    }

    QRect depRect = IconDelegate::getDepricateItemRect(containingRect);
    if(depRect.contains(localPos)){
        CatItem depricateItem(addPrefix(OPERATION_PREFIX,DEPRICATE_OPERATION_NAME));
        //emit listItemAction(path, depricateItem);
        //fickin signals not going through...
        gMainWidget->operateOnItem(path,depricateItem);
        return;
    }
    if(listWidgetItem){
        listWidgetItem->setSelected(true);
        setCurrentRow(index.row());
        CatItem clickItem(addPrefix(OPERATION_PREFIX,SELECTION_OPERATION_NAME));
        gMainWidget->operateOnItem(path,clickItem);
    }

}
Example #8
0
void MyListWidget::itemChanged( QListWidgetItem * n , QListWidgetItem * ){
     QModelIndex index = this->indexFromItem(n);
     QString path = index.data(ROLE_ITEM_PATH).toString();
     CatItem clickItem(addPrefix(OPERATION_PREFIX,SELECTION_OPERATION_NAME));
     gMainWidget->operateOnItem(path,clickItem);
}