コード例 #1
0
void PanelKMenu::removeClientMenu(int id)
{
    clients.remove(id);
    removeItem(id);
    slotClear();
}
コード例 #2
0
ファイル: hglayout.cpp プロジェクト: huqiuyun/qt.project
bool HGLayout::removeGWidget(QGraphicsWidget* widget)
{
    return removeItem(widget);
}
コード例 #3
0
ファイル: accessq.cpp プロジェクト: chenbk85/tphProjects
//It gets an item from the mobile element list which 
//is an unsorted container. 
MobileElement *AccessibleQueue::removeHead (void)
{
    MobileElement *obj = getItem (HEAD);
    removeItem (HEAD);
    return obj;
}
コード例 #4
0
ファイル: osdSelector.cpp プロジェクト: rducom/Heditor
void
OSDSelector::clearItems(void) {
  while(getNbItems()) {
    removeItem(accessItem(0));
  }
}
コード例 #5
0
ファイル: itemorderlist.cpp プロジェクト: amosbird/CopyQ
void ItemOrderList::removeRow(int row)
{
    auto item = listItem(row);
    removeItem(item);
}
コード例 #6
0
void GxsChannelPostItem::fill()
{
	/* fill in */

	if (isLoading()) {
		/* Wait for all requests */
		return;
	}

#ifdef DEBUG_ITEM
	std::cerr << "GxsChannelPostItem::fill()";
	std::cerr << std::endl;
#endif

	mInFill = true;

	QString title;

	if (!mIsHome)
	{
		if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
			removeItem();
		}

		title = tr("Channel Feed") + ": ";
		RetroShareLink link;
		link.createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, groupName());
		title += link.toHtml();
		ui->titleLabel->setText(title);

		RetroShareLink msgLink;
		msgLink.createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName());
		ui->subjectLabel->setText(msgLink.toHtml());

		if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags))
		{
			ui->unsubscribeButton->setEnabled(true);
		}
		else 
		{
			ui->unsubscribeButton->setEnabled(false);
		}
		ui->readButton->hide();
		ui->newLabel->hide();
		ui->copyLinkButton->hide();

		if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) {
			mCloseOnRead = true;
		}
	}
	else
	{
		/* subject */
		ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str()));

		// fill first 4 lines of message
		ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 4), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
		
		//QString score = QString::number(post.mTopScore);
		// scoreLabel->setText(score); 

		/* disable buttons: deletion facility not enabled with cache services yet */
		ui->clearButton->setEnabled(false);
		ui->unsubscribeButton->setEnabled(false);
		ui->clearButton->hide();
		ui->readAndClearButton->hide();
		ui->unsubscribeButton->hide();
		ui->copyLinkButton->show();

		if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags))
		{
			ui->readButton->setVisible(true);

			setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus));
		} 
		else 
		{
			ui->readButton->setVisible(false);
			ui->newLabel->setVisible(false);
		}

		mCloseOnRead = false;
	}
	
	// differences between Feed or Top of Comment.
	if (mFeedHolder)
	{
		if (mIsHome) {
			ui->commentButton->show();
		} else if (ui->commentButton->icon().isNull()){
			//Icon is seted if a comment received.
			ui->commentButton->hide();
		}

// THIS CODE IS doesn't compile - disabling until fixed.
#if 0
		if (post.mComments)
		{
			QString commentText = QString::number(post.mComments);
			commentText += " ";
			commentText += tr("Comments");
			ui->commentButton->setText(commentText);
		}
		else
		{
			ui->commentButton->setText(tr("Comment"));
		}
#endif

	}
	else
	{
		ui->commentButton->hide();
	}
	
	// disable voting buttons - if they have already voted.
	/*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK)
	{
		voteUpButton->setEnabled(false);
		voteDownButton->setEnabled(false);
	}*/

	ui->msgFrame->setVisible(!mPost.mMsg.empty());
	if (wasExpanded() || ui->expandFrame->isVisible()) {
		fillExpandFrame();
	}

	ui->datetimelabel->setText(DateTime::formatLongDateTime(mPost.mMeta.mPublishTs));

	ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg(tr("Files")).arg(misc::friendlyUnit(mPost.mSize)));

	if (mFileItems.empty() == false) {
		std::list<SubFileItem *>::iterator it;
		for(it = mFileItems.begin(); it != mFileItems.end(); ++it)
		{
			delete(*it);
		}
		mFileItems.clear();
	}

	std::list<RsGxsFile>::const_iterator it;
	for(it = mPost.mFiles.begin(); it != mPost.mFiles.end(); ++it)
	{
		/* add file */
		std::string path;
		SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize, SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, RsPeerId());
		mFileItems.push_back(fi);
		
		/* check if the file is a media file */
		if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix()))
		{ 
        fi->mediatype();
				/* check if the file is not a media file and change text */
        ui->playButton->setText(tr("Open"));
        ui->playButton->setToolTip(tr("Open File"));
    } else {
        ui->playButton->setText(tr("Play"));
        ui->playButton->setToolTip(tr("Play Media"));
    }

		QLayout *layout = ui->expandFrame->layout();
		layout->addWidget(fi);
	}

	if(mPost.mThumbnail.mData != NULL)
	{
		QPixmap thumbnail;
		thumbnail.loadFromData(mPost.mThumbnail.mData, mPost.mThumbnail.mSize, "PNG");
		// Wiping data - as its been passed to thumbnail.
		ui->logoLabel->setPixmap(thumbnail);
	}

	mInFill = false;
}
コード例 #7
0
void FeedReaderFeedItem::readAndClearItem()
{
	setMsgRead();
	removeItem();
}
コード例 #8
0
ファイル: itemmodel.cpp プロジェクト: Bodillium/openmw
 MWWorld::Ptr ItemModel::moveItem(const ItemStack &item, size_t count, ItemModel *otherModel)
 {
     MWWorld::Ptr ret = otherModel->copyItem(item, count);
     removeItem(item, count);
     return ret;
 }
