void VariableDialog::okClicked() { QValueList<MetaDataBase::Variable> lst; QListViewItemIterator it( varView ); while ( it.current() != 0 ) { MetaDataBase::Variable v; v.varName = it.current()->text( 0 ).simplifyWhiteSpace(); if ( v.varName[ (int)v.varName.length() - 1 ] != ';' ) v.varName += ";"; v.varAccess = it.current()->text( 1 ); lst << v; ++it; } if ( !lst.isEmpty() ) { QValueList<MetaDataBase::Variable> invalidLst; QValueList<MetaDataBase::Variable>::Iterator it1 = lst.begin(); QValueList<MetaDataBase::Variable>::Iterator it2; for ( ; it1 != lst.end(); ++it1 ) { it2 = it1; ++it2; for ( ; it2 != lst.end(); ++it2 ) { if ( MetaDataBase::extractVariableName( (*it1).varName ) == MetaDataBase::extractVariableName( (*it2).varName ) ) { invalidLst << (*it1); break; } } } if ( !invalidLst.isEmpty() ) { if ( QMessageBox::information( this, tr( "Edit Variables" ), tr( "One variable has been declared twice.\n" "Remove this variable?" ), tr( "&Yes" ), tr( "&No" ) ) == 0 ) { for ( it2 = invalidLst.begin(); it2 != invalidLst.end(); ++it2 ) { it = varView->firstChild(); while ( it.current() != 0 ) { if ( MetaDataBase::extractVariableName( (*it)->text( 0 ).simplifyWhiteSpace() ) == MetaDataBase::extractVariableName( (*it2).varName ) ) { delete (*it); break; } ++it; } } } formWindow->mainWindow()->objectHierarchy()->updateFormDefinitionView(); return; } } Command *cmd = new SetVariablesCommand( "Edit variables", formWindow, lst ); formWindow->commandHistory()->addCommand( cmd ); cmd->execute(); accept(); }
void KstEditViewObjectDialogI::fillPenStyleWidget(QComboBox* widget) { QRect rect = widget->style().querySubControlMetrics(QStyle::CC_ComboBox, widget, QStyle::SC_ComboBoxEditField); rect.setLeft(rect.left() + 2); rect.setRight(rect.right() - 2); rect.setTop(rect.top() + 2); rect.setBottom(rect.bottom() - 2); // fill the combo with pen styles QPixmap ppix(rect.width(), rect.height()); QPainter pp(&ppix); QPen pen(Qt::black, 0); widget->clear(); QValueList<Qt::PenStyle> styles; styles.append(Qt::SolidLine); styles.append(Qt::DashLine); styles.append(Qt::DotLine); styles.append(Qt::DashDotLine); styles.append(Qt::DashDotDotLine); while (!styles.isEmpty()) { pen.setStyle(styles.front()); pp.setPen(pen); pp.fillRect( pp.window(), QColor("white")); pp.drawLine(1,ppix.height()/2,ppix.width()-1, ppix.height()/2); widget->insertItem(ppix); styles.pop_front(); } }
void UmlClass::generate_formals(QTextOStream & f) { QValueList<UmlFormalParameter> fs = formals(); if (! fs.isEmpty()) { QValueList<UmlFormalParameter>::Iterator it; const char * sep = "<"; for (it = fs.begin(); it != fs.end(); it++) { UmlFormalParameter & p = *it; f << sep; sep = ", "; f << p.name(); const UmlTypeSpec & t = p.extend(); if (t.type != 0) { f << " extends "; t.type->write(f); } else if (! t.explicit_type.isEmpty()) f << " extends " << JavaSettings::type(t.explicit_type); } f << ">"; } }
QPtrList<KAction> KDataToolAction::dataToolActionList( const QValueList<KDataToolInfo> & tools, const QObject *receiver, const char* slot ) { QPtrList<KAction> actionList; if ( tools.isEmpty() ) return actionList; actionList.append( new KActionSeparator() ); QValueList<KDataToolInfo>::ConstIterator entry = tools.begin(); for( ; entry != tools.end(); ++entry ) { QStringList userCommands = (*entry).userCommands(); QStringList commands = (*entry).commands(); Q_ASSERT(!commands.isEmpty()); if ( commands.count() != userCommands.count() ) kdWarning() << "KDataTool desktop file error (" << (*entry).service()->entryPath() << "). " << commands.count() << " commands and " << userCommands.count() << " descriptions." << endl; QStringList::ConstIterator uit = userCommands.begin(); QStringList::ConstIterator cit = commands.begin(); for (; uit != userCommands.end() && cit != commands.end(); ++uit, ++cit ) { //kdDebug() << "creating action " << *uit << " " << *cit << endl; KDataToolAction * action = new KDataToolAction( *uit, *entry, *cit ); connect( action, SIGNAL( toolActivated( const KDataToolInfo &, const QString & ) ), receiver, slot ); actionList.append( action ); } } return actionList; }
/****************************************************************************** * Check if the rule is a daily rule with or without BYDAYS specified. */ bool KARecurrence::dailyType(const RecurrenceRule *rrule) { if(rrule->recurrenceType() != RecurrenceRule::rDaily || !rrule->bySeconds().isEmpty() || !rrule->byMinutes().isEmpty() || !rrule->byHours().isEmpty() || !rrule->byWeekNumbers().isEmpty() || !rrule->byMonthDays().isEmpty() || !rrule->byMonths().isEmpty() || !rrule->bySetPos().isEmpty() || !rrule->byYearDays().isEmpty()) return false; QValueList<RecurrenceRule::WDayPos> days = rrule->byDays(); if(days.isEmpty()) return true; // Check that all the positions are zero (i.e. every time) bool found = false; for(QValueList<RecurrenceRule::WDayPos>::ConstIterator it = days.begin(); it != days.end(); ++it) { if((*it).pos() != 0) return false; found = true; } return found; }
void ClusterPalette::moveClustersToArtefact() { QValueList<int> selected = selectedClusters(); if(!selected.isEmpty()) { emit moveClustersToArtefact(selected); isUpToDate = true; } }
void K3bWriterSelectionWidget::slotRefreshWriterSpeeds() { if( writerDevice() ) { QValueList<int> speeds = k3bappcore->mediaCache()->writingSpeeds( writerDevice() ); int lastSpeed = writerSpeed(); clearSpeedCombo(); m_comboSpeed->insertItem( i18n("Auto") ); if( k3bappcore->mediaCache()->diskInfo( writerDevice() ).isDvdMedia() ) { m_comboSpeed->insertItem( i18n("Ignore") ); d->haveIgnoreSpeed = true; } else d->haveIgnoreSpeed = false; if( !d->forceAutoSpeed ) { if( speeds.isEmpty() || writerDevice() == m_comboMedium->overrideDevice() ) { // // In case of the override device we do not know which medium will actually be used // So this is the only case in which we need to use the device's max writing speed // // But we need to know if it will be a CD or DVD medium. Since the override device // is only used for CD/DVD copy anyway we simply reply on the inserted medium's type. // int i = 1; int speed = ( k3bappcore->mediaCache()->diskInfo( writerDevice() ).isDvdMedia() ? 1385 : 175 ); int max = writerDevice()->maxWriteSpeed(); while( i*speed <= max ) { insertSpeedItem( i*speed ); // a little hack to handle the stupid 2.4x DVD speed if( i == 2 && speed == 1385 ) insertSpeedItem( (int)(2.4*1385.0) ); i = ( i == 1 ? 2 : i+2 ); } // // Since we do not know the exact max writing speed if an override device is set (we can't becasue // the writer always returns the speed relative to the inserted medium) we allow the user to specify // the speed manually // m_comboSpeed->insertItem( i18n("More...") ); d->haveManualSpeed = true; } else { for( QValueList<int>::iterator it = speeds.begin(); it != speeds.end(); ++it ) insertSpeedItem( *it ); } } // try to reload last set speed if( d->lastSetSpeed == -1 ) setSpeed( lastSpeed ); else setSpeed( d->lastSetSpeed ); } m_comboSpeed->setEnabled( writerDevice() != 0 ); }
int K3bDataUrlAddingDialog::copyMoveItems( const QValueList<K3bDataItem*>& items, K3bDirItem* dir, QWidget* parent, bool copy ) { if( items.isEmpty() ) return 0; K3bDataUrlAddingDialog dlg( dir->doc(), parent ); dlg.m_infoLabel->setText( i18n("Moving files to project \"%1\"...").arg(dir->doc()->URL().fileName()) ); dlg.m_copyItems = copy; for( QValueList<K3bDataItem*>::const_iterator it = items.begin(); it != items.end(); ++it ) { dlg.m_items.append( qMakePair( *it, dir ) ); ++dlg.m_totalFiles; if( (*it)->isDir() ) { dlg.m_totalFiles += static_cast<K3bDirItem*>( *it )->numFiles(); dlg.m_totalFiles += static_cast<K3bDirItem*>( *it )->numDirs(); } } dlg.slotCopyMoveItems(); int ret = QDialog::Accepted; if( !dlg.m_items.isEmpty() ) { dlg.m_progressWidget->setTotalSteps( dlg.m_totalFiles ); ret = dlg.exec(); } return ret; }
void MyMoneyReport::validDateRange ( QDate& _db, QDate& _de ) { _db = fromDate(); _de = toDate(); // if either begin or end date are invalid we have one of the following // possible date filters: // // a) begin date not set - first transaction until given end date // b) end date not set - from given date until last transaction // c) both not set - first transaction until last transaction // // If there is no transaction in the engine at all, we use the current // year as the filter criteria. if ( !_db.isValid() || !_de.isValid() ) { QValueList<MyMoneyTransaction> list = MyMoneyFile::instance()->transactionList ( *this ); QDate tmpBegin, tmpEnd; if ( !list.isEmpty() ) { qHeapSort ( list ); tmpBegin = list.front().postDate(); tmpEnd = list.back().postDate(); } else { tmpBegin = QDate ( QDate::currentDate().year(), 1, 1 ); // the first date in the file tmpEnd = QDate ( QDate::currentDate().year(), 12, 31 );// the last date in the file } if ( !_db.isValid() ) _db = tmpBegin; if ( !_de.isValid() ) _de = tmpEnd; } if ( _db > _de ) _db = _de; }
void MessageActions::setMessageStatus(KMMsgStatus status, bool toggle) { QValueList<Q_UINT32> serNums = mVisibleSernums; if(serNums.isEmpty() && mCurrentMessage) serNums.append(mCurrentMessage->getMsgSerNum()); if(serNums.empty()) return; KMCommand *command = new KMSetStatusCommand(status, serNums, toggle); command->start(); }
void qListToIterator(DBusMessageIter* it, const QValueList<QDBusData>& list) { if (list.isEmpty()) return; QValueList<QDBusData>::ConstIterator listIt = list.begin(); QValueList<QDBusData>::ConstIterator listEndIt = list.end(); for (; listIt != listEndIt; ++listIt) { qDBusDataToIterator(it, *listIt); } }
KAboutApplication::KAboutApplication( const KAboutData *aboutData, QWidget *parent, const char *name, bool modal) : AboutDlgBase(parent, name, modal) { SET_WNDPROC setCaption(caption()); connect(btnOK, SIGNAL(clicked()), this, SLOT(close())); setIcon(Pict("licq")); lblIcon->setPixmap(Icon("licq").pixmap(QIconSet::Large, QIconSet::Normal)); lblVersion->setText(i18n("%1 Version: %2") .arg(aboutData->appName()) .arg(aboutData->version())); txtAbout->setText((QString("<center><br>%1<br><br>%2<br><br>") + "<a href=\"%3\">%4</a><br><br>" + i18n("Bug report") + ": <a href=\"mailto:%5\">%6</a>" + "</center>") .arg(quote(aboutData->shortDescription())) .arg(quote(aboutData->copyrightStatement())) .arg(quote(aboutData->homepage())) .arg(quote(aboutData->homepage())) .arg(quote(aboutData->bugAddress())) .arg(quote(aboutData->bugAddress()))); QString txt; QValueList<KAboutPerson>::ConstIterator it; for (it = aboutData->authors().begin(); it != aboutData->authors().end(); ++it) { txt += addPerson(&(*it)); txt += "<br>"; } txtAuthors->setText(txt); txt = ""; QValueList<KAboutTranslator> translators = aboutData->translators(); QValueList<KAboutTranslator>::ConstIterator itt; if (!translators.isEmpty()){ for (itt = translators.begin(); itt != translators.end(); ++itt) { const KAboutTranslator &t = *itt; txt += QString("%1 <<a href=\"mailto:%2\">%3</a>><br>") .arg(quote(t.name())) .arg(quote(t.emailAddress())) .arg(quote(t.emailAddress())); txt += "<br>"; } txtTranslations->setText(txt); }else{ tabMain->removePage(tabTranslation); } txtLicence->setText(quote(aboutData->license())); }
PluginFactory::PluginFactory( PConfigArgs& args ): args(args), d(new PluginFactoryPrivate) { pluginFactory = this; QValueList<int> keys = ancaConf->readIntListEntry( "onStartupMapKeys" ); QValueList<int> values = ancaConf->readIntListEntry( "onStartupMapValues" ); if( !keys.isEmpty() && keys.count() == values.count() ) { QValueList<int>::iterator it1 = keys.begin(); QValueList<int>::iterator it2 = values.begin(); for( ; it1 != keys.end() /* && it2 != values.end() */; ++it1, ++it2 ) onStartupMap[*it1] = *it2; } }
QDBusDataList::QDBusDataList(const QValueList<Q_UINT64>& other) : d(new Private()) { d->type = QDBusData::UInt64; if (other.isEmpty()) return; QValueList<Q_UINT64>::ConstIterator it = other.begin(); QValueList<Q_UINT64>::ConstIterator endIt = other.end(); for (; it != endIt; ++it) { d->list << QDBusData::fromUInt64(*it); } }
QDBusDataList::QDBusDataList(const QValueList<double>& other) : d(new Private()) { d->type = QDBusData::Double; if (other.isEmpty()) return; QValueList<double>::ConstIterator it = other.begin(); QValueList<double>::ConstIterator endIt = other.end(); for (; it != endIt; ++it) { d->list << QDBusData::fromDouble(*it); } }
QDBusDataList::QDBusDataList(const QValueList<Q_INT32>& other) : d(new Private()) { d->type = QDBusData::Int32; if (other.isEmpty()) return; QValueList<Q_INT32>::const_iterator it = other.begin(); QValueList<Q_INT32>::const_iterator endIt = other.end(); for (; it != endIt; ++it) { d->list << QDBusData::fromInt32(*it); } }
void Smtp::dnsLookupHelper() { QValueList<QDns::MailServer> s = mxLookup->mailServers(); if ( s.isEmpty() ) { if ( !mxLookup->isWorking() ) emit status( tr( "Error in MX record lookup" ) ); return; } emit status( tr( "Connecting to %1" ).arg( s.first().name ) ); socket->connectToHost( s.first().name, 25 ); t = new QTextStream( socket ); }
void EditorView::updateKeyTree ( ) { QValueList<QString> temp = openedKeys; openedKeys.clear ( ); keyTree->clear ( ); KeySet *roots = ksNew ( ); if ( kdbGetRootKeys ( roots ) ) { perror ( "opening roots" ); } ksSort ( roots ); ksRewind ( roots ); ::Key *k = ksNext ( roots ); while ( k ) { addRootItem( k ); k = ksNext ( roots ); } ksDel ( roots ); if ( temp.isEmpty ( ) ) return; QValueList<QString>::iterator it = temp.begin ( ); while ( it != temp.end ( ) ) { QListViewItem * item = getItem ( *it ); if ( item ) { if ( *it == keyName ( item ) ) { keyTree->setOpen ( item, true ); //cout << "ok" << endl; } else cout << "f**k " << keyName ( item ) << " != " << *it << endl; } /*if ( item->isOpen ( ) ) cout << "not open" << endl;*/ //openKeyDir ( item ); ++it; } }
QDBusDataList::QDBusDataList(const QValueList< QDBusObjectPath > &other) : d(new Private()) { d->type = QDBusData::ObjectPath; if(other.isEmpty()) return; QValueList< QDBusObjectPath >::const_iterator it = other.begin(); QValueList< QDBusObjectPath >::const_iterator endIt = other.end(); for(; it != endIt; ++it) { d->list << QDBusData::fromObjectPath(*it); } }
void ConnectionEditor::signalChanged() { QCString signal = signalBox->currentText().latin1(); if ( !signal.data() ) return; signal = normalizeSignalSlot( signal.data() ); slotBox->clear(); if ( signalBox->currentText().isEmpty() ) return; int n = receiver->metaObject()->numSlots( TRUE ); for( int i = 0; i < n; ++i ) { // accept only public slots. For the form window, also accept protected slots QMetaData* md = receiver->metaObject()->slot( i, TRUE ); if ( ( (receiver->metaObject()->slot_access( i, TRUE ) == QMetaData::Public) || ( formWindow->isMainContainer( (QWidget*)receiver ) && receiver->metaObject()->slot_access(i, TRUE) == QMetaData::Protected) ) && !ignoreSlot( md->name ) && checkConnectArgs( signal.data(), receiver, md->name ) ) slotBox->insertItem( md->name ); } if ( formWindow->isMainContainer( (QWidget*)receiver ) ) { QValueList<MetaDataBase::Slot> moreSlots = MetaDataBase::slotList( formWindow ); if ( !moreSlots.isEmpty() ) { for ( QValueList<MetaDataBase::Slot>::Iterator it = moreSlots.begin(); it != moreSlots.end(); ++it ) { QCString s = (*it).slot; if ( !s.data() ) continue; s = normalizeSignalSlot( s.data() ); if ( checkConnectArgs( signal.data(), receiver, s ) ) slotBox->insertItem( QString( (*it).slot ) ); } } } if ( receiver->inherits( "CustomWidget" ) ) { MetaDataBase::CustomWidget *w = ( (CustomWidget*)receiver )->customWidget(); for ( QValueList<MetaDataBase::Slot>::Iterator it = w->lstSlots.begin(); it != w->lstSlots.end(); ++it ) { QCString s = (*it).slot; if ( !s.data() ) continue; s = normalizeSignalSlot( s.data() ); if ( checkConnectArgs( signal.data(), receiver, s ) ) slotBox->insertItem( QString( (*it).slot ) ); } } slotsChanged(); }
void K3bVideoDVDRippingView::slotStartRipping() { QValueList<int> titles; int i = 1; for( QListViewItemIterator it( m_titleView ); *it; ++it, ++i ) if( static_cast<K3bCheckListViewItem*>( *it )->isChecked() ) titles.append( i ); if( titles.isEmpty() ) { KMessageBox::error( this, i18n("Please select the titles to rip."), i18n("No Titles Selected") ); } else { K3bVideoDVDRippingDialog dlg( m_dvd, titles, this ); dlg.exec(); } }
// emits the given QDomDocument for eventual plugins, checks after that // if there are any relevance elements. If there are none, random search is // implied and performed. // finally, the search is actually started void MrmlPart::performQuery( QDomDocument& doc ) { QDomElement mrml = doc.documentElement(); emit aboutToStartQuery( doc ); // let plugins play with it :) // no items available? All "neutral"? -> random search QDomElement queryStep = KMrml::firstChildElement( mrml, "query-step" ); bool randomSearch = false; if ( !queryStep.isNull() ) { QDomElement relevanceList = KMrml::firstChildElement(queryStep, "user-relevance-element-list"); QValueList<QDomElement> relevanceElements = KMrml::directChildElements( relevanceList, "user-relevance-element" ); randomSearch = relevanceElements.isEmpty(); if ( randomSearch ) { m_random->setChecked( true ); m_random->setEnabled( false ); queryStep.setAttribute("query-type", "at-random"); // remove user-relevance-element-list element for random search relevanceList.parentNode().removeChild( relevanceList ); } } else { KMessageBox::error( m_view, i18n("Error formulating the query. The " "\"query-step\" element is missing."), i18n("Query Error") ); } m_job = transferJob( url() ); slotSetStatusBar( randomSearch ? i18n("Random search...") : i18n("Searching...") ); m_job->addMetaData( MrmlShared::kio_task(), MrmlShared::kio_startQuery() ); qDebug("\n\nSending XML:\n%s", doc.toString().latin1()); m_job->addMetaData( MrmlShared::mrml_data(), doc.toString() ); }
void UmlClass::get_extended(QValueList<QCString> & r) { r.clear(); const QVector<UmlItem> ch = children(); unsigned n = ch.size(); unsigned i; for (i = 0; i != n; i += 1) { UmlItem * x = ch[i]; if ((x->kind() == aRelation) && (((UmlRelation *) x)->relationKind() == aDirectionalAssociation) && (((UmlRelation *) x)->roleType()->stereotype() == "metaclass")) r.append(((UmlRelation *) x)->roleType()->name()); } if (r.isEmpty()) r.append("Element"); }
int K3bAudioMaxSpeedJob::WorkThread::maxSpeedByMedia() const { int s = 0; QValueList<int> speeds = m_doc->burner()->determineSupportedWriteSpeeds(); // simply use what we have and let the writer decide if the speeds are empty if( !speeds.isEmpty() ) { // start with the highest speed and go down the list until we are below our max QValueListIterator<int> it = speeds.end(); --it; while( *it > maxSpeed && it != speeds.begin() ) --it; // this is the first valid speed or the lowest supported one s = *it; kdDebug() << "(K3bAudioMaxSpeedJob) using speed factor: " << (s/175) << endl; } return s; }
QDBusDataList::QDBusDataList(const QValueList< QDBusData > &other) : d(new Private()) { if(other.isEmpty()) return; QValueList< QDBusData >::const_iterator it = other.begin(); QValueList< QDBusData >::const_iterator endIt = other.end(); d->type = (*it).type(); QCString elementSignature; if(hasContainerItemType()) { d->containerItem = other[0]; // would be nice to get an empty one elementSignature = d->containerItem.buildDBusSignature(); } for(++it; it != endIt; ++it) { if(d->type != (*it).type()) { d->type = QDBusData::Invalid; d->containerItem = QDBusData(); return; } else if(hasContainerItemType()) { if((*it).buildDBusSignature() != elementSignature) { d->type = QDBusData::Invalid; d->containerItem = QDBusData(); return; } } } d->list = other; }
void Navigator::slotJumpToPreviousFunction() { kdDebug ( 9003 ) << k_funcinfo << endl; if ( !m_part->m_activeViewCursor ) return; unsigned int currentLine, currentCol; m_part->m_activeViewCursor->cursorPositionReal ( ¤tLine, ¤tCol ); QValueList<int> lines = QValueList_reversed<int> ( functionStartLines() ); if ( lines.isEmpty() ) return; QValueList<int>::iterator it = lines.begin(); while ( it != lines.end() ) { if ( *it < currentLine ) { KURL url; url.setPath ( m_part->m_activeFileName ); m_part->partController()->editDocument ( url, *it ); break; } ++it; } }
//BEGIN internal SLOTS void ThumbnailList::slotRequestVisiblePixmaps( int /*newContentsX*/, int newContentsY ) { // if an update is already scheduled or the widget is hidden, don't proceed if ( (m_delayTimer && m_delayTimer->isActive()) || !isShown() ) return; int vHeight = visibleHeight(), vOffset = newContentsY == -1 ? contentsY() : newContentsY; // scroll from the top to the last visible thumbnail m_visibleThumbnails.clear(); QValueList< PixmapRequest * > requestedPixmaps; QValueVector<ThumbnailWidget *>::iterator tIt = m_thumbnails.begin(), tEnd = m_thumbnails.end(); for ( ; tIt != tEnd; ++tIt ) { ThumbnailWidget * t = *tIt; int top = childY( t ) - vOffset; if ( top > vHeight ) break; if ( top + t->height() < 0 ) continue; // add ThumbnailWidget to visible list m_visibleThumbnails.push_back( t ); // if pixmap not present add it to requests if ( !t->page()->hasPixmap( THUMBNAILS_ID, t->pixmapWidth(), t->pixmapHeight() ) ) { PixmapRequest * p = new PixmapRequest( THUMBNAILS_ID, t->pageNumber(), t->pixmapWidth(), t->pixmapHeight(), THUMBNAILS_PRIO, true ); requestedPixmaps.push_back( p ); } } // actually request pixmaps if ( !requestedPixmaps.isEmpty() ) m_document->requestPixmaps( requestedPixmaps ); }
bool TableEditor::setTableArea( int bLine, int bCol, int eLine, int eCol, Parser *docParser ) { const uint pInitialTableSize = 20; m_bLine = bLine; m_bCol = bCol; m_eLine = eLine; m_eCol = eCol; m_createNodes = false; //don't create the cell and row content when adding a new cell/row Node *node = docParser->nodeAt(bLine, bCol + 1); Node *lastNode = docParser->nodeAt(eLine, eCol); if (node) kdDebug(24000) << "node = " << node->tag->name << endl; if (lastNode) kdDebug(24000) << "lastnode = " << lastNode->tag->name << endl; if (!node || !lastNode) return false; m_write = node->tag->write(); m_dtd = node->tag->dtd(); if ( !QuantaCommon::closesTag(node->tag, lastNode->tag) ) { return false; } int nCol, nRow, maxCol; nCol = nRow = maxCol = 0; bool countRows = false; bool missingBody = false; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; QValueList<TableNode> tableRowTags; QValueVector< QValueVector<TableNode> > mergeMatrix; mergeMatrix.resize(pInitialTableSize); for (uint i = 0; i < pInitialTableSize; i++) mergeMatrix[i].resize(pInitialTableSize); TableNode tableNode; Node *n = node; while (n != lastNode->nextSibling()) { QString tagName = n->tag->name.lower(); if (tagName == "table") { if (m_table && m_dataTable && nRow > 0 && nCol > 0) //nested table! { int line, col; n->tag->beginPos(line, col); NestedTable table; table.row = nRow -1; table.col = nCol - 1; table.bLine = line; table.bCol = col; if (n->next && QuantaCommon::closesTag(n->tag, n->next->tag)) { n->next->tag->endPos(table.eLine, table.eCol); table.node = n; table.nestedData = m_write->text(table.bLine, table.bCol, table.eLine, table.eCol); m_nestedTables.append(table); m_dataTable->item(nRow -1, nCol -1)->setPixmap(QIconSet(UserIcon("quick_table")).pixmap()); m_dataTable->updateCell(nRow - 1, nCol - 1); } n = n->next; } else { m_table = new Tag(*(n->tag)); newNum++; } } else if (tagName == "thead") { headerCheckBox->setChecked(true); countRows = true; m_rowSpin = headerRowSpinBox; m_colSpin = headerColSpinBox; m_dataTable= headerTableData; m_tableTags = m_tableHeaderTags; m_tableRows = m_tableHeaderRows; if (m_thead) { //there was already a <thead> tag in the area nRow = m_dataTable->numRows(); } else { m_thead = new Tag(*(n->tag)); newNum++; } } else if (tagName == "/thead") { headerRowSpinBox->setValue(nRow); headerColSpinBox->setValue(maxCol); countRows = false; nCol = nRow = maxCol = 0; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; } else if (tagName == "tfoot") { footerCheckBox->setChecked(true); m_rowSpin = footerRowSpinBox; m_colSpin = footerColSpinBox; m_tableTags = m_tableFooterTags; m_tableRows = m_tableFooterRows; m_dataTable = footerTableData; countRows = true; if (m_tfoot) { //there was already a <tfoot> tag in the area nRow = m_dataTable->numRows(); } else { m_tfoot = new Tag(*(n->tag)); newNum++; } } else if (tagName == "/tfoot") { footerRowSpinBox->setValue(nRow); footerColSpinBox->setValue(maxCol); countRows = false; nCol = nRow = maxCol = 0; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; } else if (tagName == "tbody") { m_rowSpin = rowSpinBox; m_colSpin = colSpinBox; m_tableTags = m_tableDataTags; m_tableRows = m_tableDataRows; m_dataTable = tableData; countRows = true; m_tbody = new Tag(*(n->tag)); newNum++; } else if (tagName == "/tbody") { rowSpinBox->setValue(nRow); colSpinBox->setValue(maxCol); countRows = false; nCol = nRow = maxCol = 0; m_tableTags = 0L; m_tableRows = 0L; m_rowSpin = 0L; m_colSpin = 0L; m_dataTable = 0L; } else if (tagName == "tr") { if (!countRows) { missingBody = true; m_rowSpin = rowSpinBox; m_colSpin = colSpinBox; m_tableTags = m_tableDataTags; m_tableRows = m_tableDataRows; m_dataTable = tableData; countRows = true; m_tbody = new Tag(); newNum++; m_tbody->parse("<tbody>", m_write); } nRow++; if ((uint)nRow >= mergeMatrix.size()) { // Check if there are enough rows in mergeMatriz mergeMatrix.resize(2 * mergeMatrix.size()); for (uint i = mergeMatrix.size() / 2; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(mergeMatrix[0].size()); } m_rowSpin->setValue(nRow); nCol = 0; tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); newNum++; tableNode.merged = false; m_tableRows->append(tableNode); } else if (tagName == "/tr") { if (countRows) { maxCol = (nCol > maxCol) ? nCol : maxCol; maxCol = (maxCol == 0) ? 1 : maxCol; for (int col = nCol; col < maxCol; col++) { if (mergeMatrix[nRow - 1][col].node != 0L) { if (m_colSpin->value() < col) m_colSpin->setValue(col); TableNode tableN = mergeMatrix[nRow - 1][col]; Node *n = tableN.node; setCellText(m_dataTable, nRow - 1, col, i18n("Merged with (%1, %2).").arg(tableN.mergedRow + 1).arg(tableN.mergedCol + 1)); m_dataTable->item(nRow-1, col)->setEnabled(false); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = true; tableNode.mergedRow = tableN.mergedRow; tableNode.mergedCol = tableN.mergedCol; tableRowTags.append(tableNode); if ((uint)nCol >= mergeMatrix[0].size()) // Check if there are enough cols for (uint i=0; i<mergeMatrix.size(); i++) mergeMatrix[i].resize(2 * mergeMatrix[i].size()); } else { tableNode.node = new Node(0L); newNum++; tableNode.node->tag = new Tag(); tableNode.node->tag->setDtd(m_dtd); tableNode.node->tag->parse("<td>", m_write); tableNode.merged = false; tableRowTags.append(tableNode); } } if (!tableRowTags.isEmpty()) m_tableTags->append(tableRowTags); tableRowTags.clear(); } } else if (tagName == "th" || tagName == "td") { if (countRows) { int col = nCol; while (mergeMatrix[nRow - 1][col].node != 0L) { if (m_colSpin->value() < col) m_colSpin->setValue(col); TableNode tableN = mergeMatrix[nRow - 1][col]; Node *n = tableN.node; setCellText(m_dataTable, nRow - 1, col, i18n("Merged with (%1, %2).").arg(tableN.mergedRow + 1).arg(tableN.mergedCol + 1)); m_dataTable->item(nRow-1, col)->setEnabled(false); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = true; tableNode.mergedRow = tableN.mergedRow; tableNode.mergedCol = tableN.mergedCol; tableRowTags.append(tableNode); col++; nCol++; if ((uint)nCol >= mergeMatrix[0].size()) // Check if there are enough cols for (uint i = 0; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(2 * mergeMatrix[i].size()); } nCol++; if (m_rowSpin && m_colSpin && m_dataTable) { m_rowSpin->setValue(nRow); if (m_colSpin->value() < nCol) m_colSpin->setValue(nCol); setCellText(m_dataTable, nRow - 1, nCol - 1, tagContent(n)); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = false; tableRowTags.append(tableNode); } QString colspanValue = n->tag->attributeValue("colspan", true); int colValue = 1; int lastCol = nCol; if (!colspanValue.isEmpty()) { bool ok; colValue = colspanValue.toInt(&ok, 10); if (ok && colValue > 1) { nCol += (colValue - 1); if (m_colSpin->value() < nCol) m_colSpin->setValue(nCol); for (int i = 0; i < colValue - 1; i++) { setCellText(m_dataTable, nRow - 1, lastCol + i, i18n("Merged with (%1, %2).").arg(nRow).arg(lastCol)); m_dataTable->item(nRow-1, lastCol + i)->setEnabled(false); tableNode.node = new Node(0L); tableNode.node->tag = new Tag(*(n->tag)); configureCell(nRow-1, col, tableNode.node); newNum++; tableNode.merged = true; tableNode.mergedRow = nRow - 1; tableNode.mergedCol = lastCol - 1; tableRowTags.append(tableNode); } } else colValue = 1; } QString rowspanValue = n->tag->attributeValue("rowspan", true); if (!rowspanValue.isEmpty()) { bool ok; int rowValue = rowspanValue.toInt(&ok, 10); if (ok && rowValue > 1) { lastCol--; // Check if there are enough columns in mergeMatriz if ((uint)(lastCol + colValue) >= mergeMatrix[0].size()) for (uint i = 0; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(2 * mergeMatrix[i].size()); // Check if there are enough rows in mergeMatriz if ((uint)(nRow + rowValue) >= mergeMatrix.size()) { mergeMatrix.resize(2 * mergeMatrix.size()); for (uint i = mergeMatrix.size() / 2; i < mergeMatrix.size(); i++) mergeMatrix[i].resize(mergeMatrix[0].size()); } for (int i = 0; i < rowValue - 1; i++) for (int j = 0; j < colValue; j++) { mergeMatrix[nRow + i][lastCol + j].mergedRow = nRow - 1; mergeMatrix[nRow + i][lastCol + j].mergedCol = lastCol; mergeMatrix[nRow + i][lastCol + j].node = n; } } } } } else if (tagName == "caption") { captionText->setText(tagContent(n)); } else if (tagName == "col" || tagName == "colgroup") { m_colTags.append(n->tag); } n = n->nextSibling(); } /* if (missingBody) { //Hm, why do we need it? I don't remember now. ;-) rowSpinBox->setValue(nRow); colSpinBox->setValue(maxCol); } */ //by default the current page is the data handling page m_tableTags = m_tableDataTags; m_tableRows = m_tableDataRows; m_dataTable = tableData; m_rowSpin = rowSpinBox; m_colSpin = colSpinBox; //create the thead, tbody, tfoot tags if they were not present in the parsed area if (!m_thead) { m_thead = new Tag(); newNum++; m_thead->parse("<thead>", m_write); } if (!m_tfoot) { m_tfoot = new Tag(); newNum++; m_tfoot->parse("<tfoot>", m_write); } m_createNodes = true; //enable cell/row creation configureTable(tableData); configureTable(headerTableData); configureTable(footerTableData); return true; }
cTexture *cAsciiFonts::buildText(unsigned char font, const QCString &text, unsigned short hueid, bool shaded, enTextAlign align, bool hueAll) { if (font > 9) { font = 3; // Default back to font 3 if the font is invalid } unsigned int width = 0; // Total width of the text unsigned int height = this->height[font]; // Total height of the text unsigned int lineWidth = 0; // Length of the current line unsigned int lines = 1; // Number of lines QValueList<unsigned int> lineWidths; // Vector with the lengths of lines // Iterate over the string once to get the width of the string QCString::ConstIterator it; for (it = text.begin(); it != text.end(); ++it) { if (*it == '\n') { lines += 1; if (lineWidth > width) { width = lineWidth; } lineWidths.append(lineWidth); lineWidth = 0; } else { cSurface *ch = getCharacter(font, *it); if (ch) { lineWidth += ch->width(); // Increase the width of the text } } } if (lineWidth > 0) { lineWidths.append(lineWidth); if (lineWidth > width) { width = lineWidth; } } unsigned int baseline = height; // Store the baseline height = lines * height; // Increase the height of the text cSurface *surface = 0; // The resulting text line if (width > 0) { surface = new cSurface(width, height); surface->clear(); // Clear the background of the surface // Start copying the characters over int destx = 0; int desty = 0; switch (align) { case ALIGN_LEFT: destx = 0; // Start on the left border break; case ALIGN_CENTER: destx = (width - lineWidths.front()) >> 1; // Take whats left of the total width and divide it into two break; case ALIGN_RIGHT: destx = (width - lineWidths.front()); // Take the right part and use it as an offset break; } lineWidths.pop_front(); for (it = text.begin(); it != text.end(); ++it) { if (*it == '\n') { if (!lineWidths.isEmpty()) { switch (align) { case ALIGN_LEFT: destx = 0; // Start on the left border break; case ALIGN_CENTER: destx = (width - lineWidths.front()) >> 1; // Take whats left of the total width and divide it into two break; case ALIGN_RIGHT: destx = (width - lineWidths.front()); // Take the right part and use it as an offset break; } lineWidths.pop_front(); } baseline += this->height[font]; } else { cSurface *ch = getCharacter(font, *it); if (ch) { desty = baseline - ch->height(); // MemCpy Line by Line for (int yl = 0; yl < ch->height(); ++yl) { unsigned char *src = ch->scanline(yl); unsigned char *dest = surface->scanline(yl + desty) + destx * 4; memcpy(dest, src, ch->width() * 4); } destx += ch->width(); // Increase for the next draw } } }
KAboutApplication::KAboutApplication( const KAboutData *aboutData, QWidget *parent, const char *name, bool modal) : AboutDlgBase(parent, name, modal) { SET_WNDPROC("about") setButtonsPict(this); setCaption(caption()); connect(btnOK, SIGNAL(clicked()), this, SLOT(close())); setIcon(Pict("licq")); const QIconSet *icon = Icon("licq"); if (icon) lblIcon->setPixmap(icon->pixmap(QIconSet::Large, QIconSet::Normal)); lblVersion->setText(i18n("%1 Version: %2") .arg(aboutData->appName()) .arg(aboutData->version())); txtAbout->setText((QString("<center><br>%1<br><br>%2<br><br>") + "<a href=\"%3\">%4</a><br><br>" + i18n("Bug report") + ": <a href=\"mailto:%5\">%6</a><br>" + i18n("Note: This is english mailing list") + "</center>") .arg(quote(aboutData->shortDescription())) .arg(quote(aboutData->copyrightStatement())) .arg(quote(aboutData->homepage())) .arg(quote(aboutData->homepage())) .arg(quote(aboutData->bugAddress())) .arg(quote(aboutData->bugAddress()))); QString txt; QValueList<KAboutPerson>::ConstIterator it; for (it = aboutData->authors().begin(); it != aboutData->authors().end(); ++it) { txt += addPerson(&(*it)); txt += "<br>"; } txtAuthors->setText(txt); txt = ""; QValueList<KAboutTranslator> translators = aboutData->translators(); QValueList<KAboutTranslator>::ConstIterator itt; if (!translators.isEmpty()){ for (itt = translators.begin(); itt != translators.end(); ++itt) { const KAboutTranslator &t = *itt; txt += QString("%1 <<a href=\"mailto:%2\">%3</a>><br>") .arg(quote(t.name())) .arg(quote(t.emailAddress())) .arg(quote(t.emailAddress())); txt += "<br>"; } txtTranslations->setText(txt); }else{ tabMain->removePage(tabTranslation); } QString license = aboutData->license(); license += "\n\n"; QFile f(QFile::decodeName(app_file("COPYING").c_str())); if (f.open(IO_ReadOnly)){ for (;;){ QString s; if (f.readLine(s, 512) == -1) break; license += s; } } txtLicence->setText(quote(license)); }