/** * Load settings from file */ void Settings::load() { // Search for a file from user's home directory QString path = QString(getenv("HOME")) + QString("/") + QString(KQLCUserDir); QString fileName = path + QString("/") + QString(KConfigFile); QPtrList <QString> list; if (FileHandler::readFileToList(fileName, list) == true) { for (QString* s = list.first(); s != NULL; s = list.next()) { if (*s == QString("Entry")) { if (*(list.next()) == QString("General")) { createContents(list); } } } } while (!list.isEmpty()) { delete list.take(0); } }
void KPrintAction::slotAboutToShow() { popupMenu()->clear(); d->printers.clear(); QPtrList<KMPrinter> *prts = KMManager::self()->printerList(); if (prts && !prts->isEmpty()) { QPtrListIterator<KMPrinter> it(*prts); bool first(false); int ID(0); for (; it.current(); ++it) { if (d->type == All || (d->type == Specials && it.current()->isSpecial()) || (d->type == Regular && !it.current()->isSpecial())) { if (d->type == All && !first && it.current()->isSpecial()) { if (popupMenu()->count() > 0) popupMenu()->insertSeparator(); first = true; } popupMenu()->insertItem(SmallIconSet(it.current()->pixmap()), it.current()->name(), ID++); d->printers.append(it.current()->name()); } } } }
//----------------------------------------------------------------------------- void KMMimePartTree::saveSelectedBodyParts( bool encoded ) { QPtrList<QListViewItem> selected = selectedItems(); Q_ASSERT( !selected.isEmpty() ); if ( selected.isEmpty() ) return; QPtrListIterator<QListViewItem> it( selected ); QPtrList<partNode> parts; while ( it.current() ) { parts.append( static_cast<KMMimePartTreeItem *>(it.current())->node() ); ++it; } mReaderWin->setUpdateAttachment(); KMSaveAttachmentsCommand *command = new KMSaveAttachmentsCommand( this, parts, mReaderWin->message(), encoded ); command->start(); }
void KGet_plug_in::slotShowLinks() { if ( !parent() || !parent()->inherits( "KHTMLPart" ) ) return; KHTMLPart *htmlPart = static_cast<KHTMLPart*>( parent() ); KParts::Part *activePart = 0L; if ( htmlPart->partManager() ) { activePart = htmlPart->partManager()->activePart(); if ( activePart && activePart->inherits( "KHTMLPart" ) ) htmlPart = static_cast<KHTMLPart*>( activePart ); } DOM::HTMLDocument doc = htmlPart->htmlDocument(); if ( doc.isNull() ) return; DOM::HTMLCollection links = doc.links(); QPtrList<LinkItem> linkList; std::set<QString> dupeCheck; for ( uint i = 0; i < links.length(); i++ ) { DOM::Node link = links.item( i ); if ( link.isNull() || link.nodeType() != DOM::Node::ELEMENT_NODE ) continue; LinkItem *item = new LinkItem( (DOM::Element) link ); if ( item->isValid() && dupeCheck.find( item->url.url() ) == dupeCheck.end() ) { linkList.append( item ); dupeCheck.insert( item->url.url() ); } else delete item; } if ( linkList.isEmpty() ) { KMessageBox::sorry( htmlPart->widget(), i18n("There are no links in the active frame of the current HTML page."), i18n("No Links") ); return; } KGetLinkView *view = new KGetLinkView(); QString url = doc.URL().string(); view->setPageURL( url ); view->setLinks( linkList ); view->show(); }
void K3bMovixView::slotRemoveSubTitleItems() { QPtrList<QListViewItem> list = m_listView->selectedItems(); QPtrListIterator<QListViewItem> it(list); if( list.isEmpty() ) kdDebug() << "nothing to remove" << endl; for( ; it.current(); ++it ) { K3bMovixListViewItem* vi = static_cast<K3bMovixListViewItem*>(*it); m_doc->removeSubTitleItem( vi->fileItem() ); } }
/***************************************************************************** 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 ); }
//////////////////////// // Device Class stuff // //////////////////////// // // Read all device classes from files // void App::initDeviceClasses() { DeviceClass* dc = NULL; QString path = QString::null; QString dir; settings()->get(KEY_SYSTEM_DIR, dir); dir += QString("/") + DEVICECLASSPATH + QString("/"); QDir d(dir); d.setFilter(QDir::Files); d.setNameFilter("*.deviceclass"); if (d.exists() == false || d.isReadable() == false) { QString msg("Unable to read from device directory!"); QMessageBox::warning(this, KApplicationNameShort, msg); return; } QStringList dirlist(d.entryList()); QStringList::Iterator it; QPtrList <QString> list; // Our stringlist that contains the files' contents // Put a slash to the end of the directory name if it isn't there if (dir.right(1) != QString("/")) { dir = dir + QString("/"); } // Go thru all files for (it = dirlist.begin(); it != dirlist.end(); ++it) { path = dir + *it; FileHandler::readFileToList(path, list); dc = DeviceClass::createDeviceClass(list); if (dc != NULL) { addDeviceClass(dc); } // The list needs to be cleared between files while (list.isEmpty() == false) { list.first(); delete list.take(); } } }
/*! Prepends the character \a ch to the read buffer so that the next read returns this character as the first character of the output. \sa getch() */ int cAsyncNetIOPrivate::ungetch( int ch ) { if ( rba.isEmpty() || rindex==0 ) { // we need a new QByteArray QByteArray *ba = new QByteArray( 1 ); rba.insert( 0, ba ); rsize++; ba->at( 0 ) = ch; } else { // we can reuse a place in the buffer QByteArray *ba = rba.first(); rindex--; rsize++; ba->at( rindex ) = ch; } return ch; }
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; }
KActionMenu *JabberTransport::actionMenu () { KActionMenu *menu = new KActionMenu( accountId(), myself()->onlineStatus().iconFor( this ), this ); QString nick = myself()->property( Kopete::Global::Properties::self()->nickName()).value().toString(); menu->popupMenu()->insertTitle( myself()->onlineStatus().iconFor( myself() ), nick.isNull() ? accountLabel() : i18n( "%2 <%1>" ).arg( accountLabel(), nick ) ); QPtrList<KAction> *customActions = myself()->customContextMenuActions( ); if( customActions && !customActions->isEmpty() ) { menu->popupMenu()->insertSeparator(); for( KAction *a = customActions->first(); a; a = customActions->next() ) a->plug( menu->popupMenu() ); } delete customActions; return menu; /* KActionMenu *m_actionMenu = Kopete::Account::actionMenu(); m_actionMenu->popupMenu()->insertSeparator(); m_actionMenu->insert(new KAction (i18n ("Join Groupchat..."), "jabber_group", 0, this, SLOT (slotJoinNewChat ()), this, "actionJoinChat")); m_actionMenu->popupMenu()->insertSeparator(); m_actionMenu->insert ( new KAction ( i18n ("Services..."), "jabber_serv_on", 0, this, SLOT ( slotGetServices () ), this, "actionJabberServices") ); m_actionMenu->insert ( new KAction ( i18n ("Send Raw Packet to Server..."), "mail_new", 0, this, SLOT ( slotSendRaw () ), this, "actionJabberSendRaw") ); m_actionMenu->insert ( new KAction ( i18n ("Edit User Info..."), "identity", 0, this, SLOT ( slotEditVCard () ), this, "actionEditVCard") ); return m_actionMenu;*/ }
/** * Display a DMX value menu, divided into submenus of 16 values */ int VCXYPadProperties::invokeDMXValueMenu(const QPoint &point) { int result; QPopupMenu* menu = new QPopupMenu; QPtrList <QPopupMenu> deleteList; menu->insertItem("Value", KNoID); menu->insertSeparator(); menu->insertItem(QString::number(KChannelValueMin), KChannelValueMin); menu->insertItem(QString::number(KChannelValueMax), KChannelValueMax); for (t_value i = 0; i != KChannelValueMax; i += 15) { QPopupMenu* sub = new QPopupMenu(); deleteList.append(sub); QString top; top.sprintf("%d - %d", i+1, i + 15); for (t_value j = 1; j < 16; j++) { QString num; num.setNum(i + j); sub->insertItem(num, i + j); } menu->insertItem(top, sub); } result = menu->exec(point); while (deleteList.isEmpty() == false) { delete deleteList.take(0); } delete menu; return result; }
void UIListBtnType::Draw(QPainter *p, int order, int context, bool active_on) { if (!m_visible || hidden) return; if (!m_initialized) Init(); if (m_order != order) return; if (m_context != -1 && m_context != context) return; // Put something on the LCD device (if one exists) if (class LCD *lcddev = LCD::Get()) { if (m_active) { // add max of lcd height menu items either side of the selected item // let the lcdserver figure out which ones to display QPtrList<LCDMenuItem> menuItems; menuItems.setAutoDelete(true); QPtrListIterator<UIListBtnTypeItem> it = (*m_selIterator); uint count = 0; // move back up the list a little while (it.current() && count < lcddev->getLCDHeight()) { --it; ++count; } if (!it.current()) it.toFirst(); count = 0; while (it.current() && count < lcddev->getLCDHeight() * 2) { UIListBtnTypeItem *curItem = it.current(); QString msg = curItem->text(); bool selected; CHECKED_STATE checkState = NOTCHECKABLE; if (curItem->checkable()) { if (curItem->state() == UIListBtnTypeItem::HalfChecked || curItem->state() == UIListBtnTypeItem::FullChecked) checkState = CHECKED; else checkState = UNCHECKED; } if (curItem == m_selItem) selected = true; else selected = false; menuItems.append(new LCDMenuItem(selected, checkState, msg)); ++it; ++count; } QString title = ""; if (m_parentListTree && m_parentListTree->getDepth() > 0) title = "<< "; else title = " "; if ((m_selItem && m_selItem->getDrawArrow()) || m_showArrow) title += " >>"; else title += " "; if (!menuItems.isEmpty()) { lcddev->switchToMenu(&menuItems, title); } } } fontProp* font = m_active ? m_fontActive : m_fontInactive; if (!active_on) { font = m_fontInactive; } p->setFont(font->face); p->setPen(font->color); int x = m_rect.x() + m_xdrawoffset; int y = m_rect.y(); QPtrListIterator<UIListBtnTypeItem> it = (*m_topIterator); while (it.current() && (y - m_rect.y()) <= (m_contentsRect.height() - m_itemHeight)) { if (active_on && it.current()->getOverrideInactive()) { font = m_fontInactive; p->setFont(font->face); p->setPen(font->color); it.current()->setJustification(m_justify); it.current()->paint(p, font, x, y, active_on); font = m_active ? m_fontActive : m_fontInactive;; p->setFont(font->face); p->setPen(font->color); } else { it.current()->setJustification(m_justify); it.current()->paint(p, font, x, y, active_on); } y += m_itemHeight + m_itemSpacing; ++it; } if (m_showScrollArrows) { if (m_showUpArrow) p->drawPixmap(x + m_arrowsRect.x(), m_rect.y() + m_arrowsRect.y(), m_upArrowActPix); else p->drawPixmap(x + m_arrowsRect.x(), m_rect.y() + m_arrowsRect.y(), m_upArrowRegPix); if (m_showDnArrow) p->drawPixmap(x + m_arrowsRect.x() + m_upArrowRegPix.width() + m_itemMargin, m_rect.y() + m_arrowsRect.y(), m_dnArrowActPix); else p->drawPixmap(x + m_arrowsRect.x() + m_upArrowRegPix.width() + m_itemMargin, m_rect.y() + m_arrowsRect.y(), m_dnArrowRegPix); } }
/***************************************************************************** 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); }
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(); } }
int PMInsertRuleSystem::canInsert( const PMObject* parentObject, const QStringList& list, const PMObject* after ) { if( list.size( ) == 1 ) { // more efficient if( canInsert( parentObject, list.first( ), after ) ) return 1; else return 0; } // find rules for target class QPtrList<PMRuleTargetClass> targetClassList; PMMetaObject* meta = parentObject->metaObject( ); for( ; meta; meta = meta->superClass( ) ) { PMRuleTargetClass* tc = m_rulesDict.find( meta->className( ) ); if( tc ) targetClassList.append( tc ); } if( targetClassList.isEmpty( ) ) return 0; // not rules found // count already inserted children QPtrListIterator<PMRuleTargetClass> tit( targetClassList ); for( ; tit.current( ); ++tit ) // ... for all target classes { QPtrListIterator<PMRule> rit = tit.current( )->rules( ); for( ; rit.current( ); ++rit ) // ... and all rules { rit.current( )->reset( ); bool afterInsertPoint = false; PMObject* o = parentObject->firstChild( ); if( !after ) afterInsertPoint = true; for( ; o; o = o->nextSibling( ) ) { rit.current( )->countChild( o->className( ), afterInsertPoint ); if( o == after ) afterInsertPoint = true; } } } int number = 0; QStringList::const_iterator oit; for( oit = list.begin( ); oit != list.end( ); ++oit ) { bool possible = false; for( tit.toFirst( ); tit.current( ) && !possible; ++tit ) { QPtrListIterator<PMRule> rit = tit.current( )->rules( ); for( ; rit.current( ) && !possible; ++rit ) { PMRule* rule = rit.current( ); if( rule->matches( *oit ) ) possible = rule->evaluate( parentObject ); } } if( possible ) { // object can be inserted, count it for( ; tit.current( ); ++tit ) { QPtrListIterator<PMRule> rit = tit.current( )->rules( ); for( ; rit.current( ); ++rit ) rit.current( )->countChild( *oit, false ); } number++; } } return number; }
void Win32MakefileGenerator::writeSubDirs(QTextStream &t) { QPtrList<SubDir> subdirs; { QStringList subdirs_in = project->variables()["SUBDIRS"]; for(QStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) { QString file = (*it); file = fileFixify(file); SubDir *sd = new SubDir; subdirs.append(sd); sd->makefile = "$(MAKEFILE)"; if((*it).right(4) == ".pro") { int slsh = file.findRev(Option::dir_sep); if(slsh != -1) { sd->directory = file.left(slsh+1); sd->profile = file.mid(slsh+1); } else { sd->profile = file; } } else { sd->directory = file; } while(sd->directory.right(1) == Option::dir_sep) sd->directory = sd->directory.left(sd->directory.length() - 1); if(!sd->profile.isEmpty()) { QString basename = sd->directory; int new_slsh = basename.findRev(Option::dir_sep); if(new_slsh != -1) basename = basename.mid(new_slsh+1); if(sd->profile != basename + ".pro") sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro } sd->target = "sub-" + (*it); sd->target.replace('/', '-'); sd->target.replace('.', '_'); } } QPtrListIterator<SubDir> it(subdirs); t << "MAKEFILE = " << (project->isEmpty("MAKEFILE") ? QString("Makefile") : var("MAKEFILE")) << endl; t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; t << "SUBTARGETS = "; for( it.toFirst(); it.current(); ++it) t << " \\\n\t\t" << it.current()->target; t << endl << endl; t << "all: $(MAKEFILE) $(SUBTARGETS)" << endl << endl; for( it.toFirst(); it.current(); ++it) { bool have_dir = !(*it)->directory.isEmpty(); //make the makefile QString mkfile = (*it)->makefile; if(have_dir) mkfile.prepend((*it)->directory + Option::dir_sep); t << mkfile << ":"; if(have_dir) t << "\n\t" << "cd " << (*it)->directory; t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); t << " -o " << (*it)->makefile; if(have_dir) { int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; t << "\n\t" << "@cd .."; for(int i = 1; i < subLevels; i++ ) t << Option::dir_sep << ".."; } t << endl; //now actually build t << (*it)->target << ": " << mkfile; if(project->variables()["QMAKE_NOFORCE"].isEmpty()) t << " FORCE"; if(have_dir) t << "\n\t" << "cd " << (*it)->directory; t << "\n\t" << "$(MAKE)"; t << " -f " << (*it)->makefile; if(have_dir) { int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; t << "\n\t" << "@cd .."; for(int i = 1; i < subLevels; i++ ) t << Option::dir_sep << ".."; } t << endl << endl; } if (project->isActiveConfig("ordered")) { // generate dependencies for( it.toFirst(); it.current(); ) { QString tar = it.current()->target; ++it; if (it.current()) t << it.current()->target << ": " << tar << endl; } t << endl; } if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); writeMakeQmake(t); t << "qmake_all:"; if ( !subdirs.isEmpty() ) { for( it.toFirst(); it.current(); ++it) { QString subdir = (*it)->directory; QString profile = (*it)->profile; int subLevels = subdir.contains(Option::dir_sep) + 1; t << "\n\t" << "cd " << subdir << "\n\t"; int lastSlash = subdir.findRev(Option::dir_sep); if(lastSlash != -1) subdir = subdir.mid( lastSlash + 1 ); t << "$(QMAKE) " << ( !profile.isEmpty() ? profile : subdir + ".pro" ) << " -o " << (*it)->makefile << " " << buildArgs() << "\n\t" << "@cd .."; for(int i = 1; i < subLevels; i++ ) t << Option::dir_sep << ".."; } } else { // Borland make does not like empty an empty command section, so insert // a dummy command. t << "\n\t" << "@cd ."; } t << endl << endl; QStringList targs; targs << "clean" << "install_subdirs" << "mocables" << "uicables" << "uiclean" << "mocclean"; targs += project->values("SUBDIR_TARGETS"); for(QStringList::Iterator targ_it = targs.begin(); targ_it != targs.end(); ++targ_it) { t << (*targ_it) << ": qmake_all"; QString targ = (*targ_it); if(targ == "install_subdirs") targ = "install"; else if(targ == "uninstall_subdirs") targ = "uninstall"; if(targ == "clean") t << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ", ""); if (!subdirs.isEmpty()) { for( it.toFirst(); it.current(); ++it) { int subLevels = (*it)->directory.contains(Option::dir_sep) + 1; bool have_dir = !(*it)->directory.isEmpty(); if(have_dir) t << "\n\t" << "cd " << (*it)->directory; QString in_file = " -f " + (*it)->makefile; t << "\n\t" << "$(MAKE) " << in_file << " " << targ; if(have_dir) { t << "\n\t" << "@cd .."; for(int i = 1; i < subLevels; i++ ) t << Option::dir_sep << ".."; } } } else { // Borland make does not like empty an empty command section, so // insert a dummy command. t << "\n\t" << "@cd ."; } t << endl << endl; } //installations project->variables()["INSTALLDEPS"] += "install_subdirs"; project->variables()["UNINSTALLDEPS"] += "uninstall_subdirs"; writeInstalls(t, "INSTALLS"); // user defined targets QStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; for(QStringList::Iterator sit = qut.begin(); sit != qut.end(); ++sit) { QString targ = var((*sit) + ".target"), cmd = var((*sit) + ".commands"), deps; if(targ.isEmpty()) targ = (*sit); QStringList &deplist = project->variables()[(*sit) + ".depends"]; for(QStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { QString dep = var((*dep_it) + ".target"); if(dep.isEmpty()) dep = (*dep_it); deps += " " + dep; } if(!project->variables()["QMAKE_NOFORCE"].isEmpty() && project->variables()[(*sit) + ".CONFIG"].findIndex("phony") != -1) deps += QString(" ") + "FORCE"; t << "\n\n" << targ << ":" << deps << "\n\t" << cmd; } t << endl << endl; if(project->variables()["QMAKE_NOFORCE"].isEmpty()) t << "FORCE:" << endl << endl; }
void ServerListDialog::slotDelete() { QPtrList<QListViewItem> selectedItems = m_serverList->selectedServerListItems(); if (selectedItems.isEmpty()) return; ServerListItem* item = static_cast<ServerListItem*>(selectedItems.first()); ServerListItem* parent = 0; // Make sure we're not deleting a network's only servers while (item) { if (item->isServer()) { parent = static_cast<ServerListItem*>(item->parent()); if (parent && parent->childCount() == 1) { KMessageBox::error(this, i18n("You cannot delete %1.\n\nThe network %2 needs to have at least one server.").arg(item->name()).arg(parent->name())); return; } else if (parent && parent->childCount() == parent->selectedChildrenCount()) { KMessageBox::error(this, i18n("You cannot delete the selected servers.\n\nThe network %1 needs to have at least one server.").arg(parent->name())); return; } } item = static_cast<ServerListItem*>(selectedItems.next()); } // Reset item item = static_cast<ServerListItem*>(selectedItems.first()); // Ask the user if he really wants to delete what he selected QString question; if (selectedItems.count()>1) question = i18n("Do you really want to delete the selected entries?"); else question = i18n("Do you really want to delete %1?").arg(item->name()); if (KMessageBox::warningContinueCancel(this,question) == KMessageBox::Cancel) { return; } QListViewItem* itemBelow = 0; QListViewItem* itemAbove = 0; // Have fun deleting while (item) { itemBelow = item->nextSibling(); itemAbove = item->itemAbove(); if (item->isServer()) { Konversation::ServerGroupSettingsPtr serverGroup = Preferences::serverGroupById(item->serverGroupId()); serverGroup->removeServer(item->server()); delete item; } else { Preferences::removeServerGroup(item->serverGroupId()); delete item; } item = static_cast<ServerListItem*>(selectedItems.next()); } if (itemBelow) { m_serverList->setSelected(itemBelow,true); m_serverList->setCurrentItem(itemBelow); } else if (itemAbove) { m_serverList->setSelected(itemAbove,true); m_serverList->setCurrentItem(itemAbove); } else { if (m_serverList->firstChild()) { m_serverList->setSelected(m_serverList->firstChild(),true); m_serverList->setCurrentItem(m_serverList->firstChild()); } } emit serverGroupsChanged(); }
// ----------------------------------------------------------------------- // Is called if the "Replace"-button is pressed. void ChangeDialog::slotButtReplace() { Expr.setWildcard(true); // switch into wildcard mode Expr.setPattern(CompNameEdit->text()); /* if(!Expr.isValid()) { QMessageBox::critical(this, tr("Error"), tr("Regular expression for component name is invalid.")); return; }*/ // create dialog showing all found components QDialog *Dia = new QDialog(this); Dia->setCaption(tr("Found Components")); QVBoxLayout *Dia_All = new QVBoxLayout(Dia); Dia_All->setSpacing(3); Dia_All->setMargin(5); QScrollView *Dia_Scroll = new QScrollView(Dia); Dia_Scroll->setMargin(5); Dia_All->addWidget(Dia_Scroll); QVBox *Dia_Box = new QVBox(Dia_Scroll->viewport()); Dia_Scroll->addChild(Dia_Box); QLabel *Dia_Label = new QLabel(tr("Change properties of\n") + tr("these components ?"), Dia); Dia_All->addWidget(Dia_Label); QHBox *Dia_h = new QHBox(Dia); Dia_h->setSpacing(5); Dia_All->addWidget(Dia_h); QPushButton *YesButton = new QPushButton(tr("Yes"), Dia_h); connect(YesButton, SIGNAL(clicked()), Dia, SLOT(accept())); connect(new QPushButton(tr("Cancel"), Dia_h), SIGNAL(clicked()), Dia, SLOT(reject())); QPtrList<QCheckBox> pList; QCheckBox *pb; Component *pc; QStringList List; QString str; int i1, i2; // search through all components for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) { if(matches(pc->Model)) { if(Expr.search(pc->Name) >= 0) for(Property *pp = pc->Props.first(); pp!=0; pp = pc->Props.next()) if(pp->Name == PropNameEdit->currentText()) { pb = new QCheckBox(pc->Name, Dia_Box); pList.append(pb); pb->setChecked(true); i1 = pp->Description.find('['); if(i1 < 0) break; // no multiple-choice property i2 = pp->Description.findRev(']'); if(i2-i1 < 2) break; str = pp->Description.mid(i1+1, i2-i1-1); str.replace( QRegExp("[^a-zA-Z0-9_,]"), "" ); List = List.split(',',str); if(List.findIndex(NewValueEdit->text()) >= 0) break; // property value is okay pb->setChecked(false); pb->setEnabled(false); break; } } } QColor theColor; if(pList.isEmpty()) { YesButton->setEnabled(false); theColor = (new QLabel(tr("No match found!"), Dia_Box))->paletteBackgroundColor(); } else theColor = pList.current()->paletteBackgroundColor(); Dia_Scroll->viewport()->setPaletteBackgroundColor(theColor); Dia->resize(50, 300); // show user all components found int Result = Dia->exec(); if(Result != QDialog::Accepted) return; bool changed = false; // change property values for(pb = pList.first(); pb!=0; pb = pList.next()) { if(!pb->isChecked()) continue; for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) { if(pb->text() != pc->Name) continue; for(Property *pp = pc->Props.first(); pp!=0; pp = pc->Props.next()) { if(pp->Name != PropNameEdit->currentText()) continue; int tx_Dist, ty_Dist, tmp; pc->textSize(tx_Dist, ty_Dist); tmp = pc->tx+tx_Dist - pc->x1; if((tmp > 0) || (tmp < -6)) tx_Dist = 0; // remember text position tmp = pc->ty+ty_Dist - pc->y1; if((tmp > 0) || (tmp < -6)) ty_Dist = 0; pp->Value = NewValueEdit->text(); int dx, dy; pc->textSize(dx, dy); // correct text position if(tx_Dist != 0) { pc->tx += tx_Dist-dx; tx_Dist = dx; } if(ty_Dist != 0) { pc->ty += ty_Dist-dy; ty_Dist = dy; } // apply changes to schematic symbol Doc->recreateComponent(pc); changed = true; break; } break; } } delete Dia_All; delete Dia; if(changed) accept(); else reject(); }
/*! Creates a KDGanttViewTaskLink according to the specification in a DOM element. \param element the DOM element from which to read the specification \return the newly created task link */ KDGanttViewTaskLink* KDGanttViewTaskLink::createFromDomElement( QDomElement& element ) { QDomNode node = element.firstChild(); QStringList fromList, toList; bool highlight = false, visible = false; QColor color, highlightColor; QString tooltipText, whatsThisText, group; LinkType linktype=None; while( !node.isNull() ) { QDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element QString tagName = element.tagName(); if( tagName == "FromItems" ) { QDomNode node = element.firstChild(); while( !node.isNull() ) { QDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element QString tagName = element.tagName(); if( tagName == "Item" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) fromList << value; } else { qDebug( "Unrecognized tag name: %s", tagName.latin1() ); Q_ASSERT( false ); } } node = node.nextSibling(); } } else if( tagName == "ToItems" ) { QDomNode node = element.firstChild(); while( !node.isNull() ) { QDomElement element = node.toElement(); if( !element.isNull() ) { // was really an element QString tagName = element.tagName(); if( tagName == "Item" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) toList << value; } else { qDebug( "Unrecognized tag name: %s", tagName.latin1() ); Q_ASSERT( false ); } } node = node.nextSibling(); } } else if( tagName == "Highlight" ) { bool value; if( KDGanttXML::readBoolNode( element, value ) ) highlight = value; } else if( tagName == "Visible" ) { bool value; if( KDGanttXML::readBoolNode( element, value ) ) visible = value; } else if( tagName == "Color" ) { QColor value; if( KDGanttXML::readColorNode( element, value ) ) color = value; } else if( tagName == "HighlightColor" ) { QColor value; if( KDGanttXML::readColorNode( element, value ) ) highlightColor = value; } else if( tagName == "TooltipText" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) tooltipText = value; } else if( tagName == "WhatsThisText" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) whatsThisText = value; } else if( tagName == "Group" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) group = value; } else if( tagName == "Linktype" ) { QString value; if( KDGanttXML::readStringNode( element, value ) ) linktype = stringToLinkType( value ); } else { qDebug( "Unrecognized tag name: %s", tagName.latin1() ); Q_ASSERT( false ); } } node = node.nextSibling(); } QPtrList<KDGanttViewItem> fromItemList; QPtrList<KDGanttViewItem> toItemList; for( QStringList::const_iterator fromIt = fromList.begin(); fromIt != fromList.end(); ++fromIt ) { KDGanttViewItem* item = KDGanttViewItem::find( *fromIt ); if( item ) fromItemList.append( item ); } for( QStringList::const_iterator toIt = toList.begin(); toIt != toList.end(); ++toIt ) { KDGanttViewItem* item = KDGanttViewItem::find( *toIt ); if( item ) toItemList.append( item ); } // safeguard aginst incorrect names if (fromItemList.isEmpty()) { qDebug("Cannot create link: fromItemList is empty"); return 0; } if (toItemList.isEmpty()) { qDebug("Cannot create link: toItemList is empty"); return 0; } KDGanttViewTaskLink* tl = new KDGanttViewTaskLink( fromItemList, toItemList ); tl->setLinkType( linktype ); tl->setVisible( visible ); tl->setHighlight( highlight ); tl->setColor( color ); tl->setHighlightColor( highlightColor ); tl->setTooltipText( tooltipText ); tl->setWhatsThisText( whatsThisText ); KDGanttViewTaskLinkGroup* gr = KDGanttViewTaskLinkGroup::find( group ); if( gr ) tl->setGroup( gr ); return tl; }
void EditFunctions::okClicked() { QValueList<MetaDataBase::Function> functionList = MetaDataBase::functionList( formWindow ); QString n = tr( "Add/Remove functions of '%1'" ).arg( formWindow->name() ); QPtrList<Command> commands; QValueList<MetaDataBase::Function>::Iterator fit; if ( !functionList.isEmpty() ) { for ( fit = functionList.begin(); fit != functionList.end(); ++fit ) { bool functionFound = FALSE; QValueList<FunctItem>::Iterator it = functList.begin(); for ( ; it != functList.end(); ++it ) { if ( MetaDataBase::normalizeFunction( (*it).oldName ) == MetaDataBase::normalizeFunction( (*fit).function ) ) { functionFound = TRUE; break; } } if ( !functionFound ) commands.append( new RemoveFunctionCommand( tr( "Remove function" ), formWindow, (*fit).function, (*fit).specifier, (*fit).access, (*fit).type, formWindow->project()->language(), (*fit).returnType ) ); } } bool invalidFunctions = FALSE; QValueList<FunctItem> invalidItems; if ( !functList.isEmpty() ) { QStrList lst; QValueList<FunctItem>::Iterator it = functList.begin(); for ( ; it != functList.end(); ++it ) { MetaDataBase::Function function; function.function = (*it).newName; function.returnType = (*it).retTyp; function.specifier = (*it).spec; function.access = (*it).access; function.type = (*it).type; function.language = formWindow->project()->language(); if ( function.returnType.isEmpty() ) function.returnType = "void"; QString s = function.function; s = s.simplifyWhiteSpace(); bool startNum = s[ 0 ] >= '0' && s[ 0 ] <= '9'; bool noParens = s.contains( '(' ) != 1 || s.contains( ')' ) != 1; bool illegalSpace = s.find( ' ' ) != -1 && s.find( ' ' ) < s.find( '(' ); if ( startNum || noParens || illegalSpace || lst.find( function.function ) != -1 ) { invalidFunctions = TRUE; invalidItems.append( (*it) ); continue; } bool functionFound = FALSE; for ( fit = functionList.begin(); fit != functionList.end(); ++fit ) { if ( MetaDataBase::normalizeFunction( (*fit).function ) == MetaDataBase::normalizeFunction( (*it).oldName ) ) { functionFound = TRUE; break; } } if ( !functionFound ) commands.append( new AddFunctionCommand( tr( "Add function" ), formWindow, function.function, function.specifier, function.access, function.type, formWindow->project()->language(), function.returnType ) ); if ( MetaDataBase::normalizeFunction( (*it).newName ) != MetaDataBase::normalizeFunction( (*it).oldName ) || (*it).spec != (*it).oldSpec || (*it).access != (*it).oldAccess || (*it).type != (*it).oldType || (*it).retTyp != (*it).oldRetTyp ) { QString normalizedOldName = MetaDataBase::normalizeFunction( (*it).oldName ); if ((*it).oldName.endsWith("const")) // make sure we get the 'const' when we remove the old name normalizedOldName += " const"; commands.append( new ChangeFunctionAttribCommand( tr( "Change function attributes" ), formWindow, function, normalizedOldName, (*it).oldSpec, (*it).oldAccess, (*it).oldType, formWindow->project()->language(), (*it).oldRetTyp ) ); } lst.append( function.function ); } } if ( invalidFunctions ) { if ( QMessageBox::information( this, tr( "Edit Functions" ), tr( "Some syntactically incorrect functions have been defined.\n" "Remove these functions?" ), tr( "&Yes" ), tr( "&No" ) ) == 0 ) { QValueList<FunctItem>::Iterator it = functList.begin(); while ( it != functList.end() ) { bool found = FALSE; QValueList<FunctItem>::Iterator vit = invalidItems.begin(); for ( ; vit != invalidItems.end(); ++vit ) { if ( (*vit).newName == (*it).newName ) { invalidItems.remove( vit ); found = TRUE; break; } } if ( found ) { int delId = (*it).id; it = functList.remove( it ); QMap<QListViewItem*, int>::Iterator fit = functionIds.begin(); while ( fit != functionIds.end() ) { if ( *fit == delId ) { QListViewItem *litem = fit.key(); functionIds.remove( fit ); delete litem; if ( functionListView->currentItem() ) functionListView->setSelected( functionListView->currentItem(), TRUE ); currentItemChanged( functionListView->currentItem() ); break; } ++fit; } } else ++it; } if ( functionListView->firstChild() ) { functionListView->setCurrentItem( functionListView->firstChild() ); functionListView->setSelected( functionListView->firstChild(), TRUE ); } } formWindow->mainWindow()->objectHierarchy()->updateFormDefinitionView(); return; } if ( !commands.isEmpty() ) { MacroCommand *cmd = new MacroCommand( n, formWindow, commands ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); } formWindow->mainWindow()->objectHierarchy()->updateFormDefinitionView(); accept(); }