コード例 #9
0
ファイル: heesitemwidget.cpp プロジェクト: siyuyue/workspace
void HEESItemWidget::removeClicked()
{
    emit removeItem(item);
}
コード例 #10
0
ファイル: equipment.cpp プロジェクト: LibreGames/keeperrl
vector<PItem> Equipment::removeItems(const vector<Item*>& items) {
  vector<PItem> ret;
  for (Item* it : items)
    ret.push_back(removeItem(it));
  return ret;
}
コード例 #11
0
void AbstractPlayer::removeCard(Card *card)
{
  removeItem(cards, card);
}
コード例 #12
0
ファイル: InventoryComponent.cpp プロジェクト: Reyfin/UE4
void UInventoryComponent::moveItem(UItemWidget* slot, UItemBase* base, UItemScrollBoxWidget* sender)
{

	
	if (sender == mainInventory->sellItemBoxWidget)
	{
		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->ItemBoxWidget) return;
			removeItem(base);
			sellItem(base);
		}
	}
	if (sender == mainInventory->ItemBoxWidget)
	{
		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->sellItemBoxWidget) return;
			addItem(base);
			unsellItem(base);
		}
		if (state == InventoryState::TRANSFER)
		{
			if (!(base->itemParent == mainInventory->otherItemBoxWidget)) return;
			
			otherInventoryForTransfering->removeItem(base);
			addItem(base);
			
		
		}
	}
	if (sender == mainInventory->otherItemBoxWidget)
	{

		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->buyItemBoxWidget) return;
			otherInventoryForTransfering->addItem(base);
			unBuyItem(base);
		}
		if (state == InventoryState::TRANSFER)
		{

			base->itemParent->inventoryParent->removeItem(base);
			otherInventoryForTransfering->addItem(base);
		}

	}
	if (sender == mainInventory->buyItemBoxWidget)
	{
		if (state == InventoryState::TRADE)
		{
			if (base->itemParent != mainInventory->otherItemBoxWidget) return;
			otherInventoryForTransfering->removeItem(base);
			buyItem(base);
		}

	}
	refresh();
	
}
コード例 #13
0
ファイル: extensions.cpp プロジェクト: JIELOGAN/alchemy-2
LogDouble LExtensions::unitPropagation(vector<WClause*>& CNF,bool ptpexactmar)
{
    LogDouble val(1,false);
    while(1)
    {
        //maintain a set of current unit clause predicate id's
        vector<int> unitPredicateIds;
        vector<bool> unitPredicateIdSign;
        for(unsigned int i=0; i<CNF.size(); i++)
        {
            if(CNF[i]->atoms.size()==1 && !CNF[i]->satisfied)
            {
                if(ptpexactmar)
                {
                    //do not unit propagate on query predicates
                    if(LvrQueryUpdater::isInstanceCreated())
                    {
                        if(LvrQueryUpdater::Instance()->isNormIdInQuery(CNF[i]->atoms[0]->symbol->normParentId))
                            continue;
                    }
                }
                int matchingId = -1;
                for(unsigned int j=0; j<unitPredicateIds.size(); j++)
                {
                    if(unitPredicateIds[j]==CNF[i]->atoms[0]->symbol->id)
                    {
                        matchingId=j;
                        break;
                    }
                }
                if(matchingId != -1)
                {
                    //if signs are the same, delete one of them since equivalent
                    if(CNF[i]->sign[0] == unitPredicateIdSign[matchingId])
                    {
                        removeItem(CNF,i);
                        i--;
                    }
                    else
                    {
                        //conflicting unit clauses can never be satisfied
                        return LogDouble(0,false);
                    }
                }
                else
                {
                    //set unit clause to satisfied
                    CNF[i]->satisfied = true;
                    //compute weight
                    val=val*getUnitClauseWeightWMPTP(CNF[i]);
                    unitPredicateIds.push_back(CNF[i]->atoms[0]->symbol->id);
                    unitPredicateIdSign.push_back(CNF[i]->sign[0]);
                    //remove atom from unit clause and count its weight
                    CNF[i]->removeAtom(0);
                    i--;
                }
            }
        }
        bool isCNFChanged = false;
        for(unsigned int i=0; i<unitPredicateIds.size(); i++)
        {
            //delete all clauses with conflicting sign for the unit atom
            for(unsigned int j=0; j<CNF.size(); j++)
            {
                for(unsigned int k=0; k<CNF[j]->atoms.size(); k++)
                {
                    if(CNF[j]->atoms[k]->symbol->id == unitPredicateIds[i])
                    {
                        if(CNF[j]->sign[k] != unitPredicateIdSign[i])
                        {
                            //conflicting atom in clause, remove it
                            CNF[j]->removeAtom(k);
                            isCNFChanged = true;
                            k--;
                            //check if we get an empty clause
                            if(CNF[j]->atoms.size()==0 && !CNF[j]->satisfied)
                                return LogDouble(0,false);
                        }
                        else
                        {
                            //set clause to satisfied
                            CNF[j]->satisfied = true;
                            //satisfied atom in clause, remove it
                            CNF[j]->removeAtom(k);
                            k--;
                        }
                    }
                }
            }
        }
        if(!isCNFChanged)
            break;
    }
    return val;
}
コード例 #14
0
void PanelKMenu::updateRecent()
{
    if (!RecentlyLaunchedApps::the().m_bNeedToUpdate)
    {
        return;
    }

    RecentlyLaunchedApps::the().m_bNeedToUpdate = false;

    int nId = serviceMenuEndId() + 1;

    // remove previous items
    if (RecentlyLaunchedApps::the().m_nNumMenuItems > 0)
    {
        // -1 --> menu title
        int i = KickerSettings::showMenuTitles() ? -1 : 0;
        for (; i < RecentlyLaunchedApps::the().m_nNumMenuItems; i++)
        {
            removeItem(nId + i);
            entryMap_.remove(nId + i);
        }
        RecentlyLaunchedApps::the().m_nNumMenuItems = 0;

        if (!KickerSettings::showMenuTitles())
        {
            removeItemAt(0);
        }
    }

    // insert new items
    QStringList RecentApps;
    RecentlyLaunchedApps::the().getRecentApps(RecentApps);

    if (RecentApps.count() > 0)
    {
        bool bNeedSeparator = KickerSettings::showMenuTitles();
        for (QValueList<QString>::ConstIterator it = RecentApps.fromLast();
             /*nop*/; --it)
        {
            KService::Ptr s = KService::serviceByDesktopPath(*it);
            if (!s)
            {
                RecentlyLaunchedApps::the().removeItem(*it);
            }
            else
            {
                if (bNeedSeparator)
                {
                    bNeedSeparator = false;
                    int id = insertItem(new PopupMenuTitle(
                        RecentlyLaunchedApps::the().caption(),
                            font()), nId - 1, 0);
                    setItemEnabled( id, false );
                }
                insertMenuItem(s, nId++, KickerSettings::showMenuTitles() ?
                    1 : 0);
                RecentlyLaunchedApps::the().m_nNumMenuItems++;
            }

            if (it == RecentApps.begin())
                break;
        }

        if (!KickerSettings::showMenuTitles())
        {
            insertSeparator(RecentlyLaunchedApps::the().m_nNumMenuItems);
        }
    }
}
コード例 #15
0
void cOrderProcesser::removeOrder(cBuildingListItem *item) {
	assert(item);
	int slot = getSlotForItem(item);
	removeItem(slot);
}
コード例 #16
0
void MessageOutput::checkMaxItems()
{
  if ( count() >= m_maxItems )
    removeItem( index(firstItem()) );
}
コード例 #17
0
void cOrderProcesser::removeAllItems() {
	for (int i = 0; i < MAX_ITEMS_TO_ORDER; i++) {
		removeItem(i);
	}
}
コード例 #18
0
ファイル: UIListView.cpp プロジェクト: Scorpiour/cocos2d-x
void ListView::removeLastItem()
{
    removeItem(_items->count() -1);
}
コード例 #19
0
ファイル: set.c プロジェクト: SIEGE/siege
int main(void)
{
    char buf[1024];
    char* ptr;

    SGSet* set = sgSetCreate(_setCmp, NULL);

    printf("Example of SIEGE sets");
    printf("----------------------------------------\n");

    int option;
    do
    {
        printf("Select a set operation:\n");
        printf("+<elem> -- Add a new element\n");
        printf("-<elem> -- Delete an element\n");
        printf("?<elem> -- Query whether an element is present\n");
        printf("p       -- Print all elements in (strcmp) order\n");
        printf("pp      -- Pretty-print the set's search tree\n");
        printf("s       -- Print the set's tree in a compact s-expression form\n");         // yes, I was bored.
        printf("ss      -- Pretty print the set's tree in a compact s-expression form\n");  // ...very bored.
        printf("\n");
        printf("q        -- Quit the program\n");
        printf("----------------------------------------\n");
        printf("Selection: "); fflush(stdout);
        fgets(buf, sizeof(buf), stdin);
        printf("\n");

        trimNL(buf);
        if(strstr(buf, "+") == buf)
            option = '+';
        else if(strstr(buf, "-") == buf)
            option = '-';
        else if(strstr(buf, "?") == buf)
            option = '?';
        else if(!strcmp(buf, "p") || !strcmp(buf, "P"))
            option = 'p';
        else if(!strcmp(buf, "pp") || !strcmp(buf, "pP") || !strcmp(buf, "Pp") || !strcmp(buf, "PP"))
            option = 'P';
        else if(!strcmp(buf, "s") || !strcmp(buf, "S"))
            option = 's';
        else if(!strcmp(buf, "ss") || !strcmp(buf, "sS") || !strcmp(buf, "Ss") || !strcmp(buf, "SS"))
            option = 'S';
        else if(!strcmp(buf, "q") || !strcmp(buf, "Q"))
            option = 'q';
        else
            option = 0;

        ptr = skipSpace(buf + 1);
        switch(option)
        {
            case '+':
                if(!strlen(ptr))
                {
                    printf("Error -- element must be a non-empty string!\n");
                    break;
                }
                switch(insertItem(set, ptr))
                {
                    case 0: printf("Element '%s' already exists in the set!\n", ptr); break;
                    case 1: printf("Element '%s' successfully added!\n", ptr); break;
                    default: printf("Error adding element '%s' -- probably out of memory!\n", ptr);
                }
                break;
            case '-':
                if(!strlen(ptr))
                {
                    printf("Error -- element must be a non-empty string!\n");
                    break;
                }
                switch(removeItem(set, ptr))
                {
                    case 0: printf("There is no element '%s' in the set!\n", ptr); break;
                    case 1: printf("Element '%s' successfully removed!\n", ptr); break;
                    default: printf("Error removing element '%s'!\n", ptr);
                }
                break;
            case '?':
                if(!strlen(ptr))
                {
                    printf("Error -- element must be a non-empty string!\n");
                    break;
                }
                if(sgSetSearch(set, ptr))
                    printf("Element '%s' is present in the set!\n", ptr);
                else
                    printf("Element '%s' is *NOT* present in the set!\n", ptr);
                break;
            case 'p':
                printSet(set);
                break;
            case 'P':
                pprintSet(set);
                break;
            case 's':
                sprintSet(set, 0);
                break;
            case 'S':
                sprintSet(set, 1);
                break;
            case 'q':
                break; /* handled by the while() */
            default:
                printf("Invalid option '%s'!\n", trimSpace(buf));
                break;
        }
        printf("\n");
        fflush(stdout);
    }
    while(option != 'q');

    while(set->root)
        removeItem(set, set->root->item);
    sgSetDestroy(set);

    return 0;
}
コード例 #20
0
ファイル: gamescene.cpp プロジェクト: Akira586/Cockatrice
void GameScene::removeZoneView(ZoneViewWidget *item)
{
        zoneViews.removeAt(zoneViews.indexOf(item));
    removeItem(item);
}
コード例 #21
0
ファイル: UIListView.cpp プロジェクト: 602147629/PlanetWar
void ListView::removeLastItem()
{
    removeItem(_items.size() -1);
}
コード例 #22
0
ファイル: UIListViewEx.cpp プロジェクト: huxia/cocos2d-x
void UIListViewEx::removeLastItem()
{
    removeItem(m_pItems->count() -1);
}
コード例 #23
0
SpecialOrderEditor::SpecialOrderEditor( QWidget *parent, bool newOne )
    : KDialog( parent )
{
    m_modelAssigned = false;
    priceEach   = 0;
    paymentEach = 0;

    groupInfo.isAvailable = true;
    groupInfo.cost  = 0;
    groupInfo.price = 0;
    groupInfo.count = 0;
    groupInfo.name  = "";

    ui = new SpecialOrderUI( this );
    setMainWidget( ui );
    setCaption( i18n("Special Orders") );
    setButtons( KDialog::Ok|KDialog::Cancel );

    //Set Validators for input boxes
    ui->editAddQty->setValidator(new QDoubleValidator(0.00, 999999999999.99, 3, ui->editAddQty));

    ui->editQty->setValue(1);
    ui->editAddQty->setText("1.00");

    connect( ui->editQty, SIGNAL(editingFinished()), this, SLOT(calculateCost()));
    connect( ui->editQty, SIGNAL(valueChanged(int)), this, SLOT(calculateCost()));

    connect( ui->editQty, SIGNAL(editingFinished()), this, SLOT(checkFieldsState()));
    connect( ui->editPayment, SIGNAL(valueChanged(double)), this, SLOT(checkFieldsState()));


    connect( ui->editFilter, SIGNAL(textEdited ( const QString &)), SLOT(applyFilter(const QString &)) );
    connect( ui->btnAdd,    SIGNAL(clicked()), SLOT(addItem()) );
    connect( ui->editAddQty,    SIGNAL(returnPressed()), SLOT(addItem()) );
    connect( ui->btnRemove, SIGNAL(clicked()), SLOT(removeItem()) );
    connect( ui->groupView, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), SLOT(itemDoubleClicked(QTableWidgetItem*)) );

    connect( ui->deliveryDT, SIGNAL(valueChanged(QDateTime)), this, SLOT(checkDate(QDateTime)) );

    connect( ui->editNotes, SIGNAL(textChanged()), SLOT(updateNoteLength()) );

    //for now, when creating a s.o. the status cannot be modified. It can be when edited.
    if (newOne) {
        dateTime         = QDateTime::currentDateTime();
        ui->deliveryDT->setDateTime(QDateTime::currentDateTime().addDays(1));
    }

    //tip
    QString path = KStandardDirs::locate("appdata", "styles/");
    path = path+"tip.svg";
    qtyTip   = new MibitTip(this, ui->editQty, path, DesktopIcon("dialog-warning",32) );
    path = KStandardDirs::locate("appdata", "styles/")+"rotated_tip.svg";
    groupTip = new MibitTip(this, ui->groupView, path, DesktopIcon("dialog-warning",32), tpAbove );

    path = KStandardDirs::locate("appdata", "styles/");
    path = path+"floating_bottom.svg";
    newClientPanel = new MibitFloatPanel(this, path, Top);
    newClientPanel->setSize(550,250);
    newClientPanel->addWidget(ui->frameClient);
    newClientPanel->setMode(pmManual);
    newClientPanel->setHiddenTotally(true);
    ui->editClientName->setEmptyMessage(i18n("Enter client name here..."));
    ui->editClientPhone->setEmptyMessage(i18n("Enter client phone here..."));
    ui->editClientCell->setEmptyMessage(i18n("Enter client cell phone here..."));

    connect( ui->btnNewClient, SIGNAL(clicked()), newClientPanel, SLOT(showPanel() ));
    connect( ui->btnNewClient, SIGNAL(clicked()), this, SLOT(enableCreateClient() ));
    connect( ui->btnClientCancel, SIGNAL(clicked()), newClientPanel, SLOT(hidePanel()));
    connect( ui->btnClientAdd, SIGNAL(clicked()), this, SLOT(createClient()));
    connect( ui->editClientName, SIGNAL(textEdited(const QString &)), this, SLOT(checkValidInfo()) );
    connect( ui->editClientAddress, SIGNAL(textChanged()), this, SLOT(checkValidInfo()) );
    connect( ui->editClientPhone, SIGNAL(textEdited(const QString &)), this, SLOT(checkValidInfo()) );
    connect( ui->editClientCell, SIGNAL(textEdited(const QString &)), this, SLOT(checkValidInfo()) );

    setDefaultButton(KDialog::None);
    ui->btnFilter->setDefault(true);
    ui->btnFilter->hide(); //hack to dont have a default OK or Cancel button

    ui->clientsCombo->setFocus();
    enableButtonOk(false);
}
コード例 #24
0
ファイル: mprCache.c プロジェクト: ni-webtech/mpr-4
static void pruneCache(MprCache *cache, MprEvent *event)
{
    MprTime         when, factor;
    MprKey          *kp;
    CacheItem       *item;
    ssize           excessKeys;

    if (!cache) {
        cache = shared;
        if (!cache) {
            return;
        }
    }
    if (event) {
        when = mprGetTime();
    } else {
        /* Expire all items by setting event to NULL */
        when = MAXINT64;
    }
    if (mprTryLock(cache->mutex)) {
        /*
            Check for expired items
         */
        for (kp = 0; (kp = mprGetNextKey(cache->store, kp)) != 0; ) {
            item = (CacheItem*) kp->data;
            mprLog(6, "Cache: \"%s\" lifespan %d, expires in %d secs", item->key, 
                    item->lifespan / 1000, (item->expires - when) / 1000);
            if (item->expires && item->expires <= when) {
                mprLog(5, "Cache prune expired key %s", kp->key);
                removeItem(cache, item);
            }
        }
        mprAssert(cache->usedMem >= 0);

        /*
            If too many keys or too much memory used, prune keys that expire soonest.
         */
        if (cache->maxKeys < MAXSSIZE || cache->maxMem < MAXSSIZE) {
            /*
                Look for those expiring in the next 5 minutes, then 20 mins, then 80 ...
             */
            excessKeys = mprGetHashLength(cache->store) - cache->maxKeys;
            factor = 5 * 60 * MPR_TICKS_PER_SEC; 
            when += factor;
            while (excessKeys > 0 || cache->usedMem > cache->maxMem) {
                for (kp = 0; (kp = mprGetNextKey(cache->store, kp)) != 0; ) {
                    item = (CacheItem*) kp->data;
                    if (item->expires && item->expires <= when) {
                        mprLog(5, "Cache too big execess keys %Ld, mem %Ld, prune key %s", 
                                excessKeys, (cache->maxMem - cache->usedMem), kp->key);
                        removeItem(cache, item);
                    }
                }
                factor *= 4;
                when += factor;
            }
        }
        mprAssert(cache->usedMem >= 0);

        if (mprGetHashLength(cache->store) == 0) {
            if (event) {
                mprRemoveEvent(event);
                cache->timer = 0;
            }
        }
        unlock(cache);
    }
}
コード例 #25
0
ファイル: itemorderlist.cpp プロジェクト: amosbird/CopyQ
void ItemOrderList::onPushButtonRemoveClicked()
{
    for (auto item : ui->listWidgetItems->selectedItems())
        removeItem(item);
}
コード例 #26
0
// Constructor.
qtractorTimeScaleForm::qtractorTimeScaleForm (
	QWidget *pParent, Qt::WindowFlags wflags )
	: QDialog(pParent, wflags)
{
	// Setup UI struct...
	m_ui.setupUi(this);

	// Window modality (let plugin/tool windows rave around).
	QDialog::setWindowModality(Qt::WindowModal);

	// Initialize locals.
	m_pTimeScale  = NULL;

	m_pTempoTap   = new QTime();
	m_iTempoTap   = 0;
	m_fTempoTap   = 0.0f;

	m_iDirtySetup = 0;
	m_iDirtyCount = 0;
	m_iDirtyTotal = 0;

	QHeaderView *pHeader = m_ui.TimeScaleListView->header();
	pHeader->setDefaultAlignment(Qt::AlignLeft);
#if QT_VERSION >= 0x050000
//	pHeader->setSectionResizeMode(QHeaderView::Custom);
	pHeader->setSectionResizeMode(QHeaderView::ResizeToContents);
	pHeader->setSectionsMovable(false);
#else
//	pHeader->setResizeMode(QHeaderView::Custom);
	pHeader->setResizeMode(QHeaderView::ResizeToContents);
	pHeader->setMovable(false);
#endif
	QAbstractItemModel *pHeaderModel = pHeader->model();
	pHeaderModel->setHeaderData(0, Qt::Horizontal,
		Qt::AlignCenter, Qt::TextAlignmentRole); // Bar
	pHeaderModel->setHeaderData(2, Qt::Horizontal,
		Qt::AlignCenter, Qt::TextAlignmentRole); // tempo

	m_ui.TimeScaleListView->setItemDelegate(
		new qtractorTimeScaleItemDelegate(m_ui.TimeScaleListView));
	m_ui.TimeScaleListView->setContextMenuPolicy(Qt::CustomContextMenu);

	// (Re)initial contents.
	// Default is main session time-scale of course...
	qtractorSession *pSession = qtractorSession::getInstance();
	if (pSession)
		setTimeScale(pSession->timeScale());

	// Try to restore normal window positioning.
	adjustSize();

	// UI signal/slot connections...
	QObject::connect(m_ui.TimeScaleListView,
		SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
		SLOT(selectItem()));
	QObject::connect(m_ui.TimeScaleListView,
		SIGNAL(customContextMenuRequested(const QPoint&)),
		SLOT(contextMenu(const QPoint&)));

	QObject::connect(m_ui.BarSpinBox,
		SIGNAL(valueChanged(int)),
		SLOT(barChanged(int)));
	QObject::connect(m_ui.TimeSpinBox,
		SIGNAL(valueChanged(unsigned long)),
		SLOT(timeChanged(unsigned long)));
	QObject::connect(m_ui.TimeSpinBox,
		SIGNAL(displayFormatChanged(int)),
		SLOT(refreshItems()));

	QObject::connect(m_ui.TempoSpinBox,
		SIGNAL(valueChanged(float, unsigned short, unsigned short)),
		SLOT(tempoChanged()));
	QObject::connect(m_ui.TempoSpinBox,
		SIGNAL(valueChanged(const QString&)),
		SLOT(tempoChanged()));
	QObject::connect(m_ui.TempoTapPushButton,
		SIGNAL(clicked()),
		SLOT(tempoTap()));
	QObject::connect(m_ui.TempoFactorPushButton,
		SIGNAL(clicked()),
		SLOT(tempoFactor()));

	QObject::connect(m_ui.MarkerTextLineEdit,
		SIGNAL(textChanged(const QString&)),
		SLOT(changed()));
	QObject::connect(m_ui.MarkerColorToolButton,
		SIGNAL(clicked()),
		SLOT(markerColor()));

	QObject::connect(m_ui.RefreshPushButton,
		SIGNAL(clicked()),
		SLOT(refresh()));
	QObject::connect(m_ui.AddPushButton,
		SIGNAL(clicked()),
		SLOT(addItem()));
	QObject::connect(m_ui.UpdatePushButton,
		SIGNAL(clicked()),
		SLOT(updateItem()));
	QObject::connect(m_ui.RemovePushButton,
		SIGNAL(clicked()),
		SLOT(removeItem()));
	QObject::connect(m_ui.ClosePushButton,
		SIGNAL(clicked()),
		SLOT(reject()));

	stabilizeForm();
}
コード例 #27
0
ファイル: CVarManager.cpp プロジェクト: CSRedRat/desura-app
//if this screws up its too late any way
void  CVarManager::UnRegCVar(CVar* var)
{
	removeItem(var->getName());
}
コード例 #28
0
ファイル: scene.cpp プロジェクト: F74045042/pd2-Taiko
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    if(screenMode == 0)
    {
        /*Beginning page*/
        //Start Game button
        if(event->scenePos().x() > btn_start->pos().x()+20 && event->scenePos().x() <= btn_start->pos().x()+80)
        {
           if(event->scenePos().y() > btn_start->pos().y()+20 && event->scenePos().y() <= btn_start->pos().y()+80)
           {
               if(x == 1)
               {
               cout<<"Start Game!"<<endl;
               bgChange();
               gameInit();
               screenMode = 1;
               /*start counting time*/
               mytime->startTime();

               //stop bgm
               bgm->stop();
               bgm2->play();
               }

           }
        }
        /*Beginning page*/
        //Exit button
        else if(event->scenePos().x() > btn_exit->pos().x()+20 && event->scenePos().x() <= btn_exit->pos().x()+100)
        {
            if(event->scenePos().y() > btn_exit->pos().y()+20 && event->scenePos().y() <= btn_exit->pos().y()+110)
            {
                if(x == 1)
                {
                    bgm->stop();
                    haha->play();
                    QTimer::singleShot(8000,this,SLOT(endofgame()));
                    //QApplication::exit();
                    x = 0;
                }
            }
        }
    }

    if(screenMode == 1)
    {

        /*Playing page*/
        //Back button setting
        if(event->scenePos().x() > btn_back->pos().x() && event->scenePos().x() <= btn_back->pos().x()+btn_back_w)
        {
            if(event->scenePos().y() > btn_back->pos().y() && event->scenePos().y() <= btn_back->pos().y()+btn_back_h)
            {
                bgRecover();
                gameInit();
                removeItem(score1);
                removeItem(mytime);

                //Initialize
                drum_list.clear();
                rand_list.clear();
                num =0;
                num_drum = 0;
                screenMode = 0;

                //add back sound
                bgm->play();
                bgm2->stop();
            }
        }
    }

}
コード例 #29
0
ファイル: simulation.cpp プロジェクト: JWalker1995/CellSim
void Simulation::replaceAtom(int selI, Atom* a, Atom* b)
{
    b->i = a->i;
    b->setPos(a->pos());
    b->state = a->state;
    b->nx = a->nx;
    b->ny = a->ny;
    b->vx = a->vx;
    b->vy = a->vy;
    memcpy(b->bondsLt, a->bondsLt, sizeof(Atom*) * 6);
    memcpy(b->bondsGt, a->bondsGt, sizeof(Atom*) * 6);
    b->numBondsLt = a->numBondsLt;
    b->numBondsGt = a->numBondsGt;
    memcpy(b->reaction, a->reaction, sizeof(int) * 18);
    b->reactionStr = a->reactionStr;
    b->selected = a->selected;

    int j = 0;
    while (j < b->numBondsLt)
    {
        int k = 0;
        int c = b->bondsLt[j]->numBondsGt;
        Atom** bonds = b->bondsLt[j]->bondsGt;
        while (k < c)
        {
            if (bonds[k] == a) {bonds[k] = b;}
            k++;
        }
        j++;
    }
    j = 0;
    while (j < b->numBondsGt)
    {
        int k = 0;
        int c = b->bondsGt[j]->numBondsLt;
        Atom** bonds = b->bondsGt[j]->bondsLt;
        while (k < c)
        {
            if (bonds[k] == a) {bonds[k] = b;}
            k++;
        }
        j++;
    }

    removeItem(a);
    addItem(b);
    b->changeSceneSize();

    atoms[a->i] = b;

    if (selI != -1)
    {
        selected[selI] = b;
    }

    modify();

    delete a;
/*
    int actualNumAtoms = numAtoms;
    numAtoms = atomIndex(a);
    qDebug() << numAtoms;
    qDebug() << a;
    removeItem(atoms[numAtoms]);
    qDebug() << "a";
    addAtom(QPointF(a->nx, a->ny), type, a->state);
    qDebug() << atoms[numAtoms - 1];

    selected.replace(i, atoms[numAtoms - 1]);

    numAtoms = actualNumAtoms;
    qDebug() << "e";

    delete a;

    qDebug() << "f";

    */
}
コード例 #30
0
ファイル: launchermodel.cpp プロジェクト: antseppa/lipstick
void LauncherModel::onFilesUpdated(const QStringList &added,
        const QStringList &modified, const QStringList &removed)
{
    QMap<int, LauncherItem *> itemsWithPositions;
    QStringList modifiedAndNeedUpdating = modified;

    // First, remove all removed launcher items before adding new ones
    foreach (const QString &filename, removed) {
        if (isDesktopFile(filename)) {
            // Desktop file has been removed - remove launcher
            LauncherItem *item = itemInModel(filename);
            if (item != NULL) {
                LAUNCHER_DEBUG("Removing launcher item:" << filename);
                unsetTemporary(item);
                removeItem(item);
            }
        } else if (isIconFile(filename)) {
            // Icons has been removed - find item and clear its icon path
            updateItemsWithIcon(filename, false);
        }
    }

    foreach (const QString &filename, added) {
        if (isDesktopFile(filename)) {
            // New desktop file appeared - add launcher
            LauncherItem *item = itemInModel(filename);

            // Check if there is a temporary launcher item, and if so, assume that
            // the newly-appeared file (if it is visible) will replace the temporary
            // launcher. In general, this should not happen if the app is properly
            // packaged (desktop file shares basename with packagename), but in some
            // cases, this is better than having the temporary and non-temporary in
            // place at the same time.
            LauncherItem *tempItem = temporaryItemToReplace();
            if (item == NULL && tempItem != NULL &&
                    isVisibleDesktopFile(filename)) {
                // Replace the single temporary launcher with the newly-added icon
                item = tempItem;

                qWarning() << "Applying heuristics:" << filename <<
                    "is the launcher item for" << item->packageName();
                item->setIconFilename("");
                item->setFilePath(filename);
            }

            if (item == NULL) {
                LAUNCHER_DEBUG("Trying to add launcher item:" << filename);
                item = addItemIfValid(filename, itemsWithPositions);

                if (item != NULL) {
                    // Try to look up an already-installed icon in the icons directory
                    foreach (const QString &iconPath, _launcherMonitor.iconDirectories()) {
                        QString iconname = filenameFromIconId(item->getOriginalIconId(), iconPath);
                        if (QFile(iconname).exists()) {
                            LAUNCHER_DEBUG("Loading existing icon:" << iconname);
                            updateItemsWithIcon(iconname, true);
                            break;
                        }
                    }
                }
            } else {