void QuickOpenFunctionDialog::gotoFile( QString name ) { FunctionModel *fmodel; FunctionList funcList; FunctionDom fdom; for( FunctionList::ConstIterator it = m_functionDefList.begin() ; it!=m_functionDefList.end() ; ++it ){ fdom = *it; fmodel = fdom.data(); if( fmodel->name() == name ){ funcList.append( fdom ); } } if( funcList.count() == 1 ){ fdom = funcList.first(); fmodel = fdom.data(); QString fileNameStr = fmodel->fileName(); int startline, startcol; fmodel->getStartPosition( &startline, &startcol ); m_part->partController()->editDocument( KURL( fileNameStr), startline, startcol ); selectClassViewItem( ItemDom(&(*fmodel)) ); }else if( funcList.count() > 1 ){ QString fileStr; QuickOpenFunctionChooseForm fdlg( this, name.ascii() ); for( FunctionList::Iterator it = funcList.begin() ; it!=funcList.end() ; ++it ){ fmodel = (*it).data(); fdlg.argBox->insertItem( m_part->languageSupport()->formatModelItem(fmodel) + (fmodel->scope().isEmpty() ? "" : " (in " + fmodel->scope().join("::") + ")")); fileStr = KURL( fmodel->fileName() ).fileName(); KURL full_url( fmodel->fileName() ); KURL base_url( part()->project()->projectDirectory()+"/" ); fdlg.setRelativePath(fdlg.fileBox->count(), KURL::relativeURL( base_url, full_url )); fdlg.fileBox->insertItem(fileStr); } if( fdlg.exec() ){ int id = fdlg.argBox->currentItem(); if( id>-1 && id < (int) funcList.count() ){ FunctionModel *model = funcList[id].data(); int line, col; model->getStartPosition( &line, &col ); selectClassViewItem( ItemDom(&(*model)) ); QString fileNameStr = model->fileName(); m_part->partController()->editDocument( KURL(fileNameStr), line ); } } } else{ KMessageBox::error( this, i18n("Error: cannot find matching name function.") ); } accept(); }
void TextEditor::cursorMoveRight(uint offset) { uint index = cursorToByte(pCursorPos); AnyString part(pText, index); auto it = part.utf8begin(); it += offset; byteToCursor(pCursorPos, index + it.offset()); invalidate(); }
void FilePath::discardMatchingHead(OovStringRef const pathPart) { std::string part(pathPart); if(pathStdStr().compare(0, part.length(), part) == 0) { CHECKSIZE(__FILE__, __LINE__, size(), part.length()); pathStdStr().erase(0, part.length()); } }
void TextEditor::cursorEndOfLine() { uint index = cursorToByte(pCursorPos); AnyString part(pText, index); uint end = part.find('\n'); AnyString cut(part, 0, end); pCursorPos.x += columnCount(cut); invalidate(); }
TEST(SimpleString, startsWith) { SimpleString hi("Hi you!"); SimpleString part("Hi"); SimpleString diff("Hrrm Hi you! ffdsfd"); CHECK(hi.startsWith(part)); CHECK(!part.startsWith(hi)); CHECK(!diff.startsWith(hi)); }
QImage DSPDFViewer::renderForTarget(QSharedPointer< Poppler::Page > page, QSize targetSize, bool onlyHalf, bool rightHalf) { PagePart part( onlyHalf? ( rightHalf? PagePart::RightHalf : PagePart::LeftHalf ) : PagePart::FullPage ); return RenderUtils::renderPagePart(page, targetSize, part); }
QPixmap QS60StylePrivate::backgroundTexture(bool /*skipCreation*/) { if (!m_background) { const QSize size = QApplication::desktop()->screen()->size(); QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size, 0); m_background = new QPixmap(background); } return *m_background; }
bool TestLuaCharacter::testBodyParts() { lua::LuaState lua; int loadResult = lua.loadString( "char = am.character.new(\"charBodyPart\")\n" "function addBodyPart(part)\n" " return char:add_body_part(part)\n" "end\n" "function removeBodyPart(part)\n" " return char:remove_body_part(part)\n" "end\n" "function hasBodyPart(part)\n" " return char:has_body_part(part)\n" "end\n" ); if (!loadResult) { lua.logStack("LOAD ERR"); } assert(loadResult); base::Handle<game::Character> charBodyPart = dynamic_cast<game::Character *>(game::Engine::getEngine()->getGameObject("charBodyPart")); assert(lua.hasGlobalFunction("hasBodyPart")); lua.push("arm"); lua_acall(lua, 1, 1); assert(!lua_toboolean(lua, -1)); lua.pop(1); assert(lua.hasGlobalFunction("addBodyPart")); base::Handle<BodyPart> part(new BodyPart("arm")); lua::wrapRefObject<game::BodyPart>(lua, part); lua_acall(lua, 1, 1); assert(lua_toboolean(lua, -1)); lua.pop(1); assert(!charBodyPart->hasBodyPart(new BodyPart("arm"))); assert(charBodyPart->hasBodyPart(part)); assert(charBodyPart->hasBodyPart("arm")); assert(lua.hasGlobalFunction("hasBodyPart")); lua.push("arm"); lua_acall(lua, 1, 1); assert(lua_toboolean(lua, -1)); lua.pop(1); assert(lua.hasGlobalFunction("hasBodyPart")); lua::wrapRefObject<game::BodyPart>(lua, part); lua_acall(lua, 1, 1); assert(lua_toboolean(lua, -1)); lua.pop(1); return true; }
status_t ResourceFilter::parse(const char* arg) { if (arg == NULL) { return 0; } const char* p = arg; const char* q; while (true) { q = strchr(p, ','); if (q == NULL) { q = p + strlen(p); } String8 part(p, q-p); if (part == "zz_ZZ") { mContainsPseudo = true; } int axis; uint32_t value; if (AaptGroupEntry::parseNamePart(part, &axis, &value)) { fprintf(stderr, "Invalid configuration: %s\n", arg); fprintf(stderr, " "); for (int i=0; i<p-arg; i++) { fprintf(stderr, " "); } for (int i=0; i<q-p; i++) { fprintf(stderr, "^"); } fprintf(stderr, "\n"); return 1; } ssize_t index = mData.indexOfKey(axis); if (index < 0) { mData.add(axis, SortedVector<uint32_t>()); } SortedVector<uint32_t>& sv = mData.editValueFor(axis); sv.add(value); // if it's a locale with a region, also match an unmodified locale of the // same language if (axis == AXIS_LANGUAGE) { if (value & 0xffff0000) { sv.add(value & 0x0000ffff); } } p = q; if (!*p) break; p++; } return NO_ERROR; }
static void cs_cmd_drop(char *origin) { user_t *u = user_find_named(origin); mychan_t *mc; char *name = strtok(NULL, " "); if (!name) { notice(chansvs.nick, origin, STR_INSUFFICIENT_PARAMS, "DROP"); notice(chansvs.nick, origin, "Syntax: DROP <#channel>"); return; } if (*name != '#') { notice(chansvs.nick, origin, STR_INVALID_PARAMS, "DROP"); notice(chansvs.nick, origin, "Syntax: DROP <#channel>"); return; } if (!(mc = mychan_find(name))) { notice(chansvs.nick, origin, "\2%s\2 is not registered.", name); return; } if (!is_founder(mc, u->myuser) && !has_priv(u, PRIV_CHAN_ADMIN)) { notice(chansvs.nick, origin, "You are not authorized to perform this operation."); return; } if (metadata_find(mc, METADATA_CHANNEL, "private:close:closer") && !has_priv(u, PRIV_CHAN_ADMIN)) { logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s failed DROP (closed)", mc->name); notice(chansvs.nick, origin, "The channel \2%s\2 is closed; it cannot be dropped.", mc->name); return; } if (!is_founder(mc, u->myuser)) { logcommand(chansvs.me, u, CMDLOG_ADMIN, "%s DROP", mc->name); wallops("%s dropped the channel \2%s\2", origin, name); } else logcommand(chansvs.me, u, CMDLOG_REGISTER, "%s DROP", mc->name); snoop("DROP: \2%s\2 by \2%s\2 as \2%s\2", mc->name, u->nick, u->myuser->name); hook_call_event("channel_drop", mc); if ((config_options.chan && irccasecmp(mc->name, config_options.chan)) || !config_options.chan) part(mc->name, chansvs.nick); mychan_delete(mc->name); notice(chansvs.nick, origin, "The channel \2%s\2 has been dropped.", name); return; }
void Game::splashBlood(Enemy &enemy, sf::Vector2f vel, int amount) { for (int i=-amount/2; i<amount/2; i++) { sf::Vector2f pvel = vecUnit(vecUnit(vel) + vecUnit(sf::Vector2f(vel.y, -vel.x))*float(i/50.0)) * (0.0004f + (rand() % 10) / 50000.f); Particle part(&clock, &window, rand() % 2 + 1, pvel, -0.0000000005, sf::Color::Red); part.disappear = false; part.position = enemy.position; particles.push_back(part); } }
int quick(int a[],int low,int high) { int pivot; if(high>low) { pivot=part(a,low,high); quick(a,low,pivot-1); quick(a,pivot+1,high); } }
void sort(int l, int r, int A[]) { if (r <= l) { return; } calls++; int pi = findPivotIndex(l, r, A); pi = part(l, r, pi, A); sort(l, pi - 1, A); sort(pi+1, r, A); }
char* TLV::dupw(void) { wchar_t *str = (wchar_t*)part(0, length_); wcs_htons(str); char* stru = mir_utf8encodeW(str); mir_free(str); return stru; }
bool KOrganizerPlugin::createDCOPInterface( const QString& serviceType ) { kdDebug(5602) << k_funcinfo << serviceType << endl; if ( serviceType == "DCOP/Organizer" || serviceType == "DCOP/Calendar" ) { if ( part() ) return true; } return false; }
int main() { dn = 0; dfs(1); for (i=2; i<=n; i++) if (dfn[ par[i]->op->j ] < low[i]) par[i]->b = par[i]->op->b = true; memset(bel,0,sizeof(bel)); for (i=1; i<=n; i++) if (!bel[i]) rt[++cnt] = i,part(i); return 0; }
void QMessage::setBody(const QString &bodyText, const QByteArray &mimeType) { QByteArray mainType("text"); QByteArray subType("plain"); QByteArray charset; int index = mimeType.indexOf("/"); if (index != -1) { mainType = mimeType.left(index).trimmed(); subType = mimeType.mid(index + 1).trimmed(); index = subType.indexOf(";"); if (index != -1) { QString remainder = subType.mid(index + 1); subType = subType.left(index).trimmed(); QRegExp charsetPattern("charset=(\\S+)"); index = charsetPattern.indexIn(remainder); if (index != -1) { charset = charsetPattern.cap(1).toLatin1(); } } } if (charset.isEmpty()) { charset = charsetFor(bodyText); } QMailMessageContentType ct; ct.setType(mainType); ct.setSubType(subType); ct.setCharset(charset); QMailMessageBody textBody(QMailMessageBody::fromData(bodyText, ct, QMailMessageBody::Base64)); if (d_ptr->_message.multipartType() == QMailMessage::MultipartNone) { // Replace the body with this data d_ptr->_message.setBody(textBody); } else { // Replace any existing text with this part TextPartLocator locator; d_ptr->_message.foreachPart<TextPartLocator&>(locator); if (locator._location.isValid()) { // Update the existing body text part to contain the new text QMailMessagePart &bodyPart = d_ptr->_message.partAt(locator._location); bodyPart.setBody(textBody); } else { // Insert the text as the new first part QMailMessageContentDisposition cd(QMailMessageContentDisposition::Inline); QMailMessagePart part(QMailMessagePart::fromData(bodyText, ct, cd, QMailMessageBody::Base64)); d_ptr->_message.prependPart(part); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- float RigFemPartCollection::characteristicElementSize() { if (partCount()) { return part(0)->characteristicElementSize(); } else { return 0; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- size_t RigFemPartCollection::totalElementCount() const { size_t elementCount = 0; for (int i = 0; i < partCount(); i++) { elementCount += part(i)->elementCount(); } return elementCount; }
u16 CPartition::part_id(const shared_str& name) const { for(u16 i=0; i<MAX_PARTS; ++i) { const CPartDef& pd = part(i); if(pd.Name == name) return i; } Msg("! there is no part named [%s]", name.c_str() ); return u16(-1); }
void qs(int a[],int p,int q) { if(p<q) { part(a,p,q); int b=s,c=t; qs(a,p,b-1); qs(a,b+1,c-1); qs(a,c+1,q); } }
TaskWPGanttView *View::createGanttView() { TaskWPGanttView *v = new TaskWPGanttView( part(), this ); connect( v, SIGNAL(requestPopupMenu(QString,QPoint)), this, SLOT(slotPopupMenu(QString,QPoint)) ); connect( v, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()) ); v->updateReadWrite( m_readWrite ); v->loadContext(); return v; }
int quick(int *arr,int l,int n) { int j; if(l<=(n)) { j=part(arr,l,n); quick(arr,l,j-1); quick(arr,j+1,n); } return 0; }
int selecte(int *a, int p, int r, int i) { if(p == r) return *(a+p); int q = part(a, p, r); //r_partition(a, p, r); int k = q - p + 1; printf("\n%d %d", i, k); if(i <= k) return selecte(a, p, q, i); else return selecte(a, q+1, r, i-k); }
void TextEditor::cursorMoveLeft(uint offset) { uint index = cursorToByte(pCursorPos); if (0 == index) return; AnyString part(pText, 0, index + 1); auto it = part.utf8begin(); it += index - offset; byteToCursor(pCursorPos, index + it.offset()); invalidate(); }
void partitionAll(int value) { printf("partitionAll %d\n", value); void part(int value, int* arr, int ind); int ind = 0; int * arr = malloc(value * sizeof(int)); part(value, arr, ind); free(arr); }
TaskWorkPackageView *View::createTaskWorkPackageView() { TaskWorkPackageView *v = new TaskWorkPackageView( part(), this ); connect( v, SIGNAL( requestPopupMenu( const QString&, const QPoint & ) ), this, SLOT( slotPopupMenu( const QString&, const QPoint& ) ) ); connect( v, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() ) ); v->updateReadWrite( m_readWrite ); v->loadContext(); return v; }
KSVG::SVGMouseEventImpl *KSVGWidget::newMouseEvent(KSVG::SVGEvent::EventId id, QMouseEvent *event) { DOM::AbstractView temp; int clientX = event->x(); int clientY = event->y(); if(part()->docImpl() && part()->docImpl()->rootElement()) { clientX = int(clientX / part()->docImpl()->rootElement()->currentScale()); clientY = int(clientY / part()->docImpl()->rootElement()->currentScale()); } int button = 0; if(event->stateAfter() & Qt::LeftButton) button = 1; else if(event->stateAfter() & Qt::MidButton) button = 2; else if(event->stateAfter() & Qt::RightButton) button = 3; KSVG::SVGMouseEventImpl *mev = new KSVG::SVGMouseEventImpl(id, // type true, // canBubbleArg true, // cancelableArg temp, // view 0, // detail event->globalX(), //screenXArg event->globalY(), // screenYArg, clientX, // clientXArg clientY, // clientYArg (event->state() & Qt::ControlButton), // ctrlKeyArg (event->state() & Qt::AltButton), // altKeyArg (event->state() & Qt::ShiftButton), // shiftKeyArg (event->state() & Qt::MetaButton), // metaKeyArg button, // buttonArg 0); mev->ref(); return mev; }
tristate KexiWindow::storeNewData(KexiView::StoreNewDataOptions options) { if (!neverSaved()) { return false; } if (d->schemaData) { return false; //schema must not exist } KexiView *v = selectedView(); if (!v) { return false; } //create schema object and assign information KexiProject *project = KexiMainWindowIface::global()->project(); KexiDB::SchemaData sdata(project->idForClass(d->part->info()->partClass())); if (!d->setupSchemaData(&sdata, d->item, options)) { return false; } bool cancel = false; d->schemaData = v->storeNewData(sdata, options, cancel); if (cancel) return cancelled; if (!d->schemaData) { setStatus(project->dbConnection(), i18n("Saving object's definition failed."), ""); return false; } if (project->idForClass(part()->info()->partClass()) < 0) { if (!project->createIdForPart(*part()->info())) return false; } /* Sets 'dirty' flag on every dialog's view. */ setDirty(false); //new schema data has now ID updated to a unique value //-assign that to item's identifier d->item->setIdentifier(d->schemaData->id()); project->addStoredItem(part()->info(), d->item); return true; }
void PartTest::testTOCReload() { QVariantList dummyArgs; Okular::Part part(NULL, NULL, dummyArgs, KGlobal::mainComponent()); part.openDocument(KDESRCDIR "data/tocreload.pdf"); QCOMPARE(part.m_toc->expandedNodes().count(), 0); part.m_toc->m_treeView->expandAll(); QCOMPARE(part.m_toc->expandedNodes().count(), 3); part.reload(); qApp->processEvents(); QCOMPARE(part.m_toc->expandedNodes().count(), 3); }