PlotLine * THERM::calculateCustom (QString &p, QPtrList<PlotLine> &d) { // format1: MA_TYPE, MA_PERIOD, THRESHOLD, SMOOTHING_TYPE, SMOOTHING_PERIOD if (checkFormat(p, d, 5, 5)) return 0; QStringList mal; getMATypes(mal); maType = mal.findIndex(formatStringList[0]); maPeriod = formatStringList[1].toInt(); threshold = formatStringList[2].toDouble(); smoothType = mal.findIndex(formatStringList[3]); smoothing = formatStringList[4].toInt(); QPtrList<PlotLine> pll; pll.setAutoDelete(FALSE); getTHERM(pll); int loop; for (loop = pll.count() - 1; loop > 0; loop--) pll.remove(loop); return pll.at(0); }
void FuturesData::getCurrentContract (QDateTime &dt, QString &cont) { cont = symbol; bool yearFlag = FALSE; QStringList ml; getMonthList(ml); QStringList fml; getMonths(fml); int currentMonth = dt.date().month() - 1; int i = ml.findIndex(fml[currentMonth]); if (i != -1) { currentMonth++; if (currentMonth == 12) { yearFlag = TRUE; currentMonth = 0; } } if (! symbol.compare("CL") || ! symbol.compare("HO") || ! symbol.compare("HU") || ! symbol.compare("NG")) { currentMonth++; if (currentMonth == 12) { yearFlag = TRUE; currentMonth = 0; } } while (1) { QString s = fml[currentMonth]; int i = ml.findIndex(s); if (i != -1) { if (yearFlag) cont.append(QString::number(dt.date().year() + 1)); else cont.append(QString::number(dt.date().year())); cont.append(fml[currentMonth]); break; } else { currentMonth++; if (currentMonth == 12) { yearFlag = TRUE; currentMonth = 0; } } } }
Key VCardTool::parseKey(const VCardLine &line) { Key key; const QStringList params = line.parameterList(); if(params.findIndex("encoding") != -1) key.setBinaryData(line.value().asByteArray()); else key.setTextData(line.value().asString()); if(params.findIndex("type") != -1) { if(line.parameter("type").lower() == "x509") key.setType(Key::X509); else if(line.parameter("type").lower() == "pgp") key.setType(Key::PGP); else { key.setType(Key::Custom); key.setCustomTypeString(line.parameter("type")); } } return key; }
void wCatalogEditor::checkUserFields( QStringList &lst) { aCfgItem item = md->find(catId); int fid; if(item.isNull()) return; item = md->findChild(item,md_element); for(int i=0; i< md->count(item,md_field); i++) { aCfgItem mdi = md->findChild(item,md_field,i); int ind = lst.findIndex(QString("uf%1").arg(md->attr(mdi,mda_id))); if(ind!=-1) { lst.insert(lst.at(i),lst[ind]); lst.remove(lst.at(ind+1)); } else { ind = lst.findIndex(QString("text_uf%1").arg(md->attr(mdi,mda_id))); if(ind!=-1) { lst.insert(lst.at(i),lst[ind]); lst.remove(lst.at(ind+1)); } } } }
void KoZoomAction::setZoom( const QString& text ) { bool ok = false; QString t = text; int zoom = t.remove( '%' ).toInt( &ok ); // where we'll store sorted new zoom values QValueList<int> list; if( zoom > 10 ) list.append( zoom ); // "Captured" non-empty sequence of digits QRegExp regexp("(\\d+)"); const QStringList itemsList( items() ); for( QStringList::ConstIterator it = itemsList.begin(); it != itemsList.end(); ++it ) { regexp.search( *it ); const int val=regexp.cap(1).toInt( &ok ); //zoom : limit inferior=10 if( ok && val>9 && list.contains( val )==0 ) list.append( val ); } qHeapSort( list ); // update items with new sorted zoom values QStringList values; for (QValueList<int>::Iterator it = list.begin(); it != list.end(); ++it ) values.append( i18n("%1%").arg(*it) ); setItems( values ); QString zoomStr = i18n("%1%").arg( zoom ); setCurrentItem( values.findIndex( zoomStr ) ); }
const QStringList XineConfig::getCategories() { QStringList cats; xine_cfg_entry_t* ent = new xine_cfg_entry_t; if (!xine_config_get_first_entry(m_xine, ent)) return cats; QString entCat; do { entCat = QString(ent->key); entCat = entCat.left(entCat.find(".")); if (cats.findIndex(entCat) == -1) { // kdDebug() << "XineConfig: new category: " << entCat << endl; cats.append(entCat); } delete ent; ent = new xine_cfg_entry_t; } while(xine_config_get_next_entry(m_xine, ent)); delete ent; return cats; }
bool KeyValuesTable::check_unique() { forceUpdateCells(); unsigned n = numRows(); if (n != 0) { unsigned index; if (text(n - 1, 0).isEmpty()) n -= 1; QStringList l; for (index = 0; index != n; index += 1) { const QString & s = text(index, 0); if (l.findIndex(s) != -1) { msg_critical(TR("Error"), TR("key '%1' used several times", s)); return FALSE; } else l.append(s); } } return TRUE; }
bool UpgradeMessage::createDir (QString &p) { QString path = p; int t = path.find("/data0/", 0, TRUE); path.replace(t + 5, 1, "1"); QStringList l = QStringList::split("/", path, FALSE); int loop = l.findIndex(".qtstalker"); loop = loop + 2; for (; loop < (int) l.count() - 1; loop++) { QString s; int loop2; for (loop2 = 0; loop2 <= loop; loop2++) s.append("/" + l[loop2]); QDir dir(s); if (! dir.exists(s, TRUE)) { if (! dir.mkdir(s, TRUE)) { qDebug("UpgradeMessage::createDir: error %s", s.latin1()); return TRUE; } } } return FALSE; }
Agent VCardTool::parseAgent(const VCardLine &line) { Agent agent; const QStringList params = line.parameterList(); if(params.findIndex("value") != -1) { if(line.parameter("value").lower() == "uri") agent.setUrl(line.value().asString()); } else { QString str = line.value().asString(); str.replace("\\n", "\r\n"); str.replace("\\N", "\r\n"); str.replace("\\;", ";"); str.replace("\\:", ":"); str.replace("\\,", ","); const Addressee::List list = parseVCards(str); if(list.count() > 0) { Addressee *addr = new Addressee; *addr = list[0]; agent.setAddressee(addr); } } return agent; }
void ResourceView::addResource() { bool ok = false; KCal::CalendarResourceManager *manager = mCalendar->resourceManager(); ResourceItem *i = static_cast<ResourceItem*>( mListView->selectedItem() ); if ( i && ( i->isSubresource() || i->resource()->canHaveSubresources() ) ) { const QString folderName = KInputDialog::getText( i18n( "Add Subresource" ), i18n( "Please enter a name for the new subresource" ), QString::null, &ok, this ); if ( !ok ) return; const QString parentId = i->isSubresource() ? i->resourceIdentifier() : QString:: null; if ( !i->resource()->addSubresource( folderName, parentId ) ) { KMessageBox::error( this, i18n("<qt>Unable to create subresource <b>%1</b>.</qt>") .arg( folderName ) ); } return; } QStringList types = manager->resourceTypeNames(); QStringList descs = manager->resourceTypeDescriptions(); QString desc = KInputDialog::getItem( i18n( "Resource Configuration" ), i18n( "Please select type of the new resource:" ), descs, 0, false, &ok, this ); if ( !ok ) return; QString type = types[ descs.findIndex( desc ) ]; // Create new resource ResourceCalendar *resource = manager->createResource( type ); if( !resource ) { KMessageBox::error( this, i18n("<qt>Unable to create resource of type <b>%1</b>.</qt>") .arg( type ) ); return; } resource->setResourceName( i18n("%1 resource").arg( type ) ); KRES::ConfigDialog *dlg = new KRES::ConfigDialog( this, QString("calendar"), resource, "KRES::ConfigDialog" ); if ( dlg && dlg->exec() ) { resource->setTimeZoneId( KOPrefs::instance()->mTimeZoneId ); if ( resource->isActive() ) { resource->open(); resource->load(); } manager->add( resource ); // we have to call resourceAdded manually, because for in-process changes // the dcop signals are not connected, so the resource's signals would not // be connected otherwise mCalendar->resourceAdded( resource ); } else { delete resource; resource = 0; } if ( dlg ) delete dlg; emitResourcesChanged(); }
/** * Opens a dialog box with all available mixers and let the user choose one. * If the user selects a mixer, "_mixer" will be set and positionChange() is called. */ void KMixApplet::selectMixer() { QStringList lst; int n=1; for (Mixer *mixer=Mixer::mixers().first(); mixer!=0; mixer=Mixer::mixers().next()) { QString s; s.sprintf("%i. %s", n, mixer->mixerName().ascii()); lst << s; n++; } bool ok = FALSE; QString res = KInputDialog::getItem( i18n("Mixers"), i18n("Available mixers:"), lst, 1, FALSE, &ok, this ); if ( ok ) { Mixer *mixer = Mixer::mixers().at( lst.findIndex( res ) ); if (!mixer) KMessageBox::sorry( this, i18n("Invalid mixer entered.") ); else { delete m_errorLabel; m_errorLabel = 0; _mixer = mixer; // Create the ViewApplet by calling positionChange() ... :) // To take over reversedDir and (more important) to create the mixer widget // if necessary! positionChange(position()); } } }
void CollectionScanner::doJob() //SLOT { std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; std::cout << "<scanner>"; QStringList entries; if( m_restart ) { QFile logFile( m_logfile ); logFile.open( IO_ReadOnly ); QString lastFile = logFile.readAll(); QFile folderFile( amaroK::saveLocation( QString::null ) + "collection_scan.files" ); folderFile.open( IO_ReadOnly ); entries = QStringList::split( "\n", folderFile.readAll() ); for( int count = entries.findIndex( lastFile ) + 1; count; --count ) entries.pop_front(); // debug() << "Restarting at: " << entries.front() << endl; } else { foreachType( QStringList, m_folders ) { if( (*it).isEmpty() ) //apparently somewhere empty strings get into the mix //which results in a full-system scan! Which we can't allow continue; QString dir = *it; if( !dir.endsWith( "/" ) ) dir += '/'; readDir( dir, entries ); } QFile folderFile( amaroK::saveLocation( QString::null ) + "collection_scan.files" ); folderFile.open( IO_WriteOnly ); QTextStream stream( &folderFile ); stream << entries.join( "\n" ); folderFile.close(); } if( !entries.isEmpty() ) { if( !m_restart ) { AttributeMap attributes; attributes["count"] = QString::number( entries.count() ); writeElement( "itemcount", attributes ); } scanFiles( entries ); } std::cout << "</scanner>" << std::endl; quit(); }
QString type(const QString & t, const QStringList & types, BrowserNodeList & nodes) { int rank = types.findIndex(t); return (rank != -1) ? QString(((BrowserClass *) nodes.at(rank))->get_name()) : t; }
int PMObjectSelect::selectObject( PMObject* link, const QStringList& t, PMObject* & obj, QWidget* parent ) { PMObject* last = link; PMObject* scene; bool stop = false; bool found = false; do { scene = last->parent( ); if( scene ) { if( scene->type( ) == "Scene" ) { last = last->prevSibling( ); stop = true; found = true; } else last = last->parent( ); } else stop = true; } while( !stop ); if( found ) { PMObjectSelect s( parent ); PMObject* o = scene->firstChild( ); bool l = false; while( o && !l && last ) { if( t.findIndex( o->type( ) ) >= 0 ) s.m_pListBox->insertItem( new PMListBoxObject( o ) ); if( o == last ) l = true; else o = o->nextSibling( ); } int result = s.exec( ); if( result == Accepted ) obj = s.selectedObject( ); return result; } else kdError( PMArea ) << "PMObjectSelect: Link does not seem to be correctly inserted in the scene.\n"; return Rejected; }
Sound VCardTool::parseSound(const VCardLine &line) { Sound snd; const QStringList params = line.parameterList(); if(params.findIndex("encoding") != -1) snd.setData(line.value().asByteArray()); else if(params.findIndex("value") != -1) { if(line.parameter("value").lower() == "uri") snd.setUrl(line.value().asString()); } /* TODO: support sound types if ( params.contains( "type" ) ) snd.setType( line.parameter( "type" ) ); */ return snd; }
QString QFileDialog::winGetOpenFileName(const QString &initialSelection, const QString &filter, QString* initialDirectory, QWidget *parent, const char* /*name*/, const QString& caption, QString* selectedFilter) { QString result; QString isel = initialSelection; if (initialDirectory && initialDirectory->left(5) == "file:") initialDirectory->remove(0, 5); QFileInfo fi(*initialDirectory); if (initialDirectory && !fi.isDir()) { *initialDirectory = fi.dirPath(true); if (isel.isEmpty()) isel = fi.fileName(); } if (!fi.exists()) *initialDirectory = QDir::homeDirPath(); QString title = caption; if (title.isNull()) title = tr("Open"); DWORD selFilIdx; int idx = 0; if (selectedFilter && !selectedFilter->isEmpty()) { QStringList filterLst = makeFiltersList(filter); idx = filterLst.findIndex(*selectedFilter); } if (parent) { QEvent e(QEvent::WindowBlocked); QApplication::sendEvent(parent, &e); qt_enter_modal(parent); } QT_WA({ // Use Unicode strings and API OPENFILENAME* ofn = makeOFN(parent, isel, *initialDirectory, title, winFilter(filter), ExistingFile); if (idx) ofn->nFilterIndex = idx + 1; if (GetOpenFileName(ofn)) { result = QString::fromUcs2((ushort*)ofn->lpstrFile); selFilIdx = ofn->nFilterIndex; } cleanUpOFN(&ofn); } , {
void ClassData::addFormals(QStringList & l) { for (int index = 0; index != nformals; index += 1) { const char * s = formals[index].get_name(); if (l.findIndex(s) == -1) l.prepend(s); } if (((BrowserNode *) browser_node->parent())->get_type() == UmlClass) ((ClassData *) ((BrowserNode *) browser_node->parent())->get_data()) ->addFormals(l); }
AType the_type(const QString & t, const QStringList & types, BrowserNodeList & nodes) { AType result; int rank = types.findIndex(t); if (rank != -1) result.type = ((BrowserClass *) nodes.at(rank)); else result.explicit_type = t; return result; }
Picture VCardTool::parsePicture(const VCardLine &line) { Picture pic; const QStringList params = line.parameterList(); if(params.findIndex("encoding") != -1) { QImage img; img.loadFromData(line.value().asByteArray()); pic.setData(img); } else if(params.findIndex("value") != -1) { if(line.parameter("value").lower() == "uri") pic.setUrl(line.value().asString()); } if(params.findIndex("type") != -1) pic.setType(line.parameter("type")); return pic; }
void FormulaEdit::functionDialog () { Config config; QStringList l; config.getIndicatorList(l); l.append("UTIL"); l.append("SYMBOL"); l.sort(); bool ok; QString function = QInputDialog::getItem(QObject::tr("Indicator Selection"), QObject::tr("Select an indicator:"), l, 0, TRUE, &ok, this); if (! ok) return; IndicatorPlugin *plug = config.getIndicatorPlugin(function); if (! plug) { qDebug("FormulaEdit::functionDialog:can't open %s plugin", function.latin1()); return; } QString s; plug->getPluginName(s); if (! s.compare("TALIB")) plug->setFormatMethod(function); QString vname, format; QStringList vl; getVariableList(vl, TRUE); plug->formatDialog(vl, vname, format); if (! vname.length()) return; if (vl.findIndex(vname) != -1) { QMessageBox::information(this, tr("Qtstalker: Error"), tr("Duplicate variable name.")); return; } format.prepend(vname + " := " + function + "("); format.append(")"); formula->insert(format); }
QStringList Tool::all_display() { QStringList r; unsigned index; for (index = 0; index != ntools; index += 1) { QString s = tools[index].display; if (r.findIndex(s) == -1) r.append(s); } r.sort(); return r; }
void LibraryWindow::changeTypeOfSelected() { LibraryListViewItem *item = dynamic_cast<LibraryListViewItem*>(modelListView_->selectedItem()); if (item != 0) { QStringList typeNames = types(); bool ok; QString type = QInputDialog::getItem ("POA", tr("Select a type"), typeNames, typeNames.findIndex(item->data().type()), true, &ok, this); if (ok) { item->data().setType(type); item->parent()->takeItem(item); getTypeItem(type)->insertItem(item); } } }
void Dialog::compute_includepath() { const QVector<UmlArtifact> & arts = _art->associatedArtifacts(); QFileInfo fi(edpro->text()); QString prodir = fi.dirPath(TRUE); unsigned index; QStringList l; for (index = 0; index != arts.count(); index += 1) { QString s = arts[index]->way(prodir, TRUE); if ((s != "./") && (l.findIndex(s) == -1)) l.append(s); } edincludepath->setText(l.join(" ")); }
void SVNHandler::checkToAdd( const QStringList& files ) { if ( files.isEmpty( ) ) return; QStringList toBeAdded; QStringList::ConstIterator it; for ( it = files.begin( ); it != files.end( ); ++it ) { // check for every entry if it needs to be added if ( ! isInSvn( *it ) ) { QFileInfo info( *it ); QString temp; // will hold the dir path if ( info.isDir( ) ) { toBeAdded << *it; temp = *it; } else { toBeAdded << *it; temp = QFileInfo( *it ).dirPath( true ); } // ### TODO: does SVN really needs this or does it do it automatically? // check recursivlely if parent dirs have to be added as well while ( ! isInSvn( temp ) && toBeAdded.findIndex( temp ) == -1 ) { toBeAdded << temp; temp = QFileInfo( temp ).dirPath( true ); } } } // remove an old command _addCommand = QString(); // ### TODO: does SVN really need this? // make sure the directories are added before the files toBeAdded.sort( ); // ### TODO: try to make this better // create a command line for adding the files and dirs for ( it = toBeAdded.begin( ); it != toBeAdded.end( ); ++it ) { QFileInfo info( *it ); _addCommand += "cd " + info.dirPath( true ) + " && svn add " + info.fileName( ) + "; "; } }
void FLConnectDBDialog::tryConnect() { FLSqlDatabase *db = new FLSqlDatabase(); if (!db->loadDriver(FLSqlDatabase::driverAliasToDriverName(comboBoxDB->currentText()))) { QMessageBox::critical(0, tr("Driver no cargado"), tr("Error al cargar el driver %1.").arg(comboBoxDB->currentText()), QMessageBox::Ok, 0, 0); error_ = true; delete db; this->accept(); return ; } if (!db->connectDB(comboBoxNameDB->currentText(), lineEditUser->text(), lineEditPassword->text(), lineEditHost->text(), lineEditPort->text().toInt())) { error_ = true; delete db; this->accept(); return ; } FLSettings::writeEntry("DBA/rememberPasswd", rememberPasswd_); FLSettings::writeEntry("DBA/username", lineEditUser->text()); if (rememberPasswd_) FLSettings::writeEntry("DBA/password", lineEditPassword->text()); else FLSettings::writeEntry("DBA/password", QString::null); FLSettings::writeEntry("DBA/port", lineEditPort->text()); FLSettings::writeEntry("DBA/hostname", lineEditHost->text()); FLSettings::writeEntry("DBA/db", comboBoxDB->currentText()); FLSettings::writeEntry("DBA/lastDB", comboBoxNameDB->currentText()); QStringList names; for (int i = 0; i < comboBoxNameDB->count(); i++) names << comboBoxNameDB->text(i); if (names.findIndex(comboBoxNameDB->currentText()) == -1) names << comboBoxNameDB->currentText(); FLSettings::writeEntry("DBA/namesDB", names); error_ = false; FLSqlConnections::addDatabase(db); this->accept(); }
bool BrowserNode::enter_child_name(QString & r, const QString & msg, UmlCode type, BrowserNodeList & nodes, BrowserNode ** old, bool allow_spaces, bool allow_empty, bool existing) { if (existing && nodes.isEmpty()) { msg_warning(TR("Error"), TR("nothing available")); return FALSE; } QStringList list; nodes.full_names(list); list.prepend(QString::null); *old = 0; for (;;) { BooL ok = FALSE; r = (list.count() == 1) ? MyInputDialog::getText("Uml", msg, QString::null, ok) : MyInputDialog::getText("Uml", msg, list, QString::null, existing, ok); if (! ok) return FALSE; if (!r.isEmpty()) { int index = list.findIndex(r); if (index != -1) { *old = nodes.at(index - 1); return TRUE; } } if (wrong_child_name(r, type, allow_spaces, allow_empty)) msg_critical(TR("Error"), r + "\n\n" + TR("illegal name or already used")); else return TRUE; } }
void CSV::updateRules () { QString current = ruleCombo->currentText(); ruleCombo->clear(); QStringList l; QDir dir(ruleDir); int loop; for (loop = 2; loop < (int) dir.count(); loop++) { QString s = dir.absPath() + "/" + dir[loop]; QFileInfo fi(s); if (! fi.isDir()) l.append(dir[loop]); } ruleCombo->insertStringList(l, -1); if (current.length()) ruleCombo->setCurrentItem(l.findIndex(current)); }
// ------------------------------------------------------- bool LibComp::createSubNetlist(QTextStream *stream, QStringList &FileList, int type) { int r = -1; QString FileString; QStringList Includes; if(type&1) { r = loadSection("Model", FileString, &Includes); } else if(type&2) { r = loadSection("VHDLModel", FileString, &Includes); } else if(type&4) { r = loadSection("VerilogModel", FileString, &Includes); } if(r < 0) return false; // also include files int error = 0; for(QStringList::Iterator it = Includes.begin(); it != Includes.end(); ++it ) { QString s = getSubcircuitFile()+"/"+*it; if(FileList.findIndex(s) >= 0) continue; FileList.append(s); // load file and stuff into stream QFile file(s); if(!file.open(QIODevice::ReadOnly)) { error++; } else { QByteArray FileContent = file.readAll(); file.close(); //?stream->writeRawBytes(FileContent.data(), FileContent.size()); (*stream) << FileContent.data(); qDebug() << "hi from libcomp"; } } (*stream) << "\n" << FileString << "\n"; return error > 0 ? false : true; }
void CriteriaEditor::loadCriteriaList( int valueType, QString condition ) { if( m_currentValueType == valueType && condition == QString::null ) return; QStringList items; switch( valueType ) { case String: case AutoCompletionString: items << i18n( "contains" ) << i18n( "does not contain" ) << i18n( "is" ) << i18n( "is not" ) << i18n( "starts with" ) << i18n( "ends with" ); break; case Rating: case Number: items << i18n( "is" ) << i18n( "is not" ) << i18n( "is greater than" ) << i18n( "is smaller than" ) << i18n( "is between" ); break; case Year: //fall through case Date: items << i18n( "is" ) << i18n( "is not" ) << i18n( "is before" ) << i18n( "is after" ) << i18n( "is in the last" ) << i18n( "is not in the last" ) << i18n( "is between" ); break; default: ; }; m_criteriaCombo->clear(); m_criteriaCombo->insertStringList( items ); if ( !condition.isEmpty() ) { int index = items.findIndex( condition ); if (index!=-1) m_criteriaCombo->setCurrentItem( index ); } }
void KoZoomAction::init() { setEditable( true ); QStringList values; values << i18n("%1%").arg("33"); values << i18n("%1%").arg("50"); values << i18n("%1%").arg("75"); values << i18n("%1%").arg("100"); values << i18n("%1%").arg("125"); values << i18n("%1%").arg("150"); values << i18n("%1%").arg("200"); values << i18n("%1%").arg("250"); values << i18n("%1%").arg("350"); values << i18n("%1%").arg("400"); values << i18n("%1%").arg("450"); values << i18n("%1%").arg("500"); setItems( values ); setCurrentItem( values.findIndex( i18n("%1%").arg( 100 ) ) ); connect( this, SIGNAL( activated( const QString& ) ), SLOT( activated( const QString& ) ) ); }