static void delete_recursive(QListViewItem *item, const QIntDict< QListViewItem > &new_items) { if(!item) return; QListViewItemIterator it(item); while(it.current()) { if(!new_items.find(it.current()->text(1).toUInt())) { delete_recursive(it.current()->firstChild(), new_items); delete it.current(); } ++it; } }
// Called by constructor (with config = kapp->getConfig()) // and by session-management (with config = sessionconfig). // So it has to apply the settings when reading them. void TEDemo::readProperties(KConfig* config) { config->setGroup("options"); // bad! will no allow us to support multi windows // Global options /////////////////////// setMenuVisible(config->readBoolEntry("menubar visible",TRUE)); setFrameVisible(config->readBoolEntry("has frame",TRUE)); scrollbar_menu_activated(QMIN(config->readUnsignedNumEntry("scrollbar",SCRRIGHT),2)); // not necessary for SM (KTMainWindow does it after), but useful for default settings if (menubar->menuBarPos() != KMenuBar::Floating) { QString entry = config->readEntry("kmenubar"); if (!entry.isEmpty() && entry == "floating") { menubar->setMenuBarPos(KMenuBar::Floating); QString geo = config->readEntry("kmenubargeometry"); if (!geo.isEmpty()) menubar->setGeometry(KWM::setProperties(menubar->winId(), geo)); } else if (!entry.isEmpty() && entry == "top") menubar->setMenuBarPos(KMenuBar::Top); else if (!entry.isEmpty() && entry == "bottom") menubar->setMenuBarPos(KMenuBar::Bottom); } // (geometry stuff removed) done by KTMainWindow for SM, and not needed otherwise // Options that should be applied to all sessions ///////////// // (1) set menu items and TEDemo members setBsHack(config->readBoolEntry("BS hack",TRUE)); setFont(QMIN(config->readUnsignedNumEntry("font",3),7)); // sets n_font and menu item setSchema(config->readEntry("schema","")); // (2) apply to sessions (currently only the 1st one) TESession* s = no2session.find(1); if (s) { s->setFontNo(n_font); s->setSchemaNo(ColorSchema::find(s_schema)->numb); if (b_bshack) s->getEmulation()->setMode(MODE_BsHack); else s->getEmulation()->resetMode(MODE_BsHack); } else { fprintf(stderr,"session 1 not found\n"); } // oops // Default values for startup, changed by "save options". Not used by SM. defaultSize.setWidth ( config->readNumEntry("defaultwidth", 0) ); defaultSize.setHeight( config->readNumEntry("defaultheight", 0) ); }
ColorSchema* ColorSchema::find(const char* path) { ColorSchema* res = 0; QString temp_path; // search for a local schema first if (path[0] != '/') temp_path = kapp->localkdedir() + "/share/apps/konsole/"; temp_path += path; if (QFile::exists(temp_path) == true) res = path2schema.find(temp_path.data()); else { temp_path = kapp->kde_datadir() + "/konsole/"; if (QFile::exists(temp_path) == true) res = path2schema.find(temp_path.data()); } return res ? res : numb2schema.find(0); }
void TEDemo::newSession(int i) { char* shell = getenv("SHELL"); if (shell == NULL || *shell == '\0') shell = "/bin/sh"; KSimpleConfig* co = no2command.find(i); if (!co) return; // oops assert( se ); //FIXME: careful here. QString cmd = co->readEntry("Exec"); // not null QString nam = co->readEntry("Name"); // not null QString emu = co->readEntry("Term"); QString sch = co->readEntry("Schema"); QString txt = co->readEntry("Comment"); // not null int fno = QMIN(co->readUnsignedNumEntry("Font",se->fontNo()),7); ColorSchema* schema = sch.isEmpty() ? (ColorSchema*)NULL : ColorSchema::find(sch); //FIXME: schema names here are absolut. Wrt. loadAllSchemas, // relative pathes should be allowed, too. int schmno = schema?schema->numb:se->schemaNo(); if (emu.isEmpty()) emu = se->emuName(); QStrList args; args.append(shell); args.append("-c"); args.append(cmd); TESession* s = new TESession(this,te,args,emu.data(),0); s->setFontNo(fno); s->setSchemaNo(schmno); s->setTitle(txt.data()); addSession(s); runSession(s); // activate and run }
void TEDemo::activateSession(int sn) { TESession* s = no2session.find(sn); if (se) { se->setConnect(FALSE); int no = (int)session2no.find(se); m_sessions->setItemChecked(no,FALSE); } se = s; if (!s) { fprintf(stderr,"session not found\n"); return; } // oops m_sessions->setItemChecked(sn,TRUE); setSchema(s->schemaNo()); //FIXME: creates flicker? Do only if differs //Set Font. Now setConnect should do the appropriate action. //if the size has changed, a resize event (noticable to the application) //should happen. Else, we could even start the application s->setConnect(TRUE); // does a bulkShow (setImage) setFont(s->fontNo()); //FIXME: creates flicker? //FIXME: check here if we're still alife. // if not, quit, otherwise, // start propagating quit. title = s->Title(); // take title from current session setHeader(); }
static void read_bodies(const char * path, QIntDict<char> & bodies) { char * s = read_file(path); if (s != 0) { char * p1 = s; char * p2; while ((p2 = strstr(p1, BodyPrefix)) != 0) { p2 += BodyPrefixLength; char * body; long id = strtol(p2, &body, 16); if (body != (p2 + 8)) { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : invalid preserve body identifier</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 1"); } if (bodies.find(id) != 0) { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : preserve body identifier used twice</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 2"); } if (*body == '\r') body += 1; if (*body == '\n') body += 1; else { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : invalid preserve body block, end of line expected</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 3"); } if (((p1 = strstr(body, BodyPostfix)) == 0) || (strncmp(p1 + BodyPostfixLength, p2, 8) != 0)) { UmlCom::trace(QCString("<font color =\"red\"> Error in ") + path + " : invalid preserve body block, wrong balanced</font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("read_bodies 4"); } p2 = p1; while ((p2 != body) && (p2[-1] != '\n')) p2 -= 1; *p2 = 0; int len = p2 - body + 1; char * b = new char[len]; memcpy(b, body, len); bodies.insert(id, b); p1 += BodyPostfixLength + 8; } delete [] s; } }
ColorSchema* ColorSchema::find(int numb) { ColorSchema* res = numb2schema.find(numb); return res ? res : numb2schema.find(0); }