예제 #1
0
aJsonObject*
aJsonClass::createDoubleArray(double *numbers, unsigned char count)
{
  unsigned char i;
  aJsonObject *n = 0, *p = 0, *a = createArray();
  for (i = 0; a && i < count; i++)
    {
      n = createItem(numbers[i]);
      if (!i)
        a->child = n;
      else
        suffixObject(p, n);
      p = n;
    }
  return a;
}
예제 #2
0
/*!
  \fn void PhoneLauncherView::setCurrentItem(int idx)
  Causes the item positioned at the given index to become the current item. If \a idx is
  invalid, no change will occur.
  \a idx: The index of a GridItem object.
*/
void PhoneLauncherView::setCurrentItem(int idx)
{
    if ( selectedItem ) {
        // Calculate the row and column of the required item according to the index.
        int row, column;
        rowAndColumn(idx,row,column);

        // Make sure we've actually got an item for that row and column, even if it's
        // an item with empty content.
        GridItem *item = selectedItem->item(row,column);
        if ( !item ) {
            item = createItem(0,row,column);
        }

        selectedItem->setCurrent(item,false); // 2nd param means no animation
    }
}
예제 #3
0
파일: listbox.cpp 프로젝트: berenm/xoreos
const std::vector<KotORWidget *> &WidgetListBox::createItemWidgets(uint count) {
	if (!_protoItem)
		throw Common::Exception("ListBox widget has no PROTOITEM");

	const int64 itemHeight = _protoItem->getStruct("EXTENT").getSint("HEIGHT");

	uint widgetCount = count;
	if ((count == 0) && (itemHeight > 0))
		widgetCount = getHeight() / itemHeight;

	for (uint i = 0; i < widgetCount; ++i) {
		Common::UString name = Common::UString::format("%s_ITEM_%u", _tag.c_str(), i);
		createItem(name);
	}

	return _itemWidgets;
}
예제 #4
0
void ObjectsScene::updateRadius(int id, BaseType r)
{
    auto obj = m_objects.find(id);
    assert(obj != m_objects.end());

    QGraphicsItem* item = createItem(r);
    item->setData(ObjectData::Id, id);
    item->setData(ObjectData::Radius, r);

    const QPointF pos = obj->second->pos();
    item->setPos(pos);

    // swap items
    removeItem(obj->second);
    delete obj->second;
    obj->second = item;
}
예제 #5
0
bool MgRecordShape::load(MgShapeFactory* factory, MgStorage* s)
{
    _clear();
    
    _sid = s->readInt("refid", _sid);
    for (int i = 0; s->readNode("p", i, false); i++) {
        ICmd* item = createItem(s->readInt("type", 0));
        
        if (item && item->load(s)) {
            _items.push_back(item);
        } else {
            delete item;
        }
        s->readNode("p", i, true);
    }
    return _load(factory, s);
}
예제 #6
0
void QProjectPropertiesDialog::createIcons()
{
    map.insert(createItem(contentsWidget,tr("General")),pagesWidget->widget(0));
    map.insert(createItem(contentsWidget,tr("Compiler")),pagesWidget->widget(1));

    QTreeWidgetItem *configButton = createItem(contentsWidget,tr("Windows Types"));
    map.insert(configButton,pagesWidget->widget(2));

    map.insert(createItem(configButton,tr("Buttons")),pagesWidget->widget(3));
    map.insert(createItem(configButton,tr("Position")),pagesWidget->widget(4));
    map.insert(createItem(configButton,tr("Navgation Panel")),pagesWidget->widget(5));
    map.insert(createItem(configButton,tr("Styles")),pagesWidget->widget(6));

    map.insert(createItem(contentsWidget,tr("Merge Files")),pagesWidget->widget(7));

    connect(contentsWidget,
            SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
            this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem*)));
}
예제 #7
0
MenuMain::MenuMain(){
	AG_Box * item;

	// nadpis
	createHeading("Nabídka dne");
	// TODO resume to game

	// new game
	item = createItem("New game");
	AG_SetEvent(item, "window-mousebuttondown", MenuNewGame::create, 0);

	// load game
	item = createItem("Load game");
	AG_SetEvent(item, "window-mousebuttondown", MenuLoadGame::create, 0);

	// TODO save game

	// deathmatch
	item = createItem("Deathmatch");
	AG_SetEvent(item, "window-mousebuttondown", MenuDeathmatch::create, 0);

	// creatures
	item = createItem("Creatures");
	AG_SetEvent(item, "window-mousebuttondown", MenuCreatures::create, 0);
	// bonuses
	item = createItem("Bonuses");
	AG_SetEvent(item, "window-mousebuttondown", MenuBonuses::create, 0);
	// credits
	item = createItem("Credits");
	AG_SetEvent(item, "window-mousebuttondown", MenuCredits::create, 0);

	// options
	item = createItem("Options");
	AG_SetEvent(item, "window-mousebuttondown", MenuOptions::create, 0);

	// quit
// 	AG_SpacerNewHoriz(win);
	item = createItem("Quit");
	AG_SetEvent(item, "window-mousebuttondown", handlerBack, 0);

	AG_SpacerNewHoriz(win);
}
예제 #8
0
void OfflineFirstFit(ListP listPtr, int *allItems, int itemsInRun){
	int j, currentItem, currentBin;
	ItemP item;

	// sort allItems
	mergeSort(allItems, itemsInRun);

	// create items and pack
	rewind(fpBins); // ensure every algorithm starts with the same Bin
	fscanf(fpBins, "%d", &currentBin);
	addBinToList(listPtr, currentBin);
	for (j = 0; j < itemsInRun; j++){
		currentItem = allItems[j];
		item = createItem(currentItem);
		FirstFit(listPtr, item);
	}
	return;
}
예제 #9
0
void HistoryController::updateForRedirectWithLockedBackForwardList()
{
#if !LOG_DISABLED
    if (m_frame->loader()->documentLoader())
        LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame->loader()->documentLoader()->title().utf8().data());
