void QUimInputContext::candidateActivate( int nr, int displayLimit ) { QValueList<uim_candidate> list; list.clear(); #if !UIM_QT_USE_NEW_PAGE_HANDLING cwin->activateCandwin( displayLimit ); /* set candidates */ uim_candidate cand; for ( int i = 0; i < nr; i++ ) { cand = uim_get_candidate( m_uc, i, displayLimit ? i % displayLimit : i ); list.append( cand ); } cwin->setCandidates( displayLimit, list ); #else /* !UIM_QT_USE_NEW_PAGE_HANDLING */ nrPages = displayLimit ? ( nr - 1 ) / displayLimit + 1 : 1; pageFilled.clear(); for ( int i = 0; i < nrPages; i++ ) pageFilled.append( false ); cwin->setNrCandidates( nr, displayLimit ); // set page candidates prepare_page_candidates( 0 ); cwin->setPage( 0 ); #endif /* !UIM_QT_USE_NEW_PAGE_HANDLING */ cwin->popup(); candwinIsActive = true; }
void QUimInputContext::prepare_page_candidates( int page ) { QValueList<uim_candidate> list; list.clear(); if ( page < 0 ) return; if (pageFilled[ page ] ) return; /* set page candidates */ uim_candidate cand; int pageNr, start, nrCandidates, displayLimit; nrCandidates = cwin->nrCandidates; displayLimit = cwin->displayLimit; start = page * displayLimit; if ( displayLimit && ( nrCandidates - start ) > displayLimit ) pageNr = displayLimit; else pageNr = nrCandidates - start; for ( int i = start; i < ( pageNr + start ); i++ ) { cand = uim_get_candidate( m_uc, i, displayLimit ? i % displayLimit : i ); list.append( cand ); } pageFilled[ page ] = true; cwin->setPageCandidates( page, list ); }
void AimLoginTask::handleLoginResponse() { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "RECV SNAC 0x17, 0x07 - AIM Login Response" << endl; SnacTransfer* st = dynamic_cast<SnacTransfer*> ( transfer() ); if ( !st ) { setError( -1 , QString::null ); return; } QValueList<TLV> tlvList = st->buffer()->getTLVList(); TLV uin = findTLV( tlvList, 0x0001 ); if ( uin ) { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "found TLV(1) [SN], SN=" << QString( uin.data ) << endl; } TLV err = findTLV( tlvList, 0x0008 ); if ( err ) { WORD errorNum = ( ( err.data[0] << 8 ) | err.data[1] ); kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << k_funcinfo << "found TLV(8) [ERROR] error= " << errorNum << endl; Oscar::SNAC s = { 0, 0, 0, 0 }; client()->fatalTaskError( s, errorNum ); setError( errorNum, QString::null ); return; //if there's an error, we'll need to disconnect anyways } TLV server = findTLV( tlvList, 0x0005 ); if ( server ) { QString ip = QString( server.data ); kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "found TLV(5) [SERVER] " << ip << endl; int index = ip.find( ':' ); m_bosHost = ip.left( index ); ip.remove( 0 , index+1 ); //get rid of the colon and everything before it m_bosPort = ip.left(4); //we only need 4 bytes kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "We should reconnect to server '" << m_bosHost << "' on port " << m_bosPort << endl; } TLV cookie = findTLV( tlvList, 0x0006 ); if ( cookie ) { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "found TLV(6) [COOKIE]" << endl; m_cookie.duplicate( cookie.data ); setSuccess( 0, QString::null ); } tlvList.clear(); }
void UmlBaseClassInstance::relationsValue(QValueList<SlotRelation> & result) { UmlCom::send_cmd(_identifier, relationsCmd, (void *) 0); unsigned n = UmlCom::read_unsigned(); result.clear(); while (n--) { UmlRelation * r = (UmlRelation *) UmlBaseItem::read_(); result.append(SlotRelation(r, (UmlClassInstance *) UmlBaseItem::read_())); } }
void UmlBaseClassInstance::attributesValue(QValueList<SlotAttribute> & result) { UmlCom::send_cmd(_identifier, attributesCmd, (char) 0); unsigned n = UmlCom::read_unsigned(); result.clear(); while (n--) { UmlAttribute * at = (UmlAttribute *) UmlBaseItem::read_(); result.append(SlotAttribute(at, UmlCom::read_string())); } }
bool Ts2Rtp::addChannels( QPtrList<ChannelDesc> *channels ) { int i, j, k, pmtpid=8191; ChannelDesc *desc, *d; QValueList<int> pids; if ( !rtpSocket && !makeSocket() ) return false; sendList = ""; for ( i=0; i<(int)channels->count(); i++ ) { desc = channels->at( i ); sendList = sendList+desc->name+"|"+QString().setNum(desc->vpid)+"|"+QString().setNum(desc->apid[0].pid)+"|"; if ( desc->apid[0].ac3 ) sendList+= "y|"; else sendList+= "n|"; sendList+= QString().setNum(desc->subpid[0].pid); sendList+= "|"; sendList+= QString().setNum(desc->subpid[0].page); sendList+= "|"; sendList+= QString().setNum(desc->subpid[0].id); sendList+= "|"; sendList+= QString().setNum(desc->subpid[0].type); sendList+= "|"; sendList+= desc->subpid[0].lang+"|"; for ( j=i; j<(int)channels->count(); j++ ) { pids.clear(); d = channels->at( j ); if ( d->vpid ) pids.append( d->vpid ); for ( k=0; k<d->napid && k<MAX_AUDIO; k++ ) pids.append( d->apid[k].pid ); for ( k=0; k<d->nsubpid && k<MAX_DVBSUB; k++ ) pids.append( d->subpid[k].pid ); while ( pmtpid==17 || pids.contains( pmtpid ) ) --pmtpid; } desc->pmtpid = pmtpid--; } sendList+="\n"; psiTables( channels ); writePsi = true; psiTimer.start( 500 ); return true; }
void UmlClass::get_extended(QValueList<QCString> & r) { r.clear(); const QVector<UmlItem> ch = children(); unsigned n = ch.size(); unsigned i; for (i = 0; i != n; i += 1) { UmlItem * x = ch[i]; if ((x->kind() == aRelation) && (((UmlRelation *) x)->relationKind() == aDirectionalAssociation) && (((UmlRelation *) x)->roleType()->stereotype() == "metaclass")) r.append(((UmlRelation *) x)->roleType()->name()); } if (r.isEmpty()) r.append("Element"); }
bool TableEditor::setTableArea( int bLine, int bCol, int eLine, int eCol, Parser *docParser ) { const uint pInitialTableSize = 20; m_bLine = bLine; m_bCol = bCol; m_eLine = eLine; m_eCol = eCol; m_createNodes = false; //don't create the cell and row content when adding a new cell/row Node *node = docParser->nodeAt(bLine, bCol + 1); Node *lastNode = docParser->nodeAt(eLine, eCol); if (node) kdDebug(24000) << "node = " << node->tag->name << endl; if (lastNode) kdDebug(24000) << "lastnode = " << lastNode->tag->name << endl; if (!node || !lastNode) return false; m_write = node->tag->write(); m_dtd = node->tag->dtd(); if ( !QuantaCommon::closesTag(node->tag, lastNode->tag) ) { return false; } int nCol, nRow, maxCol; nCol = nRow = maxCol = 0; bool countRows = false; bool missingBody = false; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; QValueList<TableNode> tableRowTags; QValueVector< QValueVector<TableNode> > mergeMatrix; mergeMatrix.resize(pInitialTableSize); for (uint i = 0; i < pInitialTableSize; i++) mergeMatrix[i].resize(pInitialTableSize); TableNode tableNode; Node *n = node; while (n != lastNode->nextSibling()) { QString tagName = n->tag->name.lower(); if (tagName == "table") { if (m_table && m_dataTable && nRow > 0 && nCol > 0) //nested table! { int line, col; n->tag->beginPos(line, col); NestedTable table; table.row = nRow -1; table.col = nCol - 1; table.bLine = line; table.bCol = col; if (n->next && QuantaCommon::closesTag(n->tag, n->next->tag)) { n->next->tag->endPos(table.eLine, table.eCol); table.node = n; table.nestedData = m_write->text(table.bLine, table.bCol, table.eLine, table.eCol); m_nestedTables.append(table); m_dataTable->item(nRow -1, nCol -1)->setPixmap(QIconSet(UserIcon("quick_table")).pixmap()); m_dataTable->updateCell(nRow - 1, nCol - 1); } n = n->next; } else { m_table = new Tag(*(n->tag)); newNum++; } } else if (tagName == "thead") { headerCheckBox->setChecked(true); countRows = true; m_rowSpin = headerRowSpinBox; m_colSpin = headerColSpinBox; m_dataTable= headerTableData; m_tableTags = m_tableHeaderTags; m_tableRows = m_tableHeaderRows; if (m_thead) { //there was already a <thead> tag in the area nRow = m_dataTable->numRows(); } else { m_thead = new Tag(*(n->tag)); newNum++; } } else if (tagName == "/thead") { headerRowSpinBox->setValue(nRow); headerColSpinBox->setValue(maxCol); countRows = false; nCol = nRow = maxCol = 0; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; } else if (tagName == "tfoot") { footerCheckBox->setChecked(true); m_rowSpin = footerRowSpinBox; m_colSpin = footerColSpinBox; m_tableTags = m_tableFooterTags; m_tableRows = m_tableFooterRows; m_dataTable = footerTableData; countRows = true; if (m_tfoot) { //there was already a <tfoot> tag in the area nRow = m_dataTable->numRows(); } else { m_tfoot = new Tag(*(n->tag)); newNum++; } } else if (tagName == "/tfoot") { footerRowSpinBox->setValue(nRow); footerColSpinBox->setValue(maxCol); countRows = false; nCol = nRow = maxCol = 0; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; } else if (tagName == "tbody") { m_rowSpin = rowSpinBox; m_colSpin = colSpinBox; m_tableTags = m_tableDataTags; m_tableRows = m_tableDataRows; m_dataTable = tableData; countRows = true; m_tbody = new Tag(*(n->tag)); newNum++; } else if (tagName == "/tbody") { rowSpinBox->setValue(nRow); colSpinBox->setValue(maxCol); countRows = false; nCol = nRow = maxCol = 0; m_tableTags = 0L; m_tableRows = 0L; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; } else if (tagName == "tr") { if (!countRows) { missingBody = true; m_rowSpin = rowSpinBox; m_colSpin = colSpinBox; m_tableTags = m_tableDataTags; m_tableRows = m_tableDataRows; m_dataTable = tableData; countRows = true; m_tbody = new Tag(); newNum++; m_tbody->parse("<tbody>", m_write); } nRow++; if ((uint)nRow >= mergeMatrix.size()) { // Check if there are enough rows in mergeMatriz mergeMatrix.resize(2 * mergeMatrix.size()); for (uint i = mergeMatrix.size() / 2; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(mergeMatrix[0].size()); } m_rowSpin->setValue(nRow); nCol = 0; tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); newNum++; tableNode.merged = false; m_tableRows->append(tableNode); } else if (tagName == "/tr") { if (countRows) { maxCol = (nCol > maxCol) ? nCol : maxCol; maxCol = (maxCol == 0) ? 1 : maxCol; for (int col = nCol; col < maxCol; col++) { if (mergeMatrix[nRow - 1][col].node != 0L) { if (m_colSpin->value() < col) m_colSpin->setValue(col); TableNode tableN = mergeMatrix[nRow - 1][col]; Node *n = tableN.node; setCellText(m_dataTable, nRow - 1, col, i18n("Merged with (%1, %2).").arg(tableN.mergedRow + 1).arg(tableN.mergedCol + 1)); m_dataTable->item(nRow-1, col)->setEnabled(false); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = true; tableNode.mergedRow = tableN.mergedRow; tableNode.mergedCol = tableN.mergedCol; tableRowTags.append(tableNode); if ((uint)nCol >= mergeMatrix[0].size()) // Check if there are enough cols for (uint i=0; i<mergeMatrix.size(); i++) mergeMatrix[i].resize(2 * mergeMatrix[i].size()); } else { tableNode.node = new Node(0L); newNum++; tableNode.node->tag = new Tag(); tableNode.node->tag->setDtd(m_dtd); tableNode.node->tag->parse("<td>", m_write); tableNode.merged = false; tableRowTags.append(tableNode); } } if (!tableRowTags.isEmpty()) m_tableTags->append(tableRowTags); tableRowTags.clear(); } } else if (tagName == "th" || tagName == "td") { if (countRows) { int col = nCol; while (mergeMatrix[nRow - 1][col].node != 0L) { if (m_colSpin->value() < col) m_colSpin->setValue(col); TableNode tableN = mergeMatrix[nRow - 1][col]; Node *n = tableN.node; setCellText(m_dataTable, nRow - 1, col, i18n("Merged with (%1, %2).").arg(tableN.mergedRow + 1).arg(tableN.mergedCol + 1)); m_dataTable->item(nRow-1, col)->setEnabled(false); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = true; tableNode.mergedRow = tableN.mergedRow; tableNode.mergedCol = tableN.mergedCol; tableRowTags.append(tableNode); col++; nCol++; if ((uint)nCol >= mergeMatrix[0].size()) // Check if there are enough cols for (uint i = 0; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(2 * mergeMatrix[i].size()); } nCol++; if (m_rowSpin && m_colSpin && m_dataTable) { m_rowSpin->setValue(nRow); if (m_colSpin->value() < nCol) m_colSpin->setValue(nCol); setCellText(m_dataTable, nRow - 1, nCol - 1, tagContent(n)); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = false; tableRowTags.append(tableNode); } QString colspanValue = n->tag->attributeValue("colspan", true); int colValue = 1; int lastCol = nCol; if (!colspanValue.isEmpty()) { bool ok; colValue = colspanValue.toInt(&ok, 10); if (ok && colValue > 1) { nCol += (colValue - 1); if (m_colSpin->value() < nCol) m_colSpin->setValue(nCol); for (int i = 0; i < colValue - 1; i++) { setCellText(m_dataTable, nRow - 1, lastCol + i, i18n("Merged with (%1, %2).").arg(nRow).arg(lastCol)); m_dataTable->item(nRow-1, lastCol + i)->setEnabled(false); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = true; tableNode.mergedRow = nRow - 1; tableNode.mergedCol = lastCol - 1; tableRowTags.append(tableNode); } } else colValue = 1; } QString rowspanValue = n->tag->attributeValue("rowspan", true); if (!rowspanValue.isEmpty()) { bool ok; int rowValue = rowspanValue.toInt(&ok, 10); if (ok && rowValue > 1) { lastCol--; // Check if there are enough columns in mergeMatriz if ((uint)(lastCol + colValue) >= mergeMatrix[0].size()) for (uint i = 0; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(2 * mergeMatrix[i].size()); // Check if there are enough rows in mergeMatriz if ((uint)(nRow + rowValue) >= mergeMatrix.size()) { mergeMatrix.resize(2 * mergeMatrix.size()); for (uint i = mergeMatrix.size() / 2; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(mergeMatrix[0].size()); } for (int i = 0; i < rowValue - 1; i++) for (int j = 0; j < colValue; j++) { mergeMatrix[nRow + i][lastCol + j].mergedRow = nRow - 1; mergeMatrix[nRow + i][lastCol + j].mergedCol = lastCol; mergeMatrix[nRow + i][lastCol + j].node = n; } } } } } else if (tagName == "caption") { captionText->setText(tagContent(n)); } else if (tagName == "col" || tagName == "colgroup") { m_colTags.append(n->tag); } n = n->nextSibling(); } /* if (missingBody) { //Hm, why do we need it? I don't remember now. ;-) rowSpinBox->setValue(nRow); colSpinBox->setValue(maxCol); } */ //by default the current page is the data handling page m_tableTags = m_tableDataTags; m_tableRows = m_tableDataRows; m_dataTable = tableData; m_rowSpin = rowSpinBox; m_colSpin = colSpinBox; //create the thead, tbody, tfoot tags if they were not present in the parsed area if (!m_thead) { m_thead = new Tag(); newNum++; m_thead->parse("<thead>", m_write); } if (!m_tfoot) { m_tfoot = new Tag(); newNum++; m_tfoot->parse("<tfoot>", m_write); } m_createNodes = true; //enable cell/row creation configureTable(tableData); configureTable(headerTableData); configureTable(footerTableData); return true; }
/****************************************************************************** * Must be called after presetting with a KCal::Recurrence, to convert the * recurrence to KARecurrence types: * - Convert hourly recurrences to minutely. * - Remove all but the first day in yearly date recurrences. * - Check for yearly recurrences falling on February 29th and adjust them as * necessary. A 29th of the month rule can be combined with either a 60th day * of the year rule or a last day of February rule. */ void KARecurrence::fix() { mCachedType = -1; mFeb29Type = FEB29_FEB29; int convert = 0; int days[2] = { 0, 0 }; RecurrenceRule *rrules[2]; RecurrenceRule::List rrulelist = rRules(); RecurrenceRule::List::ConstIterator rr = rrulelist.begin(); for(int i = 0; i < 2 && rr != rrulelist.end(); ++i, ++rr) { RecurrenceRule *rrule = *rr; rrules[i] = rrule; bool stop = true; int rtype = recurrenceType(rrule); switch(rtype) { case rHourly: // Convert an hourly recurrence to a minutely one rrule->setRecurrenceType(RecurrenceRule::rMinutely); rrule->setFrequency(rrule->frequency() * 60); // fall through to rMinutely case rMinutely: case rDaily: case rWeekly: case rMonthlyDay: case rMonthlyPos: case rYearlyPos: if(!convert) ++rr; // remove all rules except the first break; case rOther: if(dailyType(rrule)) { // it's a daily rule with BYDAYS if(!convert) ++rr; // remove all rules except the first } break; case rYearlyDay: { // Ensure that the yearly day number is 60 (i.e. Feb 29th/Mar 1st) if(convert) { // This is the second rule. // Ensure that it can be combined with the first one. if(days[0] != 29 || rrule->frequency() != rrules[0]->frequency() || rrule->startDt() != rrules[0]->startDt()) break; } QValueList<int> ds = rrule->byYearDays(); if(!ds.isEmpty() && ds.first() == 60) { ++convert; // this rule needs to be converted days[i] = 60; stop = false; break; } break; // not day 60, so remove this rule } case rYearlyMonth: { QValueList<int> ds = rrule->byMonthDays(); if(!ds.isEmpty()) { int day = ds.first(); if(convert) { // This is the second rule. // Ensure that it can be combined with the first one. if(day == days[0] || day == -1 && days[0] == 60 || rrule->frequency() != rrules[0]->frequency() || rrule->startDt() != rrules[0]->startDt()) break; } if(ds.count() > 1) { ds.clear(); // remove all but the first day ds.append(day); rrule->setByMonthDays(ds); } if(day == -1) { // Last day of the month - only combine if it's February QValueList<int> months = rrule->byMonths(); if(months.count() != 1 || months.first() != 2) day = 0; } if(day == 29 || day == -1) { ++convert; // this rule may need to be converted days[i] = day; stop = false; break; } } if(!convert) ++rr; break; } default: break; } if(stop) break; } // Remove surplus rules for(; rr != rrulelist.end(); ++rr) { removeRRule(*rr); delete *rr; } QDate end; int count; QValueList<int> months; if(convert == 2) { // There are two yearly recurrence rules to combine into a February 29th recurrence. // Combine the two recurrence rules into a single rYearlyMonth rule falling on Feb 29th. // Find the duration of the two RRULEs combined, using the shorter of the two if they differ. if(days[0] != 29) { // Swap the two rules so that the 29th rule is the first RecurrenceRule *rr = rrules[0]; rrules[0] = rrules[1]; // the 29th rule rrules[1] = rr; int d = days[0]; days[0] = days[1]; days[1] = d; // the non-29th day } // If February is included in the 29th rule, remove it to avoid duplication months = rrules[0]->byMonths(); if(months.remove(2)) rrules[0]->setByMonths(months); count = combineDurations(rrules[0], rrules[1], end); mFeb29Type = (days[1] == 60) ? FEB29_MAR1 : FEB29_FEB28; } else if(convert == 1 && days[0] == 60) { // There is a single 60th day of the year rule. // Convert it to a February 29th recurrence. count = duration(); if(!count) end = endDate(); mFeb29Type = FEB29_MAR1; } else return; // Create the new February 29th recurrence setNewRecurrenceType(RecurrenceRule::rYearly, frequency()); RecurrenceRule *rrule = defaultRRule(); months.append(2); rrule->setByMonths(months); QValueList<int> ds; ds.append(29); rrule->setByMonthDays(ds); if(count) setDuration(count); else setEndDate(end); }
int QDockAreaLayout::layoutItems( const QRect &rect, bool testonly ) { if ( !dockWindows || !dockWindows->first() ) return 0; dirty = FALSE; // some corrections QRect r = rect; if ( orientation() == Vertical ) r.setHeight( r.height() - 3 ); // init lines.clear(); ls.clear(); QPtrListIterator<QDockWindow> it( *dockWindows ); QDockWindow *dw = 0; int start = start_pos( r, orientation() ); int pos = start; int sectionpos = 0; int linestrut = 0; QValueList<DockData> lastLine; int tbstrut = -1; int maxsize = size_extent( rect.size(), orientation() ); int visibleWindows = 0; // go through all widgets in the dock while ( ( dw = it.current() ) != 0 ) { ++it; if ( dw->isHidden() ) continue; ++visibleWindows; // find position for the widget: This is the maximum of the // end of the previous widget and the offset of the widget. If // the position + the width of the widget dosn't fit into the // dock, try moving it a bit back, if possible. int op = pos; int dockExtend = dock_extent( dw, orientation(), maxsize ); if ( !dw->isStretchable() ) { pos = QMAX( pos, dw->offset() ); if ( pos + dockExtend > size_extent( r.size(), orientation() ) - 1 ) pos = QMAX( op, size_extent( r.size(), orientation() ) - 1 - dockExtend ); } if ( !lastLine.isEmpty() && !dw->newLine() && space_left( rect, pos, orientation() ) < dockExtend ) shrink_extend( dw, dockExtend, space_left( rect, pos, orientation() ), orientation() ); // if the current widget doesn't fit into the line anymore and it is not the first widget of the line if ( !lastLine.isEmpty() && ( space_left( rect, pos, orientation() ) < dockExtend || dw->newLine() ) ) { if ( !testonly ) // place the last line, if not in test mode place_line( lastLine, orientation(), linestrut, size_extent( r.size(), orientation() ), tbstrut, maxsize, this ); // remember the line coordinats of the last line if ( orientation() == Horizontal ) lines.append( QRect( 0, sectionpos, r.width(), linestrut ) ); else lines.append( QRect( sectionpos, 0, linestrut, r.height() ) ); // do some clearing for the next line lastLine.clear(); sectionpos += linestrut; linestrut = 0; pos = start; tbstrut = -1; } // remeber first widget of a line if ( lastLine.isEmpty() ) { ls.append( dw ); // try to make the best position int op = pos; if ( !dw->isStretchable() ) pos = QMAX( pos, dw->offset() ); if ( pos + dockExtend > size_extent( r.size(), orientation() ) - 1 ) pos = QMAX( op, size_extent( r.size(), orientation() ) - 1 - dockExtend ); } // do some calculations and add the remember the rect which the docking widget requires for the placing QRect dwRect(pos, sectionpos, dockExtend, dock_strut( dw, orientation() ) ); lastLine.append( DockData( dw, dwRect ) ); if ( ::qt_cast<QToolBar*>(dw) ) tbstrut = QMAX( tbstrut, dock_strut( dw, orientation() ) ); linestrut = QMAX( dock_strut( dw, orientation() ), linestrut ); add_size( dockExtend, pos, orientation() ); } // if some stuff was not placed/stored yet, do it now if ( !testonly ) place_line( lastLine, orientation(), linestrut, size_extent( r.size(), orientation() ), tbstrut, maxsize, this ); if ( orientation() == Horizontal ) lines.append( QRect( 0, sectionpos, r.width(), linestrut ) ); else lines.append( QRect( sectionpos, 0, linestrut, r.height() ) ); if ( *(--lines.end()) == *(--(--lines.end())) ) lines.remove( lines.at( lines.count() - 1 ) ); it.toFirst(); bool hadResizable = FALSE; while ( ( dw = it.current() ) != 0 ) { ++it; if ( !dw->isVisibleTo( parentWidget ) ) continue; hadResizable = hadResizable || dw->isResizeEnabled(); dw->updateSplitterVisibility( visibleWindows > 1 ); //!dw->area()->isLastDockWindow( dw ) ); } return sectionpos + linestrut; }
void ChunkManager::downloadPriorityChanged(TorrentFile* tf,Priority newpriority,Priority oldpriority) { if (newpriority == EXCLUDED) { downloadStatusChanged(tf, false); return; } if (oldpriority == EXCLUDED) { downloadStatusChanged(tf, true); return; } savePriorityInfo(); Uint32 first = tf->getFirstChunk(); Uint32 last = tf->getLastChunk(); // first and last chunk may be part of multiple files // so we can't just exclude them QValueList<Uint32> files; // get list of files where first chunk lies in tor.calcChunkPos(first,files); Chunk* c = chunks[first]; // if one file in the list needs to be downloaded,increment first for (QValueList<Uint32>::iterator i = files.begin();i != files.end();i++) { Priority np = tor.getFile(*i).getPriority(); if (np > newpriority && *i != tf->getIndex()) { // make sure we don't go past last if (first == last) return; first++; break; } } files.clear(); // get list of files where last chunk lies in tor.calcChunkPos(last,files); c = chunks[last]; // if one file in the list needs to be downloaded,decrement last for (QValueList<Uint32>::iterator i = files.begin();i != files.end();i++) { Priority np = tor.getFile(*i).getPriority(); if (np > newpriority && *i != tf->getIndex()) { // make sure we don't wrap around if (last == 0 || last == first) return; last--; break; } } // last smaller then first is not normal, so just return if (last < first) { return; } prioritise(first,last,newpriority); if (newpriority == ONLY_SEED_PRIORITY) excluded(first,last); }
void KGrCanvas::initView() { changeColours (& colourScheme [0]); // Set "KGoldrunner" landscape. // Set up the pixmaps for the editable objects. freebg = 0; // Free space. nuggetbg = 1; // Nugget. polebg = 2; // Pole or bar. ladderbg = 3; // Ladder. hladderbg = 4; // Hidden ladder (for editing). edherobg = 5; // Static hero (for editing). edenemybg = 6; // Static enemy (for editing). betonbg = 7; // Concrete. // The bricks have 10 pixmaps (showing various stages of digging). brickbg = 8; // Solid brick - 1st pixmap. fbrickbg = 15; // False brick - 8th pixmap (for editing). QPixmap pixmap; QImage image; pixmap = QPixmap (hgbrick_xpm); bgw = pixmap.width(); // Save dimensions for "getPixmap". bgh = pixmap.height(); bgd = pixmap.depth(); // Assemble the background and editing pixmaps into a strip (18 pixmaps). bgPix = QPixmap ((brickbg + 10) * bgw, bgh, bgd); makeTiles(); // Fill the strip with 18 tiles. // Define the canvas as an array of tiles. Default tile is 0 (free space). int frame = frameWidth()*2; field = new QCanvas ((FIELDWIDTH+border) * bgw, (FIELDHEIGHT+border) * bgh); field->setTiles (bgPix, (FIELDWIDTH+border), (FIELDHEIGHT+border), bgw, bgh); // Embed the canvas in the view and make it occupy the whole of the view. setCanvas (field); setVScrollBarMode (QScrollView::AlwaysOff); setHScrollBarMode (QScrollView::AlwaysOff); setFixedSize (field->width() + frame, field->height() + frame); ////////////////////////////////////////////////////////////////////////// // The pixmaps for hero and enemies are arranged in strips of 20: walk // // right (4), walk left (4), climb right along bar (4), climb left (4), // // climb up ladder (2) and fall (2) --- total 20. // ////////////////////////////////////////////////////////////////////////// // Convert the pixmap strip for hero animation into a QCanvasPixmapArray. pixmap = QPixmap (hero_xpm); image = pixmap.convertToImage (); #ifdef QT3 QPixmap pm; QValueList<QPixmap> pmList; for (int i = 0; i < 20; i++) { pm.convertFromImage (image.copy (i * 16, 0, 16, 16)); pmList.append (pm); } heroArray = new QCanvasPixmapArray (pmList); // Hot spots all (0,0). #else QPixmap * pm; QPoint * pt; QList<QPixmap> pmList; QList<QPoint> ptList; pt = new QPoint (0, 0); // "Hot spot" not used in KGoldrunner. for (int i = 0; i < 20; i++) { pm = new QPixmap (); pm->convertFromImage (image.copy (i * 16, 0, 16, 16)); pmList.append (pm); ptList.append (pt); } heroArray = new QCanvasPixmapArray (pmList, ptList); #endif // Convert pixmap strips for enemy animations into a QCanvasPixmapArray. // First convert the pixmaps for enemies with no gold ... pixmap = QPixmap (enemy1_xpm); image = pixmap.convertToImage (); pmList.clear(); #ifdef QT3 for (int i = 0; i < 20; i++) { pm.convertFromImage (image.copy (i * 16, 0, 16, 16)); pmList.append (pm); } #else ptList.clear(); for (int i = 0; i < 20; i++) { pm = new QPixmap (); pm->convertFromImage (image.copy (i * 16, 0, 16, 16)); pmList.append (pm); ptList.append (pt); } #endif // ... then convert the gold-carrying enemies. pixmap = QPixmap (enemy2_xpm); image = pixmap.convertToImage (); #ifdef QT3 for (int i = 0; i < 20; i++) { pm.convertFromImage (image.copy (i * 16, 0, 16, 16)); pmList.append (pm); } enemyArray = new QCanvasPixmapArray (pmList); // Hot spots all (0,0). #else for (int i = 0; i < 20; i++) { pm = new QPixmap (); pm->convertFromImage (image.copy (i * 16, 0, 16, 16)); pmList.append (pm); ptList.append (pt); } enemyArray = new QCanvasPixmapArray (pmList, ptList); #endif goldEnemy = 20; // Offset of gold-carrying frames. // Draw the border around the playing area (z = 0). makeBorder(); // Create a title item, in off-white colour, on top of the border. title = 0; makeTitle(); // Create an empty list of enemy sprites. #ifdef QT3 enemySprites = new QPtrList<QCanvasSprite> (); #else enemySprites = new QList<QCanvasSprite> (); #endif enemySprites->setAutoDelete(TRUE); }