int main(int argc,char **argv) { QApplication app(argc,argv); QPtrList<int> list; for (int i=0;i<3;i++) { list.append(new int(i)); // 插入資料 } list.first(); // 先跳到第一個元素 for (int i=0;i<3;i++,list.next()) { cout << *(list.current()) << endl; } list.first(); list.next(); list.remove(); list.remove(); list.remove(); cout << *(list.current()) << endl; // 由這一個例子可以知道,刪掉一個成員後,指標會跑到下一個.但若刪掉後沒有下一個時,指標會跑到前一個 return 0; }
/*! \internal Reads and removes from internal read buffer \a nbytes and place then into \a sink. Returns true if successfull or false if there were not enought bytes to fullfill the request. */ bool cAsyncNetIOPrivate::consumeReadBuf( Q_ULONG nbytes, char *sink ) { if ( nbytes <= 0 || nbytes > rsize ) return false; rsize -= nbytes; for ( ;; ) { QByteArray *a = rba.first(); if ( rindex + nbytes >= a->size() ) { // Here we skip the whole byte array and get the next later int len = a->size() - rindex; if ( sink ) { memcpy( sink, a->data()+rindex, len ); sink += len; } nbytes -= len; rba.remove(); rindex = 0; if ( nbytes == 0 ) { // nothing more to skip break; } } else { // Here we skip only a part of the first byte array if ( sink ) memcpy( sink, a->data()+rindex, nbytes ); rindex += nbytes; break; } } return true; }
void xQGanttBarViewPort::deleteSelectedItems() { #ifdef _DEBUG_ printf("-> xQGanttBarViewPort::deleteSelectedItems()\n"); #endif QPtrList<KGanttItem> list; observeList(&list); getSelectedItems(_toplevelitem, list); for(KGanttItem *subitem = list.first(); subitem != 0; subitem = list.next()) { #ifdef _DEBUG_ printf(" : %s \n", subitem->getText().latin1()); #endif connect(subitem, SIGNAL(destroyed(KGanttItem *)), this, SLOT(itemDestroyed(KGanttItem *))); } list.remove(_toplevelitem); while(list.count() > 0) { KGanttItem *item = list.getFirst(); delete item; } #ifdef _DEBUG_ printf("<- xQGanttBarViewPort::deleteSelectedItems()\n"); #endif }
// The dtor. QsciScintillaBase::~QsciScintillaBase() { // Remove it from the pool. poolList.remove(this); delete sci; }
PlotLine * THERM::calculateCustom (QString &p, QPtrList<PlotLine> &d) { // format1: MA_TYPE, MA_PERIOD, THRESHOLD, SMOOTHING_TYPE, SMOOTHING_PERIOD if (checkFormat(p, d, 5, 5)) return 0; QStringList mal; getMATypes(mal); maType = mal.findIndex(formatStringList[0]); maPeriod = formatStringList[1].toInt(); threshold = formatStringList[2].toDouble(); smoothType = mal.findIndex(formatStringList[3]); smoothing = formatStringList[4].toInt(); QPtrList<PlotLine> pll; pll.setAutoDelete(FALSE); getTHERM(pll); int loop; for (loop = pll.count() - 1; loop > 0; loop--) pll.remove(loop); return pll.at(0); }
/*! \internal Removes from internal read buffer \a nbytes. Returns true if successfull or false if there were not enought bytes in buffer to fullfill the request. */ bool cAsyncNetIOPrivate::consumeWriteBuf( Q_ULONG nbytes ) { if ( nbytes > wsize ) { wsize = 0; return false; } if ( nbytes <= 0 || nbytes > wsize ) return false; wsize -= nbytes; for ( ; ; ) { QByteArray* a = ewba.first(); if ( windex + nbytes >= a->size() ) { nbytes -= a->size() - windex; ewba.remove(); windex = 0; if ( nbytes == 0 ) break; } else { windex += nbytes; break; } } return false; }
void QEventLoopEx::unregisterSocketNotifier( QSocketNotifier *notifier ) { int sockfd = notifier->socket(); int type = notifier->type(); if ( sockfd < 0 || type < 0 || type > 2 || notifier == 0 ) { #if defined(QT_CHECK_RANGE) qWarning( "QSocketNotifier: Internal error" ); #endif return; } #ifdef _DEBUG_EVENTLOOPEX qDebug( "QSocketNotifier::unregisterSocketNotifier %p", notifier ); #endif EnterCriticalSection(&d->m_csVec); QPtrList<QSockNotEx> *list = d->sn_vec[type].list; fd_set *fds = &d->sn_vec[type].enabled_fds; QSockNotEx *sn; if ( ! list ) { LeaveCriticalSection(&d->m_csVec); QEventLoop::unregisterSocketNotifier(notifier); return; } sn = list->first(); while ( sn && !(sn->obj == notifier && sn->fd == sockfd) ) sn = list->next(); if ( !sn ) {// not found LeaveCriticalSection(&d->m_csVec); QEventLoop::unregisterSocketNotifier(notifier); return; } FD_CLR( sockfd, fds ); // clear fd bit FD_CLR( sockfd, sn->queue ); EnterCriticalSection(&d->m_csPendingList); d->sn_pending_list.removeRef( sn ); // remove from activation list bool bNowEmpty = (d->sn_pending_list.count() == 0); LeaveCriticalSection(&d->m_csPendingList); if(bNowEmpty) SetEvent(d->m_evPendingListEmpty); list->remove(); // remove notifier found above if ( d->sn_highest == sockfd ) {// find highest fd d->sn_highest = -1; for ( int i=0; i<3; i++ ) { if ( d->sn_vec[i].list && ! d->sn_vec[i].list->isEmpty() ) d->sn_highest = QMAX( d->sn_highest, // list is fd-sorted d->sn_vec[i].list->getFirst()->fd ); } } LeaveCriticalSection(&d->m_csVec); #ifdef _DEBUG_EVENTLOOPEX qDebug( "QSocketNotifier::signal update socket"); #endif closesocket(d->m_sockUpdate); }
void KSSLInfoDlg::slotChain(int x) { if(x == 0) { displayCert(d->_cert); } else { QPtrList< KSSLCertificate > cl = d->_cert->chain().getChain(); cl.setAutoDelete(true); for(int i = 0; i < x - 1; i++) cl.remove((unsigned int)0); KSSLCertificate thisCert = *(cl.at(0)); cl.remove((unsigned int)0); thisCert.chain().setChain(cl); displayCert(&thisCert); } }
QUimInputContext::~QUimInputContext() { #ifdef ENABLE_DEBUG qDebug( "~QUimInputContext()" ); #endif contextList.remove( this ); if ( m_uc ) uim_release_context( m_uc ); if ( this == focusedInputContext ) { focusedInputContext = NULL; disableFocusedContext = true; } #ifdef Q_WS_X11 delete mCompose; #endif }
void QEventLoop::unregisterSocketNotifier( QSocketNotifier *notifier ) { int sockfd = notifier->socket(); int type = notifier->type(); if ( sockfd < 0 || type < 0 || type > 2 || notifier == 0 ) { #if defined(QT_CHECK_RANGE) qWarning( "QSocketNotifier: Internal error" ); #endif return; } QPtrList<QSockNot> *list = d->sn_vec[type].list; fd_set *fds = &d->sn_vec[type].enabled_fds; QSockNot *sn; if ( ! list ) return; sn = list->first(); while ( sn && !(sn->obj == notifier && sn->fd == sockfd) ) sn = list->next(); if ( !sn ) // not found return; FD_CLR( sockfd, fds ); // clear fd bit FD_CLR( sockfd, sn->queue ); d->sn_pending_list.removeRef( sn ); // remove from activation list list->remove(); // remove notifier found above if ( d->sn_highest == sockfd ) { // find highest fd d->sn_highest = -1; for ( int i=0; i<3; i++ ) { if ( d->sn_vec[i].list && ! d->sn_vec[i].list->isEmpty() ) d->sn_highest = QMAX( d->sn_highest, // list is fd-sorted d->sn_vec[i].list->getFirst()->fd ); } } }
void HiddenFileView::checkBoxClicked(QCheckBox* chkBox,KToggleAction* action,QLineEdit* edit, int column,QPtrList<QRegExp> & reqExpList,bool b) { // We don't save the old state so // disable the tristate mode chkBox->setTristate(false); action->setChecked(b); chkBox->setChecked(b); HiddenListViewItem* item; for (item = static_cast<HiddenListViewItem*>(_dlg->hiddenListView->firstChild());item; item = static_cast<HiddenListViewItem*>(item->nextSibling())) { if (!item->isSelected()) continue; if (b == item->isOn(column)) continue; if (!b) { QRegExp* rx = getRegExpListMatch(item->text(0),reqExpList); // Perhaps the file was hidden because it started with a dot if (!rx && item->text(0)[0]=='.' && _dlg->hideDotFilesChk->isChecked()) { int result = KMessageBox::questionYesNo(_dlg,i18n( "<qt>Some files you have selected are hidden because they start with a dot; " "do you want to uncheck all files starting with a dot?</qt>"),i18n("Files Starting With Dot"),i18n("Uncheck Hidden"), i18n("Keep Hidden")); if (result == KMessageBox::No) { QPtrList<HiddenListViewItem> lst = getMatchingItems(QRegExp(".*",false,true)); deselect(lst); } else { _dlg->hideDotFilesChk->setChecked(false); } continue; } else { if (rx) { // perhaps it is matched by a wildcard string QString p = rx->pattern(); if ( p.find("*") > -1 || p.find("?") > -1 ) { // TODO after message freeze: why show three times the wildcard string? Once should be enough. // TODO remove <b></b> and use <qt> instead int result = KMessageBox::questionYesNo(_dlg,i18n( "<b></b>Some files you have selected are matched by the wildcarded string <b>'%1'</b>; " "do you want to uncheck all files matching <b>'%1'</b>?").arg(rx->pattern()).arg(rx->pattern()).arg(rx->pattern()), i18n("Wildcarded String"),i18n("Uncheck Matches"),i18n("Keep Selected")); QPtrList<HiddenListViewItem> lst = getMatchingItems( *rx ); if (result == KMessageBox::No) { deselect(lst); } else { setState(lst,column,false); reqExpList.remove(rx); updateEdit(edit, reqExpList); } continue; } else { reqExpList.remove(rx); updateEdit(edit, reqExpList); } } } } else { reqExpList.append( new QRegExp(item->text(0)) ); updateEdit(edit, reqExpList); } item->setOn(column,b); } _dlg->hiddenListView->update(); }
void NPmxExport::doExport() { int i, j; NVoice *voice_elem; NStaff *staff_elem; NTimeSig *timesig; NKeySig *keysig; NClef *clef; QPtrList<QString> lyrNames; QString *lyrName; QString lyricslist[NUM_LYRICS]; property_type kind; int count; int acr; bool staffsWritten, first; const char *endOfLine; int voice_count; int barpos; int count_of_lyrics; int idx; int multistaffnr; int numOfStaffsInMultistaff; #if GCC_MAJ_VERS > 2 ostringstream os; ostringstream *pmxout[2]; #else char obuffer[2][OBLONG]; char buffer[BUFLONG]; ostrstream os(buffer, 100); ostrstream *pmxout[2]; #endif badmeasure *bad; lastTone_ = 1000; lastLength_ = 1000; openSpecialEnding_ = 0; pendingSpecialEnd_ = 0; pendingEndSpecialEnd_ = false; tupletBase_ = 0; countof128th_ = 128; barNr_ = 1; tiePool_ = 0; slurPool_ = 0; vaPool_ = 0; pendingTimeSig_ = 0; pendingKeySig_ = 0; pendingSpecialEnd_ = 0; drum_problem_written_ = false; exportDialog_->getPMXOptions( pmxOpts_ ); specialCharList_.clear(); badlist_.clear(); if (fileName.isNull()) return; if (NResource::staffSelExport_ == 0) { NResource::staffSelExport_ = new bool[staffList_->count()]; for (i = 0; i < (int)staffList_->count(); NResource::staffSelExport_[i++] = true); staffsToExport_ = staffList_->count(); } else { staffsToExport_ = 0; for (i = 0; i < (int)staffList_->count(); i++) { if (NResource::staffSelExport_[i]) { staffsToExport_++; } } } out_.open(fileName); if (!out_) { os << "error opening file " << fileName << '\0'; #if GCC_MAJ_VERS > 2 KMessageBox::sorry (0, QString(os.str().c_str()), kapp->makeStdCaption(i18n("PMX export"))); #else KMessageBox::sorry (0, QString(os.str()), kapp->makeStdCaption(i18n("PMX export"))); #endif return; } #if GCC_MAJ_VERS > 2 pmxout[0] = new ostringstream(); pmxout[1] = new ostringstream(); #else pmxout[0] = new ostrstream(obuffer[0], OBLONG); pmxout[1] = new ostrstream(obuffer[1], OBLONG); #endif va_descr_ = (struct trill_descr_str *) alloca(staffsToExport_ * sizeof(struct trill_descr_str)); for (i = 0; i < staffsToExport_; i++) { va_descr_[i].trill_nr = -1; } LastPMXfile_ = fileName; voice_elem = staffList_->first()->getVoiceNr(0); keysig = voice_elem->getFirstKeysig(); if (!keysig) { keysig = new NKeySig(0, 0); } timesig = voice_elem->getFirstTimeSig(); if (!timesig) { timesig = new NTimeSig(0, &NResource::nullprops_); timesig->setSignature(4, 4); } countof128th_ = timesig->numOf128th(); mStaffInf_ = new NMultistaffInfo(mainWidget_, staffList_, staffList_->count()); if (mStaffInf_->hasDisconnectedPianoBars()) { bad = new badmeasure(PMX_ERR_DISCONT_PIANO, 1 /*dummy */, 0 /* dummy */, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } out_ << "%-----------------------------------------%" << endl; out_ << "% %" << endl; out_ << "% PMX output generated by \"NoteEdit\" %" << endl; out_ << "% %" << endl; out_ << "%-----------------------------------------%" << endl; if (pmxOpts_.mLyr) { out_ << "---" << endl; out_ << "\\input musixtex" << endl; out_ << "\\input pmx" << endl; out_ << "\\input musixlyr" << endl << endl; lyrNames.setAutoDelete(true); for (i = 0, staff_elem = staffList_->first(); staff_elem; staff_elem = staffList_->next(), i++) { if (!NResource::staffSelExport_[i]) continue; voice_elem = staff_elem->getVoiceNr(0); if (!(count_of_lyrics = voice_elem->countOfLyricsLines())) continue; voice_elem->collectLyrics(lyricslist); lyrNames.clear(); for (j = 0; j < NUM_LYRICS; j++) { if (!lyricslist[j].isEmpty()) { lyrName = new QString(); if (count_of_lyrics < 2) { lyrName->sprintf("lyrstaff%d", staffsToExport_ - i); } else { lyrName->sprintf("lyrstaff%dverse%d", staffsToExport_ - i, j+1); } lyrNames.append(lyrName); out_ << "\\setlyrics{" << (*lyrName) << "}{" << lyrics2TeX(&(lyricslist[j])) << "}" << endl; } } out_ << "\\assignlyrics{" << (staffsToExport_ - i) << "}{"; while(!lyrNames.isEmpty()) { out_ << *(lyrNames.first()); lyrNames.remove(); if (!lyrNames.isEmpty()) out_ << ','; } out_ << '}' << endl << endl; } out_ << "---" << endl; } /* out_ << "---" << endl; out_ << "\\def\\mtxInterInstrument#1#2{\\setinterinstrument{#1}{#2\\Interligne}}" << endl; out_ << "\\def\\mtxStaffBottom#1{\\staffbotmarg #1\\Interligne}" << endl; out_ << "---" << endl << endl; */ out_ << "% nv,noinst,mtrnuml,mtrdenl,mtrnump,mtrdenp,xmtrnum0,isig," << endl; out_ << " " << staffsToExport_ << " "; if (staffsToExport_ == mStaffInf_->getMultiStaffCount()) { out_ << staffsToExport_ << " "; } else { out_ << '-' << mStaffInf_->getMultiStaffCount() << ' '; for (i = 0; i < mStaffInf_->getMultiStaffCount(); i++) { out_ << mStaffInf_->getStaffCount(mStaffInf_->getMultiStaffCount()-i-1) << ' '; } } out_ << timesig->getNumerator() << " " << timesig->getDenominator() << " " << timesig->getNumerator() << " " << timesig->getDenominator(); acr = voice_elem->determineAnacrusis(); if (acr>0) { out_ << " " << ((double) acr / (128.0 / (double) timesig->getDenominator())) << " "; } else { out_ << " 0 "; } if (keysig->isRegular(&kind, &count)) { if (kind == PROP_FLAT) count = -count; out_ << count << endl; } else { out_ << "0" << endl; } out_ << "% npages,nsyst,musicsize,fracindent" << endl; out_ << " " << pmxOpts_.num << " " << pmxOpts_.system << " 20 0.07" << endl; out_ << "%" << endl; for (i = 0; i < mStaffInf_->getMultiStaffCount(); i++) { if ((staff_elem = staffList_->at(mStaffInf_->getfirstStaffInMultistaff(mStaffInf_->getMultiStaffCount()-i-1))) == 0) { NResource::abort("NPmxExport::doExport: internal error", 1); } if (!staff_elem->staffName_.isEmpty()) { out_ << staff_elem->staffName_ << endl; } else { out_ << endl; } } for (i = 0, staff_elem = staffList_->last(); staff_elem; staff_elem = staffList_->prev(), i++) { if (!NResource::staffSelExport_[staffList_->count() - i - 1]) continue; if ((voice_count = staff_elem->voiceCount()) > 2) { bad = new badmeasure(PMX_ERR_MULTIPLE_VOICES, i+1, 0, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } voice_elem = staff_elem->getVoiceNr(0); clef = voice_elem->getFirstClef(); switch (clef->getSubType()) { case BASS_CLEF: out_ << "b"; break; case SOPRANO_CLEF: out_ << "s"; break; case ALTO_CLEF: out_ << "a"; break; case TENOR_CLEF: out_ << "n"; break; case DRUM_CLEF: if (!drum_problem_written_) { drum_problem_written_ = true; bad = new badmeasure(PMX_ERR_DRUM_STAFF, i+1, 0, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } case DRUM_BASS_CLEF: if (!drum_problem_written_) { drum_problem_written_ = true; bad = new badmeasure(PMX_ERR_DRUM_STAFF, i+1, 0, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } default: out_ << "t"; break; } for (j = 0; j < voice_count && j < 2; j++) { voice_elem = staff_elem->getVoiceNr(j); voice_elem->prepareForWriting(); } } out_ << endl << "./" << endl; mStaffInf_->writeAkkoladen(&out_, true); if (!mStaffInf_->ContinuedBarLines()) { if (mStaffInf_->DiscontOutsidePiano()) { bad = new badmeasure(PMX_ERR_INDIV_BAR, 1 /* dummy */, 0 /* dummy */, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); out_ << "\\\\input musixdbr.tex\\relax\\" << endl; out_ << "\\\\indivbarrules\\" << endl << "\\\\allbarrules\\sepbarrule"; for (i = 0; i < (int)staffList_->count(); i++) { if (mainWidget_->barCont_[i].valid) { for (j = mainWidget_->barCont_[i].beg; j < mainWidget_->barCont_[i].end; j++) { idx = mStaffInf_->multistaffIdxOfStaff(j, &multistaffnr, &numOfStaffsInMultistaff); if (idx == numOfStaffsInMultistaff - 1) { out_ << "\\conbarrule{" << (mStaffInf_->getMultiStaffCount() - multistaffnr) << '}'; } } } } } else { out_ << "\\\\sepbarrules"; } out_ << "\\" << endl; } out_ << "w" << pmxOpts_.width << "m" << endl; out_ << "h" << pmxOpts_.height << "m" << endl; if (!mainWidget_->scTitle_.isEmpty()) { out_ << "Tt" << endl << '{' << mainWidget_->scTitle_ << '}' << endl; } if (!mainWidget_->scAuthor_.isEmpty()) { out_ << "Tc" << endl << '{' << mainWidget_->scAuthor_ << '}' << endl; } /* out_ << endl << "\\\\mtxStaffBottom{2}\\" << endl; for (i = 0; i < staffsToExport_; i++) { out_ << "\\\\mtxInterInstrument{" << (i+1) << "}{-1}\\" << endl; } */ do { staffsWritten = false; first = true; out_ << endl << "% Measure " << barNr_ << " - " << barNr_ + pmxOpts_.measure - 1 << endl; for (i = staffList_->count(), staff_elem = staffList_->last(); staff_elem; staff_elem = staffList_->prev(), i--) { if (!NResource::staffSelExport_[i-1]) continue; voice_count = staff_elem->voiceCount(); for (j = 0; j < voice_count && j < 2; j++) { voice_elem = staff_elem->getVoiceNr(j); endOfLine = j == 0 ? "/" : "//"; pmxout_ = pmxout[j]; if (j == 0) barpos = (1 << 30); /* infinity */ lastLength_ = 1000; /* invalidate */ lastTone_ = 1000; /* invalidate */ if (writeTrack(voice_elem, i, j, voice_count, pmxOpts_.measure, first, endOfLine, &barpos)) { staffsWritten = true; } } first = false; if (staffsWritten) { for (j = voice_count > 1 ? 1 : 0; j >= 0; j--) { lineOut(pmxout[j]); #if GCC_MAJ_VERS > 2 delete pmxout[j]; pmxout[j] = new ostringstream(); #else pmxout[j]->seekp(0); #endif } } } barNr_ += pmxOpts_.measure; } while (staffsWritten); out_.close(); if (NResource::staffSelExport_ != 0) { delete [] NResource::staffSelExport_; NResource::staffSelExport_ = 0; } delete mStaffInf_; if (!badlist_.isEmpty()) { QString output; output = i18n ("NoteEdit has exported the score to PMX format but there are some problems which can prevent successful PostScript/PDF output or can change the final score layout.\n"); output += i18n("-----------------------------------------------------\n"); for (bad = badlist_.first(); bad; bad = badlist_.next()) { switch (bad->kind) { case PMX_ERR_BAD_NOTE_COUNT : output += i18n ( "Staff %1, measure %2: %3 128th, should be: %4\n"). arg(bad->track).arg(bad->measure).arg(bad->realcount).arg(bad->shouldbe); break; case PMX_ERR_MULTIREST : output += i18n ( "Staff %1, measure %2: PMX cannot deal with multi rests if more than 1 staff is exported"). arg(bad->track).arg(bad->measure); break; case PMX_ERR_TOO_MANY_TIES: output += i18n ( "measure %1: Too many opened ties\n").arg(bad->measure); break; case PMX_ERR_TOO_MANY_SLURS: output += i18n ( "measure %1: Too many opened slurs\n").arg(bad->measure); break; case PMX_ERR_NOT_NUM_TUMPLET: output += i18n ("Staff %1, measure %2: PMX can only deal with equal tuplet members or members in ratio 2:1\n"). arg(bad->track).arg(bad->measure); break; case PMX_ERR_TUPLET_ENDS_REST: output += i18n ("Staff %1, measure %2: In PMX tuplet cannot end with a rest\n"). arg(bad->track).arg(bad->measure); break; case PMX_ERR_MULTIPLE_VOICES: output += i18n ("PMX cannot deal with more than 2 voices per staff\n"); break; case PMX_ERR_DRUM_STAFF: output += i18n ("Staff %1 contains drum staff. This cannot be expressed in PMX.\n") .arg(bad->track); break; case PMX_WARN_MIXED_GRACES: output += i18n ("Staff %1, measure %2: PMX cannot deal with mixed graces\n"). arg(bad->track).arg(bad->measure); break; case PMX_ERR_GRACES: output += i18n ("Staff %1, measure %2: grace has no main note. PMX will not work\n"). arg(bad->track).arg(bad->measure); break; case PMX_TUPLET_LENGTH: output += i18n ("Staff %1, measure %2: Tuplet must be expressible by on (ev. dotted) note. PMX will not work\n"). arg(bad->track).arg(bad->measure); break; case PMX_ERR_INDIV_BAR: output += i18n ("The score has individual bar layout (partial continued and partial discontinued)\nPlease install \"musixdbr.tex\" by Rainer Dunker\n"); break; case PMX_ERR_DISCONT_PIANO: output += i18n ("The score has piano staffs with discontinued bar rules. This cannot be expressed in PMX\n"); break; case PMX_ERR_NESTED_VAS: output += i18n ("Nested trills in measure: %1 ;\n").arg(bad->measure); break; case PMX_ERR_TOO_MANY_VAS: output += i18n ("Too many va lines in measure: %1: maximum = 6\n").arg(bad->measure); break; } } NResource::exportWarning_->setOutput(i18n ("PMX produced. But there are some problems."), &output); NResource::exportWarning_->show(); } }
void CustomPalette::slotRemoveColor() { int i, j; if ( sel_row == -1 || sel_col == -1 ) { //do nothing } else { if ( cur_col == 0 ) { cur_col = numCols() - 1; cur_row--; } else cur_col--; color_matrix[sel_row][sel_col] = invalid_color; color_names[sel_row][sel_col] = ""; alpha_matrix[sel_row][sel_col] = -1; updateCell( sel_row, sel_col ); QPtrList<Color> cl = k_toon -> document() -> getPalette() -> getColors(); cl.setAutoDelete( true ); cl.remove( map2Dto1D( sel_row, sel_col ) ); cl.setAutoDelete( false ); k_toon -> document() -> getPalette() -> setColors( cl ); for ( i = sel_row; i < numRows(); i++ ) { if ( i == sel_row ) { for ( j = sel_col; j < numCols(); j++ ) { if ( j == numCols() - 1 && i < numRows() - 1 ) { color_matrix[i][j] = color_matrix[i + 1][0]; color_names[i][j] = color_names[i + 1][0]; alpha_matrix[i][j] = alpha_matrix[i + 1][0]; updateCell( i, j ); } else if ( j < numCols() - 1 ) { color_matrix[i][j] = color_matrix[i][j + 1]; color_names[i][j] = color_names[i][j + 1]; alpha_matrix[i][j] = alpha_matrix[i][j + 1]; updateCell( i, j ); } else if ( j == numCols() - 1 && i < numRows() - 1 ) { color_matrix[i][j] = invalid_color; color_names[i][j] = ""; alpha_matrix[i][j] = -1; updateCell( i, j ); } } } else { for ( j = 0; j < numCols(); j++ ) { if ( j == numCols() - 1 && i < numRows() - 1 ) { color_matrix[i][j] = color_matrix[i + 1][0]; color_names[i][j] = color_names[i + 1][0]; alpha_matrix[i][j] = alpha_matrix[i + 1][0]; updateCell( i, j ); } else if ( j < numCols() - 1 ) { color_matrix[i][j] = color_matrix[i][j + 1]; color_names[i][j] = color_names[i][j + 1]; alpha_matrix[i][j] = alpha_matrix[i][j + 1]; updateCell( i, j ); } else if ( j == numCols() - 1 && i < numRows() - 1 ) { color_matrix[i][j] = invalid_color; color_names[i][j] = ""; alpha_matrix[i][j] = -1; updateCell( i, j ); } } } } if ( cur_col == sel_col && cur_row == sel_row ) { sel_row = -1; sel_col = -1; updateCell( cur_row, cur_col ); } } }
bool DVBevents::tableEIT( unsigned char* buffer ) { unsigned char* buf = buffer; unsigned int length, loop, sid, tid, eid, tsid, sn, lsn, nid; int i, sec; EventDesc *desc=0, *itdesc=0; EventSid *slist; QPtrList<EventDesc> *currentEvents; bool nodesc, parse; QDateTime start, cur, dt; unsigned int cdt = QDateTime::currentDateTime().toTime_t(); tid = getBits(buf,0,8); length = getBits(buf,12,12); sid = getBits(buf,24,16); sn = getBits(buf,48,8); lsn = getBits(buf,56,8); tsid = getBits(buf,64,16); nid = getBits(buf,80,16); length -=11; buf +=14; slist = currentSrc->getEventSid( nid, tsid, sid ); if ( !slist ) return false; slist->lock(); currentEvents = slist->getEvents(); QPtrListIterator<EventDesc> it( *currentEvents ); while ( length>4 ) { nodesc=parse=false; if ( !safeLen( buf+2 ) ) goto stop; eid = getBits(buf,0,16); if ( !safeLen( buf+2+5 ) ) goto stop; start = getDateTime( buf+2 ); nodesc=parse=true; it.toFirst(); while ( (desc=it.current())!=0 ) { if ( desc->sid==sid ) { if ( desc->startDateTime==start || desc->eid==eid ) { if ( desc->tid==0x4e && tid!=0x4e ) { parse = false; nodesc = false; break; } else { nodesc = false; if ( (cdt-desc->loop)<300 ) { // only reparse events every 300 seconds parse = false; } else { desc->extEvents.clear(); desc->shortEvents.clear(); desc->title=desc->subtitle=""; } break; } } } ++it; } if ( nodesc ) desc = new EventDesc(); if ( parse ) { if ( !safeLen( buf+10 ) ) goto stop; desc->duration = getTime( buf+7 ); if ( !safeLen( buf+11 ) ) goto stop; desc->running = getBits(buf,80,3); desc->sid = sid; desc->tid = tid; desc->tsid = tsid; desc->nid = nid; desc->lsn = lsn; desc->sn = sn; desc->eid = eid; desc->loop = cdt; } if ( desc->sn != sn ) { slist->unlock(); return false; } if ( !safeLen( buf+12 ) ) goto stop; loop = getBits(buf,84,12); buf +=12; length -=(12+loop); while ( loop>0 ) { if ( parse ) { if ( !safeLen( buf+1 ) ) goto stop; switch ( getBits(buf,0,8) ) { case 0x4D : if ( !shortEventDesc( buf, desc ) ) goto stop; break; case 0x4E : if ( !extEventDesc( buf, desc ) ) goto stop; break; default : break; } } if ( !safeLen( buf+2 ) ) goto stop; loop -=( getBits(buf,8,8)+2 ); buf +=( getBits(buf,8,8)+2 ); } //out: if ( parse ) { if ( !nodesc ) { if ( start==desc->startDateTime ) goto ifend; currentEvents->take( currentEvents->find( desc ) ); } desc->startDateTime = start; for ( i=0; i<(int)currentEvents->count(); i++ ) { itdesc = currentEvents->at(i); if ( desc->startDateTime<itdesc->startDateTime ) { currentEvents->insert( i, desc ); break; } itdesc = 0; } if ( !itdesc ) currentEvents->append( desc ); } ifend: if ( parse ) ++(desc->sn); if ( nodesc ) { cur = QDateTime::currentDateTime(); dt = desc->startDateTime; sec = desc->duration.hour()*3600+desc->duration.minute()*60+desc->duration.second(); if ( dt.addSecs( sec )<cur || desc->title.length()<3 ) { currentEvents->remove( desc ); } else desc->source = currentSrc->getSource(); } } slist->unlock(); return true; stop: slist->unlock(); fprintf( stderr, "Stop parsing EIT (%d:%d)\n", adapter, tuner ); if ( nodesc ) delete desc; return false; }