const QValueList<KAboutTranslator> KAboutData::translators() const { QValueList<KAboutTranslator> personList; if (d->translatorName == 0) return personList; QStringList nameList; QStringList emailList; QString names = i18n(d->translatorName); if (names != QString::fromUtf8(d->translatorName)) { nameList = QStringList::split(',',names); } if (d->translatorEmail) { QString emails = i18n(d->translatorEmail); if (emails != QString::fromUtf8(d->translatorEmail)) { emailList = QStringList::split(',',emails,true); } } QStringList::Iterator nit; QStringList::Iterator eit=emailList.begin(); for (nit = nameList.begin(); nit != nameList.end(); ++nit) { QString email; if (eit != emailList.end()) { email=*eit; ++eit; } QString name=*nit; personList.append(KAboutTranslator(name.stripWhiteSpace(), email.stripWhiteSpace())); } return personList; }
void TableEditor::slotInsertRow() { int num = m_dataTable->numRows(); if (m_row >= 0) num = m_row; m_dataTable->insertRows(num); m_dataTable->setRowHeight(num, 50); if (m_createNodes) { TableNode tableNode; tableNode.merged = false; tableNode.node = new Node(0L); newNum++; tableNode.node->tag = new Tag(); tableNode.node->tag->setDtd(m_dtd); tableNode.node->tag->parse("<tr>", m_write); QValueList<TableNode>::Iterator rowIt = m_tableRows->at(num); if (rowIt != m_tableRows->end()) m_tableRows->insert(rowIt, tableNode); else m_tableRows->append(tableNode); QValueList<TableNode> tableRowTags; for (int i = 0; i < m_dataTable->numCols(); i++) { tableNode.merged = false; tableNode.node = new Node(0L); newNum++; tableNode.node->tag = new Tag(); tableNode.node->tag->setDtd(m_dtd); if (m_tableTags == m_tableHeaderTags) { tableNode.node->tag->parse("<th>", m_write); } else { tableNode.node->tag->parse("<td>", m_write); } tableRowTags.append(tableNode); setCellText(m_dataTable, num, i, ""); } QValueList<QValueList<TableNode> >::Iterator it = m_tableTags->at(num); if (it != m_tableTags->end()) m_tableTags->insert(it, tableRowTags); else m_tableTags->append(tableRowTags); } m_rowSpin->setValue(m_dataTable->numRows()); }
QValueList<DebuggerBreakpoint*> BreakpointListView::breakpointsFrom(const KURL& url) { QValueList<DebuggerBreakpoint*> list; BreakpointListViewItem* item = dynamic_cast<BreakpointListViewItem*>(firstChild()); while(item) { if(item->breakpoint()->url() == url) { list.append(item->breakpoint()); } item = dynamic_cast<BreakpointListViewItem*>(item-> nextSibling()); } return list; }
QValueList<int> KlustersXmlReader::getNbChannelsByGroup(int electrodeGroupID)const{ QValueList<int> channels; xmlXPathObjectPtr result; xmlChar* searchPath = xmlCharStrdup("//" + SPIKE + "/" + CHANNEL_GROUPS + "/" + GROUP); //Evaluate xpath expression result = xmlXPathEvalExpression(searchPath,xpathContex); if(result != NULL){ xmlNodeSetPtr nodeset = result->nodesetval; if(!xmlXPathNodeSetIsEmpty(nodeset)){ //loop on all the GROUP until reaching the electrodeGroupID one. int nbGroups = nodeset->nodeNr; for(int i = 0; i < nbGroups; ++i){ if((i + 1) != electrodeGroupID) continue; xmlNodePtr child; for(child = nodeset->nodeTab[i]->children;child != NULL;child = child->next){ //skip the carriage return (text node named text and containing /n) if(child->type == XML_TEXT_NODE) continue; if(QString((char*)child->name) == CHANNELS){ //Should be only one CHANNELS element xmlNodePtr channel; for(channel = child->children;channel != NULL;channel = channel->next){ //skip the carriage return (text node named text and containing /n) if(channel->type == XML_TEXT_NODE) continue; if(QString((char*)channel->name) == CHANNEL){ xmlChar* sId = xmlNodeListGetString(doc,channel->children, 1); int channelId = QString((char*)sId).toInt(); xmlFree(sId); channels.append(channelId); } } } } if((i + 1) == electrodeGroupID) break; } } } xmlFree(searchPath); xmlXPathFreeObject(result); return channels; }
void PanelRemoveAppletMenu::slotAboutToShow() { int id = 0; clear(); m_containers = m_containerArea->containers("Applet") + m_containerArea->containers("Special Button"); QValueList<PanelMenuItemInfo> items; for (BaseContainer::List::const_iterator it = m_containers.constBegin(); it != m_containers.constEnd();) { BaseContainer* container = *it; if (container->isImmutable()) { ++it; m_containers.remove(container); continue; } items.append(PanelMenuItemInfo(container->icon(), container->visibleName().replace("&", "&&"), id)); ++id; ++it; } qHeapSort(items); for (QValueList<PanelMenuItemInfo>::iterator it = items.begin(); it != items.end(); ++it) { (*it).plug(this); } if (m_containers.count() > 1) { insertSeparator(); insertItem(i18n("All"), this, SLOT(slotRemoveAll()), 0, id); } }
void FavoriteFolderView::initializeFavorites() { QValueList<int> seenInboxes = GlobalSettings::self()->favoriteFolderViewSeenInboxes(); KMFolderTree *ft = mainWidget()->folderTree(); assert(ft); for(QListViewItemIterator it(ft); it.current(); ++it) { KMFolderTreeItem *fti = static_cast<KMFolderTreeItem *>(it.current()); if(fti->type() == KFolderTreeItem::Inbox && fti->folder() && !seenInboxes.contains(fti->folder()->id())) { seenInboxes.append(fti->folder()->id()); if(fti->folder() == kmkernel->inboxFolder() && hideLocalInbox()) continue; if(kmkernel->iCalIface().hideResourceFolder(fti->folder())) continue; addFolder(fti->folder(), prettyName(fti)); } } GlobalSettings::self()->setFavoriteFolderViewSeenInboxes(seenInboxes); }
QValueList<int> ClusterPalette::selectedClusters() { //Get the list of clusters with their color ItemColors& clusterColors = doc->clusterColors(); QValueList<int> selectedClusters; ClusterPaletteIconViewItem* clusterPaletteItem; for(QIconViewItem* item = iconView->firstItem(); item; item = item->nextItem()) { clusterPaletteItem = static_cast<ClusterPaletteIconViewItem*>(item); if(item->isSelected()) { selectedClusters.append(clusterColors.itemId(item->index())); } } //Selection has just changed isUpToDate = false; return selectedClusters; }
void KUserGroup::fillGroup(struct group *p) { if (!p) { d = new KUserGroupPrivate(); return; } QString name = KStringHandler::from8Bit(p->gr_name); QValueList<KUser> users; char **user = p->gr_mem; for ( ; *user; user++) { KUser kUser(QString::fromLocal8Bit(*user)); users.append(kUser); } d = new KUserGroupPrivate(p->gr_gid, QString::fromLocal8Bit(p->gr_name), users); }
QValueList<QDate> MyMoneyForecast::accountMinimumBalanceDateList(const MyMoneyAccount& acc) { QValueList<QDate> minBalanceList; int daysToBeginDay; daysToBeginDay = QDate::currentDate().daysTo(beginForecastDate()); for(int t_cycle = 0; ((t_cycle * accountsCycle()) + daysToBeginDay) < forecastDays() ; ++t_cycle) { MyMoneyMoney minBalance = forecastBalance(acc, (t_cycle * accountsCycle() + daysToBeginDay)); QDate minDate = QDate::currentDate().addDays(t_cycle * accountsCycle() + daysToBeginDay); for(int t_day = 1; t_day <= accountsCycle() ; ++t_day) { if( minBalance > forecastBalance(acc, (t_cycle * accountsCycle()) + daysToBeginDay + t_day) ) { minBalance = forecastBalance(acc, (t_cycle * accountsCycle()) + daysToBeginDay + t_day ); minDate = QDate::currentDate().addDays( (t_cycle * accountsCycle()) + daysToBeginDay + t_day); } } minBalanceList.append(minDate); } return minBalanceList; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // DccCanvasWidget // DccCanvasWidget::DccCanvasWidget(QWidget * par) : QWidget(par,"canvas_widget") { m_pCanvas = new QCanvas(this); //#warning "Make this size as parameter of Dcc ?" m_pCanvas->resize(648,480); m_pMenuBar = new QMenuBar(this); m_pSplitter = new QSplitter(QSplitter::Horizontal,this); m_pCanvasView = new KviCanvasView(m_pCanvas,this,m_pSplitter); m_pStatusLabel = new QLabel(this); m_pPropertiesWidget = new KviCanvasItemPropertiesWidget(m_pSplitter); QValueList<int> l; l.append(80); l.append(20); m_pSplitter->setSizes(l); connect(m_pPropertiesWidget,SIGNAL(propertyChanged(const QString &,const QVariant &)),m_pCanvasView,SLOT(propertyChanged(const QString &,const QVariant &))); QMenu * add = new QMenu(m_pMenuBar); QMenu * shapes = new QMenu(add); QMenu * polygons = new QMenu(add); QMenu * items = new QMenu(add); shapes->addAction(__tr2qs_ctx("&Line","dcc"),m_pCanvasView,SLOT(insertLine())); shapes->addAction(__tr2qs_ctx("&Rectangle","dcc"),m_pCanvasView,SLOT(insertRectangle())); shapes->addAction(__tr2qs_ctx("&Ellipse","dcc"),m_pCanvasView,SLOT(insertEllipse())); shapes->addAction(__tr2qs_ctx("&Pie","dcc"),m_pCanvasView,SLOT(insertPie())); shapes->addAction(__tr2qs_ctx("&Chord","dcc"),m_pCanvasView,SLOT(insertChord())); items->addAction(__tr2qs_ctx("&Rich text (html)","dcc"),m_pCanvasView,SLOT(insertRichText())); polygons->addAction(__tr2qs_ctx("&Triangle","dcc"),m_pCanvasView,SLOT(insertPolygonTriangle())); polygons->addAction(__tr2qs_ctx("&Rectangle","dcc"),m_pCanvasView,SLOT(insertPolygonRectangle())); polygons->addAction(__tr2qs_ctx("&Pentagon","dcc"),m_pCanvasView,SLOT(insertPolygonPentagon())); polygons->addAction(__tr2qs_ctx("&Hexagon","dcc"),m_pCanvasView,SLOT(insertPolygonHexagon())); add->addAction(__tr2qs_ctx("&Shape","dcc"),shapes); add->addAction(__tr2qs_ctx("&Item","dcc"),items); add->addAction(__tr2qs_ctx("&Polygons","dcc"),polygons); m_pMenuBar->addAction(__tr2qs_ctx("&Insert","dcc"),add); }
QValueList<KTextEditor::CompletionEntry> BashCodeCompletion::getVars(const QString &startText) { kdDebug() << "getVars for " << startText << endl; QValueList<KTextEditor::CompletionEntry> varList; QValueList<QString>::ConstIterator it; for (it = m_vars.begin(); it != m_vars.end(); ++it) { QString var = "$" + (*it); kdDebug() << "Compair " << var << endl; if( var.startsWith( startText )) { KTextEditor::CompletionEntry e; e.text = var; //e.postfix =""; //e.prefix =""; kdDebug() << "getVar: " << var << endl; varList.append(e); } } return varList; }
QValueList<PMPolynomExponents> PMPolynomExponents::recPolynom( const PMPolynomExponents& base, int xyz, int n, int rem ) { QValueList<PMPolynomExponents> res; if( n >= 0 ) { if( ( ( rem + n ) == 0 ) || ( xyz > 2 ) ) res.append( base ); else { PMPolynomExponents newBase = base; newBase.setExponent( xyz, n ); res += recPolynom( newBase, xyz + 1, rem, 0 ); res += recPolynom( base, xyz, n - 1, rem + 1 ); } } return res; }
/*! Constructs a DocLnkSet that contains DocLnk objects representing all the files in the \a directory (and any subdirectories, recursively). If \a mimefilter is not null, only documents with a MIME type matching \a mimefilter are selected. The value may contain multiple wild-card patterns separated by ";", such as \c{*o/mpeg;audio/x-wav}. See also \link applnk.html#files-and-links Files and Links\endlink. */ DocLnkSet::DocLnkSet( const QString &directory, const QString& mimefilter ) : AppLnkSet() { QDir dir( directory ); mFile = dir.dirName(); QDict<void> reference(1021); QStringList subFilter = QStringList::split(";", mimefilter); QValueList<QRegExp> mimeFilters; for( QStringList::Iterator it = subFilter.begin(); it != subFilter.end(); ++ it ) mimeFilters.append( QRegExp(*it, FALSE, TRUE) ); findChildren(directory, mimeFilters, reference); const QList<DocLnk> &list = children(); for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { reference.remove( (*it)->file() ); } for ( QDictIterator<void> dit(reference); dit.current(); ++dit ) { if ( dit.current() == (void*)2 ) { // Unreferenced, make an unwritten link DocLnk* dl = new DocLnk; QFileInfo fi( dit.currentKey() ); dl->setFile(fi.filePath()); dl->setName(fi.baseName()); // #### default to current path? // dl->setCategories( ... ); bool match = mimefilter.isNull(); if ( !match ) for( QValueList<QRegExp>::Iterator it = mimeFilters.begin(); it != mimeFilters.end() && !match; ++ it ) if ( (*it).match(dl->type()) >= 0 ) match = TRUE; if ( match /* && dl->type() != "application/octet-stream" */ && !!dl->exec() ) add(dl); else delete dl; } } }
void ButtonBar::shrink(int preferredDimension, int actualDimension) { if (!preferredDimension) return; m_shrinked = true; uint textLength = 0; QValueList<uint> texts; uint maxLength = 0; for (ButtonList::const_iterator it = m_buttons.constBegin(); it != m_buttons.constEnd(); ++it) { uint length = (*it)->text().length(); maxLength = length > maxLength ? length : maxLength ; texts.append(length); textLength += length; } uint newPreferredLength = actualDimension * textLength / preferredDimension; uint newMaxLength = maxLength; uint newTextLength; do { newMaxLength -= 1; newTextLength = 0; for (QValueList<uint>::iterator it = texts.begin(); it != texts.end(); ++it) { if (*it > newMaxLength) *it = newMaxLength; newTextLength += *it; } } while (newTextLength > newPreferredLength); int i = 0; for (ButtonList::iterator it = m_buttons.begin(); it != m_buttons.end(); ++it) { (*it)->setText(KStringHandler::rsqueeze((*it)->realText(), texts[i++])); (*it)->updateSize(); } }
/*! Copy MySQL table to KexiDB database */ bool MySQLMigrate::drv_copyTable(const QString& srcTable, KexiDB::Connection *destConn, KexiDB::TableSchema* dstTable) { if(d->executeSQL("SELECT * FROM `" + drv_escapeIdentifier(srcTable)) + "`") { MYSQL_RES *res = mysql_use_result(d->mysql); if (res != NULL) { MYSQL_ROW row; const KexiDB::QueryColumnInfo::Vector fieldsExpanded( dstTable->query()->fieldsExpanded() ); while ((row = mysql_fetch_row(res)) != NULL) { const int numFields = QMIN((int)fieldsExpanded.count(), (int)mysql_num_fields(res)); QValueList<QVariant> vals; unsigned long *lengths = mysql_fetch_lengths(res); if (!lengths) { mysql_free_result(res); return false; } for(int i = 0; i < numFields; i++) vals.append( KexiDB::cstringToVariant(row[i], fieldsExpanded.at(i)->field, (int)lengths[i]) ); if (!destConn->insertRecord(*dstTable, vals)) { mysql_free_result(res); return false; } updateProgress(); } if (!row && mysql_errno(d->mysql)) { mysql_free_result(res); return false; } /*! @todo Check that wasn't an error, rather than end of result set */ mysql_free_result(res); } else { kdDebug() << "MySQLMigrate::drv_copyTable: null result" << endl; } return true; } else { return false; } }
QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() { QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); /* this is needed! */ if (m_storage) mailstorage_disconnect(m_storage); init_storage(); if (!m_storage) { return folders; } mail_list*flist = 0; clistcell*current=0; int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); if (r != MAIL_NO_ERROR || !flist) { odebug << "error getting folder list" << oendl; return folders; } for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { QString t = (char*)current->data; t.replace(0,MHPath.length(),""); folders->append(new MHFolder(t,MHPath)); } mail_list_free(flist); return folders; }
void PMPrismMemento::setPrismPoints( const QValueList< QValueList<PMVector> >& v ) { if( !m_bPrismPointsSaved ) { // Direct assignment does not work with Qt 2.3.x // The list will be changed later in a graphical // change because QValueList::detach( ) is called // too late! // Copy the list by hand. QValueList< QValueList< PMVector > >::ConstIterator sit = v.begin( ); for( ; sit != v.end( ); ++sit ) { QValueList<PMVector> list; QValueList<PMVector>::ConstIterator it = ( *sit ).begin( ); for( ; it != ( *sit ).end( ); ++it ) list.append( *it ); m_prismPoints.append( list ); } m_bPrismPointsSaved = true; addChange( PMCData ); } }
QValueList<KURL> MessagesSource::filesInDir(KURL url,bool recursive) { QValueList<KURL> result; QDir d(url.path()); d.setMatchAllDirs(true); kdDebug(0) << d.count() << " files in dir "<< url.path()<<endl; const QFileInfoList* files = d.entryInfoList(); kdDebug(0) << files << endl; // QPtrListIterator<QFileInfo> it(*files); if(files){ for (QPtrListIterator<QFileInfo> fileit(*files); !fileit.atLast(); ++fileit ) { if ((*fileit)->isDir()) { if(recursive) { if((*fileit)->fileName()!="." && (*fileit)->fileName() !="..") { result+=filesInDir(KURL((*fileit)->absFilePath()),recursive); kdDebug(0) << "Recursion done for " << (*fileit)->fileName() << endl; } } } else { kdDebug(0) << (*fileit)->fileName() << endl; result.append(KURL((*fileit)->absFilePath())); } } } kdDebug(0) << result.count() << endl; return result; }
/** * Return a list of PackageVersion objects sorted by their version numbers, * with the oldest version at the beginning and the latest version at the end * of the list. */ QValueList<PackageVersion*> Package::sortedVersionList() { QValueList<PackageVersion*> sortedVersions; QValueList<PackageVersion*>::iterator sortedVersionIterator; PackageVersionMap::iterator versionIterator; for( versionIterator = m_versions.begin(); versionIterator != m_versions.end(); versionIterator++ ) { if( versionIterator == m_versions.begin() ) { sortedVersions.append( *versionIterator ); continue; // if there is only one version, it can't be compared } // reverse iteration through the sorted version list sortedVersionIterator = sortedVersions.end(); while( true ) { if( sortedVersionIterator == sortedVersions.begin() ) { sortedVersions.prepend( *versionIterator ); break; } sortedVersionIterator--; if( (*versionIterator)->isNewerThan( (*sortedVersionIterator)->version() ) ) { sortedVersionIterator++; // insert after the compared one, not before sortedVersions.insert( sortedVersionIterator, *versionIterator ); break; } } } return sortedVersions; } // end of sortedVersionList()
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; }
CorrelationView::CorrelationView(KlustersDoc& doc,KlustersView& view,QColor backgroundColor,KStatusBar * statusBar,QWidget* parent,Data::ScaleMode scale,int binSize, int correlationTimeFrame,bool shoulderLine, const char* name, int minSize, int maxSize, int windowTopLeft ,int windowBottomRight, int border) : ViewWidget(doc,view,backgroundColor,statusBar,parent,name,minSize,maxSize,windowTopLeft,windowBottomRight,border,XMARGIN,YMARGIN), scaleMode(scale),dataReady(true),binSize(binSize),timeWindow(correlationTimeFrame),shoulderLine(shoulderLine), isZoomed(false),goingToDie(false),printState(false){ //The list owns its objects, it will delete the items that are removed. threadsToBeKill.setAutoDelete(true); //The treads will be delete only from threadsToBeKill //Set the only mode available. mode = ZOOM; //Set the drawing variables nbBins = timeWindow / binSize; binWidth = 100; widthBorder = (nbBins * binWidth) / 30; heightBorder = 20; Xspace = (nbBins * binWidth) / 10; Yspace = 40; YsizeForMaxAmp = 200; if(scale == Data::RAW) Yfactor = 1; else Yfactor = YsizeForMaxAmp; shift = nbBins * binWidth + Xspace; //Compute variable to draw tick marks int n = 0; if((timeWindow - 1)/2 <= 30) n = 5; if((timeWindow - 1)/2 > 30 && (timeWindow - 1)/2 <= 100) n = 10; if((timeWindow - 1)/2 >= 100) n = 20; int pixelPerTimeWindow = (timeWindow * binWidth) / binSize; tickMarkStep = static_cast<float>(pixelPerTimeWindow * n) / static_cast<float>(timeWindow); nbTickMarks = static_cast<int>(floor(0.5 + static_cast<float>((timeWindow/2) / static_cast<float>(n)))); tickMarkZero = ((nbBins - 1)/2)* binWidth + binWidth/2; abscissaMin = 0; ordinateMax = 0; //Create the pairs for the clusters to show. const QValueList<int>& shownClusters = view.clusters(); QValueList<int> clusters; QValueList<int>::const_iterator clustersIterator; for(clustersIterator = shownClusters.begin(); clustersIterator != shownClusters.end(); ++clustersIterator) clusters.append(*clustersIterator); qHeapSort(clusters); QValueList<int>::iterator iterator; int i = 0; for(iterator = clusters.begin(); iterator != clusters.end(); ++iterator){ QValueList<int>::iterator iterator2; for(iterator2 = clusters.at(i); iterator2 != clusters.end(); ++iterator2){ //Create pairs as (*iterator,*iterator2) where *iterator <= *iterator2 pairs.append(Pair(*iterator,*iterator2)); } ++i; } updateWindow(); //Set the cursor shap to a magnifier as the only action allowed on the widget is to zoom. setCursor(zoomCursor); //Allowed the mouse tracking to write the time in the status bar. setMouseTracking(true) ; }
void MidpMountedRoots::update(bool notify) { DEBUG_PRINT("update"); #ifdef UNIX QValueList<QString> disks; QValueList<QString> paths; bool rebuild = false; int count = 0; // Read system mounts struct mntent *me; FILE *mntfp = setmntent("/etc/mtab", "r"); if (mntfp) { while ((me = getmntent( mntfp )) != 0) { QString disk = me->mnt_fsname; if (isValidDisk(disk)) { count++; disks.append(disk); QString path = QString(me->mnt_dir) + '/'; paths.append(path); if (!isCachedDisk(disk)) { rebuild = true; } } } endmntent(mntfp); } // Add special roots for PIM, FC and Private const pcsl_string* storage = storage_get_root(INTERNAL_STORAGE_ID); if (pcsl_string_length(storage) >= 0) { const char* cstorage = (const char*)pcsl_string_get_utf8_data(storage); QString qstorage = cstorage; pcsl_string_release_utf8_data((const jbyte*)cstorage, storage); QString fc = qstorage + "storage/"; QFile ffc(fc); // determine whether the path exists // Note: the path is created by the build system. if (ffc.exists()) { count++; const QString name = "storage"; disks.append(name); paths.append(fc); if (!isCachedDisk(name)) { rebuild = true; } } QString pim = qstorage + "pimdb/"; QFile fpim(pim); // determine whether the path exists // Note: the path is created by the build system. if (fpim.exists()) { count++; const QString name = "pimdb"; disks.append(name); paths.append(pim); if (!isCachedDisk(name)) { rebuild = true; } } QString prv = qstorage + "private/"; QFile fprv(prv); // determine whether the path exists // Note: the path is created by the build system. if (fprv.exists()) { count++; const QString name = "private"; disks.append(name); paths.append(prv); if (!isCachedDisk(name)) { rebuild = true; } } } if (rebuild || count != (int)mRoots.count()) { mRoots.clear(); QStringList::ConstIterator it = disks.begin(); QStringList::ConstIterator pit = paths.begin(); for (; it != disks.end(); ++it, ++pit) { QString disk = *it; QString path = *pit; QString root, local; if (getDiskInfo(disk, root, local)) { MidpFileRoot* fs = new MidpFileRoot(disk, path, root, local); mRoots.append(fs); } } // Call the handler if required if (notify) { disksChanged(); } } #endif }
uint numCols) const #else QList<QRect> QwtDynGridLayout::layoutItems(const QRect &rect, uint numCols) const #endif { #if QT_VERSION < 0x040000 QValueList<QRect> itemGeometries; #else QList<QRect> itemGeometries; #endif if ( numCols == 0 || isEmpty() ) return itemGeometries; uint numRows = itemCount() / numCols; if ( numRows % itemCount() ) numRows++; QwtArray<int> rowHeight(numRows); QwtArray<int> colWidth(numCols); layoutGrid(numCols, rowHeight, colWidth); bool expandH, expandV; #if QT_VERSION >= 0x040000 expandH = expandingDirections() & Qt::Horizontal; expandV = expandingDirections() & Qt::Vertical; #else expandH = expanding() & QSizePolicy::Horizontally; expandV = expanding() & QSizePolicy::Vertically; #endif if ( expandH || expandV ) stretchGrid(rect, numCols, rowHeight, colWidth); QwtDynGridLayout *that = (QwtDynGridLayout *)this; const int maxCols = d_data->maxCols; that->d_data->maxCols = numCols; const QRect alignedRect = alignmentRect(rect); that->d_data->maxCols = maxCols; const int xOffset = expandH ? 0 : alignedRect.x(); const int yOffset = expandV ? 0 : alignedRect.y(); QwtArray<int> colX(numCols); QwtArray<int> rowY(numRows); const int xySpace = spacing(); rowY[0] = yOffset + margin(); for ( int r = 1; r < (int)numRows; r++ ) rowY[r] = rowY[r-1] + rowHeight[r-1] + xySpace; colX[0] = xOffset + margin(); for ( int c = 1; c < (int)numCols; c++ ) colX[c] = colX[c-1] + colWidth[c-1] + xySpace; const int itemCount = d_data->itemList.size(); for ( int i = 0; i < itemCount; i++ ) { const int row = i / numCols; const int col = i % numCols; QRect itemGeometry(colX[col], rowY[row], colWidth[col], rowHeight[row]); itemGeometries.append(itemGeometry); } return itemGeometries; }
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 } } }
QString KXMLGUIClient::findMostRecentXMLFile( const QStringList &files, QString &doc ) { QValueList<DocStruct> allDocuments; QStringList::ConstIterator it = files.begin(); QStringList::ConstIterator end = files.end(); for (; it != end; ++it ) { //kdDebug() << "KXMLGUIClient::findMostRecentXMLFile " << *it << endl; QString data = KXMLGUIFactory::readConfigFile( *it ); DocStruct d; d.file = *it; d.data = data; allDocuments.append( d ); } QValueList<DocStruct>::Iterator best = allDocuments.end(); uint bestVersion = 0; QValueList<DocStruct>::Iterator docIt = allDocuments.begin(); QValueList<DocStruct>::Iterator docEnd = allDocuments.end(); for (; docIt != docEnd; ++docIt ) { QString versionStr = findVersionNumber( (*docIt).data ); if ( versionStr.isEmpty() ) continue; bool ok = false; uint version = versionStr.toUInt( &ok ); if ( !ok ) continue; //kdDebug() << "FOUND VERSION " << version << endl; if ( version > bestVersion ) { best = docIt; //kdDebug() << "best version is now " << version << endl; bestVersion = version; } } if ( best != docEnd ) { if ( best != allDocuments.begin() ) { QValueList<DocStruct>::Iterator local = allDocuments.begin(); // load the local document and extract the action properties QDomDocument document; document.setContent( (*local).data ); ActionPropertiesMap properties = extractActionProperties( document ); // in case the document has a ActionProperties section // we must not delete it but copy over the global doc // to the local and insert the ActionProperties section if ( !properties.isEmpty() ) { // now load the global one with the higher version number // into memory document.setContent( (*best).data ); // and store the properties in there storeActionProperties( document, properties ); (*local).data = document.toString(); // make sure we pick up the new local doc, when we return later best = local; // write out the new version of the local document QFile f( (*local).file ); if ( f.open( IO_WriteOnly ) ) { QCString utf8data = (*local).data.utf8(); f.writeBlock( utf8data.data(), utf8data.length() ); f.close(); } } else { QString f = (*local).file; QString backup = f + QString::fromLatin1( ".backup" ); QDir dir; dir.rename( f, backup ); } } doc = (*best).data; return (*best).file; } else if ( files.count() > 0 ) { //kdDebug() << "returning first one..." << endl; doc = (*allDocuments.begin()).data; return (*allDocuments.begin()).file; } return QString::null; }
void CorrelationView::drawClusterIds(QPainter& painter){ QValueList<int> shownClusters; QValueList<int>::const_iterator iterator; QValueList<int> const clusters = view.clusters(); for(iterator = clusters.begin(); iterator != clusters.end(); ++iterator) shownClusters.append(*iterator); qHeapSort(shownClusters); QFont f("Helvetica",8); painter.setFont(f); painter.setPen(colorLegend); //set the color for the legends. //Draw the absciss ids //The abscissa of the legend for the current correlogram. uint X = widthBorder + 2; //The ordinate of the legend for the current correlogram. uint Y = 0; int width = nbBins * binWidth + XMARGIN; //Variable used to draw the firing rate uint firingX = 0; uint firingY = 0; int clusterIndex = 1; int nbClusters = shownClusters.size(); ItemColors& clusterColors = doc.clusterColors(); QRect r((QRect)window); bool isMargin = true; if(r.left() != 0) isMargin = false; for(iterator = shownClusters.begin(); iterator != shownClusters.end(); ++iterator){ //the abscissa is increase by the font size to adjust for conversion from world coordinates to viewport coordinates. QRect r; if(isMargin) r = QRect(worldToViewport(X,-Y).x() + 10,worldToViewport(X,-Y).y() - 2,worldToViewportWidth(width),10); else r = QRect(worldToViewport(X,-Y).x() + 10 - XMARGIN,worldToViewport(X,-Y).y() - 2,worldToViewportWidth(width),10); painter.drawText(r,Qt::AlignHCenter,QString("%1").arg(*iterator)); if(shoulderLine){ QString firingRate = ""; if(firingRates.contains(*iterator)) firingRate = firingRates[*iterator]; if(nbClusters == 1){ firingX = X; firingY = heightBorder + YsizeForMaxAmp; QRect rf; if(isMargin) rf = QRect(worldToViewport(firingX,-firingY).x() + 10,worldToViewport(firingX,-firingY).y() - 17,worldToViewportWidth(width + 20),15); else rf = QRect(worldToViewport(firingX,-firingY).x() + 10 - XMARGIN,worldToViewport(firingX,-firingY).y() - 17,worldToViewportWidth(width + 20),15); painter.setPen(clusterColors.color(*iterator)); painter.setBrush(NoBrush); painter.drawRect(rf); painter.setPen(colorLegend); painter.drawText(rf,Qt::AlignCenter,firingRate); } else if(clusterIndex == 1){ firingX = X + width + Xspace; firingY = heightBorder; QRect rf; if(isMargin) rf = QRect(worldToViewport(firingX,-firingY).x() + 10,worldToViewport(firingX,-firingY).y() - 13,worldToViewportWidth(width + 20),15); else rf = QRect(worldToViewport(firingX,-firingY).x() + 10 - XMARGIN,worldToViewport(firingX,-firingY).y() - 13,worldToViewportWidth(width + 20),15); painter.setPen(clusterColors.color(*iterator)); painter.setBrush(NoBrush); painter.drawRect(rf); painter.setPen(colorLegend); painter.drawText(rf,Qt::AlignCenter,firingRate); } else{ firingY = heightBorder + (clusterIndex - 1) * (YsizeForMaxAmp + Yspace) - (Yspace / 2); QRect rf; if(isMargin) rf = QRect(worldToViewport(firingX,-firingY).x() + 10,worldToViewport(firingX,-firingY).y(),worldToViewportWidth(width + 20),15); else rf = QRect(worldToViewport(firingX,-firingY).x() + 10 - XMARGIN,worldToViewport(firingX,-firingY).y(),worldToViewportWidth(width + 20),15); painter.setPen(clusterColors.color(*iterator)); painter.setBrush(NoBrush); painter.drawRect(rf); painter.setPen(colorLegend); painter.drawText(rf,Qt::AlignCenter,firingRate); firingX += shift; } clusterIndex++; } X += shift; } //Draw the ordinate ids X = 0; Y = heightBorder + YsizeForMaxAmp + Yspace - 2; uint yshift = YsizeForMaxAmp + Yspace; for(iterator = shownClusters.begin(); iterator != shownClusters.end(); ++iterator){ QRect r(worldToViewport(X,-Y).x(),worldToViewport(X,-Y).y(),10,worldToViewportHeight(YsizeForMaxAmp + Yspace)); painter.drawText(r,Qt::AlignCenter,QString("%1").arg(*iterator)); Y += yshift; } }
void DayView::relayoutPage( bool fromResize ) { if(m_disabled) return; m_box->setUpdatesEnabled( FALSE ); if ( !fromResize ) { getEvents(); // no need we already have them! if (m_allDays->items() > 0 ) m_allDays->show(); /* * else if ( m_allDays->items() == 0 ) already hide in getEvents */ } widgetList->sort(); //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view int wCount = widgetList->count(); int wid = m_view->columnWidth(0)-1; int wd; int n = 1; QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); if ( wCount < 20 ) { QArray<QRect> geometries(wCount); for (int i = 0; i < wCount; geometries[i] = widgetList->at(i)->geometry(), i++); //stores geometry for each widget in vector for ( int i = 0; i < wCount; i++) { QValueList<int> intersectedWidgets; //find all widgets intersecting with widgetList->at(i) for ( int j = 0; j < wCount; j++) { if (i != j) if (geometries[j].intersects(geometries[i])) intersectedWidgets.append(j); } //for each of these intersecting widgets find out how many widgets are they intersecting with for ( uint j = 0; j < intersectedWidgets.count(); j++) { QArray<int> inter(wCount); inter[j]=1; if (intersectedWidgets[j] != -1) for ( uint k = j; k < intersectedWidgets.count(); k++) { if (j != k && intersectedWidgets[k] != -1) if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { inter[j]++; intersectedWidgets[k] = -1; } if (inter[j] > anzIntersect[i]) anzIntersect[i] = inter[j] + 1; } } if (anzIntersect[i] == 1 && intersectedWidgets.count()) anzIntersect[i]++; } for ( int i = 0; i < wCount; i++) { DateBookDayWidget *w = widgetList->at(i); QRect geom = w->geometry(); geom.setX( 0 ); wd = (m_view->columnWidth(0)-1) / anzIntersect[i] - (anzIntersect[i]>1?2:0); geom.setWidth( wd ); while ( intersects( w, geom ) ) { geom.moveBy( wd + 2 + 1, 0 ); } w->setGeometry( geom ); } if (jumpToCurTime && this->date() == QDate::currentDate()) { m_view->setContentsPos( 0, QTime::currentTime().hour() * m_view->rowHeight(0) ); //set listview to current hour } else { m_view->setContentsPos( 0, startTime * m_view->rowHeight(0) ); } } else { int hours[24]; memset( hours, 0, 24*sizeof( int ) ); bool overFlow = FALSE; for ( int i = 0; i < wCount; i++ ) { DateBookDayWidget *w = widgetList->at(i); int start = w->event().startTime().hour(); QTime e = w->event().endTime(); int end = e.hour(); if ( e.minute() < 5 ) end--; if ( end < start ) end = start; while( start <= end ) { hours[start]++; if ( hours[start] >= 10 ) overFlow = TRUE; ++start; } if ( overFlow ) break; } for ( int i = 0; i < 24; i++ ) { n = QMAX( n, hours[i] ); } wid = ( m_view->columnWidth(0)-1 ) / n; bool used[24*10]; memset( used, FALSE, 24*10*sizeof( bool ) ); for ( int i = 0; i < wCount; i++ ) { DateBookDayWidget *w = widgetList->at(i); int xp = place( w, used, n ); if ( xp != -1 ) { QRect geom = w->geometry(); geom.setX( xp*(wid+2) ); geom.setWidth( wid ); w->setGeometry( geom ); } } if (jumpToCurTime && this->date() == QDate::currentDate()) { m_view->setContentsPos( 0, QTime::currentTime().hour() * m_view->rowHeight(0) ); //set listview to current hour } else { m_view->setContentsPos( 0, startTime * m_view->rowHeight(0) ); } } timeMarker->setTime( QTime::currentTime() ); //display timeMarker timeMarker->raise(); //on top of all widgets if (this->date() == QDate::currentDate()) { //only show timeMarker on current day timeMarker->show(); } else { timeMarker->hide(); } m_box->setUpdatesEnabled( TRUE ); }
void K3bMixedJob::start() { jobStarted(); m_canceled = false; m_errorOccuredAndAlreadyReported = false; d->copiesDone = 0; d->copies = m_doc->copies(); m_currentAction = PREPARING_DATA; d->maxSpeed = false; if( m_doc->dummy() ) d->copies = 1; prepareProgressInformation(); // // Check if all files exist // QValueList<K3bAudioFile*> nonExistingFiles; K3bAudioTrack* track = m_doc->audioDoc()->firstTrack(); while( track ) { K3bAudioDataSource* source = track->firstSource(); while( source ) { if( K3bAudioFile* file = dynamic_cast<K3bAudioFile*>( source ) ) { if( !QFile::exists( file->filename() ) ) nonExistingFiles.append( file ); } source = source->next(); } track = track->next(); } if( !nonExistingFiles.isEmpty() ) { if( questionYesNo( "<p>" + i18n("The following files could not be found. Do you want to remove them from the " "project and continue without adding them to the image?") + "<p>" + createNonExistingFilesString( nonExistingFiles, 10 ), i18n("Warning"), i18n("Remove missing files and continue"), i18n("Cancel and go back") ) ) { for( QValueList<K3bAudioFile*>::const_iterator it = nonExistingFiles.begin(); it != nonExistingFiles.end(); ++it ) { delete *it; } } else { m_canceled = true; emit canceled(); jobFinished(false); return; } } // // Make sure the project is not empty // if( m_doc->audioDoc()->numOfTracks() == 0 ) { emit infoMessage( i18n("Please add files to your project first."), ERROR ); jobFinished(false); return; } // set some flags that are needed m_doc->audioDoc()->setOnTheFly( m_doc->onTheFly() ); // for the toc writer m_doc->audioDoc()->setHideFirstTrack( false ); // unsupported m_doc->dataDoc()->setBurner( m_doc->burner() ); // so the isoImager can read ms data emit newTask( i18n("Preparing data") ); determineWritingMode(); // // First we make sure the data portion is valid // // we do not have msinfo yet m_currentAction = INITIALIZING_IMAGER; m_isoImager->setMultiSessionInfo( QString::null ); m_isoImager->init(); }
//QValueList<QString> segment(const QString &a) void segment(const QString &a, QValueList<QString> &out) { ushort _kar[] = {0x09be,0x09bf,0x09c0,0x09c1,0x09c2,0x09c3,0x09c7, 0x09c8,0x09cb,0x09cc}; ushort _vowel[] = {0x0985,0x0986,0x0987,0x0988,0x0989,0x098a, 0x098b, 0x098c,0x098f,0x0990,0x0993,0x0994, 0x09e6,0x09e7,0x09e8,0x09e9,0x09ea,0x09eb,0x09ec,0x09ed,0x09ee,0x09ef,0x09f7}; QChar candrabindu(0x0981), ligature(0x09cd), zwnj(0x200c), zwj(0x200d); QString kar, vowel; kar.setUnicodeCodes(_kar, 10); vowel.setUnicodeCodes(_vowel,24); // QValueList<QString> out ; QString temp ; for(int i = 0 ; i < (int)a.length() ; i++) { //not bangla, not our problem //if(((a[i].unicode() < 0x0980) | // (a[i].unicode() > 0x09ff)) & (a[i].unicode() != 0x200c ) & (a[i].unicode() != 0x0964)) if(!isBangla(a[i])) { //flush any bangla there if(!temp.isEmpty()) out.append(temp); out.append(QString(a[i])); temp = ""; } else { //a kar always means the letter has ended //except when some people put a chondrobindu at the end ! if(kar.find(a[i]) > -1) { if(a[i+1] == candrabindu) //chondrobindo after { temp += candrabindu ; temp += a[i++]; } else temp += a[i] ; out.append(temp); temp = ""; /* temp += a[i] ; out.append(temp); temp = ""; */ } else /* //a vowel always stands alone, //unless there's a chondrobindu //or a jawphola (exception for a actually) if(vowel.find(a[i]) > -1) { if(!temp.isEmpty()) { out.append(temp); temp =""; } if(a[i+1] == candrabindu) //chondrobindo after out.append(QString(a[i++])+candrabindu); else if(a[i+1] == { } else out.append(QString(a[i])); } else*/ //this must be a consonant,ligature or zwnj if( a[i] == ligature )//out of step here, ignore { out.append(QString(a[i])); temp = ""; } //its a consonant or zwnj else //its a zwnj or a zwj, that completes the character if( (a[i] == zwnj) | (a[i] == zwj) ) { temp += a[i]; out.append(temp); temp = ""; } //it has to be a consonant :) else { //a consonant. Look back. Did we add anything to temp ? if(!temp.isEmpty()) { //if so, if its anythng but a ligature we need to //start afresh now except if its a candrabindu if((temp.right(1) != ligature) && (a[i] != candrabindu)) { out.append(temp); temp = ""; } } temp += a[i] ; //is there a ligature ahead if(i < (int)a.length() -1) { if(a[i+1] == ligature) //OK, its part of a consonant conjunct, skip forward { i++; temp += a[i]; } } else { out.append(temp);//last thing here... temp = ""; } } } } //2002.08.24 [email protected] debugged //if we get weird stuff like a consonant and a ligature symbol dangling like that //ie from real time transliteration, for the time being ignore the dangling ligature if(!temp.isEmpty()) { temp = temp.left(temp.length() - 1); out.append(temp); } //return(out); }
VCard21ParserImpl *VCard21ParserImpl::parseVCard(const QString &vc, int *err) { int _err = 0; int _state = VC_STATE_BEGIN; QValueList< VCardLineX > *vcdata; QValueList< QString > lines; vcdata = new QValueList< VCardLineX >; lines = QStringList::split(QRegExp("[\x0d\x0a]"), vc); // for each line in the vCard for(QStringList::Iterator j = lines.begin(); j != lines.end(); ++j) { VCardLineX _vcl; // take spaces off the end - ugly but necessary hack for(int g = (*j).length() - 1; g > 0 && (*j)[g].isSpace(); --g) (*j)[g] = 0; // first token: // verify state, update if necessary if(_state & VC_STATE_BEGIN) { if(!qstricmp((*j).latin1(), VCARD_BEGIN)) { _state = VC_STATE_BODY; continue; } else { _err = VC_ERR_NO_BEGIN; break; } } else if(_state & VC_STATE_BODY) { if(!qstricmp((*j).latin1(), VCARD_END)) { _state |= VC_STATE_END; break; } // split into two tokens int colon = (*j).find(':'); if(colon < 0) { _err = VC_ERR_INVALID_LINE; break; } QString key = (*j).left(colon); QString value = (*j).mid(colon + 1); // check for qualifiers and // set name, qualified, qualifier(s) QStringList keyTokens = QStringList::split(';', key); bool qp = false, first_pass = true; bool b64 = false; if(keyTokens.count() > 0) { _vcl.qualified = false; _vcl.name = keyTokens[0].lower(); for(QStringList::Iterator z = keyTokens.begin(); z != keyTokens.end(); ++z) { QString zz = (*z).lower(); if(zz == VCARD_QUOTED_PRINTABLE || zz == VCARD_ENCODING_QUOTED_PRINTABLE) { qp = true; } else if(zz == VCARD_BASE64) { b64 = true; } else if(!first_pass) { _vcl.qualified = true; _vcl.qualifiers.append(zz); } first_pass = false; } } else { _err = VC_ERR_INVALID_LINE; } if(_err != 0) break; if(_vcl.name == VCARD_VERSION) _state |= VC_STATE_HAVE_VERSION; if(_vcl.name == VCARD_N || _vcl.name == VCARD_FN) _state |= VC_STATE_HAVE_N; // second token: // split into tokens by ; // add to parameters vector if(b64) { if(value[value.length() - 1] != '=') do { value += *(++j); } while((*j)[(*j).length() - 1] != '='); } else { if(qp) { // join any split lines while(value[value.length() - 1] == '=') { value.remove(value.length() - 1, 1); value.append(*(++j)); } } _vcl.parameters = QStringList::split(';', value, true); if(qp) { // decode the quoted printable for(QStringList::Iterator z = _vcl.parameters.begin(); z != _vcl.parameters.end(); ++z) *z = KCodecs::quotedPrintableDecode((*z).latin1()); } } } else { _err = VC_ERR_INTERNAL; break; } // validate VCardLineX if(!_vcl.isValid()) { _err = VC_ERR_INVALID_LINE; break; } // add to vector vcdata->append(_vcl); } // errors to check at the last minute (exit state related) if(_err == 0) { if(!(_state & VC_STATE_END)) // we have to have an end!! _err = VC_ERR_NO_END; if(!(_state & VC_STATE_HAVE_N) || // we have to have the mandatories! !(_state & VC_STATE_HAVE_VERSION)) _err = VC_ERR_MISSING_MANDATORY; } // set the error message if we can, and only return an object // if the vCard was valid. if(err) *err = _err; if(_err != 0) { delete vcdata; return 0; } return new VCard21ParserImpl(vcdata); }