void VCXYPadProperties::slotOKClicked() { QPtrList<XYChannelUnit>* list; // Update the X list list = m_parent->channelsX(); list->setAutoDelete(true); list->clear(); list->setAutoDelete(false); QListViewItemIterator xit(m_listX); while (xit.current()) { list->append(createChannelUnit(*xit)); ++xit; } // Update the Y list list = m_parent->channelsY(); list->setAutoDelete(true); list->clear(); list->setAutoDelete(false); QListViewItemIterator yit(m_listY); while (yit.current()) { list->append(createChannelUnit(*yit)); ++yit; } accept(); }
void KSSLD::cacheSaveToDisk() { KSSLCNode *node; for (node = certList.first(); node; node = certList.next()) { if (node->permanent || node->expires > QDateTime::currentDateTime()) { // First convert to a binary format and then write the kconfig entry // write the (CN, policy, cert) to KSimpleConfig cfg->setGroup(node->cert->getSubject()); cfg->writeEntry("Certificate", node->cert->toString()); cfg->writeEntry("Policy", node->policy); cfg->writeEntry("Expires", node->expires); cfg->writeEntry("Permanent", node->permanent); cfg->writeEntry("Hosts", node->hosts); // Also write the chain QStringList qsl; QPtrList<KSSLCertificate> cl = node->cert->chain().getChain(); for (KSSLCertificate *c = cl.first(); c != 0; c = cl.next()) { //kdDebug() << "Certificate in chain: " << c->toString() << endl; qsl << c->toString(); } cl.setAutoDelete(true); cfg->writeEntry("Chain", qsl); } } cfg->sync(); // insure proper permissions -- contains sensitive data QString cfgName(KGlobal::dirs()->findResource("config", "ksslpolicies")); if (!cfgName.isEmpty()) ::chmod(QFile::encodeName(cfgName), 0600); }
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); }
void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString) { DOMString ppPropertyString = preprocess(propertyString.string(),true); QPtrList<CSSProperty> *props = parseProperties(ppPropertyString.unicode(), ppPropertyString.unicode()+ppPropertyString.length()); if(!props || !props->count()) return; props->setAutoDelete(false); if(!m_lstValues) { m_lstValues = new QPtrList<CSSProperty>; m_lstValues->setAutoDelete( true ); } CSSProperty *prop = props->first(); while( prop ) { removeProperty(prop->m_id, false); m_lstValues->append(prop); prop = props->next(); } delete props; setChanged(); }
void Win32MakefileGenerator::processPrlFiles() { QDict<void> processed; QPtrList<MakefileDependDir> libdirs; libdirs.setAutoDelete(TRUE); { QStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { QString r = (*libpathit), l = r; fixEnvVariables(l); libdirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); } } for(bool ret = FALSE; TRUE; ret = FALSE) { //read in any prl files included.. QStringList l_out; QString where = "QMAKE_LIBS"; if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) where = project->first("QMAKE_INTERNAL_PRL_LIBS"); QStringList &l = project->variables()[where]; for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) { QString opt = (*it); if(opt.startsWith("/")) { if(opt.startsWith("/LIBPATH:")) { QString r = opt.mid(9), l = r; fixEnvVariables(l); libdirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); } } else { if(!processed[opt]) { if(processPrlFile(opt)) { processed.insert(opt, (void*)1); ret = TRUE; } else { for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { QString prl = mdd->local_dir + Option::dir_sep + opt; if(processed[prl]) { break; } else if(processPrlFile(prl)) { processed.insert(prl, (void*)1); ret = TRUE; break; } } } } } if(!opt.isEmpty()) l_out.append(opt); } if(ret) l = l_out; else break; } }
void KMJobViewer::jobSelection(QPtrList<KMJob>& l) { l.setAutoDelete(false); QPtrListIterator<JobItem> it(m_items); for (; it.current(); ++it) if (it.current()->isSelected()) l.append(it.current()->job()); }
void KWDocStructRootItem::setupTextFrameSets() { // Delete Empty item from list. QListViewItem* lvItem = firstChild(); if (lvItem && (lvItem->text(0) == i18n("Empty"))) delete lvItem; // Build a list of framesets ordered by their screen position (top left corner). KWDocument* dok = doc(); QValueList<KWOrderedFrameSet> orderedFrameSets; for ( int i = dok->frameSetCount() - 1; i >= 0; i-- ) { KWFrameSet* frameset = dok->frameSet(i); if ( frameset->type() == FT_TEXT && frameset->frameSetInfo() == KWFrameSet::FI_BODY && !frameset->groupmanager() && frameset->frameCount()>0) orderedFrameSets.append(KWOrderedFrameSet(frameset)); } qHeapSort(orderedFrameSets); // Build a list of frameset pointers from the sorted list. QPtrList<KWTextFrameSet> frameSetPtrs; frameSetPtrs.setAutoDelete(false); for ( uint i = 0; i < orderedFrameSets.count(); i++ ) frameSetPtrs.append(dynamic_cast<KWTextFrameSet *>(orderedFrameSets[i].frameSet())); // Remove deleted framesets from the listview. KWDocStructTextFrameSetItem* item = dynamic_cast<KWDocStructTextFrameSetItem *>(firstChild()); KWDocStructTextFrameSetItem* delItem; while (item) { delItem = item; item = dynamic_cast<KWDocStructTextFrameSetItem *>(item->nextSibling()); if (frameSetPtrs.containsRef(delItem->frameSet()) == 0) delete delItem; } // Add new framesets to the list or update existing ones. KWDocStructTextFrameSetItem* after = 0L; for ( uint i = 0; i < orderedFrameSets.count(); i++ ) { KWTextFrameSet* textFrameset = dynamic_cast<KWTextFrameSet *>(orderedFrameSets[i].frameSet()); item = findTextFrameSetItem(textFrameset); if (item) item->setText(0, textFrameset->name()); else { if (after) item = new KWDocStructTextFrameSetItem( this, after, textFrameset->name(), textFrameset); else item = new KWDocStructTextFrameSetItem(this, textFrameset->name(), textFrameset); } after = item; item->setupTextFrames(); } if ( childCount() == 0 ) ( void )new KListViewItem( this, i18n( "Empty" ) ); }
/***************************************************************************** QEventLoop implementations for UNIX *****************************************************************************/ void QEventLoop::registerSocketNotifier( QSocketNotifier *notifier ) { int sockfd = notifier->socket(); int type = notifier->type(); if ( sockfd < 0 || sockfd >= FD_SETSIZE || 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 ) { // create new list, the QSockNotType destructor will delete it for us list = new QPtrList<QSockNot>; Q_CHECK_PTR( list ); list->setAutoDelete( TRUE ); d->sn_vec[type].list = list; } sn = new QSockNot; Q_CHECK_PTR( sn ); sn->obj = notifier; sn->fd = sockfd; sn->queue = &d->sn_vec[type].pending_fds; if ( list->isEmpty() ) { list->insert( 0, sn ); } else { // sort list by fd, decreasing QSockNot *p = list->first(); while ( p && p->fd > sockfd ) p = list->next(); #if defined(QT_CHECK_STATE) if ( p && p->fd == sockfd ) { static const char *t[] = { "read", "write", "exception" }; qWarning( "QSocketNotifier: Multiple socket notifiers for " "same socket %d and type %s", sockfd, t[type] ); } #endif if ( p ) list->insert( list->at(), sn ); else list->append( sn ); } FD_SET( sockfd, fds ); d->sn_highest = QMAX( d->sn_highest, sockfd ); }
Indicator * THERM::calculate () { Indicator *output = new Indicator; output->setDateFlag(dateFlag); output->setLogScale(logScale); QPtrList<PlotLine> pll; pll.setAutoDelete(FALSE); getTHERM(pll); int loop; for (loop = 0; loop < (int) pll.count(); loop++) output->addLine(pll.at(loop)); return output; }
void KWDocStructTextFrameSetItem::setupTextFrames() { // TODO: KWTextFrameSet::frame() method returns frames in screen order? // Build a list of frame pointers. QPtrList<KWFrame> framePtrs; framePtrs.setAutoDelete(false); for (uint j = 0; j < m_frameset->frameCount(); j++) framePtrs.append(m_frameset->frame(j)); // Remove deleted frames from the listview. KWDocStructTextFrameItem* item = dynamic_cast<KWDocStructTextFrameItem *>(firstChild()); KWDocStructTextFrameItem* delItem; while (item) { delItem = item; item = dynamic_cast<KWDocStructTextFrameItem *>(item->nextSibling()); if (framePtrs.containsRef(delItem->frame()) == 0) delete delItem; } // Add new frames to the list or update existing ones. KWDocument* dok = doc(); KWDocStructTextFrameItem* after = 0; for (uint j = 0; j < framePtrs.count(); j++) { KWFrame* frame = framePtrs.at(j); QString name; if ( KListViewItem::parent()->firstChild() == this && dok->processingType() == KWDocument::WP ) { if ( dok->numColumns() == 1 ) name=i18n( "Page %1" ).arg(QString::number(j + 1)); else name=i18n( "Column %1" ).arg(QString::number(j + 1)); } else name=i18n( "Text Frame %1" ).arg(QString::number(j + 1)); KWDocStructTextFrameItem* child = findTextFrameItem(frame); if (child) child->setText(0, name); else { if (after) child = new KWDocStructTextFrameItem(this, after, name, m_frameset, frame); else child = new KWDocStructTextFrameItem(this, name, m_frameset, frame); } child->setupTextParags(); after = child; } }
void KWDocStructTableItem::setupCells() { // TODO: KWTableFrameSet::cell() method returns cells in screen order? // Build a list of cell pointers. QPtrList<KWTextFrameSet> cellPtrs; cellPtrs.setAutoDelete(false); for (uint row = 0; row < m_table->getRows(); ++row) for (uint col = 0; col < m_table->getColumns(); ++ col) { KWTextFrameSet* cell = m_table->cell(row, col); if (cell) cellPtrs.append(cell); } // Remove deleted cells from the listview. KWDocStructTextFrameItem* item = dynamic_cast<KWDocStructTextFrameItem *>(firstChild()); KWDocStructTextFrameItem* delItem; while (item) { delItem = item; item = dynamic_cast<KWDocStructTextFrameItem *>(item->nextSibling()); if (cellPtrs.containsRef(delItem->frameSet()) == 0) delete delItem; } // Add new cells to the list or update existing ones. // Note we skip over the frameset and add the frame instead, // as every cell has exactly one frame in the frameset. KWDocStructTextFrameItem* child; KWDocStructTextFrameItem* after = 0; for (uint j = 0; j < cellPtrs.count(); j++) { KWTextFrameSet* cell = cellPtrs.at(j); KWFrame* frame = cell->frame(0); if (frame) { QString name = cell->name(); child = findCellItem(cell); if (child) child->setText(0, name); else { if (after) child = new KWDocStructTextFrameItem(this, after, name, cell, frame); else child = new KWDocStructTextFrameItem(this, name, cell, frame); } child->setupTextParags(); after = child; } } }
QString localRootIP() { char buf[256]; buf[0] = '\0'; if(!gethostname(buf, sizeof(buf))) buf[sizeof(buf) - 1] = '\0'; QPtrList< KAddressInfo > infos = KExtendedSocket::lookup(buf, QString::null); infos.setAutoDelete(true); if(infos.count() > 0) { QString IPstr = infos.first()->address()->nodeName(); int p = IPstr.findRev('.'); IPstr.truncate(p); return IPstr; } return QString::null; }
void RenderFlow::paintOutlines(QPainter *p, int _tx, int _ty) { if (style()->outlineStyle() <= BHIDDEN) return; QPtrList <QRect> rects; rects.setAutoDelete(true); rects.append(new QRect(0,0,0,0)); for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) { rects.append(new QRect(curr->xPos(), curr->yPos(), curr->width(), curr->height())); } rects.append(new QRect(0,0,0,0)); for (unsigned int i = 1; i < rects.count() - 1; i++) paintOutlineForLine(p, _tx, _ty, *rects.at(i-1), *rects.at(i), *rects.at(i+1)); }
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); } }
void KfindWindow::deleteFiles() { QString tmp = i18n("Do you really want to delete the selected file?", "Do you really want to delete the %n selected files?", selectedItems().count()); if(KMessageBox::warningContinueCancel(parentWidget(), tmp, "", KGuiItem(i18n("&Delete"), "editdelete")) == KMessageBox::Cancel) return; // Iterate on all selected elements QPtrList< QListViewItem > selected = selectedItems(); for(uint i = 0; i < selected.count(); i++) { KfFileLVI *item = (KfFileLVI *)selected.at(i); KFileItem file = item->fileitem; KIO::NetAccess::del(file.url(), this); } selected.setAutoDelete(true); }
bool tryLookup(const char *node, const char *serv) { int error; QString _node = QString::fromLatin1(node); QString _serv = QString::fromLatin1(serv); printf("\tTrying to lookup %s|%s... ", node, serv); QPtrList< KAddressInfo > list = KExtendedSocket::lookup(_node, _serv, 0, &error); list.setAutoDelete(true); if(!list.isEmpty()) { printf("worked\n"); return true; } printf("failed\n\tReason was: %s\n", (const char *)KExtendedSocket::strError(IO_LookupError, error).local8Bit()); return false; }
void UIServer::showSSLInfoDialog(const QString &url, const KIO::MetaData &meta, int mainwindow) { KSSLInfoDlg *kid = new KSSLInfoDlg(meta["ssl_in_use"].upper() == "TRUE", 0L /*parent?*/, 0L, true); KSSLCertificate *x = KSSLCertificate::fromString(meta["ssl_peer_certificate"].local8Bit()); if(x) { // Set the chain back onto the certificate QStringList cl = QStringList::split(QString("\n"), meta["ssl_peer_chain"]); QPtrList< KSSLCertificate > ncl; ncl.setAutoDelete(true); for(QStringList::Iterator it = cl.begin(); it != cl.end(); ++it) { KSSLCertificate *y = KSSLCertificate::fromString((*it).local8Bit()); if(y) ncl.append(y); } if(ncl.count() > 0) x->chain().setChain(ncl); kdDebug(7024) << "ssl_cert_errors=" << meta["ssl_cert_errors"] << endl; kid->setCertState(meta["ssl_cert_errors"]); QString ip = meta.contains("ssl_proxied") ? "" : meta["ssl_peer_ip"]; kid->setup(x, ip, url, // the URL meta["ssl_cipher"], meta["ssl_cipher_desc"], meta["ssl_cipher_version"], meta["ssl_cipher_used_bits"].toInt(), meta["ssl_cipher_bits"].toInt(), KSSLCertificate::KSSLValidation(meta["ssl_cert_state"].toInt())); kdDebug(7024) << "Showing SSL Info dialog" << endl; if(mainwindow != 0) KWin::setMainWindow(kid, mainwindow); kid->exec(); delete x; kdDebug(7024) << "SSL Info dialog closed" << endl; } else { KMessageBox::information(0L, // parent ? i18n("The peer SSL certificate appears to be corrupt."), i18n("SSL")); } // Don't delete kid!! }
void KMJobViewer::slotSelectionChanged() { int acts = m_manager->actions(); int state(-1); int thread(0); bool completed(true), remote(false); QPtrListIterator<JobItem> it(m_items); QPtrList<KMJob> joblist; joblist.setAutoDelete(false); for (; it.current(); ++it) { if (it.current()->isSelected()) { // check if threaded job. "thread" value will be: // 0 -> no jobs // 1 -> only thread jobs // 2 -> only system jobs // 3 -> thread and system jobs if (it.current()->job()->type() == KMJob::Threaded) thread |= 0x1; else thread |= 0x2; if (state == -1) state = it.current()->job()->state(); else if (state != 0 && state != it.current()->job()->state()) state = 0; completed = (completed && it.current()->job()->isCompleted()); joblist.append(it.current()->job()); if (it.current()->job()->isRemote()) remote = true; } } if (thread != 2) joblist.clear(); actionCollection()->action("job_remove")->setEnabled((thread == 1) || (/*!remote &&*/ !completed && (state >= 0) && (acts & KMJob::Remove))); actionCollection()->action("job_hold")->setEnabled(/*!remote &&*/ !completed && (thread == 2) && (state > 0) && (state != KMJob::Held) && (acts & KMJob::Hold)); actionCollection()->action("job_resume")->setEnabled(/*!remote &&*/ !completed && (thread == 2) && (state > 0) && (state == KMJob::Held) && (acts & KMJob::Resume)); actionCollection()->action("job_move")->setEnabled(!remote && !completed && (thread == 2) && (state >= 0) && (acts & KMJob::Move)); actionCollection()->action("job_restart")->setEnabled(!remote && (thread == 2) && (state >= 0) && (completed) && (acts & KMJob::Restart)); m_manager->validatePluginActions(actionCollection(), joblist); }
PlotLine * PP::calculateCustom (QString &p, QPtrList<PlotLine> &d) { // format1: PP_TYPE if (checkFormat(p, d, 1, 1)) return 0; int t = ppList.findIndex(formatStringList[0]); if (t == -1) { qDebug("PP::calculateCustom: invalid PP_TYPE parm"); return 0; } QPtrList<PlotLine> pll; pll.setAutoDelete(TRUE); getPP(pll); PlotLine *line = new PlotLine; PlotLine *tline = pll.at(t); line->copy(tline); return line; }
/***************************************************************************** QEventLoopEx implementations for Windows (for synchronous socket calls) *****************************************************************************/ void QEventLoopEx::registerSocketNotifier( QSocketNotifier *notifier ) { int sockfd = notifier->socket(); int type = notifier->type(); u_long n; DWORD dw; #ifdef _DEBUG_EVENTLOOPEX qDebug( "QSocketNotifier::registerSocketNotifier %p", notifier ); #endif if(ioctlsocket(sockfd,FIONREAD,&n) == SOCKET_ERROR) { #ifdef _DEBUG_EVENTLOOPEX qDebug( "QSocketNotifier::registerSocketNotifier %p not a socket", notifier ); #endif dw = WSAGetLastError(); QEventLoop::registerSocketNotifier(notifier); return; } if ( sockfd < 0 || type < 0 || type > 2 || notifier == 0 ) { #if defined(QT_CHECK_RANGE) qWarning( "QSocketNotifier: Internal error" ); #endif return; } 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 ) { // create new list, the QSockNotType destructor will delete it for us list = new QPtrList<QSockNotEx>; Q_CHECK_PTR( list ); list->setAutoDelete( TRUE ); d->sn_vec[type].list = list; } sn = new QSockNotEx; Q_CHECK_PTR( sn ); sn->obj = notifier; sn->fd = sockfd; sn->queue = &d->sn_vec[type].pending_fds; if ( list->isEmpty() ) { list->insert( 0, sn ); } else { // sort list by fd, decreasing QSockNotEx *p = list->first(); while ( p && p->fd > sockfd ) p = list->next(); if ( p ) list->insert( list->at(), sn ); else list->append( sn ); } FD_SET( sockfd, fds ); d->sn_highest = QMAX( d->sn_highest, sockfd ); LeaveCriticalSection(&d->m_csVec); #ifdef _DEBUG_EVENTLOOPEX qDebug( "QSocketNotifier::signal update socket"); #endif closesocket(d->m_sockUpdate); }
int Observer::messageBox(int progressId, int type, const QString &text, const QString &caption, const QString &buttonYes, const QString &buttonNo, const QString &dontAskAgainName) { kdDebug() << "Observer::messageBox " << type << " " << text << " - " << caption << endl; int result = -1; KConfig *config = new KConfig("kioslaverc"); KMessageBox::setDontShowAskAgainConfig(config); switch(type) { case KIO::SlaveBase::QuestionYesNo: result = KMessageBox::questionYesNo(0L, // parent ? text, caption, buttonYes, buttonNo, dontAskAgainName); break; case KIO::SlaveBase::WarningYesNo: result = KMessageBox::warningYesNo(0L, // parent ? text, caption, buttonYes, buttonNo, dontAskAgainName); break; case KIO::SlaveBase::WarningContinueCancel: result = KMessageBox::warningContinueCancel(0L, // parent ? text, caption, buttonYes, dontAskAgainName); break; case KIO::SlaveBase::WarningYesNoCancel: result = KMessageBox::warningYesNoCancel(0L, // parent ? text, caption, buttonYes, buttonNo, dontAskAgainName); break; case KIO::SlaveBase::Information: KMessageBox::information(0L, // parent ? text, caption, dontAskAgainName); result = 1; // whatever break; case KIO::SlaveBase::SSLMessageBox: { QCString observerAppId = caption.utf8(); // hack, see slaveinterface.cpp // Contact the object "KIO::Observer" in the application <appId> // Yes, this could be the same application we are, but not necessarily. Observer_stub observer(observerAppId, "KIO::Observer"); KIO::MetaData meta = observer.metadata(progressId); KSSLInfoDlg *kid = new KSSLInfoDlg(meta["ssl_in_use"].upper() == "TRUE", 0L /*parent?*/, 0L, true); KSSLCertificate *x = KSSLCertificate::fromString(meta["ssl_peer_certificate"].local8Bit()); if(x) { // Set the chain back onto the certificate QStringList cl = QStringList::split(QString("\n"), meta["ssl_peer_chain"]); QPtrList< KSSLCertificate > ncl; ncl.setAutoDelete(true); for(QStringList::Iterator it = cl.begin(); it != cl.end(); ++it) { KSSLCertificate *y = KSSLCertificate::fromString((*it).local8Bit()); if(y) ncl.append(y); } if(ncl.count() > 0) x->chain().setChain(ncl); kid->setup(x, meta["ssl_peer_ip"], text, // the URL meta["ssl_cipher"], meta["ssl_cipher_desc"], meta["ssl_cipher_version"], meta["ssl_cipher_used_bits"].toInt(), meta["ssl_cipher_bits"].toInt(), KSSLCertificate::KSSLValidation(meta["ssl_cert_state"].toInt())); kdDebug(7024) << "Showing SSL Info dialog" << endl; kid->exec(); delete x; kdDebug(7024) << "SSL Info dialog closed" << endl; } else { KMessageBox::information(0L, // parent ? i18n("The peer SSL certificate appears to be corrupt."), i18n("SSL")); } // This doesn't have to get deleted. It deletes on it's own. result = 1; // whatever break; } default: kdWarning() << "Observer::messageBox: unknown type " << type << endl; result = 0; break; } KMessageBox::setDontShowAskAgainConfig(0); delete config; return result; #if 0 QByteArray data, replyData; QCString replyType; QDataStream arg( data, IO_WriteOnly ); arg << progressId; arg << type; arg << text; arg << caption; arg << buttonYes; arg << buttonNo; if ( kapp->dcopClient()->call( "kio_uiserver", "UIServer", "messageBox(int,int,QString,QString,QString,QString)", data, replyType, replyData, true ) && replyType == "int" ) { int result; QDataStream _reply_stream( replyData, IO_ReadOnly ); _reply_stream >> result; kdDebug(KDEBUG_OBSERVER) << "Observer::messageBox got result " << result << endl; return result; }
int main( int argc, char **argv ) { if ( argc < 2 ) { qWarning( "Usage:\n\t%s [--images] files", argv[0] ); return 1; } QFile output; bool output_hdr = FALSE; bool images = FALSE; output.open( IO_WriteOnly, stdout ); QTextStream out( &output ); QPtrList<EmbedImage> list_image; QPtrList<Embed> list; list.setAutoDelete( TRUE ); list_image.setAutoDelete( TRUE ); long l = rand(); out << "#ifndef _QEMBED_" << l << endl; out << "#define _QEMBED_" << l << endl; QStringList args; for ( int i = 1; i < argc; ++i ) { QString file( argv[i] ); #ifdef Q_WS_WIN // Since wildcards are not expanded automatically for us on Windows, we need to do // it ourselves if ( file.contains( '*' ) || file.contains( '?' ) ) { QDir d; const QFileInfoList *fiList = d.entryInfoList( file, QDir::Files ); QFileInfoListIterator it(*fiList); while ( it.current() ) { args << (*it)->filePath(); ++it; } } else #endif args << file; } for ( QStringList::Iterator it = args.begin(); it != args.end(); ++it ) { QString arg = (*it); if ( arg == "--images" ) { if ( !images ) { out << "#include <qimage.h>\n"; out << "#include <qdict.h>\n"; images = TRUE; } } else { QFile f( *it ); if ( !f.open(IO_ReadOnly) ) { qWarning( "Cannot open file %s, ignoring it", (*it).latin1() ); continue; } QByteArray a( f.size() ); if ( f.size() == 0 || f.readBlock(a.data(), f.size()) != (int)f.size() ) { qWarning( "Cannot read file %s, ignoring it", (*it).latin1() ); continue; } if ( images ) { QImage img; if ( !img.loadFromData(a) ) { qWarning( "Cannot read image from file %s, ignoring it", (*it).latin1() ); continue; } EmbedImage *e = new EmbedImage; e->width = img.width(); e->height = img.height(); e->depth = img.depth(); e->numColors = img.numColors(); e->colorTable = new QRgb[e->numColors]; e->alpha = img.hasAlphaBuffer(); memcpy(e->colorTable, img.colorTable(), e->numColors*sizeof(QRgb)); QFileInfo fi( (*it) ); e->name = fi.baseName(); e->cname = convertFileNameToCIdentifier( e->name.latin1() ); list_image.append( e ); QString s; if ( e->depth == 32 ) { out << s.sprintf( "static const QRgb %s_data[] = {", (const char *)e->cname ); embedData( (QRgb*)img.bits(), e->width*e->height, &output ); } else { if ( e->depth == 1 ) img = img.convertBitOrder(QImage::BigEndian); out << s.sprintf( "static const unsigned char %s_data[] = {", (const char *)e->cname ); embedData( img.bits(), img.numBytes(), &output ); } out << "\n};\n\n"; if ( e->numColors ) { out << s.sprintf( "static const QRgb %s_ctable[] = {", (const char *)e->cname ); embedData( e->colorTable, e->numColors, &output ); out << "\n};\n\n"; } } else { Embed *e = new Embed; e->size = f.size(); e->name = (*it); e->cname = convertFileNameToCIdentifier( (*it) ); list.append( e ); QString s; out << s.sprintf( "static const unsigned int %s_len = %d;\n", (const char *)e->cname, e->size ); out << s.sprintf( "static const unsigned char %s_data[] = {", (const char *)e->cname ); embedData( a, &output ); out << "\n};\n\n"; } if ( !output_hdr ) { output_hdr = TRUE; out << header; } } } if ( list.count() > 0 ) { out << "#include <qcstring.h>\n"; if ( !images ) out << "#include <qdict.h>\n"; out << "static struct Embed {\n" " unsigned int size;\n" " const unsigned char *data;\n" " const char *name;\n" "} embed_vec[] = {\n"; Embed *e = list.first(); while ( e ) { out << " { " << e->size << ", " << e->cname << "_data, " << "\"" << e->name << "\" },\n"; e = list.next(); } out << " { 0, 0, 0 }\n};\n"; out << "\n" "static const QByteArray& qembed_findData( const char* name )\n" "{\n" " static QDict<QByteArray> dict;\n" " QByteArray* ba = dict.find( name );\n" " if ( !ba ) {\n" " for ( int i = 0; embed_vec[i].data; i++ ) {\n" " if ( strcmp(embed_vec[i].name, name) == 0 ) {\n" " ba = new QByteArray;\n" " ba->setRawData( (char*)embed_vec[i].data,\n" " embed_vec[i].size );\n" " dict.insert( name, ba );\n" " break;\n" " }\n" " }\n" " if ( !ba ) {\n" " static QByteArray dummy;\n" " return dummy;\n" " }\n" " }\n" " return *ba;\n" "}\n\n"; } if ( list_image.count() > 0 ) { out << "static struct EmbedImage {\n" " int width, height, depth;\n" " const unsigned char *data;\n" " int numColors;\n" " const QRgb *colorTable;\n" " bool alpha;\n" " const char *name;\n" "} embed_image_vec[] = {\n"; EmbedImage *e = list_image.first(); while ( e ) { out << " { " << e->width << ", " << e->height << ", " << e->depth << ", " << "(const unsigned char*)" << e->cname << "_data, " << e->numColors << ", "; if ( e->numColors ) out << e->cname << "_ctable, "; else out << "0, "; if ( e->alpha ) out << "TRUE, "; else out << "FALSE, "; out << "\"" << e->name << "\" },\n"; e = list_image.next(); } out << " { 0, 0, 0, 0, 0, 0, 0, 0 }\n};\n"; out << "\n" "static const QImage& qembed_findImage( const QString& name )\n" "{\n" " static QDict<QImage> dict;\n" " QImage* img = dict.find( name );\n" " if ( !img ) {\n" " for ( int i = 0; embed_image_vec[i].data; i++ ) {\n" " if ( strcmp(embed_image_vec[i].name, name.latin1()) == 0 ) {\n" " img = new QImage((uchar*)embed_image_vec[i].data,\n" " embed_image_vec[i].width,\n" " embed_image_vec[i].height,\n" " embed_image_vec[i].depth,\n" " (QRgb*)embed_image_vec[i].colorTable,\n" " embed_image_vec[i].numColors,\n" " QImage::BigEndian );\n" " if ( embed_image_vec[i].alpha )\n" " img->setAlphaBuffer( TRUE );\n" " dict.insert( name, img );\n" " break;\n" " }\n" " }\n" " if ( !img ) {\n" " static QImage dummy;\n" " return dummy;\n" " }\n" " }\n" " return *img;\n" "}\n\n"; } out << "#endif" << endl; return 0; }
bool BpDocument::composeGraphs( bool lineGraphs, bool showDialogs ) { // Bar graph settings int tics = 2; double max = 100.; double min = 0.; // Line graph settings if ( lineGraphs ) { tics = 11; max = tableRow( tableRows()-1 ); min = tableRow(0); } GraphAxleParms *xParms = new GraphAxleParms( min, max, tics ); checkmem( __FILE__, __LINE__, xParms, "GraphAxleParms xParms", 1 ); if ( lineGraphs && min > 0. && property()->boolean( "graphXOriginAtZero" ) ) { xParms->useOrigin(); } // Determine the x-, y-, and z-variables. EqVar *xVar = m_eqTree->m_rangeVar[0]; EqVar *zVar = m_eqTree->m_rangeVar[1]; EqVar *yVar = 0; //-------------------------------------------------------------------------- // 2: Determine nice axis parameters for the x- and all the y-variables. //-------------------------------------------------------------------------- // Initialize the Y axle for each graph to a nice range QPtrList<GraphAxleParms> *yParmsList = new QPtrList<GraphAxleParms>(); yParmsList->setAutoDelete( true ); GraphAxleParms *yParms = 0; int yid; for ( yid = 0; yid < tableVars(); yid++ ) { yVar = tableVar( yid ); yParms = 0; // The yVar must be continuous. if ( yVar->isContinuous() ) { // Get Y range if ( lineGraphs ) { graphYMinMax( yid, min, max ); } else { barYMinMax( yid, min, max ); } // Determine and store nice axis parameters tics = 11; yParms = new GraphAxleParms( min, max, tics ); checkmem( __FILE__, __LINE__, yParms, "GraphAxleParms yParms", 1 ); yParmsList->append( yParms ); // If bar graph, or line graphs must start at origin if ( min > 0. ) { if ( ! lineGraphs || property()->boolean( "graphYOriginAtZero" ) ) { yParms->useOrigin(); } } // If min and max are the same, make them different if ( min == max ) { yParms->setAxle( min-1., max+1., 3 ); } } } //-------------------------------------------------------------------------- // 1: Allow the user to change the axle parameters. //-------------------------------------------------------------------------- if ( showDialogs && property()->boolean( "graphYUserRange" ) ) { GraphLimitsDialog *dialog = new GraphLimitsDialog( this, yParmsList, "graphLimitsDialog" ); checkmem( __FILE__, __LINE__, dialog, "GraphLimitsDialog dialog", 1 ); if ( dialog->exec() == QDialog::Accepted ) { dialog->store(); } delete dialog; dialog = 0; } //-------------------------------------------------------------------------- // 3: Draw each graph. //-------------------------------------------------------------------------- // Set up the progress dialog. int step = 0; int steps = tableVars(); QString text(""), button(""); if ( lineGraphs ) { translate( text, "BpDocument:Graphs:DrawingLineGraphs" ); } else { translate( text, "BpDocument:Graphs:DrawingBarGraphs" ); } translate( button, "BpDocument:Graphs:Abort" ); QProgressDialog *progress = new QProgressDialog( QString( text ).arg( steps ), button, steps ); Q_CHECK_PTR( progress ); progress->setMinimumDuration( 0 ); progress->setProgress( 0 ); // Loop for each output variable: one graph is composed per output variable. bool result = true; for ( yid = 0, yParms = yParmsList->first(); yid < tableVars(); yid++ ) { yVar = tableVar( yid ); // The yVar must be continuous. if ( yVar->isContinuous() ) { // Recompute nice Y axis //min = ( yParms->m_axleMin < yParms->m_dataMin ) // ? yParms->m_axleMin // : yParms->m_dataMin; min = yParms->m_axleMin; //max = ( yParms->m_axleMax > yParms->m_dataMax ) // ? yParms->m_axleMax // : yParms->m_dataMax; max = yParms->m_axleMax; // If min and max are the same, make them different tics = 11; if ( min == max ) { yParms->setAxle( min-1., max+1., 3 ); } // Compose this graph. if ( lineGraphs ) { composeLineGraph( yid, xVar, yVar, zVar, xParms, yParms ); } else { composeBarGraph( yid, xVar, yVar, xParms, yParms ); } // Update progress dialog. progress->setProgress( ++step ); qApp->processEvents(); if ( progress->wasCancelled() ) { result = false; break; } yParms = yParmsList->next(); } } // Cleanup and return. delete progress; progress = 0; delete xParms; xParms = 0; delete yParmsList; yParmsList = 0; return( result ); }
parseResult * ChannelParser::parseINFOMode(QString string) { // Basic idea here is simple, go through the mode change and // assign each mode a + or a - and an argument or "" if there is // none. After that each mode change it looked at to see if // we should handle it in any special way. // Strip off leading sirc info string.remove(0, 4); /* * 1k is pretty safe since KProcess returns 1 k blocks, and lines don't get split between reads. This is emprical */ QString modes, args, channel; int found = 0; if(string.find("for user") >= 0) return new parseSucc(" " + string, ksopts->infoColor, "user|mode"); /* * We need to 2 scanf's, one for the case of arguments, and one for no args. */ QRegExp rx("Mode change \"(\\S+) *([^\"]*)\" on channel (\\S+)"); if(rx.search(string) >= 0){ modes = rx.cap(1); args = rx.cap(2); channel = rx.cap(3); found = 1; } rx.setPattern("Mode for channel (\\S+) is \"([^\" ]+)\""); if(found == 0 && rx.search(string) >= 0){ channel = rx.cap(1); modes = rx.cap(2); found = 1; } rx.setPattern("Your user mode is"); if(found == 0 && rx.search(string) >= 0){ /* * Don't parse user mode requests */ return new parseSucc(" " + string, ksopts->infoColor, "user|mode"); } if(found == 0) return new parseError(" Failed to parse mode change: " + string, QString::null); /* * op specifie if it's a + or -. tru is + false is - */ bool op = true; /* * arglist is the list of argument * we use the itirator to tstep through the list * as need be */ QStringList arglist = QStringList::split(" ", args); QStringList::Iterator ai = arglist.begin(); /* * the ptr list structure contains the parsed contents */ QPtrList<const mode_info> pmList; pmList.setAutoDelete(true); for(uint pos = 0; pos < modes.length(); pos++){ switch(modes.at(pos).unicode()){ case '+': op = true; break; case '-': op = false; break; case 'l': // Chan limits /* * -l doesn't take any arguments, so just add the mode and break * +l otoh does, so read the argument */ if(op == false){ pmList.append(new mode_info(op, 'l', QString::null)); break; } case 'o': // Op, arg is the nick case 'v': // Voice, arg is the nick case 'b': // Ban, arg is mask banned case 'k': // kcik, arg is nick if(ai == NULL) return new parseError(i18n("Unable to parse mode change: %1").arg(string), QString::null); pmList.append(new mode_info(op, modes.at(pos), *ai)); ai++; break; case 'i': // Invite only case 'n': // No message to chan case 'p': // Private case 'm': // Moderated case 's': // Secret case 't': // Topic setable by ops case 'R': // (Dalnet) only registered may join case 'r': // (Dalnet) only registered may join or something /* * Mode changes which don't take args */ pmList.append(new mode_info(op, modes.at(pos), QString::null)); break; default: kdDebug(5008) << "Unknown mode change: " << modes.mid(pos, 1) << " Assume no args" << endl; pmList.append(new mode_info(op, modes.at(pos), QString::null)); } } // We have the modes set in mode and arg, now we go though // looking at each mode seeing if we should handle it. bool mode_o_plus = false; bool mode_o_minus = false; bool mode_b_plus = false; bool mode_b_minus = false; QPtrListIterator<const mode_info> it(pmList); const mode_info *mi; while ( (mi = it.current()) != 0 ) { ++it; /* * Look at the second character, it's uniq, check for +,- latter */ if(mi->mode().unicode() == 'o'){ mode_o_plus = mi->op(); mode_o_minus = !mi->op(); if(top->ksircProcess()->getNick() == mi->arg()) top->channelButtons->setButtonsEnabled(mi->op()); if(mi->arg().length() == 0){ qWarning("Invalid nick in +/- o mode change"); continue; } int offset = top->nicks->findNick(mi->arg()); if(offset >= 0){ nickListItem *irc = new nickListItem(); *irc = *top->nicks->item(offset); top->nicks->removeItem(offset); // remove old nick irc->setOp(mi->op()); // add new nick in sorted pass,with colour top->nicks->inSort(irc); top->nicks->repaint(TRUE); } else{ kdDebug(5008) << "Toplevel+o: nick search failed on " << mi->arg() << endl; } } else if(mi->mode() == 't'){ if(mi->op()) top->channelButtons->setProtectMode(true); // set on else top->channelButtons->setProtectMode(false); // set off } else if(mi->mode() == 'm'){ if(mi->op()) top->channelButtons->setModerateMode(true); // set on else top->channelButtons->setModerateMode(false); // set off } else if(mi->mode() == 'n'){ if(mi->op()) top->channelButtons->setNooutsideMode(true); // set on else top->channelButtons->setNooutsideMode(false); // set off } else if(mi->mode() == 'v'){ bool voice; if(mi->op()) voice = TRUE; else voice = FALSE; if(mi->arg().length() == 0){ qWarning("Invalid nick in +-v mode change"); continue; } int offset = top->nicks->findNick(mi->arg()); if(offset >= 0){ nickListItem *irc = new nickListItem(); *irc = *top->nicks->item(offset); top->nicks->removeItem(offset); // remove old nick irc->setVoice(voice) ; // add new nick in sorted pass,with colour top->nicks->inSort(irc); top->nicks->repaint(); } } else if(mi->mode() == 'b'){ if(mi->op()) mode_b_plus = true; else mode_b_minus = true; } else if(mi->mode() == 'k'){ if(mi->op()){ if(mi->arg().length() == 0){ qWarning("Invalid +k mode set, no argument!"); continue; } top->m_channelInfo.setKey(mi->arg()); } else { top->m_channelInfo.setKey(""); /* no key set anymore */ } } else{ QChar c(mi->mode()); QString m(&c, 1); QString o; if(mi->op()) o = "+"; else o = "-"; kdDebug(5008) << "Did not handle: " << o << m << " arg: " << mi->arg() << endl; } } /* * We're all done, so output the message and be done with it */ QString pixname = "user|mode"; if(mode_o_plus) pixname = "user|oplus"; else if(mode_o_minus) pixname = "user|ominus"; else if(mode_b_plus) pixname ="user|bplus"; else if(mode_b_minus) pixname = "user|bminus"; return new parseSucc(" " + string, ksopts->infoColor, pixname); }
void QueueLabel::mousePressEvent( QMouseEvent* mouseEvent ) { hideToolTip(); if( m_timer.isActive() ) // if the user clicks again when (right after) the menu is open, { // (s)he probably wants to close it m_timer.stop(); return; } Playlist *pl = Playlist::instance(); PLItemList &queue = pl->m_nextTracks; if( queue.isEmpty() ) return; int length = 0; for( QPtrListIterator<PlaylistItem> it( queue ); *it; ++it ) { const int s = (*it)->length(); if( s > 0 ) length += s; } QPtrList<KPopupMenu> menus; menus.setAutoDelete( true ); KPopupMenu *menu = new KPopupMenu; menus.append( menu ); const uint count = queue.count(); if( length ) menu->insertTitle( i18n( "1 Queued Track (%1)", "%n Queued Tracks (%1)", count ) .arg( MetaBundle::prettyLength( length, true ) ) ); else menu->insertTitle( i18n( "1 Queued Track", "%n Queued Tracks", count ) ); Pana::actionCollection()->action( "queue_manager" )->plug( menu ); menu->insertItem( SmallIconSet( Pana::icon( "rewind" ) ), count > 1 ? i18n( "&Dequeue All Tracks" ) : i18n( "&Dequeue Track" ), 0 ); menu->insertSeparator(); uint i = 1; QPtrListIterator<PlaylistItem> it( queue ); it.toFirst(); while( i <= count ) { for( uint n = kMin( i + MAX_TO_SHOW - 1, count ); i <= n; ++i, ++it ) menu->insertItem( KStringHandler::rsqueeze( i18n( "%1. %2" ).arg( i ).arg( veryNiceTitle( *it ) ), 50 ), i ); if( i < count ) { menus.append( new KPopupMenu ); menu->insertSeparator(); menu->insertItem( i18n( "1 More Track", "%n More Tracks", count - i + 1 ), menus.getLast() ); menu = menus.getLast(); } } menu = menus.getFirst(); int mx, my; const int mw = menu->sizeHint().width(), mh = menu->sizeHint().height(), sy = mapFrom( Pana::StatusBar::instance(), QPoint( 0, 0 ) ).y(), sheight = Pana::StatusBar::instance()->height(); const QRect dr = QApplication::desktop()->availableGeometry( this ); if( mapYToGlobal( sy ) - mh > dr.y() ) my = mapYToGlobal( sy ) - mh; else if( mapYToGlobal( sy + sheight ) + mh < dr.y() + dr.height() ) my = mapYToGlobal( sy + sheight ); else my = mapToGlobal( mouseEvent->pos() ).y(); mx = mapXToGlobal( 0 ) - ( mw - width() ) / 2; int id = menu->exec( QPoint( mx, my ) ); if( id < 0 ) m_timer.start( 50, true ); else if( id == 0 ) //dequeue { const PLItemList dequeued = queue; while( !queue.isEmpty() ) pl->queue( queue.getLast(), true ); emit queueChanged( PLItemList(), dequeued ); } else { PlaylistItem *selected = queue.at( id - 1 ); if( selected ) pl->ensureItemCentered( selected ); } }
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(); } }
bool Win32MakefileGenerator::findLibraries(const QString &where) { QStringList &l = project->variables()[where]; QPtrList<MakefileDependDir> dirs; { QStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { QString r = (*libpathit), l = r; fixEnvVariables(l); dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); } } dirs.setAutoDelete(TRUE); for(QStringList::Iterator it = l.begin(); it != l.end(); ) { QChar quote; bool modified_opt = FALSE, remove = FALSE; QString opt = (*it).stripWhiteSpace(); if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) { quote = opt[0]; opt = opt.mid(1, opt.length()-2); } if(opt.startsWith("/LIBPATH:")) { QString r = opt.mid(9), l = Option::fixPathToLocalOS(r); dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); } else if(opt.startsWith("-L") || opt.startsWith("/L")) { QString r = opt.mid(2), l = Option::fixPathToLocalOS(r); dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); remove = TRUE; //we eat this switch } else if(opt.startsWith("-l") || opt.startsWith("/l")) { QString lib = opt.right(opt.length() - 2), out; if(!lib.isEmpty()) { for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { QString extension; int ver = findHighestVersion(mdd->local_dir, lib); if(ver > 0) extension += QString::number(ver); extension += ".lib"; if(QMakeMetaInfo::libExists(mdd->local_dir + Option::dir_sep + lib) || QFile::exists(mdd->local_dir + Option::dir_sep + lib + extension)) { out = mdd->real_dir + Option::dir_sep + lib + extension; break; } } } if(out.isEmpty()) { remove = TRUE; //just eat it since we cannot find one.. } else { modified_opt = TRUE; (*it) = out; } } else if(!QFile::exists(Option::fixPathToLocalOS(opt))) { QPtrList<MakefileDependDir> lib_dirs; QString file = opt; int slsh = file.findRev(Option::dir_sep); if(slsh != -1) { QString r = file.left(slsh+1), l = r; fixEnvVariables(l); lib_dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); file = file.right(file.length() - slsh - 1); } else { lib_dirs = dirs; } if (!project->variables()["QMAKE_QT_DLL"].isEmpty()) { if(file.endsWith(".lib")) { file = file.left(file.length() - 4); if(!file.at(file.length()-1).isNumber()) { for(MakefileDependDir *mdd = lib_dirs.first(); mdd; mdd = lib_dirs.next() ) { QString lib_tmpl(file + "%1" + ".lib"); int ver = findHighestVersion(mdd->local_dir, file); if(ver != -1) { if(ver) lib_tmpl = lib_tmpl.arg(ver); else lib_tmpl = lib_tmpl.arg(""); if(slsh != -1) { QString dir = mdd->real_dir; if(!dir.endsWith(Option::dir_sep)) dir += Option::dir_sep; lib_tmpl.prepend(dir); } modified_opt = TRUE; (*it) = lib_tmpl; break; } } } } } } if(remove) { it = l.remove(it); } else { if(!quote.isNull() && modified_opt) (*it) = quote + (*it) + quote; ++it; } } return TRUE; }
void KSSLInfoDlg::setup(KSSLCertificate *cert, const QString &ip, const QString &url, const QString &cipher, const QString &cipherdesc, const QString &sslversion, int usedbits, int bits, KSSLCertificate::KSSLValidation /*certState*/) { // Needed to put the GUI stuff here to get the layouting right d->_cert = cert; QGridLayout *layout = new QGridLayout(4, 2, KDialog::spacingHint()); layout->addWidget(new QLabel(i18n("Chain:"), this), 0, 0); d->_chain = new KComboBox(this); layout->addMultiCellWidget(d->_chain, 1, 1, 0, 1); connect(d->_chain, SIGNAL(activated(int)), this, SLOT(slotChain(int))); d->_chain->clear(); if(cert->chain().isValid() && cert->chain().depth() > 1) { d->_chain->setEnabled(true); d->_chain->insertItem(i18n("0 - Site Certificate")); int cnt = 0; QPtrList< KSSLCertificate > cl = cert->chain().getChain(); cl.setAutoDelete(true); for(KSSLCertificate *c = cl.first(); c != 0; c = cl.next()) { KSSLX509Map map(c->getSubject()); QString id; id = map.getValue("CN"); if(id.length() == 0) id = map.getValue("O"); if(id.length() == 0) id = map.getValue("OU"); d->_chain->insertItem(QString::number(++cnt) + " - " + id); } d->_chain->setCurrentItem(0); } else d->_chain->setEnabled(false); layout->addWidget(new QLabel(i18n("Peer certificate:"), this), 2, 0); layout->addWidget(d->_subject = static_cast< KSSLCertBox * >(buildCertInfo(cert->getSubject())), 3, 0); layout->addWidget(new QLabel(i18n("Issuer:"), this), 2, 1); layout->addWidget(d->_issuer = static_cast< KSSLCertBox * >(buildCertInfo(cert->getIssuer())), 3, 1); d->m_layout->addMultiCell(layout, 1, 1, 0, 2); layout = new QGridLayout(11, 2, KDialog::spacingHint()); layout->setColStretch(1, 1); QLabel *ipl = new QLabel(i18n("IP address:"), this); layout->addWidget(ipl, 0, 0); if(ip.isEmpty()) { ipl->hide(); } layout->addWidget(ipl = new QLabel(ip, this), 0, 1); if(ip.isEmpty()) { ipl->hide(); } layout->addWidget(new QLabel(i18n("URL:"), this), 1, 0); KSqueezedTextLabel *urlLabel = new KSqueezedTextLabel(url, this); layout->addWidget(urlLabel, 1, 1); layout->addWidget(new QLabel(i18n("Certificate state:"), this), 2, 0); layout->addWidget(d->_csl = new QLabel("", this), 2, 1); update(); layout->addWidget(new QLabel(i18n("Valid from:"), this), 3, 0); layout->addWidget(d->_validFrom = new QLabel("", this), 3, 1); layout->addWidget(new QLabel(i18n("Valid until:"), this), 4, 0); layout->addWidget(d->_validUntil = new QLabel("", this), 4, 1); layout->addWidget(new QLabel(i18n("Serial number:"), this), 5, 0); layout->addWidget(d->_serialNum = new QLabel("", this), 5, 1); layout->addWidget(new QLabel(i18n("MD5 digest:"), this), 6, 0); layout->addWidget(d->_digest = new QLabel("", this), 6, 1); layout->addWidget(new QLabel(i18n("Cipher in use:"), this), 7, 0); layout->addWidget(new QLabel(cipher, this), 7, 1); layout->addWidget(new QLabel(i18n("Details:"), this), 8, 0); layout->addWidget(new QLabel(cipherdesc.simplifyWhiteSpace(), this), 8, 1); layout->addWidget(new QLabel(i18n("SSL version:"), this), 9, 0); layout->addWidget(new QLabel(sslversion, this), 9, 1); layout->addWidget(new QLabel(i18n("Cipher strength:"), this), 10, 0); layout->addWidget(new QLabel(i18n("%1 bits used of a %2 bit cipher").arg(usedbits).arg(bits), this), 10, 1); d->m_layout->addMultiCell(layout, 2, 2, 0, 2); displayCert(cert); }
// transforms one line of the paragraph to visual order // the caller is responisble to delete the returned list of QTextRuns. QPtrList<QTextRun> *QComplexText::bidiReorderLine( QBidiControl *control, const QString &text, int start, int len, QChar::Direction basicDir ) { int last = start + len - 1; //printf("doing BiDi reordering from %d to %d!\n", start, last); QPtrList<QTextRun> *runs = new QPtrList<QTextRun>; runs->setAutoDelete(TRUE); QBidiContext *context = control->context; if ( !context ) { // first line if( start != 0 ) qDebug( "bidiReorderLine::internal error"); context = new QBidiContext( 0, QChar::DirL ); control->status.last = QChar::DirL; } QBidiStatus status = control->status; QChar::Direction dir = QChar::DirON; int sor = start; int eor = start; int current = start; while(current <= last) { QChar::Direction dirCurrent; if(current == (int)text.length()) { QBidiContext *c = context; while ( c->parent ) c = c->parent; dirCurrent = c->dir; } else if ( current == last ) { dirCurrent = ( basicDir != QChar::DirON ? basicDir : basicDirection( text, current ) ); } else dirCurrent = text.at(current).direction(); #if (BIDI_DEBUG >= 2) cout << "directions: dir=" << dir << " current=" << dirCurrent << " last=" << status.last << " eor=" << status.eor << " lastStrong=" << status.lastStrong << " embedding=" << context->dir << " level =" << (int)context->level << endl; #endif switch(dirCurrent) { // embedding and overrides (X1-X9 in the BiDi specs) case QChar::DirRLE: { uchar level = context->level; if(level%2) // we have an odd level level += 2; else level++; if(level < 61) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; context = new QBidiContext(level, QChar::DirR, context); status.last = QChar::DirR; status.lastStrong = QChar::DirR; } break; } case QChar::DirLRE: { uchar level = context->level; if(level%2) // we have an odd level level++; else level += 2; if(level < 61) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; context = new QBidiContext(level, QChar::DirL, context); status.last = QChar::DirL; status.lastStrong = QChar::DirL; } break; } case QChar::DirRLO: { uchar level = context->level; if(level%2) // we have an odd level level += 2; else level++; if(level < 61) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; context = new QBidiContext(level, QChar::DirR, context, TRUE); dir = QChar::DirR; status.last = QChar::DirR; status.lastStrong = QChar::DirR; } break; } case QChar::DirLRO: { uchar level = context->level; if(level%2) // we have an odd level level++; else level += 2; if(level < 61) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; context = new QBidiContext(level, QChar::DirL, context, TRUE); dir = QChar::DirL; status.last = QChar::DirL; status.lastStrong = QChar::DirL; } break; } case QChar::DirPDF: { QBidiContext *c = context->parent; if(c) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; status.last = context->dir; if( context->deref() ) delete context; context = c; if(context->override) dir = context->dir; else dir = QChar::DirON; status.lastStrong = context->dir; } break; } // strong types case QChar::DirL: if(dir == QChar::DirON) dir = QChar::DirL; switch(status.last) { case QChar::DirL: eor = current; status.eor = QChar::DirL; break; case QChar::DirR: case QChar::DirAL: case QChar::DirEN: case QChar::DirAN: runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; break; case QChar::DirES: case QChar::DirET: case QChar::DirCS: case QChar::DirBN: case QChar::DirB: case QChar::DirS: case QChar::DirWS: case QChar::DirON: if(dir != QChar::DirL) { //last stuff takes embedding dir if( context->dir == QChar::DirR ) { if(status.eor != QChar::DirR) { // AN or EN runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; dir = QChar::DirR; } else eor = current - 1; runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; } else { if(status.eor != QChar::DirL) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; dir = QChar::DirL; } else { eor = current; status.eor = QChar::DirL; break; } } } else { eor = current; status.eor = QChar::DirL; } default: break; } status.lastStrong = QChar::DirL; break; case QChar::DirAL: case QChar::DirR: if(dir == QChar::DirON) dir = QChar::DirR; switch(status.last) { case QChar::DirR: case QChar::DirAL: eor = current; status.eor = QChar::DirR; break; case QChar::DirL: case QChar::DirEN: case QChar::DirAN: runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; break; case QChar::DirES: case QChar::DirET: case QChar::DirCS: case QChar::DirBN: case QChar::DirB: case QChar::DirS: case QChar::DirWS: case QChar::DirON: if( status.eor != QChar::DirR && status.eor != QChar::DirAL ) { //last stuff takes embedding dir if(context->dir == QChar::DirR || status.lastStrong == QChar::DirR) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; dir = QChar::DirR; eor = current; } else { eor = current - 1; runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; dir = QChar::DirR; } } else { eor = current; status.eor = QChar::DirR; } default: break; } status.lastStrong = dirCurrent; break; // weak types: case QChar::DirNSM: // ### if @sor, set dir to dirSor break; case QChar::DirEN: if(status.lastStrong != QChar::DirAL) { // if last strong was AL change EN to AL if(dir == QChar::DirON) { if(status.lastStrong == QChar::DirL) dir = QChar::DirL; else dir = QChar::DirAN; } switch(status.last) { case QChar::DirET: if ( status.lastStrong == QChar::DirR || status.lastStrong == QChar::DirAL ) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; status.eor = QChar::DirON; dir = QChar::DirAN; } // fall through case QChar::DirEN: case QChar::DirL: eor = current; status.eor = dirCurrent; break; case QChar::DirR: case QChar::DirAL: case QChar::DirAN: runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; status.eor = QChar::DirEN; dir = QChar::DirAN; break; case QChar::DirES: case QChar::DirCS: if(status.eor == QChar::DirEN || dir == QChar::DirAN) { eor = current; break; } case QChar::DirBN: case QChar::DirB: case QChar::DirS: case QChar::DirWS: case QChar::DirON: if(status.eor == QChar::DirR) { // neutrals go to R eor = current - 1; runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirEN; dir = QChar::DirAN; } else if( status.eor == QChar::DirL || (status.eor == QChar::DirEN && status.lastStrong == QChar::DirL)) { eor = current; status.eor = dirCurrent; } else { // numbers on both sides, neutrals get right to left direction if(dir != QChar::DirL) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; eor = current - 1; dir = QChar::DirR; runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; dir = QChar::DirAN; } else { eor = current; status.eor = dirCurrent; } } default: break; } break; } case QChar::DirAN: dirCurrent = QChar::DirAN; if(dir == QChar::DirON) dir = QChar::DirAN; switch(status.last) { case QChar::DirL: case QChar::DirAN: eor = current; status.eor = QChar::DirAN; break; case QChar::DirR: case QChar::DirAL: case QChar::DirEN: runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; break; case QChar::DirCS: if(status.eor == QChar::DirAN) { eor = current; status.eor = QChar::DirR; break; } case QChar::DirES: case QChar::DirET: case QChar::DirBN: case QChar::DirB: case QChar::DirS: case QChar::DirWS: case QChar::DirON: if(status.eor == QChar::DirR) { // neutrals go to R eor = current - 1; runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; dir = QChar::DirAN; } else if( status.eor == QChar::DirL || (status.eor == QChar::DirEN && status.lastStrong == QChar::DirL)) { eor = current; status.eor = dirCurrent; } else { // numbers on both sides, neutrals get right to left direction if(dir != QChar::DirL) { runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; eor = current - 1; dir = QChar::DirR; runs->append( new QTextRun(sor, eor, context, dir) ); ++eor; sor = eor; dir = QChar::DirON; status.eor = QChar::DirON; dir = QChar::DirAN; } else { eor = current; status.eor = dirCurrent; } } default: break; } break; case QChar::DirES: case QChar::DirCS: break; case QChar::DirET: if(status.last == QChar::DirEN) { dirCurrent = QChar::DirEN; eor = current; status.eor = dirCurrent; break; } break; // boundary neutrals should be ignored case QChar::DirBN: break; // neutrals case QChar::DirB: // ### what do we do with newline and paragraph separators that come to here? break; case QChar::DirS: // ### implement rule L1 break; case QChar::DirWS: case QChar::DirON: break; default: break; } //cout << " after: dir=" << // dir << " current=" << dirCurrent << " last=" << status.last << " eor=" << status.eor << " lastStrong=" << status.lastStrong << " embedding=" << context->dir << endl; if(current >= (int)text.length()) break; // set status.last as needed. switch(dirCurrent) { case QChar::DirET: case QChar::DirES: case QChar::DirCS: case QChar::DirS: case QChar::DirWS: case QChar::DirON: switch(status.last) { case QChar::DirL: case QChar::DirR: case QChar::DirAL: case QChar::DirEN: case QChar::DirAN: status.last = dirCurrent; break; default: status.last = QChar::DirON; } break; case QChar::DirNSM: case QChar::DirBN: // ignore these break; default: status.last = dirCurrent; } ++current; }
/* * Constructs a KBabelDictView which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ KBabelDictView::KBabelDictView( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setSpacing(KDialog::spacingHint()); mainLayout->setMargin(KDialog::marginHint()); splitter = new QSplitter(this); mainLayout->addWidget(splitter); QWidget *w = new QWidget(splitter); QVBoxLayout *wLayout= new QVBoxLayout(w); wLayout->setSpacing(KDialog::spacingHint()); wLayout->setMargin(KDialog::marginHint()); QHBoxLayout *hbox = new QHBoxLayout(wLayout); QLabel *label = new QLabel(i18n("Search in module:"), w); hbox->addWidget(label); moduleCombo = new KComboBox(w); hbox->addWidget(moduleCombo); QWidget *temp = new QWidget(w); hbox->addWidget(temp); hbox->setStretchFactor(temp,2); editButton = new QPushButton(i18n("&Edit"),w); editButton->setEnabled(false); hbox->addWidget(editButton); // added a button "clear search" here hbox = new QHBoxLayout(wLayout); QPushButton* clearButton = new QPushButton(w); clearButton->setFlat(true); clearButton->setPixmap(SmallIcon("locationbar_erase")); hbox->addWidget(clearButton); textEdit = new KLineEdit(w,"textedit"); textEdit->setFocus(); hbox->addWidget(textEdit); hbox = new QHBoxLayout(wLayout); startButton = new QPushButton(i18n("&Start Search"),w); hbox->addWidget(startButton); inTransButton = new QCheckBox(i18n("Sea&rch in translations"),w); hbox->addWidget(inTransButton); hbox->addStretch(1); stopButton = new QPushButton(i18n("S&top"),w); stopButton->setEnabled(false); hbox->addWidget(stopButton); KSeparator *sep = new KSeparator(w); wLayout->addWidget(sep); dictBox = new KBabelDictBox(w,"kbabeldictbox"); wLayout->addWidget(dictBox); prefWidget = new QWidget(splitter); QVBoxLayout *tempLayout= new QVBoxLayout(prefWidget); tempLayout->setSpacing(KDialog::spacingHint()); tempLayout->setMargin(KDialog::marginHint()); label = new QLabel(i18n("Settings:"),prefWidget); tempLayout->addWidget(label); prefStack = new QWidgetStack(prefWidget); tempLayout->addWidget(prefStack); tempLayout->addStretch(1); KConfig *config = KGlobal::config(); dictBox->readSettings(config); dictBox->setAutoUpdateOptions(true); QStringList modules = dictBox->moduleNames(); moduleCombo->insertStringList(modules); QPtrList<PrefWidget> prefs = dictBox->modPrefWidgets(prefStack); prefs.setAutoDelete(false); PrefWidget *p; int i=0; for(p = prefs.first(); p != 0; p=prefs.next()) { prefStack->addWidget(p,i); i++; } int active=dictBox->activeModule(); prefStack->raiseWidget(active); moduleCombo->setCurrentItem(active); QHBox *h = new QHBox(this); h->setSpacing(KDialog::spacingHint()); mainLayout->addWidget(h); progressLabel = new QLabel(h); progressBar = new KProgress(h); connect(textEdit,SIGNAL(returnPressed()),startButton,SLOT(animateClick())); connect(startButton,SIGNAL(clicked()),this, SLOT(startSearch())); connect(stopButton, SIGNAL(clicked()), dictBox,SLOT(slotStopSearch())); connect(editButton, SIGNAL(clicked()), dictBox, SLOT(edit())); connect(dictBox, SIGNAL(searchStarted()), this, SLOT(searchStarted())); connect(dictBox, SIGNAL(searchStopped()), this, SLOT(searchStopped())); connect(dictBox, SIGNAL(progressed(int)), progressBar, SLOT(setProgress(int))); connect(dictBox, SIGNAL(activeModuleChanged(bool)) , editButton, SLOT(setEnabled(bool))); connect(dictBox, SIGNAL(progressStarts(const QString&)) , this, SLOT(progressStarted(const QString&))); connect(dictBox, SIGNAL(progressEnds()), this, SLOT(progressStopped())); connect(moduleCombo, SIGNAL(activated(int)), dictBox, SLOT(setActiveModule(int))); connect(dictBox, SIGNAL(activeModuleChanged(int)) , this, SLOT(switchModule(int))); connect(clearButton, SIGNAL(clicked()), this, SLOT(slotClearSearch())); }