QLayoutItem *BorderLayoutIterator::takeCurrent() { BorderLayout::BorderLayoutStruct *b = idx < int( list->count() ) ? list->take( idx ) : 0; QLayoutItem *item = b ? b->item : 0; delete b; return item; }
void qapp::tile_maximize(xwindow *client) { int i; if(tmaxclient != NULL && (i = clients.find(tmaxclient)) != -1) clients.insert(clients.find(client), clients.take(i)); tile_order(client); }
bool Doc::readFileToList(QString &fileName, QList<QString> &list) { QFile file(fileName); QString s = QString::null; QString t = QString::null; QString buf = QString::null; int i = 0; if (fileName == QString::null) { return false; } while (list.isEmpty() == false) { list.first(); delete list.take(); } if (file.open(IO_ReadOnly)) { list.append(new QString("Entry")); list.append(new QString("Dummy")); // First read all entries to a string list while (file.atEnd() == false) { file.readLine(buf, 1024); // If there is no "equal" sign on this row or it begins // with a hash, ignore it i = buf.find(QString("=")); if (i > -1 && buf.left(1) != QString("#")) { /* Get the string up to equal sign */ s = buf.mid(0, i).stripWhiteSpace(); list.append(new QString(s)); /* Get the string after the equal sign */ t = buf.mid(i + 1).stripWhiteSpace(); list.append(new QString(t)); } } file.close(); return true; } else { return false; } }
bool Doc::readDeviceClasses() { DeviceClass* dc = NULL; QString path = QString::null; QString dir; _app->settings()->get(KEY_SYSTEM_DIR, dir); dir += QString("/") + DEVICECLASSPATH + QString("/"); QDir d(dir); d.setFilter(QDir::Files); d.setNameFilter("*.deviceclass"); if (d.exists() == false || d.isReadable() == false) { QMessageBox::warning(_app, "QLC", "Unable to open or read from device directory! Check settings and permissions."); return false; } QStringList dirlist(d.entryList()); QStringList::Iterator it; QList <QString> list; // Our stringlist that contains the files' contents // Put a slash to the end of the directory name if it isn't there if (dir.right(1) != QString("/")) { dir = dir + QString("/"); } // Go thru all files for (it = dirlist.begin(); it != dirlist.end(); ++it) { path = dir + *it; FileHandler::readFileToList(path, list); dc = createDeviceClass(list); if (dc != NULL) { dc->setFile(path); m_deviceClassList.append(dc); } // 03-Jan-2002 / HJu // The list wasn't cleared between files while (list.isEmpty() == false) { list.first(); delete list.take(); } } return true; }
/*! Decrease the level of the contents hierarchy. * This will end the current sublist. * \sa incContentsDepth() */ void FTVHelp::decContentsDepth() { ASSERT(m_indent>0); if (m_indent>0) { m_indent--; QList<FTVNode> *nl = &m_indentNodes[m_indent]; FTVNode *parent = nl->getLast(); QList<FTVNode> *children = &m_indentNodes[m_indent+1]; while (!children->isEmpty()) { parent->children.append(children->take(0)); } } }
//==================================== // setTouchPanel //------------------------------------ void SaXManipulateTouchscreens::setTouchPanel (const QString& group) { // .../ //! set all panel data associated with the given group name to //! the current pointer data. The group name consists of the //! vendor and model name separated by a colon // ---- if ( ! mCDBPanels ) { mCDBPanels = new SaXProcess (); mCDBPanels -> start (CDB_TOUCHERS); } QList< QDict<QString> > data; data = mCDBPanels -> getTablePointerCDB_DATA ( group ); if (data.isEmpty()) { excCDBRecordNotFound (group); qError (errorString(),EXC_CDBRECORDNOTFOUND); return; } // .../ // move the data record to the correct position // refering to the section ID -> mPointer // ---- QDict<QString>* record = data.take(0); for (int n=0;n < mPointer;n++) { data.append(new QDict<QString>()); } data.append ( record ); // .../ // merge the toucher data into the current section // ---- mImport -> merge ( data ); // .../ // set vendor and name tag // ---- QStringList nameList = QStringList::split ( ":", group ); setNamePair ( nameList.first(), nameList.last() ); }
//==================================== // setMouse //------------------------------------ void SaXManipulateMice::setMouse ( const QString& group ) { // .../ //! set all mouse data associated with the given group name to //! the current pointer data. The group name consists of the //! vendor and model name separated by a colon // ---- if ( ! mCDBMice ) { mCDBMice = new SaXProcess (); mCDBMice -> start (CDB_POINTERS); } QList< QDict<QString> > data; data = mCDBMice -> getTablePointerCDB_DATA ( group ); // .../ // move the data record to the correct position // refering to the section ID -> mPointer // ---- QDict<QString>* record = data.take(0); for (int n=0;n < mPointer;n++) { data.append(new QDict<QString>()); } data.append ( record ); // .../ // merge the data into the current section now // ---- if (data.isEmpty()) { excCDBRecordNotFound (group); qError (errorString(),EXC_CDBRECORDNOTFOUND); return; } mImport -> merge ( data ); // .../ // set vendor and name tag // ---- QStringList nameList = QStringList::split ( ":", group ); mImport -> setItem ( "Vendor", nameList.first() ); mImport -> setItem ( "Name" , nameList.last() ); }
void CiteDict::generatePage() const { //printf("** CiteDict::generatePage() count=%d\n",m_ordering.count()); // do not generate an empty citations page if (isEmpty()) return; // nothing to cite // 1. generate file with markers and citations to OUTPUT_DIRECTORY QFile f; QCString outputDir = Config_getString("OUTPUT_DIRECTORY"); QCString citeListFile = outputDir+"/citelist.doc"; f.setName(citeListFile); if (!f.open(IO_WriteOnly)) { err("could not open file %s for writing\n",citeListFile.data()); } FTextStream t(&f); t << "<!-- BEGIN CITATIONS -->" << endl; t << "<!--" << endl; QDictIterator<CiteInfo> it(m_entries); CiteInfo *ci; for (it.toFirst();(ci=it.current());++it) { t << "\\citation{" << ci->label << "}" << endl; } t << "-->" << endl; t << "<!-- END CITATIONS -->" << endl; t << "<!-- BEGIN BIBLIOGRAPHY -->" << endl; t << "<!-- END BIBLIOGRAPHY -->" << endl; f.close(); // 2. generate bib2xhtml QCString bib2xhtmlFile = outputDir+"/bib2xhtml.pl"; f.setName(bib2xhtmlFile); QCString bib2xhtml = bib2xhtml_pl; if (!f.open(IO_WriteOnly)) { err("could not open file %s for writing\n",bib2xhtmlFile.data()); } f.writeBlock(bib2xhtml, bib2xhtml.length()); f.close(); // 3. generate doxygen.bst QCString doxygenBstFile = outputDir+"/doxygen.bst"; QCString bstData = doxygen_bst; f.setName(doxygenBstFile); if (!f.open(IO_WriteOnly)) { err("could not open file %s for writing\n",doxygenBstFile.data()); } f.writeBlock(bstData, bstData.length()); f.close(); // 4. for html we just copy the bib files to the output so that // bibtex can find them without path (bibtex doesn't support path's // with spaces!) QList<QCString> tempFiles; tempFiles.setAutoDelete(TRUE); QDir thisDir; if (Config_getBool("GENERATE_HTML")) { // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString bibOutputDir = outputDir+"/"; QFileInfo fo(bibOutputDir); const char *bibdata = citeDataList.first(); while (bibdata) { QCString bibFile = bibdata; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); if (fi.exists() && fi.dirPath(TRUE)!=fo.absFilePath()) { if (!bibFile.isEmpty()) { QCString destFile=bibOutputDir+fi.fileName().data(); copyFile(bibFile,destFile); tempFiles.append(new QCString(destFile)); } } else if (!fi.exists()) { err("bib file %s not found!\n",bibFile.data()); } bibdata = citeDataList.next(); } } QCString oldDir = QDir::currentDirPath().utf8(); QDir::setCurrent(outputDir); // 5. run bib2xhtml perl script on the generated file which will insert the // bibliography in citelist.doc portable_system("perl","\""+bib2xhtmlFile+"\" "+getListOfBibFiles(" ",FALSE)+" \""+ citeListFile+"\""); QDir::setCurrent(oldDir); // 6. read back the file f.setName(citeListFile); if (!f.open(IO_ReadOnly)) { err("could not open file %s/citelist.doc for reading\n",outputDir.data()); } bool insideBib=FALSE; QCString doc; QFileInfo fi(citeListFile); QCString input(fi.size()+1); f.readBlock(input.data(),fi.size()); f.close(); input.at(fi.size())='\0'; int p=0,s; //printf("input=[%s]\n",input.data()); while ((s=input.find('\n',p))!=-1) { QCString line = input.mid(p,s-p); //printf("p=%d s=%d line=[%s]\n",p,s,line.data()); p=s+1; if (line.find("<!-- BEGIN BIBLIOGRAPHY")!=-1) insideBib=TRUE; else if (line.find("<!-- END BIBLIOGRAPH")!=-1) insideBib=FALSE; else if (insideBib) doc+=line+"\n"; int i; // determine text to use at the location of the @cite command if (insideBib && (i=line.find("<a name=\"CITEREF_"))!=-1) { int j=line.find("\">["); int k=line.find("]</a>"); if (j!=-1 && k!=-1) { QCString label = line.mid(i+17,j-i-17); QCString number = line.mid(j+2,k-j-1); CiteInfo *ci = m_entries.find(label); //printf("label='%s' number='%s' => %p\n",label.data(),number.data(),ci); if (ci) { ci->text = number; } } } } //printf("doc=[%s]\n",doc.data()); // 7. add it as a page addRelatedPage(CiteConsts::fileName, theTranslator->trCiteReferences(),doc,0,CiteConsts::fileName,1,0,0,0); // 8. for latex we just copy the bib files to the output and let // latex do this work. if (Config_getBool("GENERATE_LATEX")) { // copy bib files to the latex output dir QStrList &citeDataList = Config_getList("CITE_BIB_FILES"); QCString latexOutputDir = Config_getString("LATEX_OUTPUT")+"/"; const char *bibdata = citeDataList.first(); while (bibdata) { QCString bibFile = bibdata; if (!bibFile.isEmpty() && bibFile.right(4)!=".bib") bibFile+=".bib"; QFileInfo fi(bibFile); if (fi.exists()) { if (!bibFile.isEmpty()) { copyFile(bibFile,latexOutputDir+fi.fileName().data()); } } else { err("bib file %s not found!\n",bibFile.data()); } bibdata = citeDataList.next(); } } // 9. Remove temporary files thisDir.remove(citeListFile); thisDir.remove(doxygenBstFile); thisDir.remove(bib2xhtmlFile); while (!tempFiles.isEmpty()) { QCString *s=tempFiles.take(0); thisDir.remove(*s); } }
void qapp::tile_order(xwindow *actclient) { if(smode) return; xwindow *client,*tmcl=NULL; int cct=0,cheight,lh=0; QWidget *dt = QApplication::desktop(); if(actclient != NULL && (clients.find(actclient) == -1 || ! actclient->is_tileable() || actclient->is_unmapped() || ! is_curdesk(actclient))) actclient = NULL; for(client = clients.first(); client != NULL; client = clients.next()) { if(client != actclient && ! client->is_unmapped() && is_curdesk(client) && client->is_tileable()) cct++; } if(actclient == NULL && cct > 0) cct--; tmaxclient = NULL; if(cct) cheight = (dt->height()-defaults::tb_height)/cct; int xpos,xcw,ypos,yp; ypos = yp = defaults::toolbar_top?defaults::tb_height+1:0; xpos = (int)(dt->width()*defaults::tleftspace); xcw = dt->width()-xpos-1; for(client = clients.first(); client != NULL; client = clients.next()) { if(! client->is_tileable() || client->is_unmapped() || ! is_curdesk(client)) continue; if(actclient == NULL || cct == 0) actclient = client; if(client == actclient) { tmcl = tmaxclient = client; continue; } if(lh < 0) lh = 0; client->minimize_frame(cct > defaults::wminframe?TRUE:FALSE); lh = client->set_tile(xpos+1, ypos-lh, xcw, cheight+lh); ypos += cheight; } if(tmcl != NULL) { tmcl->minimize_frame(FALSE); tmcl->set_tile(0, yp, xpos, dt->height()-defaults::tb_height); } if(actclient != NULL) clients.prepend(clients.take(clients.find(actclient))); }
//==================================== // addPen //------------------------------------ int SaXManipulateTablets::addPen (const QString& group) { // .../ //! add a new Pen or Eraser associated with the given group name to //! the current pointer data. The group name consists of the //! vendor and model name separated by a colon. The contents of the //! data record will set the InputFashion type for this addon //! pointer device // ---- if ( ! mCDBPens ) { mCDBPens = new SaXProcess (); mCDBPens -> start (CDB_PENS); } QList< QDict<QString> > data; data = mCDBPens -> getTablePointerCDB_DATA ( group ); if (data.isEmpty()) { excCDBRecordNotFound (group); qError (errorString(),EXC_CDBRECORDNOTFOUND); return -1; } // .../ // set input fashion type for the selected pen // ---- QDict<QString> penData = *data.at(0); QString* type = penData["TabletType"]; if (! type) { excPointerFashionTypeFailed ("undefined"); qError (errorString(),EXC_POINTERFASHIONTYPEFAILED); return -1; } if ((*type != "stylus") && (*type != "eraser")) { excPointerFashionTypeFailed (*type); qError (errorString(),EXC_POINTERFASHIONTYPEFAILED); return -1; } QString fashion (SAX_INPUT_PEN); if (*type == "eraser") { fashion = SAX_INPUT_ERASER; } // .../ // create new input device for the pen and make // it the current pointer device // ---- int newPen = mManipInputDevices->addInputDevice (fashion); if ( ! selectPointer (newPen)) { return -1; } // .../ // move the data record to the correct position // refering to the section ID -> mPointer // ---- QDict<QString>* record = data.take(0); for (int n=0;n < mPointer;n++) { data.append(new QDict<QString>()); } data.append ( record ); // .../ // merge the pen data now into the current section // ---- mImport -> merge ( data ); // .../ // set vendor and name tag // ---- QStringList nameList = QStringList::split ( ":", group ); mImport -> setItem ( "Vendor", nameList.first() ); mImport -> setItem ( "Name" , nameList.last() ); return newPen; }