#endif
    
    Settings* settings = m_frame->settings();
    bool needPrivacy = !settings || settings->privateBrowsingEnabled();
    const KURL& historyURL = m_frame->loader()->documentLoader()->urlForHistory();

    if (m_frame->loader()->documentLoader()->isClientRedirect()) {
        if (!m_currentItem && !m_frame->tree()->parent()) {
            if (!historyURL.isEmpty()) {
                updateBackForwardListClippedAtTarget(true);
                if (!needPrivacy) {
                    m_frame->loader()->client()->updateGlobalHistory();
                    m_frame->loader()->documentLoader()->setDidCreateGlobalHistoryEntry(true);
                    if (m_frame->loader()->documentLoader()->unreachableURL().isEmpty())
                        m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
                }
                if (Page* page = m_frame->page())
                    page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForward()->currentItem());
            }
        }
        if (m_currentItem) {
            m_currentItem->setURL(m_frame->loader()->documentLoader()->url());
            m_currentItem->setFormInfoFromRequest(m_frame->loader()->documentLoader()->request());
        }
    } else {
        Frame* parentFrame = m_frame->tree()->parent();
        if (parentFrame && parentFrame->loader()->history()->m_currentItem)
            parentFrame->loader()->history()->m_currentItem->setChildItem(createItem(true));
    }

    if (!historyURL.isEmpty() && !needPrivacy) {
        if (Page* page = m_frame->page())
            addVisitedLink(page, historyURL);

        if (!m_frame->loader()->documentLoader()->didCreateGlobalHistoryEntry() && m_frame->loader()->documentLoader()->unreachableURL().isEmpty() && !m_frame->loader()->url().isEmpty())
            m_frame->loader()->client()->updateGlobalHistoryRedirectLinks();
    }
}
예제 #10
0
void PopupMenuEditor::enterEditMode( QKeyEvent * e )
{
    PopupMenuEditorItem * i = currentItem();

    if ( i == &addSeparator ) {
	i = createItem( new QSeparatorAction( 0 ) );
    } else if ( i->isSeparator() ) {
	return;
    } else if ( currentField == 0 ) {
	choosePixmap();
    } else if ( currentField == 1 ) {
	showLineEdit();
	return;
    } else {// currentField == 2
	setAccelerator( e->key(), e->state() );
    }
    showSubMenu();
    return;
}
예제 #11
0
/**
 *\fn           void runSftp(const char *path)
 *\brief        运行SFTP客户端
 *\param[in]    const char * path
 *\return       void 无
 */
