MemberDef* VerilogDocGen::findInstMember(QCString & cl,QCString & inst,QCString & key,bool b) { ClassDef* cdInst=0; ClassDef* cdClass=0; if(!cl.isEmpty()) cdClass=getClass(cl.data()); if(!inst.isEmpty()) cdInst=getClass(inst.data()); if(!buildInst) { buildVariableDict(cdInst,cdClass); buildInst=true; } if(!b) return classPortDict.find(key.data()); else return instPortDict.find(key.data()); }//find
/*************************************************************************** * Returns a list of all the pounces of a user. ***************************************************************************/ QDict<pounce> setup::readPounces(const QString &user){ QDict<pounce> list; if(user.isEmpty() || (user == QString("<new user>")) ) return list; QString settingsFileXml = KINKATTA_DIR; settingsFileXml += user.lower(); settingsFileXml += ".xml"; Preferences prefs(settingsFileXml, QString("kinkatta user prefs"), QString("1.0")); prefs.setGroup("pounces"); pounce *p; int count = prefs.getNumber("pounce_count", 0); for(int i = 0; i < count; i++){ p = new pounce; p->buddyName = prefs.getString(QString("pounce_%1").arg(i) + "_buddyName", QString("")); p->signOn = prefs.getBool(QString("pounce_%1").arg(i) + "_signOn",false); p->returnAway = prefs.getBool(QString("pounce_%1").arg(i) + "_returnAway", false); p->returnIdle = prefs.getBool(QString("pounce_%1").arg(i) + "_returnIdle", false); p->openChat = prefs.getBool(QString("pounce_%1").arg(i) + "_openChat", false); p->sendMessage = prefs.getBool(QString("pounce_%1").arg(i) + "_sendMessage", false); p->message = prefs.getString(QString("pounce_%1").arg(i) + "_message", QString("")); p->execCommand = prefs.getBool(QString("pounce_%1").arg(i) + "_execCommand", false); p->command = prefs.getString(QString("pounce_%1").arg(i) + "_command", QString("")); p->doNotRemove = true; p->hidden = prefs.getBool(QString("pounce_%1").arg(i) + "_hidden", false); p->ignoreSettings = prefs.getBool(QString("pounce_%1").arg(i) + "_ignoreSettings", false); p->signOnSound = prefs.getString(QString("pounce_%1").arg(i) + "_signOnSound", QString("")); p->signOffSound = prefs.getString(QString("pounce_%1").arg(i) + "_signOffSound", QString("")); list.insert(p->buddyName, p); } return list; }
MemberDef* VerilogDocGen::findMemberDef(ClassDef* cd,QCString& key,MemberList::ListType type,int spec,bool def) { static QCString className; static QCString prevName; static ClassDef* sClass=0; MemberDef *mem=NULL; if(cd==0) { mem=globalMemDict.find(key.data()); if(mem) return mem; return NULL; } className=cd->name(); if(prevName != className ) { prevName=className; buildVariableDict(cd); } if(mem==0) mem=variableDict.find(key.data()); if(mem) { return mem; } mem=globalMemDict.find(key.data()); if(mem) return mem; return NULL; }//findMemberDef
/** Inserts a package into the list */ void PackageList::insertPackage( OipkgPackage* pack ) { if (!pack) return; OipkgPackage* p = packageListAll->find( pack->name() ); if ( p ) { if ( (p->version() == pack->version()) // && (p->dest() == pack->dest()) ) { p->copyValues( pack ); delete pack; pack = p; } else { QDict<OipkgPackage> *packver = p->getOtherVersions(); // p->setName( pack->name()+"["+p->version()+"]" ); if (!packver) { packver = new QDict<OipkgPackage>(); packver->insert( pack->name(), p ); p->setOtherVersions( packver ); } pack->setName( pack->name() );//+"["+pack->version()+"]" ); pack->setOtherVersions( packver ); packver->insert( pack->name(), pack ); packageListAll->insert( pack->name(), pack ); packageList.insert( pack->name(), pack ); origPackageList.insert( pack->name(), pack ); } }else{ packageListAll->insert( pack->name(), pack ); packageList.insert( pack->name(), pack ); origPackageList.insert( pack->name(), pack ); }; empty=false; updateSections( pack ); }
void buildVariableDict(ClassDef *cd) { if(cd==0) return; variableDict.clear(); MemberList* ml=cd->getMemberList(MemberList::variableMembers); if(ml) { MemberListIterator mnii(*ml); MemberDef *md; for (mnii.toFirst();(md=mnii.current());++mnii) variableDict.insert(md->name().data(),md); } ml=cd->getMemberList(MemberList::pubMethods); if(ml) { MemberListIterator mnii(*ml); MemberDef *md; for (mnii.toFirst();(md=mnii.current());++mnii) variableDict.insert(md->name().data(),md); } }
/* * We do simple ref counting... We will add the QLibrary again * and again to the dictionary and on deref we will pop and pop it * until there are no more library and we will unload and delete the library * luckily dlopen does some ref counting as well so we don't need * to hack QPEApplication */ QLibrary* OPluginLibraryHolder::ref(const QString& str) { QLibrary *lib = m_libs[str]; /* if not in the dict try to load it */ if ( !lib ) { lib = new QLibrary( str, QLibrary::Immediately ); if ( !lib->isLoaded() ) { delete lib; return 0l; } } /* now refcount one up */ m_libs.insert( str, lib ); return lib; }
QList<ArgDict>* readRegionFile(const char* filename) { QList <ArgDict>* region=regionFileDict[filename]; if (region) return region; // read regionfile // QFile rfp("/project/geoaida/tmp/reglist.dest"); QFile rfp(filename); if (!rfp.open(IO_ReadOnly)) { fprintf(stderr, "regionfile %s not found\n", filename); return 0; } // Read and process regions QList < ArgDict > *regionList=new QList < ArgDict >(); regionList->setAutoDelete(true); MLParser parser(&rfp); QString keywords[] = { "region", "" }; const MLTagTable nodeTagTable(keywords); const int TOK_REGION = 1; int tag; do { tag = parser.tag(nodeTagTable); ArgDict *args; switch (tag) { case TOK_REGION:{ args = parser.args(); regionList->append(args); break; } case -TOK_REGION: break; case MLParser::END_OF_FILE: break; default:{ args = parser.args(); delete args; qDebug("Unknown keyword %s in line %d", parser.lasttagstr().latin1(), parser.lineNumber()); break; } } } while (tag != MLParser::END_OF_FILE); rfp.close(); regionFileDict.insert(filename,regionList); return regionList; }
void loadStylesheet(const char *name, QDict<StyleData>& dict) { QFile file(name); if (!file.open(IO_ReadOnly)) { err("Can't open RTF style sheet file %s. Using defaults.\n",name); return; } msg("Loading RTF style sheet %s...\n",name); static const QRegExp separator("[ \t]*=[ \t]*"); uint lineNr=1; QTextStream t(&file); #if QT_VERSION >= 200 t.setEncoding(QTextStream::Latin1); #endif while (!t.eof()) { QCString s(4096); // string buffer of max line length s = t.readLine().stripWhiteSpace(); if (s.isEmpty() || s.at(0)=='#') continue; // skip blanks & comments int sepLength; int sepStart = separator.match(s,0,&sepLength); if (sepStart<=0) // no valid assignment statement { warn(name,lineNr,"Assignment of style sheet name expected!\n"); continue; } QCString key=s.left(sepStart); if (dict[key]==0) // not a valid style sheet name { warn(name,lineNr,"Invalid style sheet name %s ignored.\n",key.data()); continue; } StyleData* styleData = dict.find(key); if (styleData == 0) { warn(name,lineNr,"Unknown style sheet name %s ignored.\n",key.data()); continue; } s+=" "; // add command separator styleData->setStyle(s.data() + sepStart + sepLength, key.data()); lineNr++; } }
void CUS::createPlot (QString &d, QDict<PlotLine> &lines, Indicator *output) { if (! d.contains("plot")) return; QStringList l = QStringList::split("(", d, FALSE); if (l.count() != 2) { qDebug("CUS::createPlot: bad plot format: %s", d.ascii()); return; } QString parms = l[1]; parms.truncate(parms.find(")", -1, TRUE)); l = QStringList::split(",", parms, FALSE); if (l.count() != 4) { qDebug("CUS::createPlot: missing plot parms: %s",d.ascii()); return; } // 1.var name l[0] = l[0].stripWhiteSpace(); PlotLine *pl = lines.find(l[0]); if (! pl) { qDebug("CUS::createPlot: bad plot parm 1: %s",d.ascii()); return; } // 2.color l[1] = l[1].stripWhiteSpace(); pl->setColor(l[1]); // 3.label l[2] = l[2].stripWhiteSpace(); pl->setLabel(l[2]); // 4.linetype l[3] = l[3].stripWhiteSpace(); pl->setType(l[3]); PlotLine *tline = new PlotLine; tline->copy(pl); output->addLine(tline); }
void GadGuiInitObjectTable() { int size; int i; for (size = 0; !_gadguifunctable[size].name.isEmpty(); size++); QString *keyword = new QString[size + 1]; for (i = 0; i < size; i++) { keyword[i] = _gadguifunctable[i].name; qDebug("GadGuiInitObjectTable %s\n", (const char *) _gadguifunctable[i].name); if ((void *) _gadguifunctable[i].func) _gadguitable.insert(_gadguifunctable[i].name, (void *) _gadguifunctable[i].func); } keyword[size] = ""; _gadguitagtable = new MLTagTable(keyword); }
/*! Finalizes the HTML help. This will finish and close the * contents file (index.hhc) and the index file (index.hhk). * \sa initialize() */ void HtmlHelp::finalize() { // end the contents file cts << "</UL>\n"; cts << "</BODY>\n"; cts << "</HTML>\n"; cts.unsetDevice(); cf->close(); delete cf; index->writeFields(kts); // end the index file kts << "</UL>\n"; kts << "</BODY>\n"; kts << "</HTML>\n"; kts.unsetDevice(); kf->close(); delete kf; createProjectFile(); s_languageDict.clear(); }
void DbPlugin::getSpreadHistory (BarData *barData, QDateTime &startDate) { QString s = "FirstSymbol"; QString fs; getData(s, fs); QString ss; s = "SecondSymbol"; getData(s, ss); // get the first symbol bars QFileInfo fi(fs); QString fn = fi.fileName(); DbPlugin db; if (db.open(fs, chartIndex)) { qDebug("Spread::getSpreadHistory: cannot open first symbol chart"); return; } BarData *bar = new BarData(fs); bar->setBarLength(barLength); db.setBarRange(barRange); db.getHistory(bar, startDate); db.close(); // get the second symbol bars QFileInfo fi2(ss); fn = fi2.fileName(); if (db.open(ss, chartIndex)) { qDebug("Spread::getSpreadHistory: cannot open second symbol chart"); delete bar; return; } BarData *bar2 = new BarData(ss); bar2->setBarLength(barLength); db.setBarRange(barRange); db.getHistory(bar2, startDate); db.close(); // create lookup dict for first symbol bars QDict<Bar> lookup; lookup.setAutoDelete(TRUE); int loop; for (loop = 0; loop < bar->count(); loop++) { Bar *r = new Bar; QDateTime dt; bar->getDate(loop, dt); r->setDate(dt); r->setClose(bar->getClose(loop)); r->getDateTimeString(FALSE, s); lookup.insert(s, r); } // match all second symbol bars for (loop = bar2->count() - 1; loop > -1; loop--) { Bar r; QDateTime dt; bar2->getDate(loop, dt); s = dt.toString("yyyyMMddhhmmss"); Bar *tr = lookup.find(s); if (tr) { double t = tr->getClose() - bar2->getClose(loop); r.setDate(dt); r.setOpen(t); r.setHigh(t); r.setLow(t); r.setClose(t); barData->prepend(r); } } delete bar; delete bar2; }
/** * Add entries to a variable. Will just add the variables to the existing line, removing duplicates * Will preserve += constructs and make sure that the variable only has one copy of the value across * all += constructs * @param fileName * @param variables key=value string of entries to add * @param add true= add these key,value pairs, false = remove. You can have empty values for an add - the whole line is * removed. For adding, we will not add an empty line. */ void AutoProjectTool::addRemoveMakefileam(const QString &fileName, QMap<QString, QString> variables, bool add) { // input file reading QFile fin(fileName); if (!fin.open(IO_ReadOnly)) { return ; } QTextStream ins(&fin); // output file writing. QFile fout(fileName + "#"); if (!fout.open(IO_WriteOnly)) { fin.close(); return ; } QTextStream outs(&fout); // variables QRegExp re("^(#kdevelop:[ \t]*)?([A-Za-z][@A-Za-z0-9_]*)[ \t]*([:\\+]?=)[ \t]*(.*)$"); // build key=map of values to add // map can be empty.we never add an empty key, but do remove empty keys from the file.. QDict< QMap<QString, bool> > interest; for (QMap<QString, QString>::Iterator it0 = variables.begin(); it0 != variables.end(); ++it0) { kdDebug(9020) << "key (" << add<<"): " << it0.key() << "="<< it0.data() << endl; QMap<QString, bool>* set = new QMap<QString, bool>(); if (!it0.data().stripWhiteSpace().isEmpty()) { QStringList variableList = QStringList::split(' ', it0.data()); for (uint i = 0; i < variableList.count(); i++) { set->insert(variableList[i], true); } } interest.insert(it0.key(), set); } bool multiLine = false; QString lastLhs; QStringList lastRhs; QMap<QString, QString> seenLhs; while (!fin.atEnd()) { QString s = ins.readLine(); if (re.exactMatch(s)) { QString lhs = re.cap(2); QMap<QString, bool>* ourRhs = interest.find(lhs); if (!ourRhs) { // not interested in this line at all // write it out as is.. outs << s << endl; } else { // we are interested in this line.. QString rhs = re.cap(4).stripWhiteSpace(); if (rhs[ rhs.length() - 1 ] == '\\') { // save it for when we have the whole line.. multiLine = true; lastLhs = lhs; rhs.setLength(rhs.length() - 1); lastRhs += QStringList::split(" ", rhs); } else { // deal with it now. QStringList bits = QStringList::split(" ", rhs); if (add) { // we are adding our interested values to this line and writing it // add this line to we we want to add to remove duplicates. for (uint index = 0; index < bits.size(); index++) { QMap<QString, bool>::iterator findEntry = ourRhs->find(bits[index]); if (findEntry == ourRhs->end()) { // we haven't seen it, so add it, so we don't add it again later.. ourRhs->insert(bits[index], true); } // else we have this value in our 'to add list' , it is either already been // added, so we don't want to add it again, or it hasn't been added, in which // case we will do so soon. so we can ignore this now.. } // now write the line out if it is not going to be empty. QString newLine(lhs); if (seenLhs.find(lhs) == seenLhs.end()) { newLine += " = "; seenLhs[lhs] = ""; } else { newLine += " += "; } int len = newLine.length(); bool added = false; QValueList<QString> keys = ourRhs->keys(); for (uint count = 0; count < keys.size(); count++) { // if out entry is true, add it.. if ((*ourRhs)[keys[count]]) { added = true; len += keys[count].length() + 1; if (len > 80) { newLine += "\\\n\t"; len = 8; } newLine += keys[count]; newLine += ' '; // set our value so we don't add it again. (*ourRhs)[keys[count]] = false; } } // only print it out if there was a value to add.. if (added) { newLine.setLength(newLine.length() - 1); outs << newLine << endl; } } else { // we are removing our interested values from this line // special case - no values, remove the line.. if (!ourRhs->empty()) { // check if any of these values are down to remove. QString newLine(lhs); if (seenLhs.find(lhs) == seenLhs.end()) { newLine += " = "; seenLhs[lhs] = ""; } else { newLine += " += "; } int len = newLine.length(); bool added = false; for (QStringList::Iterator posIter = bits.begin(); posIter != bits.end();posIter++) { QMap<QString, bool>::iterator findEntry = ourRhs->find(*posIter); if (findEntry == ourRhs->end()) { // we do not want to remove it.. added = true; len += (*posIter).length() + 1; if (len > 80) { newLine += "\\\n\t"; len = 8; } newLine += (*posIter); newLine += ' '; } // else we have this value in our 'to remove list', so don't add it. } // only print it out if there was a value on it.. if (added) { newLine.setLength(newLine.length() - 1); outs << newLine << endl; } } }//if (add) }//if ( rhs[ rhs.length() - 1 ] == '\\' ) }//if ( found == interest.end()) } else if (multiLine) { s = s.stripWhiteSpace(); // we are only here if were interested in this line.. if (s[s.length()-1] == '\\') { s.setLength(s.length() - 1); // still more multi line we wait for.. } else { // end of the multi line.. multiLine = false; } lastRhs += QStringList::split(" ", s); if (!multiLine) { // now we have to deal with this multiLine value.. // ourRhs will always be a value, as we only get multiLine if we're interested in it.. QMap<QString, bool>* ourRhs = interest.find(lastLhs); if (add) { // we are adding our interested values to this line and writing it // add this line to we we want to add to remove duplicates. for (uint index = 0; index < lastRhs.size(); index++) { QMap<QString, bool>::iterator findEntry = ourRhs->find(lastRhs[index]); if (findEntry == ourRhs->end()) { // we haven't seen it, so add it, so we don't add it again later.. ourRhs->insert(lastRhs[index], true); } // else we have this value in our 'to add list' , it is either already been // added, so we don't want to add it again, or it hasn't been added, in which // case we will do so soon. so we can ignore this now.. } // now write the line out if it is not going to be empty. QString newLine(lastLhs); if (seenLhs.find(lastLhs) == seenLhs.end()) { newLine += " = "; seenLhs[lastLhs] = ""; } else { newLine += " += "; } int len = newLine.length(); bool added = false; QValueList<QString> keys = ourRhs->keys(); for (uint count = 0; count < keys.size(); count++) { // if out entry is true, add it.. if ((*ourRhs)[keys[count]]) { added = true; len += keys[count].length() + 1; if (len > 80) { newLine += "\\\n\t"; len = 8; } newLine += keys[count]; newLine += ' '; // set our value so we don't add it again. (*ourRhs)[keys[count]] = false; } } // only print it out if there was a value to add.. if (added) { newLine.setLength(newLine.length() - 1); outs << newLine << endl; } } else { // we are removing our interested values from this line // special case - no values, remove the line.. if (!ourRhs->empty()) { // check if any of these values are down to remove. QString newLine(lastLhs); if (seenLhs.find(lastLhs) == seenLhs.end()) { newLine += " = "; seenLhs[lastLhs] = ""; } else { newLine += " += "; } int len = newLine.length(); bool added = false; for (QStringList::Iterator posIter = lastRhs.begin(); posIter != lastRhs.end();posIter++) { QMap<QString, bool>::iterator findEntry = ourRhs->find(*posIter); if (findEntry == ourRhs->end()) { // we do not want to remove it.. added = true; len += (*posIter).length() + 1; if (len > 80) { newLine += "\\\n\t"; len = 8; } newLine += (*posIter); newLine += ' '; } // else we have this value in our 'to remove list', so don't add it. } // only print it out if there was a value on it.. if (added) { newLine.setLength(newLine.length() - 1); outs << newLine << endl; } } } lastLhs.setLength(0); lastRhs.clear(); } } else { // can write this line out.. // not a match, not a multi line, outs << s << endl; } } if (add) { QDictIterator<QMap<QString, bool> > it(interest); for (; it.current(); ++it) { QString lhs = it.currentKey(); QMap<QString, bool>* ourRhs = it.current(); QString newLine(lhs); if (seenLhs.find(lhs) == seenLhs.end()) { newLine += " = "; seenLhs[lastLhs] = ""; } else { newLine += " += "; } int len = newLine.length(); bool added = false; QValueList<QString> keys = ourRhs->keys(); for (uint count = 0; count < keys.size(); count++) { if ((*ourRhs)[keys[count]]) { added = true; len += keys[count].length() + 1; if (len > 80) { newLine += "\\\n\t"; len = 8; } newLine += keys[count]; newLine += ' '; // set our value so we don't add it again. (*ourRhs)[keys[count]] = false; } } // only print it out if there was a value to add.. if (added) { newLine.setLength(newLine.length() - 1); outs << newLine << endl; } } } interest.setAutoDelete(true); interest.clear(); fin.close(); fout.close(); QDir().rename(fileName + "#", fileName); }
static QCString keywordToType(const char *keyword) { static bool init=TRUE; static QDict<void> flowKeywords(47); static QDict<void> typeKeywords(47); if (init) { flowKeywords.insert("break",(void*)0x8); flowKeywords.insert("case",(void*)0x8); flowKeywords.insert("catch",(void*)0x8); flowKeywords.insert("continue",(void*)0x8); flowKeywords.insert("default",(void*)0x8); flowKeywords.insert("do",(void*)0x8); flowKeywords.insert("else",(void*)0x8); flowKeywords.insert("finally",(void*)0x8); flowKeywords.insert("for",(void*)0x8); flowKeywords.insert("foreach",(void*)0x8); flowKeywords.insert("for each",(void*)0x8); flowKeywords.insert("goto",(void*)0x8); flowKeywords.insert("if",(void*)0x8); flowKeywords.insert("return",(void*)0x8); flowKeywords.insert("switch",(void*)0x8); flowKeywords.insert("throw",(void*)0x8); flowKeywords.insert("throws",(void*)0x8); flowKeywords.insert("try",(void*)0x8); flowKeywords.insert("while",(void*)0x8); flowKeywords.insert("@try",(void*)0x8); flowKeywords.insert("@catch",(void*)0x8); flowKeywords.insert("@finally",(void*)0x8); typeKeywords.insert("bool",(void*)0x8); typeKeywords.insert("char",(void*)0x8); typeKeywords.insert("double",(void*)0x8); typeKeywords.insert("float",(void*)0x8); typeKeywords.insert("int",(void*)0x8); typeKeywords.insert("long",(void*)0x8); typeKeywords.insert("object",(void*)0x8); typeKeywords.insert("short",(void*)0x8); typeKeywords.insert("signed",(void*)0x8); typeKeywords.insert("unsigned",(void*)0x8); typeKeywords.insert("void",(void*)0x8); typeKeywords.insert("wchar_t",(void*)0x8); typeKeywords.insert("size_t",(void*)0x8); typeKeywords.insert("boolean",(void*)0x8); typeKeywords.insert("id",(void*)0x8); typeKeywords.insert("SEL",(void*)0x8); typeKeywords.insert("string",(void*)0x8); typeKeywords.insert("nullptr",(void*)0x8); init=FALSE; } if (flowKeywords[keyword]) return "keywordflow"; if (typeKeywords[keyword]) return "keywordtype"; return "keyword"; }
void DbPlugin::getIndexHistory (BarData *barData, QDateTime &startDate) { QString s = "List"; QString s2; getData(s, s2); QStringList l = QStringList::split(":", s2, FALSE); if (! l.count()) return; QDict<Bar> lookup; lookup.setAutoDelete(TRUE); int loop; int count = 0; for (loop = 0; loop < (int) l.count(); loop = loop + 2) { float weight = l[loop + 1].toFloat(); if (weight == 0) weight = 1; loadIndexData(l[loop], lookup, startDate, weight, barRange, barLength); count++; } l.clear(); QDictIterator<Bar> it(lookup); for (; it.current(); ++it) { Bar *r = it.current(); if (r->getOI() == count) { r->setOpen(r->getOpen() / count); r->setHigh(r->getHigh() / count); r->setLow(r->getLow() / count); r->setClose(r->getClose() / count); if (r->getOpen() > r->getHigh()) r->setHigh(r->getOpen()); if (r->getOpen() < r->getLow()) r->setLow(r->getOpen()); if (r->getClose() > r->getHigh()) r->setHigh(r->getClose()); if (r->getClose() < r->getLow()) r->setLow(r->getClose()); r->getDateTimeString(FALSE, s); l.append(s); } else lookup.remove(it.currentKey()); } l.sort(); for (loop = l.count() - 1; loop > -1; loop--) { Bar *r = lookup.find(l[loop]); if (r) { QDateTime dt; r->getDate(dt); Bar tr; tr.setDate(dt); tr.setOpen(r->getOpen()); tr.setHigh(r->getHigh()); tr.setLow(r->getLow()); tr.setClose(r->getClose()); barData->prepend(tr); } } }
bool CppRefType::add(const QCString & t, QList<CppRefType> & l, bool incl) { if (t.isEmpty()) return FALSE; static QDict<char> cpp_builtin_types; if (cpp_builtin_types.count() == 0) { cpp_builtin_types.insert("unsigned", " "); cpp_builtin_types.insert("signed", " "); cpp_builtin_types.insert("char", " "); cpp_builtin_types.insert("short", " "); cpp_builtin_types.insert("int", " "); cpp_builtin_types.insert("long", " "); cpp_builtin_types.insert("float", " "); cpp_builtin_types.insert("double", " "); cpp_builtin_types.insert("bool", " "); cpp_builtin_types.insert("void", " "); } if (cpp_builtin_types[t] != 0) return TRUE; CppRefType * ref; Weight w = (incl) ? Medium : Low; for (ref = l.first(); ref; ref = l.next()) { if (ref->type.toString() == t) { if (w > ref->weight) ref->included = incl; return TRUE; } } l.append(new CppRefType(t, incl, w)); return TRUE; }
//===================================== // main program... //------------------------------------- int main(int argc,char*argv[]) { //===================================== // init variables... //------------------------------------- bool uniFont = false; bool noBorder = false; bool fastSetup = false; bool withDialog = false; bool yastMode = false; bool useHwData = false; bool fullScreen = false; bool setInfo = false; bool set3D = false; bool setXIdle = false; bool checkPacs = false; for (int n=0;n<argc;n++) { if (strcmp(argv[n],"-style") == 0) { globalStyle = (char*) malloc (sizeof(char) * 128); sprintf(globalStyle,"%s",argv[n+1]); break; } } //===================================== // check for root priviliges... //------------------------------------- if (! accessAllowed()) { fprintf (stderr,"xapi: only root can do this\n"); usage(); } //===================================== // start logging... //------------------------------------- logInit(); //===================================== // allocate main qt object... //------------------------------------- for (int i=0;i<argc;i++) { QString item (argv[i]); if ((item == "-h") || (item == "--help")) { logExit(); usage(); exit(0); } } QApplication app(argc,argv); //===================================== // get additional options... //------------------------------------- QString* idlePID = NULL; QString* cardName3D = NULL; QString* popUpDialog = NULL; QString* cardDriver = NULL; while (1) { int option_index = 0; static struct option long_options[] = { {"usehwdata" , 0 , 0 , 'u'}, {"fullscreen" , 0 , 0 , 'l'}, {"info" , 0 , 0 , 'i'}, {"yast" , 0 , 0 , 'y'}, {"checkpacs" , 0 , 0 , 'c'}, {"noborder" , 0 , 0 , 'n'}, {"3d" , 1 , 0 , 'D'}, {"driver" , 1 , 0 , 'd'}, {"frameWidth" , 1 , 0 , 'w'}, {"dialog" , 1 , 0 , 'O'}, {"unifont" , 0 , 0 , 'U'}, {"xidle" , 0 , 0 , 'x'}, {"pid" , 1 , 0 , 'p'}, {"fast" , 0 , 0 , 'f'}, {"help" , 0 , 0 , 'h'}, {0 , 0 , 0 , 0 } }; int c = getopt_long ( argc, argv, "uicD:fhxlw:d:yp:nUO:",long_options, &option_index ); if (c == -1) break; switch (c) { case 0: fprintf (stderr,"xapi: option %s", long_options[option_index].name); if (optarg) fprintf (stderr," with arg %s", optarg); fprintf (stderr,"\n"); break; case 'f': fastSetup = true; break; case 'U': uniFont = true; break; case 'O': withDialog = true; popUpDialog = new QString (optarg); break; case 'n': noBorder = true; break; case 'y': yastMode = true; break; case 'w': globalFrameWidth = atoi (optarg); break; case 'u': useHwData = true; break; case 'l': fullScreen = true; break; case 'i': setInfo = true; break; case 'c': checkPacs = true; break; case 'D': set3D = true; cardName3D = new QString (optarg); break; case 'p': idlePID = new QString (optarg); break; case 'd': cardDriver = new QString (optarg); break; case 'x': setXIdle = true; break; case 'h': logExit(); usage(); break; default: logExit(); exit(1); } } //===================================== // check if xapi should act as xidle //------------------------------------- if (setXIdle) { XTimeElapsed* idleTimer = new XTimeElapsed ( idlePID ); app.setMainWidget (idleTimer); idleTimer->show(); return app.exec(); } //===================================== // check md5 sum of current config //------------------------------------- if ((! setInfo) && (! set3D) && (! checkPacs) && (! useHwData) && (! fastSetup) ) { bool createMD5sum = false; QFileInfo xc (MD5CONFIG); if (xc.exists()) { QString mD5Sum = qx(MD5,STDOUT,1,"%s",XCONFIG); QFile mHandle (MD5CONFIG); if (mHandle.open(IO_ReadOnly)) { QString compare; mHandle.readLine(compare,MAX_LINE_LENGTH); mHandle.close(); compare = compare.stripWhiteSpace(); if (compare == mD5Sum) { fastSetup = true; } else { fastSetup = false; } } } else { fastSetup = false; } if (createMD5sum) { QString mD5Sum = qx(MD5,STDOUT,1,"%s",XCONFIG); QFile mHandle (MD5CONFIG); if (mHandle.open(IO_WriteOnly)) { mHandle.writeBlock (mD5Sum.ascii(),mD5Sum.length()); mHandle.close(); } } } //===================================== // check option combinations... //------------------------------------- if (useHwData == true) { fastSetup = false; } //===================================== // set root window cursor to the watch //------------------------------------- setMouseCursor ("watch"); //===================================== // init program... //------------------------------------- QWidget::WFlags wflags = Qt::WType_TopLevel; if (noBorder) { wflags |= Qt::WStyle_Customize | Qt::WStyle_NoBorder; } if (uniFont) { QFont currentFont = QFont( "Helvetica", 12 ); currentFont.setStyleHint( QFont::SansSerif, QFont::PreferBitmap ); currentFont.setRawName (UNIFONT); qApp->setFont (currentFont); } xapi = new XFrame ( globalFrameWidth, wflags ); if (setInfo) { signal (SIGHUP ,gotKill); signal (SIGKILL,gotKill); signal (SIGABRT,gotKill); signal (SIGTERM,gotKill); XInfo infoBox (xapi); infoBox.showIntroBox(); logExit(); setMouseCursor (); exit ( infoBox.returnCode() ); } if (set3D) { XInfo infoBox (xapi); infoBox.show3DBox (*cardName3D,cardDriver); printf("%d\n",infoBox.returnCode()); logExit(); setMouseCursor (); exit ( infoBox.returnCode() ); } if (fastSetup) { xapi->fastSetup = true; } if (useHwData) { xapi->useHwData = true; } if (fullScreen) { xapi->fullScreen = true; } if (yastMode) { xapi->yastMode = true; } //===================================== // check 3D environment //------------------------------------- XStringList packageInfo ( qx (GET3D,STDOUT) ); packageInfo.setSeperator (":"); QString package = packageInfo.getList().at(0); QString real3d = packageInfo.getList().at(1); QString soft3d = packageInfo.getList().at(2); QString general = packageInfo.getList().at(3); QString active = packageInfo.getList().at(4); QString answer = packageInfo.getList().at(5); QString flag = packageInfo.getList().at(6); global3DActive = active.toInt(); QString status1 ("1"); if (checkPacs) { // ... // if the 3D Answer was no, there is no need // to check for any packages or scripts // --- if (answer == "no") { setMouseCursor (); exit (0); } // ... // install the missing packages using YaST2 // sw_single mode // --- if (package != "<none>") { if (setMessage("InstallPackage",xapi)) { status1 = qx ( GETINSTALLED,STDOUT,1,"%s",package.ascii() ); } } setMouseCursor (); exit (0); } //===================================== // remove lilo code file... //------------------------------------- unlink (LILOCODE); //===================================== // init main frame... //------------------------------------- if (! xapi->frameInitialized()) { xapi->setFrame (); } //===================================== // set signal handler... //------------------------------------- signal (SIGUSR2,SIG_IGN); signal (SIGINT ,gotInterrupted); //===================================== // init dialogs... //------------------------------------- XIntro* intro = new XIntro(); XAccessX* xaccess = new XAccessX(); XMouse* mouse = new XMouse(); XCard* card = new XCard(); XDesktop* desktop = new XDesktop(); XDisplayGeometry* geo = new XDisplayGeometry(); XKeyboard* keyboard = new XKeyboard(); XLayout* layout = new XLayout(); XMonitor* monitor = new XMonitor(); XMultihead* multi = new XMultihead(); XTablet* tablet = new XTablet(); XTouchScreen* toucher = new XTouchScreen(); XOpenGL* opengl = new XOpenGL(); XVirtual* virtuals = new XVirtual(); Xvnc* vnc = new Xvnc(); intro -> addTo (xapi); xaccess -> addTo (xapi,intro); mouse -> addTo (xapi,intro); card -> addTo (xapi,intro); desktop -> addTo (xapi,intro); geo -> addTo (xapi,intro); keyboard -> addTo (xapi,intro); layout -> addTo (xapi,intro); monitor -> addTo (xapi,intro); multi -> addTo (xapi,intro); tablet -> addTo (xapi,intro); toucher -> addTo (xapi,intro); opengl -> addTo (xapi,intro); virtuals -> addTo (xapi,intro); vnc -> addTo (xapi,intro); //===================================== // save intro pointer... //------------------------------------- introPointer = intro; //===================================== // make sure the serverlayout structure // is created at least one time //------------------------------------- XLayout* layoutDialog; layoutDialog = (XLayout*) intro -> retrieve (Layout); layoutDialog -> setupLayout(); //===================================== // make sure the card dialog was build // in init stage //------------------------------------- XCard* cardDialog; cardDialog = (XCard*) intro -> retrieve (Card); cardDialog -> showSetupWindow (false); cardDialog -> slotRun (Card); cardDialog -> showSetupWindow (true); //===================================== // call resetPage of the desktop dialog // to check for framebuffer usage //------------------------------------- XDesktop* desktopDialog; desktopDialog = (XDesktop*) intro -> retrieve (Colors); desktopDialog -> resetPage ( PAGE_RELOAD ); //===================================== // add margin around pushbutton texts // this is only needed for QT3 //------------------------------------- #if 1 QObject* obj; QObjectList* l = xapi->queryList( "QPushButton" ); QObjectListIt it( *l ); QDict<char>* mText = xapi->getTextPointer(); while ( (obj=it.current()) != 0 ) { ++it; QPushButton* btn = (QPushButton*) obj; QString text = btn->text(); if (! text.isNull()) { QDictIterator<char> n (*mText); for (; n.current(); ++n) { if (n.current() == text) { QString* newText = new QString(); QTextOStream (newText) << " " << text << " "; mText->replace (n.currentKey(),*newText); break; } } QString addText; QTextOStream (&addText) << " " << text << " "; btn->setText (addText); } } delete l; // ... // special keys which are used dynamically on widgets // with initially other texts // --- QList<char> keyList; keyList.append ( "finish" ); keyList.append ( "Next" ); QListIterator<char> io ( keyList ); for (; io.current(); ++io) { QString key ( io.current() ); QString curText (mText->operator[](key)); QString* newText = new QString(); QTextOStream (newText) << " " << curText << " "; mText->replace (key,*newText); } #endif //===================================== // remove xfine cache directory... //------------------------------------- removeXFineCache(); //===================================== // go to main event loop... //------------------------------------- app.setMainWidget(xapi); xapi -> show(); xapi -> enterEvent ( 0 ); xapi -> activateFirstItem(); setMouseCursor(); if (! withDialog) { intro -> checkDetected(); } else { if ( *popUpDialog == "Monitor" ) { xapi -> runDialog (Monitor); } else if ( *popUpDialog == "Card") { xapi -> runDialog (Card); } else { fprintf (stderr,"xapi: no such dialog: %s\n",popUpDialog->ascii()); exit (1); } } return app.exec(); }
int main( int argc, char **argv ) { msgSender=0; // Initialize the mime++ library DwInitialize(); KApplication *a=new KApplication ( argc, argv, "krn" ); //a.enableSessionManagement(); app=a; conf=a->getConfig(); checkConf(); nls=a->getLocale(); keys = new KStdAccel(conf); kbp=new KBusyPtr(); msgSender=new KRNSender(); msgSender->readConfig(); msgSender->setMethod(KMSender::smSMTP); KMMessage::readConfig(); addrBook=new KMAddrBook(); addrBook->readConfig(); addrBook->load(); // Create our directory. If it exists, no problem // Should do some checking, though testDir( "/share" ); testDir( "/share/config" ); testDir( "/share/apps" ); testDir( "/share/apps/krn" ); testDir( "/share/apps/krn/cache" ); testDir( "/share/apps/krn/groupinfo" ); testDir( "/share/apps/krn/outgoing" ); krnpath = KApplication::localkdedir() + "/share/apps/krn/"; mkdir (krnpath.data(),S_IREAD|S_IWRITE|S_IEXEC); cachepath=krnpath+"/cache/"; mkdir (cachepath.data(),S_IREAD|S_IWRITE|S_IEXEC); groupinfopath=krnpath+"/groupinfo/"; mkdir (groupinfopath.data(),S_IREAD|S_IWRITE|S_IEXEC); outpath=krnpath+"outgoing/"; mkdir (outpath.data(),S_IREAD|S_IWRITE|S_IEXEC); // Create the articles database artinfopath=krnpath+"/artinfo.db"; artdb=gdbm_open(artinfopath.data(),0,GDBM_WRCREAT | GDBM_FAST,448,0); artinfopath=krnpath+"/refs.db"; refsdb=gdbm_open(artinfopath.data(),0,GDBM_WRCREAT | GDBM_FAST,448,0); artinfopath=krnpath+"/scores.db"; scoredb=gdbm_open(artinfopath.data(),0,GDBM_WRCREAT | GDBM_FAST,448,0); if ((!artdb) || (!refsdb) || (!scoredb)) //the gdbm open failed! { int i=KMsgBox::yesNo(0,"KRN - Error", "I have detected another Krn running\n" "Do you REALLY want to continue?\n" "If you are sure there isn't one, press \"Yes\"\n" "But if there *is* another one, it's going to be UGLY\n"); } // Fill the unreadDict datum key=gdbm_firstkey ( artdb ); datum nextkey; while ( key.dptr ) { unreadDict.insert(key.dptr,key.dptr); nextkey = gdbm_nextkey ( artdb, key ); free (key.dptr); key = nextkey; }; // Load the rules ruleFile=new KSimpleConfig(krnpath+"/rules"); Rule::updateGlobals(); Groupdlg *k=new Groupdlg(); main_widget = k; //insert this: if (a->isRestored()) k->restore(1); a->setMainWidget( k ); a->setTopWidget( k ); k->setMinimumSize( 250, 250 ); k->show(); a->exec(); expireCache(); // k->close(); gdbm_reorganize(artdb); gdbm_reorganize(refsdb); gdbm_reorganize(scoredb); gdbm_close(artdb); gdbm_close(refsdb); gdbm_close(scoredb); // delete k; }
//==================================== // removeInputDevice //------------------------------------ int SaXManipulateDevices::removeInputDevice (int id) { // .../ //! remove the input device of the given id (id) and return the //! previous input device id. The current input device id is set //! to this previous input device id. If the input device does //! not exist or the input device id is the core (0|1) mouse or //! keyboard the method will return (-1) // ---- if (! inputHandlingAllowed) { return -1; } //==================================== // don't allow removing the core entry //------------------------------------ if (id <= 1) { excInvalidArgument (id); qError (errorString(),EXC_INVALIDARGUMENT); return -1; } //==================================== // remove input devices... //------------------------------------ if (! mInput->delID (id)) { return -1; } //==================================== // select previous input device //------------------------------------ for (int i=1;i<=2;i++) { QDict<QString>* data = mInput->getTablePointer (i); if ((data) && (! data->isEmpty())) { mInput->setID (i); break; } } //==================================== // check input device type //------------------------------------ bool isMouse = true; QString baseItem ("InputDevice"); QString baseID ("Mouse"); if (mInput->getCurrentID() % 2 == 0) { isMouse = false; baseItem = "Keyboard"; baseID = "Keyboard"; } //==================================== // update server layout //------------------------------------ QString result; QString IDstring; IDstring.sprintf ("%d",id); QString deviceList = mLayout -> getItem (baseItem); QStringList optlist = QStringList::split ( ",", deviceList ); for ( QStringList::Iterator in = optlist.begin(); in != optlist.end(); ++in ) { QString item (*in); if (item == QString(baseID + "["+IDstring+"]")) { continue; } QRegExp identifier ("\\[(.+)\\]"); int pos = identifier.search (item); if (pos >= 0) { int curID = identifier.cap(1).toInt(); if ( curID > id ) { QString newMK; newMK.sprintf ("%s[%d],",baseID.ascii(),curID - 2); result.append ( newMK ); } else { result.append (item+","); } } } result.remove (result.length()-1,result.length()); mLayout -> setItem (baseItem,result); return mInput -> getCurrentID(); }
/*! This will create a contents file (index.hhc) and a index file (index.hhk) * and write the header of those files. * It also creates a project file (index.hhp) * \sa finalize() */ void HtmlHelp::initialize() { const char *str = Config_getString("CHM_INDEX_ENCODING"); if (!str) str = "CP1250"; // use safe and likely default m_fromUtf8 = portable_iconv_open(str,"UTF-8"); if (m_fromUtf8==(void *)(-1)) { err("Error: unsupported character conversion for CHM_INDEX_ENCODING: '%s'->'UTF-8'\n", str); exit(1); } /* open the contents file */ QCString fName = Config_getString("HTML_OUTPUT") + "/index.hhc"; cf = new QFile(fName); if (!cf->open(IO_WriteOnly)) { err("Could not open file %s for writing\n",fName.data()); exit(1); } /* Write the header of the contents file */ cts.setDevice(cf); cts << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n" "<HTML><HEAD></HEAD><BODY>\n" "<OBJECT type=\"text/site properties\">\n" "<param name=\"FrameName\" value=\"right\">\n" "</OBJECT>\n" "<UL>\n"; /* open the contents file */ fName = Config_getString("HTML_OUTPUT") + "/index.hhk"; kf = new QFile(fName); if (!kf->open(IO_WriteOnly)) { err("Could not open file %s for writing\n",fName.data()); exit(1); } /* Write the header of the contents file */ kts.setDevice(kf); kts << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n" "<HTML><HEAD></HEAD><BODY>\n" "<OBJECT type=\"text/site properties\">\n" "<param name=\"FrameName\" value=\"right\">\n" "</OBJECT>\n" "<UL>\n"; /* language codes for Html help 0x405 Czech 0x406 Danish 0x413 Dutch 0xC09 English (Australia) 0x809 English (Britain) 0x1009 English (Canada) 0x1809 English (Ireland) 0x1409 English (New Zealand) 0x1C09 English (South Africa) 0x409 English (United States) 0x40B Finnish 0x40C French 0x407 German 0x408 Greece 0x40E Hungarian 0x410 Italian 0x814 Norwegian 0x415 Polish 0x816 Portuguese(Portugal) 0x416 Portuguese(Brazil) 0x419 Russian 0x80A Spanish(Mexico) 0xC0A Spanish(Modern Sort) 0x40A Spanish(Traditional Sort) 0x41D Swedish 0x41F Turkey 0x411 Japanese 0x412 Korean 0x804 Chinese (PRC) 0x404 Chinese (Taiwan) New LCIDs: 0x421 Indonesian 0x41A Croatian 0x418 Romanian 0x424 Slovenian 0x41B Slovak 0x422 Ukrainian 0x81A Serbian (Serbia, Latin) 0x403 Catalan 0x427 Lithuanian 0x436 Afrikaans 0x42A Vietnamese 0x429 Persian (Iran) 0xC01 Arabic (Egypt) - I don't know which version of arabic is used inside translator_ar.h , so I have chosen Egypt at random */ s_languageDict.setAutoDelete(TRUE); s_languageDict.clear(); s_languageDict.insert("czech", new QCString("0x405 Czech")); s_languageDict.insert("danish", new QCString("0x406 Danish")); s_languageDict.insert("dutch", new QCString("0x413 Dutch")); s_languageDict.insert("finnish", new QCString("0x40B Finnish")); s_languageDict.insert("french", new QCString("0x40C French")); s_languageDict.insert("german", new QCString("0x407 German")); s_languageDict.insert("greek", new QCString("0x408 Greece")); s_languageDict.insert("hungarian", new QCString("0x40E Hungarian")); s_languageDict.insert("italian", new QCString("0x410 Italian")); s_languageDict.insert("norwegian", new QCString("0x814 Norwegian")); s_languageDict.insert("polish", new QCString("0x415 Polish")); s_languageDict.insert("portuguese", new QCString("0x816 Portuguese(Portugal)")); s_languageDict.insert("brazil", new QCString("0x416 Portuguese(Brazil)")); s_languageDict.insert("russian", new QCString("0x419 Russian")); s_languageDict.insert("spanish", new QCString("0x40A Spanish(Traditional Sort)")); s_languageDict.insert("swedish", new QCString("0x41D Swedish")); s_languageDict.insert("turkish", new QCString("0x41F Turkey")); s_languageDict.insert("japanese", new QCString("0x411 Japanese")); s_languageDict.insert("japanese-en", new QCString("0x411 Japanese")); s_languageDict.insert("korean", new QCString("0x412 Korean")); s_languageDict.insert("korean-en", new QCString("0x412 Korean")); s_languageDict.insert("chinese", new QCString("0x804 Chinese (PRC)")); s_languageDict.insert("chinese-traditional", new QCString("0x404 Chinese (Taiwan)")); // new LCIDs s_languageDict.insert("indonesian", new QCString("0x412 Indonesian")); s_languageDict.insert("croatian", new QCString("0x41A Croatian")); s_languageDict.insert("romanian", new QCString("0x418 Romanian")); s_languageDict.insert("slovene", new QCString("0x424 Slovenian")); s_languageDict.insert("slovak", new QCString("0x41B Slovak")); s_languageDict.insert("ukrainian", new QCString("0x422 Ukrainian")); s_languageDict.insert("serbian", new QCString("0x81A Serbian (Serbia, Latin)")); s_languageDict.insert("catalan", new QCString("0x403 Catalan")); s_languageDict.insert("lithuanian", new QCString("0x427 Lithuanian")); s_languageDict.insert("afrikaans", new QCString("0x436 Afrikaans")); s_languageDict.insert("vietnamese", new QCString("0x42A Vietnamese")); s_languageDict.insert("persian", new QCString("0x429 Persian (Iran)")); s_languageDict.insert("arabic", new QCString("0xC01 Arabic (Egypt)")); }
Indicator * CUS::calculate () { Config config; QStringList varList; QDict<PlotLine> lines; lines.setAutoDelete(TRUE); checkIncludes(); Indicator *output = new Indicator; output->setDateFlag(dateFlag); output->setLogScale(logScale); int loop; for (loop = 0; loop < (int) formulaList.count(); loop++) { // check if whole line is a comment QString s = formulaList[loop].left(2); if ( ! s.compare("//")) continue; if (formulaList[loop].contains(":=")) { QStringList l = QStringList::split(":=", formulaList[loop], FALSE); if (l.count() != 2) { qDebug("CUS::calculate: line %i parm missing", loop); return output; } QString var = l[0].stripWhiteSpace(); if (varList.findIndex(var) != -1) { qDebug("CUS::calculate: line %i duplicate variable: %s", loop, var.latin1()); return output; } varList.append(var); QStringList l2 = QStringList::split("(", l[1], FALSE); if (l2.count() != 2) { qDebug("CUS::calculate: line %i bad indicator format", loop); return output; } QString plugin = l2[0].stripWhiteSpace(); QString parms = l2[1]; parms.truncate(parms.find(")", 0, TRUE)); parms = parms.stripWhiteSpace(); while(parms.contains(" ")) parms = parms.remove(parms.find(" ", 0, TRUE), 1); IndicatorPlugin *plug = config.getIndicatorPlugin(plugin); if (! plug) { qDebug("CUS::calculate: %s plugin not loaded", plugin.latin1()); config.closePlugin(plugin); return output; } plug->setIndicatorInput(data); l = QStringList::split(",", parms, FALSE); int loop2; QPtrList<PlotLine> inList; inList.setAutoDelete(FALSE); for (loop2 = 0; loop2 < (int) l.count(); loop2++) { if (varList.findIndex(l[loop2]) != -1) inList.append(lines.find(l[loop2])); else { int itype = inputTypeList.findIndex(l[loop2]); if (itype != -1) { PlotLine *in = data->getInput((BarData::InputType) itype); if (! in) { qDebug("CUS::calculate:line%i parm%i: input not found", loop, loop2); return output; } lines.replace(l[loop2], in); inList.append(in); } } } PlotLine *out = plug->calculateCustom(parms, inList); if (! out) { qDebug("CUS::calculate: line %i: no PlotLine returned: %s", loop, parms.latin1()); config.closePlugin(plugin); return output; } lines.replace(var, out); } createPlot(formulaList[loop], lines, output); } return output; }
//==================================== // remove and reorganize section ID... //------------------------------------ bool SaXStorage::delID ( int id ) { // .../ //! remove a data record and adapt the Identifier strings //! to provide consistency // ---- if ((! mData.at (id)) || (mData.at(id)->isEmpty())) { return false; } int step = 1; int type = SAX_DESKTOP_TYPE; QString ident = *mData.at(id)->find ("Identifier"); if (ident.contains ("Mouse")) { type = SAX_POINTER_TYPE; step = 2; } if (ident.contains ("Keyboard")) { type = SAX_KEYBOARD_TYPE; step = 2; } int index = -1; QListIterator < QDict<QString> > in (mData); for (; in.current(); ++in) { index++; QDict<QString>* data = in.current(); QString* ident = data->find ("Identifier"); if (! ident) { continue; } int curType = SAX_DESKTOP_TYPE; if (ident->contains("Mouse")) { curType = SAX_POINTER_TYPE; } if (ident->contains("Keyboard")) { curType = SAX_KEYBOARD_TYPE; } if ((data->isEmpty()) || (index <= id) || (curType != type)) { continue; } QString oIDstr; QString nIDstr; oIDstr.sprintf ("%d",index); nIDstr.sprintf ("%d",index - step); QString mouseIDstr ("Mouse[" + oIDstr +"]"); QString keyboardIDstr ("Keyboard["+ oIDstr +"]"); QString deviceIDstr ("Device[" + oIDstr +"]"); QString monitorIDstr ("Monitor[" + oIDstr +"]"); QString screenIDstr ("Screen[" + oIDstr +"]"); QDictIterator<QString> it (*data); for (; it.current(); ++it) { QString val = *it.current(); QString key = it.currentKey(); if (val == mouseIDstr) { QString* nMouseIDstr = new QString ("Mouse["+nIDstr+"]"); data -> replace (key,nMouseIDstr); } if (val == keyboardIDstr) { QString* nKbdIDstr = new QString ("Keyboard["+nIDstr+"]"); data -> replace (key,nKbdIDstr); } if (val == deviceIDstr) { QString* nDeviceIDstr = new QString ("Device["+nIDstr+"]"); data -> replace (key,nDeviceIDstr); } if (val == monitorIDstr) { QString* nMonitorIDstr = new QString ("Monitor["+nIDstr+"]"); data -> replace (key,nMonitorIDstr); } if (val == screenIDstr) { QString* nScreenIDstr = new QString ("Screen["+nIDstr+"]"); data -> replace (key,nScreenIDstr); } if ((key == "Screen") && (val == oIDstr)) { QString* nScreenIDstr = new QString (nIDstr); data -> replace (key,nScreenIDstr); } } } mData.remove (id); if ((mData.at(id)) && (mData.at(id)->isEmpty())) { mData.remove (id); } return true; }
PlotLine * SYMBOL::getSYMBOL () { QString s; Config config; config.getData(Config::IndexPath, s); DBIndex index; index.open(s); PlotLine *line = new PlotLine(); DbPlugin db; if (db.open(symbol, &index)) { db.close(); index.close(); return line; } QDateTime date; data->getDate(0, date); QString ts; config.getData(Config::BarLength, ts); db.setBarLength((BarData::BarLength) ts.toInt()); config.getData(Config::Bars, ts); db.setBarRange(ts.toInt()); BarData *recordList = new BarData(symbol); QDateTime dt = QDateTime::currentDateTime(); db.getHistory(recordList, dt); QDict<Setting> dict; dict.setAutoDelete(TRUE); int loop; ts = "Close"; QString ts2; for (loop = 0; loop < (int) recordList->count(); loop++) { Setting *r = new Setting; ts2 = QString::number(recordList->getClose(loop)); r->setData(ts, ts2); recordList->getDate(loop, dt); QString s = dt.toString("yyyyMMddhhmmss"); dict.insert(s, r); } double val = 0; for (loop = 0; loop < (int) data->count(); loop++) { data->getDate(loop, dt); QString s = dt.toString("yyyyMMddhhmmss"); Setting *r2 = dict[s]; if (r2) { val = r2->getDouble(ts); line->append(val); } } delete recordList; db.close(); index.close(); line->setScaleFlag(TRUE); return line; }
void Spread::getHistory (BarData *barData, QDateTime &startDate, QString &fs, QString &ss, int barRange, BarData::BarLength barLength) { // get the first symbol bars QString s; DbPlugin db; if (db.openChart(fs)) { qDebug("DbPlugin::getSpreadHistory: cannot open first symbol chart"); db.close(); return; } BarData *bar = new BarData(fs); bar->setBarLength(barLength); db.setBarRange(barRange); db.getHistory(bar, startDate); db.close(); // get the second symbol bars if (db.openChart(ss)) { qDebug("DbPlugin::getSpreadHistory: cannot open second symbol chart"); db.close(); delete bar; return; } BarData *bar2 = new BarData(ss); bar2->setBarLength(barLength); db.setBarRange(barRange); db.getHistory(bar2, startDate); db.close(); // create lookup dict for first symbol bars QDict<Bar> lookup; lookup.setAutoDelete(TRUE); int loop; for (loop = 0; loop < bar->count(); loop++) { Bar *r = new Bar; QDateTime dt; bar->getDate(loop, dt); r->setDate(dt); r->setClose(bar->getClose(loop)); r->getDateTimeString(FALSE, s); lookup.insert(s, r); } // match all second symbol bars for (loop = bar2->count() - 1; loop > -1; loop--) { Bar r; QDateTime dt; bar2->getDate(loop, dt); s = dt.toString("yyyyMMddhhmmss"); Bar *tr = lookup.find(s); if (tr) { double t = tr->getClose() - bar2->getClose(loop); r.setDate(dt); r.setOpen(t); r.setHigh(t); r.setLow(t); r.setClose(t); barData->prepend(r); } } delete bar; delete bar2; }
//===================================== // XMouse virtual slots... //------------------------------------- bool XMouse::slotRun (int index) { if (XTemplate::slotRun (index)) { // log(L_INFO,"XMouse::slotRun() called: %d\n",index); // ... // this function is called if the mouse page is activated. // use this function to init the dialog with the current // setup of the mice // --- XWrapPointer< QDict<char> > mText (mTextPtr); mStatus -> message (mText["RunXMouse"]); mFrame -> nextButton() -> setText (mText["finish"]); // ... // get the mFiles pointer wrapper from the Intro // object which has read all the data files // --- QDict<XFile>* mFilePtr = mIntro->getFiles(); XWrapFile < QDict<XFile> > mFiles (mFilePtr); // ... // fill the mouseList listbox with the // configured simple pointer devices // --- mouseList -> clear(); mIndexList.clear(); QString topic; XData* sysData; QDict<char> mouseInfo; int mice; mice = mFiles["sys_INPUT"]->getDeviceCount(); int count = -1; for (int n=0; n<mice; n++) { count += 2; sysData = mFiles["sys_INPUT"] -> getDevice(count); if (! sysData) { continue; } mouseInfo = sysData -> getData(); if (QString(mouseInfo["InputFashion"]).isNull()) { mouseInfo.insert ("InputFashion","Mouse"); } if (QString(mouseInfo["InputFashion"]) != "Mouse") { continue; } QString topic (mouseInfo["Name"]); XStringList name (mouseInfo["Name"]); name.setSeperator (";"); QList<char> mouseName = name.getList(); if (mouseName.count() == 2) { topic.sprintf("%s %s",mouseName.at(0),mouseName.at(1)); } QString topicStream; QTextOStream (&topicStream) << topic << " ( " << mouseInfo["Protocol"] << " " << mText["at"] << " " << mouseInfo["Device"] << " )"; topic = topicStream; int* index = (int*) malloc (sizeof(int)); *index = count; mIndexList.append (index); mouseList -> insertItem ( QPixmap(PIXINTROMOUSE),topic ); } // ... // enable/disable configure/remove buttons // and select first element of the listbox // --- if (mice > 0) { mDel -> setDisabled ( false ); mSetup -> setDisabled ( false ); mouseList -> setCurrentItem ( 0 ); mouseList -> setSelected ( 0,true ); mSelected = 0; } else { mDel -> setDisabled ( true ); mSetup -> setDisabled ( true ); } } return (TRUE); }
/** * Reads all path= entries from the smb.conf file * and fills the sharedPaths dict with the values */ bool KSambaSharePrivate::readSmbConf() { QFile f(smbConf); kdDebug(7000) << "KSambaShare::readSmbConf " << smbConf << endl; if (!f.open(IO_ReadOnly)) { kdError() << "KSambaShare: Could not open " << smbConf << endl; return false; } sharedPaths.clear(); QTextStream s(&f); bool continuedLine = false; // is true if the line before ended with a backslash QString completeLine; while (!s.eof()) { QString currentLine = s.readLine().stripWhiteSpace(); if (continuedLine) { completeLine += currentLine; continuedLine = false; } else completeLine = currentLine; // is the line continued in the next line ? if ( completeLine[completeLine.length()-1] == '\\' ) { continuedLine = true; // remove the ending backslash completeLine.truncate( completeLine.length()-1 ); continue; } // comments or empty lines if (completeLine.isEmpty() || '#' == completeLine[0] || ';' == completeLine[0]) { continue; } // parameter int i = completeLine.find('='); if (i>-1) { QString name = completeLine.left(i).stripWhiteSpace().lower(); QString value = completeLine.mid(i+1).stripWhiteSpace(); if (name == KGlobal::staticQString("path")) { // Handle quotation marks if ( value[0] == '"' ) value.remove(0,1); if ( value[value.length()-1] == '"' ) value.truncate(value.length()-1); // Normalize path if ( value[value.length()-1] != '/' ) value += '/'; bool b = true; sharedPaths.insert(value,&b); kdDebug(7000) << "KSambaShare: Found path: " << value << endl; } } } f.close(); return true; }
//==================================== // addInputDevice //------------------------------------ int SaXManipulateDevices::addInputDevice (const char* fashion) { // .../ //! add a new input device at the end of the current input //! device list. The new input device ID is returned. pointer //! input devices are following the odd order (1,3,5,7...) //! whereas keyboard input devices use the even order (0,2,4,6...) // ---- if (! inputHandlingAllowed) { return -1; } //==================================== // check fashion string... //------------------------------------ QString inputFashion (fashion); if ( (inputFashion != SAX_INPUT_TOUCHPANEL) && (inputFashion != SAX_INPUT_TABLET) && (inputFashion != SAX_INPUT_PEN) && (inputFashion != SAX_INPUT_ERASER) && (inputFashion != SAX_INPUT_MOUSE) && (inputFashion != SAX_INPUT_VNC) && (inputFashion != SAX_INPUT_KEYBOARD) ) { excWrongInputFashion (fashion); qError (errorString(),EXC_WRONGINPUTFASHION); return -1; } //==================================== // determine new input device ID... //------------------------------------ QString baseID ("Mouse"); QString baseDriver ("mouse"); if (fashion == SAX_INPUT_VNC) { baseDriver = "rfbmouse"; } QDict<QString>* data = mInput->getTablePointer (0); int newID = mInput->getCount (true) * 2 + 1; if ((data) && (! data->isEmpty())) { baseDriver ="kbd"; if (fashion == SAX_INPUT_VNC) { baseDriver = "rfbkeyb"; } baseID = "Keyboard"; newID = mInput->getCount (true) * 2; } if (! mInput -> addID (newID)) { return -1; } //==================================== // add new input device section... //------------------------------------ QString newIDstring; newIDstring.sprintf ("%d",newID); mInput -> setItem ("Identifier",baseID + "[" + newIDstring + "]"); mInput -> setItem ("InputFashion",fashion); //==================================== // set some defaults... //------------------------------------ mInput -> setItem ("Driver",baseDriver); //==================================== // update server layout //------------------------------------ if (baseID == "Mouse") { QString inputDevice; QTextOStream (&inputDevice) << mLayout -> getItem ("InputDevice") << ",Mouse[" << newIDstring << "]"; mLayout -> setItem ("InputDevice",inputDevice); } if (baseID == "Keyboard") { QString inputDevice; QTextOStream (&inputDevice) << mLayout -> getItem ("Keyboard") << ",Keyboard[" << newIDstring << "]"; mLayout -> setItem ("Keyboard",inputDevice); } return mInput -> getCurrentID(); }
void ColorSchema::addSchema() { numb2schema.insert(numb,this); path2schema.insert(path.data(),this); }
int DoIt(const char* outFile, const char* regFile, const char* maskFile, const char* resultFile, int mask_x, int mask_y, int mask_size_x, int mask_size_y) { // Read maskfile FILE *mfp = fopen(maskFile, "r"); // FILE *mfp=fopen("/project/geoaida/tmp/mask.pbm","r"); if (!mfp) { fprintf(stderr, "mask file %s not found\n", maskFile); return 1; } GaMaskImage mask; mask.read(mfp); fclose(mfp); // read regionfile // QFile rfp("/project/geoaida/tmp/reglist.dest"); QFile rfp(regFile); if (!rfp.open(IO_ReadOnly)) { fprintf(stderr, "regionfile %s not founed\n", regFile); return 1; } // Read and process regions QList < ArgDict > regionList; regionList.setAutoDelete(true); MLParser parser(&rfp); QString keywords[] = { "region", "" }; const MLTagTable nodeTagTable(keywords); const int TOK_REGION = 1; int tag; do { tag = parser.tag(nodeTagTable); ArgDict *args; switch (tag) { case TOK_REGION:{ args = parser.args(); if (processRegion (*args, mask, mask_x, mask_y, mask_size_x, mask_size_y)) regionList.append(args); else delete args; break; } case -TOK_REGION: break; case MLParser::END_OF_FILE: break; default:{ args = parser.args(); delete args; qDebug("Unknown keyword %s in line %d", parser.lasttagstr().latin1(), parser.lineNumber()); break; } } } while (tag != MLParser::END_OF_FILE); rfp.close(); // Write labels if (outFile) { if (labelImageDict.count() > 1) { fprintf(stderr, "regionmask: Cannot generate multiple labelfiles\n"); return 1; } else { if (regionList.count()>0) { ArgDict *dict = regionList.first(); QString *oldfile = (*dict)["file"]; QString *labelfile = new QString(); if (resultFile) labelfile->sprintf("%s", resultFile); else labelfile->sprintf("%s.plm", outFile); LabelImage *im = labelImageDict.take(*oldfile); labelImageDict.replace(*labelfile, im); QListIterator < ArgDict > it(regionList); for (; it.current(); ++it) { ArgDict *argDict = it.current(); assert(argDict); argDict->replace("file", labelfile); } } } rfp.setName(outFile); } else { printf("regionmask: overwriting %s\n",regFile); outFile = regFile; } QDictIterator < LabelImage > git(labelImageDict); if (regionList.count()>0) { for (; git.current(); ++git) { LabelImage *im = git.current(); qDebug("Writing %s", git.currentKey().latin1()); im->image.write(git.currentKey().latin1()); } } // Write regions if (!rfp.open(IO_WriteOnly)) { fprintf(stderr, "cannot open regionfile %s for writing\n", outFile); return 1; } if (regionList.count()>0) { QListIterator < ArgDict > it(regionList); QTextStream ts(&rfp); for (; it.current(); ++it) { ArgDict *argDict = it.current(); assert(argDict); ts << "<region "; ts << (*argDict); ts << " />" << endl; } } rfp.close(); labelImageDict.setAutoDelete(true); labelImageDict.clear(); regionList.setAutoDelete(true); return 0; }
int DoIt(const char* outFile, const char* regFile, const char* maskFile, const char* resultFile, int mask_x, int mask_y, int mask_size_x, int mask_size_y) { // Read maskfile FILE *mfp = fopen(maskFile, "r"); // FILE *mfp=fopen("/project/geoaida/tmp/mask.pbm","r"); if (!mfp) { fprintf(stderr, "mask file %s not found\n", maskFile); return 1; } GaMaskImage mask; mask.read(mfp); fclose(mfp); QList<ArgDict> *regionSourceList=readRegionFile(regFile); if (!regionSourceList) return 1; QList<ArgDict> regionList; // Process regions for (ArgDict* arg = regionSourceList->first(); arg; arg=regionSourceList->next()) { ArgDict* args=new ArgDict(*arg); if (processRegion (*args, mask, mask_x, mask_y, mask_size_x, mask_size_y)) regionList.append(args); else delete args; } // Write labels QFile rfp(outFile ? outFile : regFile); if (outFile) { if (labelImageDict.count() > 1) { fprintf(stderr, "regionmask: Cannot generate multiple labelfiles\n"); return 1; } else { if (regionList.count()>0) { ArgDict *dict = regionList.first(); QString *oldfile = (*dict)["file"]; QString *labelfile = new QString(); if (resultFile) labelfile->sprintf("%s", resultFile); else labelfile->sprintf("%s.plm", outFile); LabelImage *im = labelImageDict.take(*oldfile); labelImageDict.replace(*labelfile, im); QListIterator < ArgDict > it(regionList); for (; it.current(); ++it) { ArgDict *argDict = it.current(); assert(argDict); argDict->replace("file", labelfile); } } } } else { printf("regionmask: overwriting %s\n",regFile); outFile = regFile; } QDictIterator < LabelImage > git(labelImageDict); if (regionList.count()>0) { for (; git.current(); ++git) { LabelImage *im = git.current(); qDebug("Writing %s", git.currentKey().latin1()); im->image.write(git.currentKey().latin1()); } } // Write regions if (!rfp.open(IO_WriteOnly)) { fprintf(stderr, "cannot open regionfile %s for writing\n", outFile); return 1; } if (regionList.count()>0) { QListIterator < ArgDict > it(regionList); QTextStream ts(&rfp); for (; it.current(); ++it) { ArgDict *argDict = it.current(); assert(argDict); ts << "<region "; ts << (*argDict); ts << " />" << endl; } } rfp.close(); labelImageDict.setAutoDelete(true); labelImageDict.clear(); regionList.setAutoDelete(true); return 0; }