コード例 #1
0
ファイル: classTable.cpp プロジェクト: ystk/debian-unixodbc
void classTable::selectionChanged( QListViewItem *p )
#endif
{
  // Determine if the selected item is a child of this table using the y coord, is there a better way?
#ifdef QT_V4LAYOUT
  Q3ListViewItem *n = nextSibling() ;
#else
  QListViewItem *n = nextSibling() ;
#endif
  int siblingPos = n ? n->itemPos() : 999999 ;
  int selectPos  = p ? p->itemPos() : 0      ;
  int thisPos    =        itemPos()          ;

  if ( thisPos <= selectPos && selectPos < siblingPos )
  {
    if ( !pBrowse )
      pBrowse = new classBrowseFrame( hDbc, qsTable, qsLibrary, pCanvas );
    pBrowse->show();
  }
  else
  {
    if ( pBrowse )
      pBrowse->hide();
  }
}
コード例 #2
0
ファイル: RowCollection.cpp プロジェクト: Myasuka/scidb
void RowCollection<Group,Hash>::getChunkIterators(vector<boost::shared_ptr<ChunkIterator> >& chunkIterators, size_t rowId) {
    Coordinates chunkPos(2);
    chunkPos[0] = rowId;
    chunkPos[1] = (_counts[rowId] / _chunkSize) * _chunkSize;

    if (isLastChunkFull(rowId)) {
        int chunkMode = ChunkIterator::SEQUENTIAL_WRITE;
        for (size_t i=0; i<_attributes.size(); ++i) {
            ScopedMutexLock lock(_mutexArrayIterators);
            Chunk& chunk = _arrayIterators[i]->newChunk(chunkPos, 0);
            chunkIterators[i] = chunk.getIterator(_query, chunkMode);
            chunkMode |= ChunkIterator::NO_EMPTY_CHECK;
        }
    }
    else {
        Coordinates itemPos(2);
        itemPos[0] = rowId;
        itemPos[1] = _counts[rowId];
        int chunkMode = ChunkIterator::APPEND_CHUNK;
        for (size_t i=0; i<_attributes.size(); ++i) {
            ScopedMutexLock lock(_mutexArrayIterators);
            _arrayIterators[i]->setPosition(chunkPos);
            Chunk& chunk = _arrayIterators[i]->updateChunk();
            chunkIterators[i] = chunk.getIterator(_query, chunkMode);
            chunkMode |= ChunkIterator::NO_EMPTY_CHECK; // no empty check except for attribute 0
            chunkIterators[i]->setPosition(itemPos);
        }
    }
}
コード例 #3
0
ファイル: popupmenueditor.cpp プロジェクト: aroraujjwal/qt3
void PopupMenuEditor::showSubMenu()
{
    if ( currentIndex < (int)itemList.count() ) {
	itemList.at( currentIndex )->showMenu( pos().x() + width() - borderSize * 3,
					       pos().y() + itemPos( at( currentIndex ) ) +
					       borderSize * 2 );
	setFocus(); // Keep focus in this widget
    }
}
コード例 #4
0
void PropertyEditor::moveEditor() {
    if (!m_currentEditor)
        return;

    QPoint p = contentsToViewport(QPoint(0, itemPos(m_editItem)));
    m_currentEditor->move(m_currentEditor->x(), p.y());

    if (m_defaults->isVisible())
        m_defaults->move(m_defaults->x(), p.y());
}
コード例 #5
0
int
KexiRelationsTableFieldList::globalY(const QString &item)
{
    Q3ListViewItem *i = findItem(item, 0);
    if (!i)
        return -1;
    int y = itemRect(i).y() + (itemRect(i).height() / 2);
    if (contentsY() > itemPos(i))
        y = 0;
    else if (y == 0)
        y = height();
    return mapToGlobal(QPoint(0, y)).y();
}
コード例 #6
0
ファイル: popupmenueditor.cpp プロジェクト: aroraujjwal/qt3
void PopupMenuEditor::showLineEdit( int index )
{
    int idx = ( index == -1 ? currentIndex : index );

    PopupMenuEditorItem * i = 0;

    if ( idx >= (int)itemList.count() )
	i = &addItem;
    else
	i = itemList.at( idx );

    // open edit currentField for item name
    lineEdit->setText( i->action()->menuText() );
    lineEdit->selectAll();
    lineEdit->setGeometry( borderSize + iconWidth, borderSize + itemPos( i ),
			   textWidth, itemHeight( i ) );
    lineEdit->show();
    lineEdit->setFocus();
}
コード例 #7
0
int
KexiRelationsTableFieldList::globalY(const QString &item)
{
    QAbstractItemModel *themodel = model();
    QModelIndex idx;

    for (int i = 0; i < themodel->rowCount(); ++i) {
        idx = themodel->index(i, 0);
        QVariant data = themodel->data(idx);
        if (data.toString() == item) {
            break;
        }
    }

    if (idx.isValid()) {
        QRect r = this->rectForIndex(idx);
        int y = r.y() + r.height()/2;

        //Not sure what this line is supposed to do...is it to check if the item is visible?
        if (visualRect(idx).y() > viewport()->height()) {
            y = 0;
        } else if (y == 0) {
            y = height();
        }
        return mapToGlobal(QPoint(0, y)).y();
    }
    return -1;

#if 0
    QModelIndexList list = themodel->match()
                           Q3ListViewItem *i = findItem(item, 0);
    if (!i)
        return -1;
    int y = itemRect(i).y() + (itemRect(i).height() / 2);
    if (contentsY() > itemPos(i))
        y = 0;
    else if (y == 0)
        y = height();
    return mapToGlobal(QPoint(0, y)).y();

#endif
}
コード例 #8
0
ファイル: World.cpp プロジェクト: emdeha/floyd
void World::InitItemFromFile(const std::string &fileName)
{
	int itemDamage = 0;
	int itemDefense = 0;
	int itemHealth = 0;
	ItemAttribute itemAttribute = ATTRIB_NONE;
	std::string itemName;
	Position itemPos(0, 0);

	std::ifstream item(ResolveFileName(fileName, DIR_ENTITIES));

	if (item.is_open())
	{
		std::string itemField;
		while (std::getline(item, itemField).good())
		{
			auto statPair = GetItemStatPairFromField(itemField);

			std::string statID = statPair.first;
			std::string statVal = statPair.second;
			if (statID == "damage")
			{
				SafeLexicalCast<int>(statVal, itemDamage);
			}
			else if (statID == "defense")
			{
				SafeLexicalCast<int>(statVal, itemDefense);
			}
			else if (statID == "health")
			{
				SafeLexicalCast<int>(statVal, itemHealth);
			}
			else if (statID == "name")
			{
				itemName = statVal;
			}
			else if (statID == "attrib")
			{
				if (statVal == "PARTICLE")
				{
					itemAttribute = ATTRIB_PARTICLE;
				}
			}
			else if (statID == "position")
			{
				size_t delimPos = statVal.find(',');
				SafeLexicalCast<int>(statVal.substr(0, delimPos), itemPos.x);
				SafeLexicalCast<int>(statVal.substr(delimPos + 1), itemPos.y);
			}
		}
	}

	item.close();

	assert(levels[currentLevelIdx].GetSpriteAtPosition(itemPos) == 'O' ||
		   levels[currentLevelIdx].GetSpriteAtPosition(itemPos) == 'I');

	bool isBuff = levels[currentLevelIdx].GetSpriteAtPosition(itemPos) == 'I' ? true : false;

	Item newItem(itemName, itemDefense, itemDamage, itemHealth, itemAttribute, itemPos, true, isBuff);
	
	itemsInCurrentLevel.push_back(newItem);
}
コード例 #9
0
void MonitorFixturePropertiesEditor::slotSetPosition()
{
    QPointF itemPos(m_xPosSpin->value() * 1000, m_yPosSpin->value() * 1000);
    m_fxItem->setPos(m_gfxView->realPositionToPixels(itemPos.x(), itemPos.y()));
    m_props->setFixturePosition(m_fxItem->fixtureID(), itemPos);
}
コード例 #10
0
void GridLayout::performLayout(NVGcontext *ctx, Widget *widget) const {
    Vector2i fs_w = widget->fixedSize();
    Vector2i containerSize(
        fs_w[0] ? fs_w[0] : widget->width(),
        fs_w[1] ? fs_w[1] : widget->height()
    );

    /* Compute minimum row / column sizes */
    std::vector<int> grid[2];
    computeLayout(ctx, widget, grid);
    int dim[2] = { (int) grid[0].size(), (int) grid[1].size() };

    Vector2i extra = Vector2i::Zero();
    if (dynamic_cast<Window *>(widget))
        extra[1] += widget->theme()->mWindowHeaderHeight - mMargin / 2;

    /* Strech to size provided by \c widget */
    for (int i = 0; i < 2; i++) {
        int gridSize = 2 * mMargin + extra[i];
        for (int s : grid[i]) {
            gridSize += s;
            if (i+1 < dim[i])
                gridSize += mSpacing[i];
        }

        if (gridSize < containerSize[i]) {
            /* Re-distribute remaining space evenly */
            int gap = containerSize[i] - gridSize;
            int g = gap / dim[i];
            int rest = gap - g * dim[i];
            for (int j = 0; j < dim[i]; ++j)
                grid[i][j] += g;
            for (int j = 0; rest > 0 && j < dim[i]; --rest, ++j)
                grid[i][j] += 1;
        }
    }

    int axis1 = (int) mOrientation, axis2 = (axis1 + 1) % 2;
    Vector2i start = Vector2i::Constant(mMargin) + extra;

    size_t numChildren = widget->children().size();
    size_t child = 0;

    Vector2i pos = start;
    for (int i2 = 0; i2 < dim[axis2]; i2++) {
        pos[axis1] = start[axis1];
        for (int i1 = 0; i1 < dim[axis1]; i1++) {
            Widget *w = nullptr;
            do {
                if (child >= numChildren)
                    return;
                w = widget->children()[child++];
            } while (!w->visible());

            Vector2i ps = w->preferredSize(ctx);
            Vector2i fs = w->fixedSize();
            Vector2i targetSize(
                fs[0] ? fs[0] : ps[0],
                fs[1] ? fs[1] : ps[1]
            );

            Vector2i itemPos(pos);
            for (int j = 0; j < 2; j++) {
                int axis = (axis1 + j) % 2;
                int item = j == 0 ? i1 : i2;
                Alignment align = alignment(axis, item);

                switch (align) {
                    case Alignment::Minimum:
                        break;
                    case Alignment::Middle:
                        itemPos[axis] += (grid[axis][item] - targetSize[axis]) / 2;
                        break;
                    case Alignment::Maximum:
                        itemPos[axis] += grid[axis][item] - targetSize[axis];
                        break;
                    case Alignment::Fill:
                        targetSize[axis] = fs[axis] ? fs[axis] : grid[axis][item];
                        break;
                }
            }
            w->setPosition(itemPos);
            w->setSize(targetSize);
            w->performLayout(ctx);
            pos[axis1] += grid[axis1][i1] + mSpacing[axis1];
        }
        pos[axis2] += grid[axis2][i2] + mSpacing[axis2];
    }
}
コード例 #11
0
void GameCore::initializeItems()
{
    if(mapMode)
    {
        MapReader* mapReader = mazeBuilder->getMapReader();
        int itemId = 0;
        if (mapReader != NULL)
        {
            float scaleFactor = mapReader->getScaleFactor();
            MapEntity2_t* ent;
            std::string meshName="LaserRifle.mesh";
            std::string materialName="LaserRifleItem";
            Ogre::Vector3 meshScale(2,2,2);
            while ((ent = mapReader->getItem()) != NULL)
            {
                if (ent->type == ItemType::LASER_MACHINE_GUN)
                {
                    meshName = "LaserRifle.mesh";
                    materialName = "LaserRifleItem";
                    meshScale=Ogre::Vector3(2,2,2);
                }
                else if(ent->type==ItemType::LASER_PISTOL)
                {
                    meshName="cube.mesh";
                    materialName="LaserPistolItem";
                    meshScale=Ogre::Vector3(.05,.05,.05);
                }
                else if(ent->type==ItemType::EAGLE_EYE)
                {
                    meshName="EagleEye.mesh";
                    materialName="NULL";
                    meshScale=Ogre::Vector3(4,4,4);
                }
                else if(ent->type==ItemType::EXTRA_HEALTH)
                {
                    meshName="Medkit.mesh";
                    materialName="NULL";
                    meshScale=Ogre::Vector3(12,12,12);
                }
				else if(ent->type==ItemType::IMMORTALITY)
				{
					meshName="Immortality.mesh";
					materialName="NULL";
					meshScale=Ogre::Vector3(10,10,10);
				}
				else if(ent->type==ItemType::ONE_SHOT)
				{
					meshName="OneShot.mesh";
					materialName="NULL";
					meshScale=Ogre::Vector3(15,15,15);
				}
                else
                {
                    Logger::getSingleton()->addLine("GameCore: unidentified item read", true);
                    continue;
                }
				Ogre::Vector3 itemPos(-ent->entityPosition.startX*scaleFactor,0,ent->entityPosition.startZ*scaleFactor);
				Ogre::Vector3 startPos=itemPos;
				Ogre::Vector3 endPos=itemPos;
				startPos.y=mazeBuilder->getWallHeight()-10;
				endPos.y=-100;
				btCollisionObject object;
				Ogre::Vector3 hitPos;
				if(PhysicsHandler::performRaycastTest(startPos,endPos,dynamics,&object,&hitPos))
				{
					CollisionObjectInfo* info=(CollisionObjectInfo*)object.getUserPointer();
					std::cout<<"type: "<<info->getObjectType()<<std::endl;
					if(info->getObjectType()==CollisionObjectTypes::GROUND || info->getObjectType()==CollisionObjectTypes::STATIC_OBJECT)
						itemPos.y=hitPos.y;
					else if(info->getObjectType()==CollisionObjectTypes::WALL)
					{
						Logger::getSingleton()->addLine("GameCoreInitializer: item-wall collision detected; item removed",true);
						continue;
					}
				}
				itemPos.y+=10;
                createItem(itemId++, (ItemType::ItemTypes)ent->type, meshName, materialName, meshScale, itemPos);
            }
        }
    }
}