void CBrowseWnd::runSftp(const char *path)
{
    _beginthread(sftp_thread_func, 0, &ssh_param_);

    // 等待连接完成
    for (int i = 0; i < 100; i++)
    {
        if (NULL != ssh_param_.channel) break;
        Sleep(100);
    }

    if (NULL == path) return;

    HTREEITEM item = createItem(path);

    updateFileList(item);

    processExpand_ = true;
}
예제 #12
0
    void shouldListTagItems()
    {
        // GIVEN
        auto data = Testlib::AkonadiFakeData();
        auto t1 = Akonadi::Tag(42);
        t1.setName(QStringLiteral("42"));
        data.createTag(t1);

        auto i1 = Akonadi::Item(42);
        i1.setPayloadFromData("42");
        i1.setTag(Akonadi::Tag(42));

        // WHEN
        data.createItem(i1);

        // THEN
        QCOMPARE(data.tagItems(t1.id()).size(), 1);
        QCOMPARE(data.tagItems(t1.id()).at(0), i1);
    }
예제 #13
0
    void shouldListChildItems()
    {
        // GIVEN
        auto data = Testlib::AkonadiFakeData();
        auto c1 = Akonadi::Collection(42);
        c1.setName(QStringLiteral("42"));
        data.createCollection(c1);

        auto i1 = Akonadi::Item(42);
        i1.setPayloadFromData("42");
        i1.setParentCollection(Akonadi::Collection(42));

        // WHEN
        data.createItem(i1);

        // THEN
        QCOMPARE(data.childItems(c1.id()).size(), 1);
        QCOMPARE(data.childItems(c1.id()).at(0), i1);
    }
예제 #14
0
void CSceneExplorer::update(const CNodeChangeInfo &change)
{
	QStandardItem *item;

	if(change.getInfoType() == CNodeChangeInfo::ENCIT_CREATED)
	{
		ENodeType type = change.getType();

		QStandardItem *parentItem = 0;
		item = createItem(change.getId(), type, QString(change.getName().c_str()));

		m_idToItemMap[change.getId()] = item;

		if(type & PROP_BIT)
		{
			parentItem = m_propItem;
		}
		else if(type & LOGIC_BIT)
		{
			parentItem = m_logicItem;
		}
		else if(type == ENT_LIGHT)
		{
			parentItem = m_lightItem;
		}
		else if(type == ENT_MAP)
		{
			parentItem = m_mapItem;
		}

		if(parentItem)
		{
			parentItem->appendRow(item);
		}
	}
	else if(change.getInfoType() == CNodeChangeInfo::ENCIT_REMOVED)
	{
		item = m_idToItemMap[change.getId()];
		removeStandardItem(item);
		m_idToItemMap.erase(change.getId());
	}
}
예제 #15
0
	void BFCBlockManager::createItem(BFCCullableObject *object, BlockID &blockID, ItemID &itemId)
	{
		
		if (_blocksNotFull.empty() == false)
		{
			auto b = *(_blocksNotFull.begin());
			auto &block = _blocks[b];
			itemId = block->createItem(object);
			blockID = std::uint8_t(b);
			if (block->isFull())
			{
				_blocksNotFull.erase(_blocksNotFull.begin());
			}
			return;
		}
		_blocks.push_back(std::make_shared<BFCBlock>());
		AGE_ASSERT(_blocks.size() < MaxBlockID);
		_blocksNotFull.insert(_blocks.size() - 1);
		createItem(object, blockID, itemId);
	}
예제 #16
0
void ItemSpawningLogic::tick2() {
    if(ItemExisting == true) {
        spawnCountdown -= 1;

        // the feature item shall be deleted after a given time
        if(spawnCountdown <= 0) {
                removeItemFromRandomShooter();
        }
    }

    else {
        // create a feature item after a random number of clock ticks
        int randomcreation = rand() % 10;

        if(randomcreation == 0) {
            createItem();
            resetSpawnCountdown();
        }
    }
}
void QDeclarativeGeoMapObjectView::modelRowsInserted(QModelIndex, int start, int end)
{
    if (!componentCompleted_ || !map_ || !map_->mapData_ || !delegate_ || !model_)
        return;
    Q_ASSERT(declarativeObjectList_.count() == group_.childObjects().count());
    QDeclarativeGeoMapObject* mapObject;
    for (int i = start; i <= end; ++i) {
        mapObject = createItem(i);
        if (!mapObject) {
            break;
        }
        declarativeObjectList_.append(mapObject);
        mapObject->setVisible(visible_);
        mapObject->setMap(map_);
        group_.addChildObject(mapObject->mapObject());
        // Needed in order for mouse areas to work.
        map_->objectMap_.insert(mapObject->mapObject(), mapObject);
    }
    Q_ASSERT(declarativeObjectList_.count() == group_.childObjects().count());
}
예제 #18
0
void RunInfoTree::parseFolderElement(const QDomElement &element,
								  QTreeWidgetItem *parentItem)
{
	QTreeWidgetItem *item = createItem(element, parentItem);
	QDomElement child = element.firstChildElement();
	item->setFlags(item->flags() | Qt::ItemIsEditable);
	item->setText(0, element.tagName());
	item->setText(1, element.attribute("value"));	
	if(child.isNull()){
		item->setIcon(0, bookmarkIcon);
		item->setText(1,element.attribute("value"));
		return;
	}
	item->setIcon(0, folderIcon);
		
	while (!child.isNull()) {
		parseFolderElement(child,item); //recursive call
		child = child.nextSiblingElement();		
	}
}
예제 #19
0
void insertIt(Item **base, char *name, char *desc, int price, char *shelf, int amount) {
  
  Item **item = &(*base);
  int size = itemCount(base);
  int c = 0;
  Item **items[size];
  
  while((*item) != NULL) {
    items[c] = item;
    if (strcmp(name, (*item)->name) < 0) {
      item = &(*item)->left;
    } else if (strcmp(name, (*item)->name) > 0) {
      item = &(*item)->right;
    } else if (strcmp(name, (*item)->name) == 0) {
      addToShelves((*item)->shelves, shelf, amount);
      break;
    }
    
    ++c;
    
  }
  
  if ((*item) == NULL) {
    (*item) =  createItem(name, desc, price, shelf, amount);
  }
  
  for (int i = c; i >= 0; i--) {

    (*item)->height = max(getHeight((*item)->left), getHeight((*item)->right)) +1;

    int balanceFactor = getBalance(*item);
  
    if (balanceFactor < -1 || balanceFactor > 1) {
      balance(item, name, balanceFactor);
    }

  }


}
예제 #20
0
void HistoryController::updateForRedirectWithLockedBackForwardList()
{
#if !LOG_DISABLED
    if (m_frame.loader().documentLoader())
        LOG(History, "WebCoreHistory: Updating History for redirect load in frame %s", m_frame.loader().documentLoader()->title().string().utf8().data());
#endif
    
    bool needPrivacy = m_frame.page()->usesEphemeralSession();
    const URL& historyURL = m_frame.loader().documentLoader()->urlForHistory();

    if (m_frame.loader().documentLoader()->isClientRedirect()) {
        if (!m_currentItem && !m_frame.tree().parent()) {
            if (!historyURL.isEmpty()) {
                updateBackForwardListClippedAtTarget(true);
                if (!needPrivacy) {
                    m_frame.loader().client().updateGlobalHistory();
                    m_frame.loader().documentLoader()->setDidCreateGlobalHistoryEntry(true);
                    if (m_frame.loader().documentLoader()->unreachableURL().isEmpty())
                        m_frame.loader().client().updateGlobalHistoryRedirectLinks();
                }

                m_frame.loader().client().updateGlobalHistoryItemForPage();
            }
        }
        // The client redirect replaces the current history item.
        updateCurrentItem();
    } else {
        Frame* parentFrame = m_frame.tree().parent();
        if (parentFrame && parentFrame->loader().history().currentItem())
            parentFrame->loader().history().currentItem()->setChildItem(createItem());
    }

    if (!historyURL.isEmpty() && !needPrivacy) {
        if (Page* page = m_frame.page())
            addVisitedLink(*page, historyURL);

        if (!m_frame.loader().documentLoader()->didCreateGlobalHistoryEntry() && m_frame.loader().documentLoader()->unreachableURL().isEmpty() && !m_frame.document()->url().isEmpty())
            m_frame.loader().client().updateGlobalHistoryRedirectLinks();
    }
}
예제 #21
0
/*!
  \fn void PhoneLauncherView::addItem(QContent* content, int pos)
  Creates a new GridItem object and adds it to the scene, or else updates the GridItem
  at the given position, if it already exists. When a new GridItem object is added,
  its position and size will be calculated and set in response to resizeevent(...).
  When an existing GridItem object is modified, its position and size do not
  change in response to \a content -- position and size are determined by other factors,
  such as the size of the view and the current resolution.

  \a content: Contains information to be used by the GridItem object, such as the
  Icon used to display it, the name of its underlying application, etc.
  \a pos: The index of the GridItem object, which will be converted into a
  row and a column position.
*/
void PhoneLauncherView::addItem(QContent* content, int pos)
{
    if ( !selectedItem ) {
        qWarning("PhoneLauncherView::addItem(...): Could not add GridItem for pos %d - no selected item.",pos);
        return;
    }

    // Calculate row and column from pos.
    int row, column;
    rowAndColumn(pos,row,column);

    GridItem *item = 0;
    if ( (item = selectedItem->item(row,column)) ) {
        // Already have an item for that row and column. That means we need to update it, not
        // create it.
        item->setContent(content);
        scene->update();
    } else {
        // Create the new GridItem object.
        createItem(content,row,column);
    }
}
예제 #22
0
bool
TableModel::setItemData(const QModelIndex &index,
                        const QMap<int, QVariant> &roles)
{
    if ( !index.isValid() ) {
        return false;
    }

    TableView *view = qobject_cast<TableView*>( QObject::parent() );
    TableItem *itm = item(index);
    if (itm) {
        itm->view = 0; // prohibits item from calling itemChanged()
        bool changed = false;
        for (QMap<int, QVariant>::ConstIterator it = roles.constBegin(); it != roles.constEnd(); ++it) {
            if ( itm->data( it.key() ) != it.value() ) {
                itm->setData( it.key(), it.value() );
                changed = true;
            }
        }
        itm->view = view;
        if (changed) {
            itemChanged(itm);
        }

        return true;
    }

    if (!view) {
        return false;
    }

    itm = createItem();
    for (QMap<int, QVariant>::ConstIterator it = roles.constBegin(); it != roles.constEnd(); ++it) {
        itm->setData( it.key(), it.value() );
    }
    view->setItem(index.row(), index.column(), itm);

    return true;
}
예제 #23
0
PassRefPtr<HistoryItem> HistoryController::createItemTree(Frame* targetFrame, bool clipAtTarget)
{
    RefPtr<HistoryItem> bfItem = createItem();
    if (!m_frameLoadComplete) {
        saveScrollPositionAndViewStateToItem(m_previousItem.get());
        saveTextWrapWidth(m_previousItem.get());
    }

    if (!clipAtTarget || m_frame != targetFrame) {
        // save frame state for items that aren't loading (khtml doesn't save those)
        saveDocumentState();

        // clipAtTarget is false for navigations within the same document, so
        // we should copy the documentSequenceNumber over to the newly create
        // item.  Non-target items are just clones, and they should therefore
        // preserve the same itemSequenceNumber.
        if (m_previousItem) {
            if (m_frame != targetFrame)
                bfItem->setItemSequenceNumber(m_previousItem->itemSequenceNumber());
            bfItem->setDocumentSequenceNumber(m_previousItem->documentSequenceNumber());
        }

        for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
            FrameLoader* childLoader = child->loader();
            bool hasChildLoaded = childLoader->frameHasLoaded();

            // If the child is a frame corresponding to an <object> element that never loaded,
            // we don't want to create a history item, because that causes fallback content
            // to be ignored on reload.
            
            if (!(!hasChildLoaded && childLoader->isHostedByObjectElement()))
                bfItem->addChildItem(childLoader->history()->createItemTree(targetFrame, clipAtTarget));
        }
    }
    // FIXME: Eliminate the isTargetItem flag in favor of itemSequenceNumber.
    if (m_frame == targetFrame)
        bfItem->setIsTargetItem(true);
    return bfItem;
}
예제 #24
0
void repo::gui::RepoDialogUserManager::addUser(const core::RepoUser &user)
{
    QList<QStandardItem *> row;
    //--------------------------------------------------------------------------
    // User object itself
    QVariant var;
    var.setValue(user);

    QStandardItem *item = new QStandardItem();
    item->setData(var);
    item->setEnabled(true);
    item->setCheckable(true);
    item->setCheckState(Qt::Checked);
    item->setTristate(false);
    item->setEditable(false);
    row.append(item);

    // Username
    row.append(createItem(QString::fromStdString(user.getUsername())));

    // First Name
    row.append(createItem(QString::fromStdString(user.getFirstName())));

    // Last Name
    row.append(createItem(QString::fromStdString(user.getLastName())));

    // Email
    row.append(createItem(QString::fromStdString(user.getEmail())));

    // Projects count
    row.append(createItem((qulonglong)(user.getProjectsList().size())));

    // Groups count
    row.append(createItem((qulonglong)(user.getGroupsList().size())));

    // Roles count
    row.append(createItem((qulonglong)(user.getRolesList().size())));

    //--------------------------------------------------------------------------
    model->invisibleRootItem()->appendRow(row);
}
예제 #25
0
    Plane::Plane( PhysicsScene* scene, const Ogre::Plane& plane,
    const Real width, const Real height, const Vector3& position, const Real u, const Real v ):
    Primitive( scene )
    {
      PxPhysics& physics = mScene->getScene()->getPhysics();

      mActor = PxCreatePlane( physics,
        PxPlane( Glacier::Math::ogreVec3ToPx( plane.normal ), plane.d ),
        *mScene->getDefaultMaterial() );
      if ( !mActor )
        ENGINE_EXCEPT( "Could not create physics plane actor" );

      mScene->getScene()->addActor( *mActor );

      Ogre::v1::MeshPtr planeMeshV1 = Ogre::v1::MeshManager::getSingleton().createPlane(
        "",
        Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
        plane, width, height,
        1, 1, true, 1, u, v, Ogre::Vector3::UNIT_Z,
        Ogre::v1::HardwareBuffer::HBU_STATIC,
        Ogre::v1::HardwareBuffer::HBU_STATIC );

      mMesh = Ogre::MeshManager::getSingleton().createManual( "", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
      mMesh->importV1( planeMeshV1.get(), true, true, true );

      // mMesh = Procedural::PlaneGenerator().setEnableNormals( true ).setSize( Vector2( width, height ) ).setNormal( plane.normal ).setNumSegX( 8 ).setNumSegY( 8 ).setUTile( u ).setVTile( v ).realizeMesh();

      auto scm = Locator::getGraphics().getScene();
      mNode = scm->getRootSceneNode()->createChildSceneNode();

      mItem = scm->createItem( mMesh );
      mItem->setQueryFlags( SceneQueryFlag_World );
      mItem->setDatablock( "GameTextures/TileLargeHexagon" );
      mItem->setCastShadows( false );
      mNode->attachObject( mItem );
      mNode->setPosition( position );
      mNode->setOrientation( Quaternion::IDENTITY );
    }
예제 #26
0
void PopupMenuEditor::choosePixmap( int index )
{
    int idx = ( index == -1 ? currentIndex : index );

    PopupMenuEditorItem * i = 0;
    QAction * a = 0;

    if ( idx < (int)itemList.count() ) {
	i = itemList.at( idx );
	a = i->action();
    } else {
	createItem();
    }

    hide(); // qChoosePixmap hides the menu
    QIconSet icons( qChoosePixmap( 0, formWnd, 0, 0 ) );
    SetActionIconsCommand * cmd =
	new SetActionIconsCommand( "Set icon", formWnd, a, this, icons );
    formWnd->commandHistory()->addCommand( cmd );
    cmd->execute();
    show();
    setFocus();
}
예제 #27
0
void Main::createItem(const QString& ch)
{
    if ( !item[ch] ) {
	QStringList deps = dependencies[ch];
	QString sec = section[ch];
	QListViewItem* parent = 0;
	for (QStringList::Iterator dp = deps.begin(); dp != deps.end(); ++dp) {
	    QString dsec = section[*dp];
	    if ( dsec.isEmpty() )
		qDebug("No section for %s",(*dp).latin1());
	    if ( !parent && dsec == sec ) {
		createItem(*dp);
		parent = item[*dp];
	    }
	}
	if ( !parent )
	    parent = sectionitem[section[ch]];
	ChoiceItem* ci = new ChoiceItem(ch,parent);
	item[ch] = ci;
	if ( !label[ch].isEmpty() )
	    ci->setInfo(label[ch],documentation[ch]);
    }
}
예제 #28
0
void PopupMenuEditor::setAccelerator( int key, Qt::ButtonState state, int index )
{
    // FIXME: make this a command

    int idx = ( index == -1 ? currentIndex : index );

    if ( key == Qt::Key_Shift ||
	 key == Qt::Key_Control ||
	 key == Qt::Key_Alt ||
	 key == Qt::Key_Meta ||
	 key == Qt::Key_unknown )
	return; // ignore these keys when they are pressed

    PopupMenuEditorItem * i = 0;

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

    int shift = ( state & Qt::ShiftButton ? Qt::SHIFT : 0 );
    int ctrl = ( state & Qt::ControlButton ? Qt::CTRL : 0 );
    int alt = ( state & Qt::AltButton ? Qt::ALT : 0 );
    int meta = ( state & Qt::MetaButton ? Qt::META : 0 );

    QAction * a = i->action();
    QKeySequence ks = a->accel();
    int keys[4] = { ks[0], ks[1], ks[2], ks[3] };
    int n = 0;
    while ( n < 4 && ks[n++] );
    n--;
    if ( n < 4 )
	keys[n] = key | shift | ctrl | alt | meta;
    a->setAccel( QKeySequence( keys[0], keys[1], keys[2], keys[3] ) );
    MetaDataBase::setPropertyChanged( a, "accel", TRUE );
    resizeToContents();
}
예제 #29
0
ScoreBoard::ScoreBoard(QWidget* parent)
:	QDialog(parent)
{
	setWindowTitle(tr("Tetris Scores"));

	// Create tree view
	m_scores = new QTreeWidget(this);
	m_scores->setHeaderLabels(QStringList() << tr("Level") << tr("Lines") << tr("Score"));
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
	m_scores->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
#else
	m_scores->header()->setResizeMode(QHeaderView::ResizeToContents);
#endif
	m_scores->setRootIsDecorated(false);

	// Load scores
	QStringList scores = QSettings().value("Scores").toString().split(";", QString::SkipEmptyParts);
	QStringList values;
	foreach (const QString& score, scores) {
		values = score.split(",", QString::SkipEmptyParts);
		if (values.count() != 3)
			continue;
		m_scores->addTopLevelItem( createItem(values[0].toInt(), values[1].toInt(), values[2].toInt()) );
	}
예제 #30
0
PassRefPtr<HistoryItem> HistoryController::createItemTree(Frame* targetFrame, bool clipAtTarget)
{
    RefPtr<HistoryItem> bfItem = createItem(m_frame->tree()->parent() ? true : false);
    if (m_previousItem)
        saveScrollPositionAndViewStateToItem(m_previousItem.get());
    if (!(clipAtTarget && m_frame == targetFrame)) {
        // save frame state for items that aren't loading (khtml doesn't save those)
        saveDocumentState();
        for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) {
            FrameLoader* childLoader = child->loader();
            bool hasChildLoaded = childLoader->frameHasLoaded();

            // If the child is a frame corresponding to an <object> element that never loaded,
            // we don't want to create a history item, because that causes fallback content
            // to be ignored on reload.
            
            if (!(!hasChildLoaded && childLoader->isHostedByObjectElement()))
                bfItem->addChildItem(childLoader->history()->createItemTree(targetFrame, clipAtTarget));
        }
    }
    if (m_frame == targetFrame)
        bfItem->setIsTargetItem(true);
    return bfItem;
}