void CreateSmileyWindow::init( ) { if(!m_FileName.isEmpty()){ TQString file = m_FileName.right( m_FileName.length() - m_FileName.findRev("/") - 1); lblSelect->setText(file); btnSelect->setEnabled(false); leShortcut->setText(file.left(6)); leTip->setText(file.left( file.findRev(".") ) ); } TQString dir = EvaMain::user->getSetting()->getCustomSmileyDir() + "/"; m_Config = new CustomFaceConfig(dir); if(m_Config->loadXML()){ TQStringList groups = m_Config->groupNames(); cbbGroup->insertStringList(m_Config->groupNames()); } cbbGroup->setCurrentItem(m_DefaultGroup); connect(btnOK, SIGNAL(clicked()), this, SLOT(slotOKClicked() )); connect(btnCancel, SIGNAL(clicked()), this, SLOT(close())); connect(btnSelect, SIGNAL(clicked()), this, SLOT(slotSelectImagesClicked() )); }
void CreateSmileyWindow::slotSelectImagesClicked( ) { TQString startDir = TQDir::homeDirPath(); TQStringList fileNames = KFileDialog::getOpenFileNames(startDir, "*.png *.bmp *.jpg *.jpeg *.gif |" + i18n(" all images (*.png *.bmp *.jpg *.jpeg *.gif)"), this, i18n("select image file(s)")); if(fileNames.count() == 1){ m_FileName = fileNames[0]; TQString file = m_FileName.right( m_FileName.length() - m_FileName.findRev("/") - 1); lblSelect->setText(file); leShortcut->setEnabled( true); leShortcut->setText(file.left(6)); leTip->setEnabled( true ); leTip->setText(file.left( file.findRev(".") ) ); }else{ m_MultiFiles = true; lblSelect->setText(i18n("Multi-Files Selected.")); m_FileNames = fileNames; leShortcut->setText(""); leTip->setText(""); leShortcut->setEnabled( false); leTip->setEnabled( false); } }
static bool parseUrl(const TQString& _url, TQString &title, TQString §ion) { section = TQString::null; TQString url = _url; if (url.at(0) == '/') { if (TDEStandardDirs::exists(url)) { title = url; return true; } else { // If the directory does not exist, then it is perhaps a normal man page kdDebug(7107) << url << " does not exist" << endl; } } while (url.at(0) == '/') url.remove(0,1); title = url; int pos = url.find('('); if (pos < 0) return true; title = title.left(pos); section = url.mid(pos+1); section = section.left(section.length()-1); return true; }
void CreateSmileyWindow::slotOKClicked( ) { bool ok = false; TQString destDir = EvaMain::user->getSetting()->getCustomSmileyDir(); if(cbbGroup->currentItem()>0) destDir += ( "/" + cbbGroup->currentText() ); if(!m_FileName.isEmpty()){ TQString destFile = EvaHelper::generateCustomSmiley(m_FileName, destDir, true); if(!destFile.isEmpty()) { TQString name = destFile.right( destFile.length() - destFile.findRev("/") - 1); CustomFace face(name, leShortcut->text(), leTip->text(), 0, cbbGroup->currentItem()); ok = m_Config->addFace(face); } } else { ///TODO: add multiple files for(TQStringList::Iterator it = m_FileNames.begin(); it != m_FileNames.end(); ++it){ TQString destFile = EvaHelper::generateCustomSmiley((*it), destDir, true); if(!destFile.isEmpty()) { TQString name = destFile.right( destFile.length() - destFile.findRev("/") - 1); CustomFace face( name, name.left(6), name.left(name.findRev(".")), 0, cbbGroup->currentItem()); ok = m_Config->addFace(face); } } } if(ok) m_Config->saveXML(); emit addCustomSmileyReady(ok); close(); }
// check $oldlayouts and $nonlatin groups for XFree 4.3 and later OldLayouts* X11Helper::loadOldLayouts(const TQString& rulesFile) { static const char* oldLayoutsTag = "! $oldlayouts"; static const char* nonLatinLayoutsTag = "! $nonlatin"; TQStringList m_oldLayouts; TQStringList m_nonLatinLayouts; TQFile f(rulesFile); if (f.open(IO_ReadOnly)) { TQTextStream ts(&f); TQString line; while (!ts.eof()) { line = ts.readLine().simplifyWhiteSpace(); if( line.find(oldLayoutsTag) == 0 ) { line = line.mid(strlen(oldLayoutsTag)); line = line.mid(line.find('=')+1).simplifyWhiteSpace(); while( !ts.eof() && line.endsWith("\\") ) line = line.left(line.length()-1) + ts.readLine(); line = line.simplifyWhiteSpace(); m_oldLayouts = TQStringList::split(TQRegExp("\\s"), line); // kdDebug() << "oldlayouts " << m_oldLayouts.join("|") << endl; if( !m_nonLatinLayouts.empty() ) break; } else if( line.find(nonLatinLayoutsTag) == 0 ) { line = line.mid(strlen(nonLatinLayoutsTag)+1).simplifyWhiteSpace(); line = line.mid(line.find('=')+1).simplifyWhiteSpace(); while( !ts.eof() && line.endsWith("\\") ) line = line.left(line.length()-1) + ts.readLine(); line = line.simplifyWhiteSpace(); m_nonLatinLayouts = TQStringList::split(TQRegExp("\\s"), line); // kdDebug() << "nonlatin " << m_nonLatinLayouts.join("|") << endl; if( !m_oldLayouts.empty() ) break; } } f.close(); } OldLayouts* oldLayoutsStruct = new OldLayouts(); oldLayoutsStruct->oldLayouts = m_oldLayouts; oldLayoutsStruct->nonLatinLayouts = m_nonLatinLayouts; return oldLayoutsStruct; }
TQString KStringHandler::csqueeze( const TQString & str, uint maxlen ) { if (str.length() > maxlen && maxlen > 3) { int part = (maxlen-3)/2; return TQString(str.left(part) + "..." + str.right(part)); } else return str; }
TQString KStringHandler::rsqueeze( const TQString & str, uint maxlen ) { if (str.length() > maxlen) { int part = maxlen-3; return TQString(str.left(part) + "..."); } else return str; }
bool LprHandler::completePrinter(KMPrinter *prt, PrintcapEntry *entry, bool) { prt->setDescription(i18n("Unknown (unrecognized entry)")); TQString val = entry->field("lp"); KURL uri; if (!val.isEmpty() && val != "/dev/null") { int p = val.find('@'); if (p != -1) { prt->setLocation(i18n("Remote queue (%1) on %2").arg(val.left(p)).arg(val.mid(p+1))); uri.setProtocol("lpd"); uri.setHost(val.mid(p+1)); uri.setPath("/" + val.left(p)); } else if ((p = val.find('%')) != -1) { prt->setLocation(i18n("Network printer (%1)").arg("socket")); uri.setProtocol("socket"); uri.setHost(val.left(p)); uri.setPort(val.mid(p+1).toInt()); } else { prt->setLocation(i18n("Local printer on %1").arg(val)); uri.setProtocol("parallel"); uri.setPath(val); } } else if (!(val = entry->field("rp")).isEmpty()) { TQString rm = entry->has("rm") ? entry->field("rm") : LprSettings::self()->defaultRemoteHost(); prt->setLocation(i18n("Remote queue (%1) on %2").arg(val).arg(rm)); uri.setProtocol("lpd"); uri.setHost(rm); uri.setPath("/" + val); } else prt->setLocation(i18n("Unknown (unrecognized entry)")); prt->setDevice(uri.url()); return true; }
static TQString extractName(TQString path) { int i = path.findRev('/'); if (i >= 0) path = path.mid(i+1); i = path.findRev('.'); if (i >= 0) path = path.left(i); return path; }
void EvaQunMemberPicker::slotClicked(TQListViewItem *item) { if(!item) return; TQCheckListItem *chkItem = dynamic_cast<TQCheckListItem *>(item); if(!chkItem) return; unsigned int id; TQString txt; TQString strID; bool ok; TQString nick; TQPixmap face; TQCheckListItem *child = dynamic_cast<TQCheckListItem *>(chkItem->firstChild()); if(!child){ txt = chkItem->text(0); int index = txt.findRev("("); nick = txt.left( index ); strID = txt.mid(index+1, txt.length() - index - 1 - 1); id = strID.toUInt(&ok); if(!ok) return; face = *(chkItem->pixmap(0)); emit memberClicked(id, chkItem->isOn()); } while(child){ child->setOn(chkItem->isOn()); txt = child->text(0); int index = txt.findRev("("); nick = txt.left( index ); strID = txt.mid(index+1, txt.length() - index - 1 - 1); id = strID.toUInt(&ok); if(!ok) return; face = *(child->pixmap(0)); emit memberClicked(id, child->isOn()); child = dynamic_cast<TQCheckListItem *>(child->nextSibling()); } }
void KMDriverDB::loadDbFile() { // first clear everything m_entries.clear(); m_pnpentries.clear(); TQFile f(dbFile()); if (f.exists() && f.open(IO_ReadOnly)) { TQTextStream t(&f); TQString line; TQStringList words; KMDBEntry *entry(0); while (!t.eof()) { line = t.readLine().stripWhiteSpace(); if (line.isEmpty()) continue; int p = line.find('='); if (p == -1) continue; words.clear(); words << line.left(p) << line.mid(p+1); if (words[0] == "FILE") { if (entry) insertEntry(entry); entry = new KMDBEntry; entry->file = words[1]; } else if (words[0] == "MANUFACTURER" && entry) entry->manufacturer = words[1].upper(); else if (words[0] == "MODEL" && entry) entry->model = words[1]; else if (words[0] == "MODELNAME" && entry) entry->modelname = words[1]; else if (words[0] == "PNPMANUFACTURER" && entry) entry->pnpmanufacturer = words[1].upper(); else if (words[0] == "PNPMODEL" && entry) entry->pnpmodel = words[1]; else if (words[0] == "DESCRIPTION" && entry) entry->description = words[1]; else if (words[0] == "RECOMMANDED" && entry && words[1].lower() == "yes") entry->recommended = true; else if (words[0] == "DRIVERCOMMENT" && entry) entry->drivercomment = ("<qt>"+words[1].replace("<", "<").replace(">", ">")+"</qt>"); } if (entry) insertEntry(entry); } }
/* pretty simple algorithm - reads the layout file and tries to find "xkb_symbols" also checks whether previous line contains "hidden" to skip it */ TQStringList* X11Helper::getVariants(const TQString& layout, const TQString& x11Dir, bool oldLayouts) { TQStringList* result = new TQStringList(); TQString file = x11Dir + "xkb/symbols/"; // workaround for XFree 4.3 new directory for one-group layouts if( TQDir(file+"pc").exists() && !oldLayouts ) file += "pc/"; file += layout; // kdDebug() << "reading variants from " << file << endl; TQFile f(file); if (f.open(IO_ReadOnly)) { TQTextStream ts(&f); TQString line; TQString prev_line; while (!ts.eof()) { prev_line = line; line = ts.readLine().simplifyWhiteSpace(); if (line[0] == '#' || line.left(2) == "//" || line.isEmpty()) continue; int pos = line.find("xkb_symbols"); if (pos < 0) continue; if( prev_line.find("hidden") >=0 ) continue; pos = line.find('"', pos) + 1; int pos2 = line.find('"', pos); if( pos < 0 || pos2 < 0 ) continue; result->append(line.mid(pos, pos2-pos)); // kdDebug() << "adding variant " << line.mid(pos, pos2-pos) << endl; } f.close(); } return result; }
void MANProtocol::parseWhatIs( TQMap<TQString, TQString> &i, TQTextStream &t, const TQString &mark ) { TQRegExp re( mark ); TQString l; while ( !t.atEnd() ) { l = t.readLine(); int pos = re.search( l ); if (pos != -1) { TQString names = l.left(pos); TQString descr = l.mid(pos + re.matchedLength()); while ((pos = names.find(",")) != -1) { i[names.left(pos++)] = descr; while (names[pos] == ' ') pos++; names = names.mid(pos); } i[names] = descr; } } }
double coordinate(TQString c) { int neg; int d=0, m=0, s=0; neg = c.left(1) == "-"; c.remove(0,1); switch (c.length()) { case 4: d = c.left(2).toInt(); m = c.mid(2).toInt(); break; case 5: d = c.left(3).toInt(); m = c.mid(3).toInt(); break; case 6: d = c.left(2).toInt(); m = c.mid(2,2).toInt(); s = c.right(2).toInt(); break; case 7: d = c.left(3).toInt(); m = c.mid(3,2).toInt(); s = c.right(2).toInt(); break; default: break; } if (neg) return - (d + m/60.0 + s/3600.0); else return d + m/60.0 + s/3600.0; }
void ZoneClockPanel::save(TDEConfig *config) { config->writeEntry("Clocks", _clocks.count()); TQPtrListIterator<ZoneClock> it(_clocks); int cnt=0; for ( ; it.current(); ++it) { TQString n = it.current()->name(); n = n.left(n.length()-1); config->writeEntry(TQString("Clock_%1_Name").arg(cnt), n); config->writeEntry(TQString("Clock_%1_Zone").arg(cnt), it.current()->zone()); cnt++; } }
void LDAPProtocol::LDAPEntry2UDSEntry( const TQString &dn, UDSEntry &entry, const LDAPUrl &usrc, bool dir ) { UDSAtom atom; int pos; entry.clear(); atom.m_uds = UDS_NAME; atom.m_long = 0; TQString name = dn; if ( (pos = name.find(",")) > 0 ) name = name.left( pos ); if ( (pos = name.find("=")) > 0 ) name.remove( 0, pos+1 ); name.replace(' ', "_"); if ( !dir ) name += ".ldif"; atom.m_str = name; entry.append( atom ); // the file type atom.m_uds = UDS_FILE_TYPE; atom.m_str = ""; atom.m_long = dir ? S_IFDIR : S_IFREG; entry.append( atom ); // the mimetype if (!dir) { atom.m_uds = UDS_MIME_TYPE; atom.m_long = 0; atom.m_str = "text/plain"; entry.append( atom ); } atom.m_uds = UDS_ACCESS; atom.m_long = dir ? 0500 : 0400; entry.append( atom ); // the url atom.m_uds = UDS_URL; atom.m_long = 0; LDAPUrl url; url=usrc; url.setPath("/"+dn); url.setScope( dir ? LDAPUrl::One : LDAPUrl::Base ); atom.m_str = url.prettyURL(); entry.append( atom ); }
void CityList::readCityList(const TQString &fname) { TQFile f(fname); if (f.open(IO_ReadOnly)) { TQTextStream is(&f); TQString line; TQStringList tags; TQRegExp coord("[+-]\\d+[+-]\\d+"); TQRegExp name("[^\\s]+/[^\\s]+"); int pos; while (!is.eof()) { line = is.readLine().stripWhiteSpace(); if (line.isEmpty() || line.left(1) == "#") continue; TQString c, n; pos = coord.search(line, 0); if (pos >= 0) c = line.mid(pos, coord.matchedLength()); pos = name.search(line, pos); if (pos > 0) n = line.mid(pos, name.matchedLength()).stripWhiteSpace(); if (!c.isEmpty() && !n.isEmpty()) { double la, lo; pos = c.find("+", 1); if (pos < 0) pos = c.find("-", 1); if (pos > 0) { la = coordinate(c.left(pos)); lo = coordinate(c.mid(pos)); _cities.append(new City(n.latin1(), la, lo)); } } } f.close(); } }
void KMWLocal::initialize() { TQStringList list = KMFactory::self()->manager()->detectLocalPrinters(); if (list.isEmpty() || (list.count() % 4) != 0) { KMessageBox::error(this, i18n("Unable to detect local ports.")); return; } TQListViewItem *last[4] = {0, 0, 0, 0}; for (TQStringList::Iterator it=list.begin(); it!=list.end(); ++it) { TQString cl = *it; ++it; TQString uri = *it; int p = uri.find( ':' ); TQString desc = *(++it), prot = ( p != -1 ? uri.left( p ) : TQString::null ); TQString printer = *(++it); int index(-1); if (desc.isEmpty()) desc = uri; if (prot == "parallel" || prot == "file") index = 0; else if (prot == "serial") index = 1; else if (prot == "usb") index = 2; else if (cl == "direct") index = 3; else continue; last[index] = new TQListViewItem(m_parents[index], last[index], desc, uri); last[index]->setPixmap(0, SmallIcon("blockdevice")); m_parents[index]->setOpen(true); m_uris << uri; if (!printer.isEmpty()) { TQListViewItem *pItem = new TQListViewItem(last[index], printer); last[index]->setOpen(true); pItem->setPixmap(0, SmallIcon("tdeprint_printer")); } } m_initialized = true; }
TQString CharactersWidget::text() const { TQString res = TQString::fromLatin1(""); if (_regexp->wordChar()) res += i18n("- A word character\n"); if (_regexp->nonWordChar()) res += i18n("- A non-word character\n"); if (_regexp->digit()) res += i18n("- A digit character\n"); if (_regexp->nonDigit()) res += i18n("- A non-digit character\n"); if ( _regexp->space() ) res += i18n("- A space character\n"); if ( _regexp->nonSpace() ) res += i18n("- A non-space character\n"); // Single characters TQStringList chars = _regexp->chars(); if ( !chars.isEmpty() ) { TQString str = chars.join( TQString::fromLocal8Bit(", ") ); res += TQString::fromLocal8Bit("- ") + str + TQString::fromLocal8Bit("\n"); } // Ranges characters TQPtrList<StringPair> range = _regexp->range(); for ( TQPtrListIterator<StringPair> it( range ); *it; ++it ) { StringPair* elm = static_cast<StringPair*>(*it); if (elm) { TQString fromText = elm->first(); TQString toText = elm->second(); res += TQString::fromLocal8Bit("- ") + i18n("from ") + fromText + i18n(" to ") + toText + TQString::fromLocal8Bit("\n"); } } return res.left(res.length()-1); }
TQString ApsHandler::printOptions(KPrinter *printer) { TQString optstr; TQMap<TQString,TQString> opts = printer->options(); for (TQMap<TQString,TQString>::ConstIterator it=opts.begin(); it!=opts.end(); ++it) { if (it.key().startsWith("kde-") || it.key().startsWith("_kde-") || it.key().startsWith( "app-" )) continue; optstr.append((*it)).append(":"); } if (!optstr.isEmpty()) { optstr = optstr.left(optstr.length()-1); if (LprSettings::self()->mode() == LprSettings::LPR) optstr.prepend("-C '").append("'"); else optstr.prepend("-Z '").append("'"); } return optstr; }
TQString KStringHandler::cPixelSqueeze(const TQString& s, const TQFontMetrics& fm, uint width) { if ( s.isEmpty() || uint( fm.width( s ) ) <= width ) { return s; } const unsigned int length = s.length(); if ( length == 2 ) { return s; } const int maxWidth = width - fm.width( '.' ) * 3; if ( maxWidth <= 0 ) { return "..."; } unsigned int leftIdx = 0, rightIdx = length; unsigned int leftWidth = fm.charWidth( s, leftIdx++ ); unsigned int rightWidth = fm.charWidth( s, --rightIdx ); while ( leftWidth + rightWidth < uint( maxWidth ) ) { while ( leftWidth <= rightWidth && leftWidth + rightWidth < uint( maxWidth ) ) { leftWidth += fm.charWidth( s, leftIdx++ ); } while ( rightWidth <= leftWidth && leftWidth + rightWidth < uint( maxWidth ) ) { rightWidth += fm.charWidth( s, --rightIdx ); } } if ( leftWidth > rightWidth ) { --leftIdx; } else { ++rightIdx; } rightIdx = length - rightIdx; if ( leftIdx == 0 && rightIdx == 1 || leftIdx == 1 && rightIdx == 0 ) { return "..."; } return s.left( leftIdx ) + "..." + s.right( rightIdx ); }
void ConfFilters::load() { TQFile f(locate("data","tdeprintfax/faxfilters")); if (f.exists() && f.open(IO_ReadOnly)) { TQTextStream t(&f); TQString line; int p(-1); TQListViewItem *item(0); while (!t.eof()) { line = t.readLine().stripWhiteSpace(); if ((p=line.find(TQRegExp("\\s"))) != -1) { TQString mime(line.left(p)), cmd(line.right(line.length()-p-1).stripWhiteSpace()); if (!mime.isEmpty() && !cmd.isEmpty()) item = new TQListViewItem(m_filters, item, mime, cmd); } } } }
static int lookupDevice(const char *x) { TQFile df("/proc/devices"); TQString thisreg; thisreg = "^[0-9]+ %1$"; thisreg = thisreg.arg(x); if (df.open(IO_ReadOnly)) { TQTextStream t(&df); TQString s; while (!t.eof()) { s = t.readLine(); if (s.contains(TQRegExp(thisreg))) { int n = (s.left(3).stripWhiteSpace()).toInt(); df.close(); return n; } } df.close(); } return -1; }
TQMap<TQString,TQString> ApsHandler::loadVarFile(const TQString& filename) { TQMap<TQString,TQString> opts; TQFile f(filename); if (f.open(IO_ReadOnly)) { TQTextStream t(&f); TQString line; int p(-1); while (!t.atEnd()) { line = t.readLine().stripWhiteSpace(); if (line.isEmpty() || line[0] == '#' || (p = line.find('=')) == -1) continue; TQString variable = line.left(p).stripWhiteSpace(); TQString value = line.mid(p+1).stripWhiteSpace(); if (!value.isEmpty() && value[0] == '\'') value = value.mid(1, value.length()-2); opts[variable] = value; } } return opts; }
void TDECompletion::addWeightedItem( const TQString& item ) { if ( myOrder != Weighted ) { addItem( item, 0 ); return; } uint len = item.length(); uint weight = 0; // find out the weighting of this item (appended to the string as ":num") int index = item.findRev(':'); if ( index > 0 ) { bool ok; weight = item.mid( index + 1 ).toUInt( &ok ); if ( !ok ) weight = 0; len = index; // only insert until the ':' } addItem( item.left( len ), weight ); return; }
void BasicTab::setEntryInfo(MenuEntryInfo *entryInfo) { blockSignals(true); _menuFolderInfo = 0; _menuEntryInfo = entryInfo; if (!entryInfo) { _nameEdit->setText(TQString::null); _descriptionEdit->setText(TQString::null); _commentEdit->setText(TQString::null); _iconButton->setIcon(TQString::null); // key binding part _keyEdit->setShortcut( TDEShortcut(), false ); _execEdit->lineEdit()->setText(TQString::null); _systrayCB->setChecked(false); _pathEdit->lineEdit()->setText(TQString::null); _termOptEdit->setText(TQString::null); _uidEdit->setText(TQString::null); _launchCB->setChecked(false); _terminalCB->setChecked(false); _uidCB->setChecked(false); enableWidgets(true, true); blockSignals(false); return; } KDesktopFile *df = entryInfo->desktopFile(); _nameEdit->setText(df->readName()); _descriptionEdit->setText(df->readGenericName()); _descriptionEdit->setCursorPosition(0); _commentEdit->setText(df->readComment()); _commentEdit->setCursorPosition(0); _iconButton->setIcon(df->readIcon()); // key binding part if( KHotKeys::present()) { _keyEdit->setShortcut( entryInfo->shortcut(), false ); } TQString temp = df->readPathEntry("Exec"); if (temp.left(12) == "ksystraycmd ") { _execEdit->lineEdit()->setText(temp.right(temp.length()-12)); _systrayCB->setChecked(true); } else { _execEdit->lineEdit()->setText(temp); _systrayCB->setChecked(false); } _pathEdit->lineEdit()->setText(df->readPath()); _termOptEdit->setText(df->readEntry("TerminalOptions")); if( df->hasKey( "X-TDE-Username" )) { _uidEdit->setText(df->readEntry("X-TDE-Username")); } else { _uidEdit->setText(df->readEntry("X-KDE-Username")); } if( df->hasKey( "StartupNotify" )) _launchCB->setChecked(df->readBoolEntry("StartupNotify", true)); else // backwards comp. _launchCB->setChecked(df->readBoolEntry("X-TDE-StartupNotify", true)); if(df->readNumEntry("Terminal", 0) == 1) _terminalCB->setChecked(true); else _terminalCB->setChecked(false); _uidCB->setChecked(df->readBoolEntry("X-TDE-SubstituteUID", false) || df->readBoolEntry("X-KDE-SubstituteUID", false)); enableWidgets(true, entryInfo->hidden); blockSignals(false); }
void KFileTreeBranch::addItems( const KFileItemList& list ) { KFileItemListIterator it( list ); kdDebug(250) << "Adding " << list.count() << " items !" << endl; KFileItem *currItem; KFileTreeViewItemList treeViewItList; KFileTreeViewItem *parentItem = 0; while ( (currItem = it.current()) != 0 ) { parentItem = parentKFTVItem( currItem ); /* Only create a new KFileTreeViewItem if it does not yet exist */ KFileTreeViewItem *newKFTVI = static_cast<KFileTreeViewItem *>(currItem->extraData( this )); if( ! newKFTVI ) { newKFTVI = createTreeViewItem( parentItem, currItem ); if (!newKFTVI) { // TODO: Don't fail if parentItem == 0 ++it; continue; } currItem->setExtraData( this, newKFTVI ); /* Cut off the file extension in case it is not a directory */ if( !m_showExtensions && !currItem->isDir() ) /* Need to cut the extension */ { TQString name = currItem->text(); int mPoint = name.findRev( '.' ); if( mPoint > 0 ) name = name.left( mPoint ); newKFTVI->setText( 0, name ); } } /* Now try to find out if there are children for dirs in the treeview */ /* This stats a directory on the local file system and checks the */ /* hardlink entry in the stat-buf. This works only for local directories. */ if( dirOnlyMode() && !m_recurseChildren && currItem->isLocalFile( ) && currItem->isDir() ) { KURL url = currItem->url(); TQString filename = url.directory( false, true ) + url.fileName(); /* do the stat trick of Carsten. The problem is, that the hardlink * count only contains directory links. Thus, this method only seem * to work in dir-only mode */ kdDebug(250) << "Doing stat on " << filename << endl; KDE_struct_stat statBuf; if( KDE_stat( TQFile::encodeName( filename ), &statBuf ) == 0 ) { int hardLinks = statBuf.st_nlink; /* Count of dirs */ kdDebug(250) << "stat succeeded, hardlinks: " << hardLinks << endl; // If the link count is > 2, the directory likely has subdirs. If it's < 2 // it's something weird like a mounted SMB share. In that case we don't know // if there are subdirs, thus show it as expandable. if( hardLinks != 2 ) { newKFTVI->setExpandable(true); } else { newKFTVI->setExpandable(false); } if( hardLinks >= 2 ) // "Normal" directory with subdirs { kdDebug(250) << "Emitting for " << url.prettyURL() << endl; emit( directoryChildCount( newKFTVI, hardLinks-2)); // parentItem, hardLinks-1 )); } } else { kdDebug(250) << "stat of " << filename << " failed !" << endl; } } ++it; treeViewItList.append( newKFTVI ); } emit newTreeViewItems( this, treeViewItList ); }
/* --| main |------------------------------------------------------ */ extern "C" int KDE_EXPORT kdemain(int argc, char* argv[]) { setgid(getgid()); setuid(getuid()); // drop privileges // deal with shell/command //////////////////////////// bool histon = true; bool menubaron = true; bool tabbaron = true; bool frameon = true; bool scrollbaron = true; bool showtip = true; TDEAboutData aboutData( "konsole", I18N_NOOP("Konsole"), KONSOLE_VERSION, description, TDEAboutData::License_GPL_V2, "Copyright (c) 2011-2014, The Trinity Desktop project\nCopyright (c) 1997-2006, Lars Doelle"); aboutData.addAuthor( "Timothy Pearson", I18N_NOOP("Maintainer, Trinity bugfixes"), "*****@*****.**" ); aboutData.addAuthor("Robert Knight",I18N_NOOP("Previous Maintainer"), "*****@*****.**"); aboutData.addAuthor("Lars Doelle",I18N_NOOP("Author"), "*****@*****.**"); aboutData.addCredit("Kurt V. Hindenburg", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Waldo Bastian", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Stephan Binner", I18N_NOOP("bug fixing and improvements"), "*****@*****.**"); aboutData.addCredit("Chris Machemer", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Stephan Kulow", I18N_NOOP("Solaris support and work on history"), "*****@*****.**"); aboutData.addCredit("Alexander Neundorf", I18N_NOOP("faster startup, bug fixing"), "*****@*****.**"); aboutData.addCredit("Peter Silva", I18N_NOOP("decent marking"), "*****@*****.**"); aboutData.addCredit("Lotzi Boloni", I18N_NOOP("partification\n" "Toolbar and session names"), "*****@*****.**"); aboutData.addCredit("David Faure", I18N_NOOP("partification\n" "overall improvements"), "*****@*****.**"); aboutData.addCredit("Antonio Larrosa", I18N_NOOP("transparency"), "*****@*****.**"); aboutData.addCredit("Matthias Ettrich", I18N_NOOP("most of main.C donated via kvt\n" "overall improvements"), "*****@*****.**"); aboutData.addCredit("Warwick Allison", I18N_NOOP("schema and selection improvements"), "*****@*****.**"); aboutData.addCredit("Dan Pilone", I18N_NOOP("SGI Port"), "*****@*****.**"); aboutData.addCredit("Kevin Street", I18N_NOOP("FreeBSD port"), "*****@*****.**"); aboutData.addCredit("Sven Fischer", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Dale M. Flaven", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Martin Jones", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("Lars Knoll", I18N_NOOP("bug fixing"), "*****@*****.**"); aboutData.addCredit("",I18N_NOOP("Thanks to many others.\n" "The above list only reflects the contributors\n" "I managed to keep track of.")); TDECmdLineArgs::init( argc, argv, &aboutData ); TDECmdLineArgs::addCmdLineOptions( options ); // Add our own options. //1.53 sec TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); TDECmdLineArgs *qtargs = TDECmdLineArgs::parsedArgs("qt"); has_noxft = !args->isSet("xft"); TEWidget::setAntialias( !has_noxft ); TEWidget::setStandalone( true ); // The following Qt options have no effect; warn users. if( qtargs->isSet("background") ) kdWarning() << "The Qt option -bg, --background has no effect." << endl; if( qtargs->isSet("foreground") ) kdWarning() << "The Qt option -fg, --foreground has no effect." << endl; if( qtargs->isSet("button") ) kdWarning() << "The Qt option -btn, --button has no effect." << endl; if( qtargs->isSet("font") ) kdWarning() << "The Qt option -fn, --font has no effect." << endl; TDEApplication* a = NULL; #ifdef COMPOSITE a = new TDEApplication(TDEApplication::openX11RGBADisplay()); argb_visual = a->isX11CompositionAvailable(); #else a = new TDEApplication; #endif TQString dataPathBase = TDEStandardDirs::kde_default("data").append("konsole/"); TDEGlobal::dirs()->addResourceType("wallpaper", dataPathBase + "wallpapers"); KImageIO::registerFormats(); // add io for additional image formats //2.1 secs TQString title; if(args->isSet("T")) { title = TQFile::decodeName(args->getOption("T")); } if(qtargs->isSet("title")) { title = TQFile::decodeName(qtargs->getOption("title")); } TQString term = ""; if(args->isSet("tn")) { term=TQString::fromLatin1(args->getOption("tn")); } login_shell = args->isSet("ls"); TQStrList eargs; const char* shell = 0; if (!args->getOption("e").isEmpty()) { if (args->isSet("ls")) TDECmdLineArgs::usage(i18n("You can't use BOTH -ls and -e.\n")); shell = strdup(args->getOption("e")); eargs.append(shell); for(int i=0; i < args->count(); i++) eargs.append( args->arg(i) ); if (title.isEmpty() && (kapp->caption() == kapp->aboutData()->programName())) { title = TQFile::decodeName(shell); // program executed in the title bar } showtip = false; } TQCString sz = ""; sz = args->getOption("vt_sz"); histon = args->isSet("hist"); menubaron = args->isSet("menubar"); tabbaron = args->isSet("tabbar") && args->isSet("toolbar"); frameon = args->isSet("frame"); scrollbaron = args->isSet("scrollbar"); TQCString wname = qtargs->getOption("name"); full_script = args->isSet("script"); auto_close = args->isSet("close"); fixed_size = !args->isSet("resize"); if (!full_script) a->dcopClient()->setQtBridgeEnabled(false); TQCString type = ""; if(args->isSet("type")) { type = args->getOption("type"); } if(args->isSet("types")) { TQStringList types = TDEGlobal::dirs()->findAllResources("appdata", "*.desktop", false, true); types.sort(); for(TQStringList::ConstIterator it = types.begin(); it != types.end(); ++it) { TQString file = *it; file = file.mid(file.findRev('/')+1); if (file.endsWith(".desktop")) file = file.left(file.length()-8); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } if(args->isSet("schemas") || args->isSet("schemata")) { ColorSchemaList colors; colors.checkSchemas(); for(int i = 0; i < (int) colors.count(); i++) { ColorSchema *schema = colors.find(i); TQString relPath = schema->relPath(); if (!relPath.isEmpty()) printf("%s\n", TQFile::encodeName(relPath).data()); } return 0; } if(args->isSet("keytabs")) { TQStringList lst = TDEGlobal::dirs()->findAllResources("data", "konsole/*.keytab"); printf("default\n"); // 'buildin' keytab lst.sort(); for(TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { TQFileInfo fi(*it); TQString file = fi.baseName(); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } TQString workDir = TQFile::decodeName( args->getOption("workdir") ); TQString keytab = ""; if (args->isSet("keytab")) keytab = TQFile::decodeName(args->getOption("keytab")); TQString schema = ""; if (args->isSet("schema")) schema = args->getOption("schema"); TDEConfig * sessionconfig = 0; TQString profile = ""; if (args->isSet("profile")) { profile = args->getOption("profile"); TQString path = locate( "data", "konsole/profiles/" + profile ); if ( TQFile::exists( path ) ) sessionconfig=new TDEConfig( path, true ); else profile = ""; } if (args->isSet("profiles")) { TQStringList profiles = TDEGlobal::dirs()->findAllResources("data", "konsole/profiles/*", false, true); profiles.sort(); for(TQStringList::ConstIterator it = profiles.begin(); it != profiles.end(); ++it) { TQString file = *it; file = file.mid(file.findRev('/')+1); printf("%s\n", TQFile::encodeName(file).data()); } return 0; } //FIXME: more: font args->clear(); int c = 0, l = 0; if ( !sz.isEmpty() ) { char *ls = strchr( sz.data(), 'x' ); if ( ls != NULL ) { *ls='\0'; ls++; c=atoi(sz.data()); l=atoi(ls); } else { TDECmdLineArgs::usage(i18n("expected --vt_sz <#columns>x<#lines> e.g. 80x40\n")); } } if (!kapp->authorizeTDEAction("size")) fixed_size = true; // /////////////////////////////////////////////// // Ignore SIGHUP so that we don't get killed when // our parent-shell gets closed. signal(SIGHUP, SIG_IGN); putenv((char*)"COLORTERM="); // to trigger mc's color detection KonsoleSessionManaged ksm; if (a->isRestored() || !profile.isEmpty()) { if (!shell) shell = konsole_shell(eargs); if (profile.isEmpty()) sessionconfig = a->sessionConfig(); sessionconfig->setDesktopGroup(); int n = 1; TQString key; TQString sTitle; TQString sPgm; TQString sTerm; TQString sIcon; TQString sCwd; int n_tabbar; // TODO: Session management stores everything in same group, // should use one group / mainwindow while (TDEMainWindow::canBeRestored(n) || !profile.isEmpty()) { sessionconfig->setGroup(TQString("%1").arg(n)); if (!sessionconfig->hasKey("Pgm0")) sessionconfig->setDesktopGroup(); // Backwards compatible int session_count = sessionconfig->readNumEntry("numSes"); int counter = 0; wname = sessionconfig->readEntry("class",wname).latin1(); sPgm = sessionconfig->readEntry("Pgm0", shell); sessionconfig->readListEntry("Args0", eargs); sTitle = sessionconfig->readEntry("Title0", title); sTerm = sessionconfig->readEntry("Term0"); sIcon = sessionconfig->readEntry("Icon0","konsole"); sCwd = sessionconfig->readPathEntry("Cwd0"); workDir = sessionconfig->readPathEntry("workdir"); n_tabbar = TQMIN(sessionconfig->readUnsignedNumEntry("tabbar",Konsole::TabBottom),2); Konsole *m = new Konsole(wname,histon,menubaron,tabbaron,frameon,scrollbaron,0/*type*/,true,n_tabbar, workDir); m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd); m->enableFullScripting(full_script); m->enableFixedSize(fixed_size); m->restore(n); sessionconfig->setGroup(TQString("%1").arg(n)); if (!sessionconfig->hasKey("Pgm0")) sessionconfig->setDesktopGroup(); // Backwards compatible m->makeGUI(); m->setEncoding(sessionconfig->readNumEntry("Encoding0")); m->setSchema(sessionconfig->readEntry("Schema0")); // Use konsolerc default as tmpFont instead? TQFont tmpFont = TDEGlobalSettings::fixedFont(); m->initSessionFont(sessionconfig->readFontEntry("SessionFont0", &tmpFont)); m->initSessionKeyTab(sessionconfig->readEntry("KeyTab0")); m->initMonitorActivity(sessionconfig->readBoolEntry("MonitorActivity0",false)); m->initMonitorSilence(sessionconfig->readBoolEntry("MonitorSilence0",false)); m->initMasterMode(sessionconfig->readBoolEntry("MasterMode0",false)); m->initTabColor(sessionconfig->readColorEntry("TabColor0")); // -1 will be changed to the default history in konsolerc m->initHistory(sessionconfig->readNumEntry("History0", -1), sessionconfig->readBoolEntry("HistoryEnabled0", true)); counter++; // show() before 2nd+ sessions are created allows --profile to // initialize the TE size correctly. m->show(); while (counter < session_count) { key = TQString("Title%1").arg(counter); sTitle = sessionconfig->readEntry(key, title); key = TQString("Args%1").arg(counter); sessionconfig->readListEntry(key, eargs); key = TQString("Pgm%1").arg(counter); // if the -e option is passed on the command line, this overrides the program specified // in the profile file if ( args->isSet("e") ) sPgm = (shell ? TQFile::decodeName(shell) : TQString()); else sPgm = sessionconfig->readEntry(key, shell); key = TQString("Term%1").arg(counter); sTerm = sessionconfig->readEntry(key); key = TQString("Icon%1").arg(counter); sIcon = sessionconfig->readEntry(key,"konsole"); key = TQString("Cwd%1").arg(counter); sCwd = sessionconfig->readPathEntry(key); m->newSession(sPgm, eargs, sTerm, sIcon, sTitle, sCwd); m->setSessionTitle(sTitle); // Use title as is key = TQString("Schema%1").arg(counter); m->setSchema(sessionconfig->readEntry(key)); key = TQString("Encoding%1").arg(counter); m->setEncoding(sessionconfig->readNumEntry(key)); key = TQString("SessionFont%1").arg(counter); TQFont tmpFont = TDEGlobalSettings::fixedFont(); m->initSessionFont(sessionconfig->readFontEntry(key, &tmpFont)); key = TQString("KeyTab%1").arg(counter); m->initSessionKeyTab(sessionconfig->readEntry(key)); key = TQString("MonitorActivity%1").arg(counter); m->initMonitorActivity(sessionconfig->readBoolEntry(key,false)); key = TQString("MonitorSilence%1").arg(counter); m->initMonitorSilence(sessionconfig->readBoolEntry(key,false)); key = TQString("MasterMode%1").arg(counter); m->initMasterMode(sessionconfig->readBoolEntry(key,false)); key = TQString("TabColor%1").arg(counter); m->initTabColor(sessionconfig->readColorEntry(key)); // -1 will be changed to the default history in konsolerc key = TQString("History%1").arg(counter); TQString key2 = TQString("HistoryEnabled%1").arg(counter); m->initHistory(sessionconfig->readNumEntry(key, -1), sessionconfig->readBoolEntry(key2, true)); counter++; } m->setDefaultSession( sessionconfig->readEntry("DefaultSession","shell.desktop") ); m->initFullScreen(); if ( !profile.isEmpty() ) { m->callReadPropertiesInternal(sessionconfig,1); profile = ""; // Hack to work-around sessions initialized with minimum size for (int i=0;i<counter;i++) m->activateSession( i ); m->setColLin(c,l); // will use default height and width if called with (0,0) } // works only for the first one, but there won't be more. n++; m->activateSession( sessionconfig->readNumEntry("ActiveSession",0) ); m->setAutoClose(auto_close); } } else { Konsole* m = new Konsole(wname,histon,menubaron,tabbaron,frameon,scrollbaron,type, false, 0, workDir); m->newSession((shell ? TQFile::decodeName(shell) : TQString()), eargs, term, TQString(), title, workDir); m->enableFullScripting(full_script); m->enableFixedSize(fixed_size); //3.8 :-( //exit(0); if (!keytab.isEmpty()) m->initSessionKeyTab(keytab); if (!schema.isEmpty()) { if (schema.right(7)!=".schema") schema+=".schema"; m->setSchema(schema); m->activateSession(0); // Fixes BR83162, transp. schema + notabbar } m->setColLin(c,l); // will use default height and width if called with (0,0) m->initFullScreen(); m->show(); if (showtip) m->showTipOnStart(); m->setAutoClose(auto_close); } int ret = a->exec(); //// Temporary code, waiting for Qt to do this properly // Delete all toplevel widgets that have WDestructiveClose TQWidgetList *list = TQApplication::topLevelWidgets(); // remove all toplevel widgets that have a parent (i.e. they // got WTopLevel explicitly), they'll be deleted by the parent list->first(); while( list->current()) { if( list->current()->parentWidget() != NULL || !list->current()->testWFlags( TQt::WDestructiveClose ) ) { list->remove(); continue; } list->next(); } TQWidgetListIt it(*list); TQWidget * w; while( (w=it.current()) != 0 ) { ++it; delete w; } delete list; delete a; return ret; }
bool tdeio_isoProtocol::checkNewFile( TQString fullPath, TQString & path, int startsec ) { kdDebug() << "tdeio_isoProtocol::checkNewFile " << fullPath << " startsec: " << startsec << endl; // Are we already looking at that file ? if ( m_isoFile && startsec == m_isoFile->startSec() && m_isoFile->fileName() == fullPath.left(m_isoFile->fileName().length()) ) { // Has it changed ? struct stat statbuf; if ( ::stat( TQFile::encodeName( m_isoFile->fileName() ), &statbuf ) == 0 ) { if ( m_mtime == statbuf.st_mtime ) { path = fullPath.mid( m_isoFile->fileName().length() ); kdDebug() << "tdeio_isoProtocol::checkNewFile returning " << path << endl; return true; } } } kdDebug() << "Need to open a new file" << endl; // Close previous file if ( m_isoFile ) { m_isoFile->close(); delete m_isoFile; m_isoFile = 0L; } // Find where the iso file is in the full path int pos = 0; TQString isoFile; path = TQString::null; int len = fullPath.length(); if ( len != 0 && fullPath[ len - 1 ] != '/' ) fullPath += '/'; kdDebug() << "the full path is " << fullPath << endl; while ( (pos=fullPath.find( '/', pos+1 )) != -1 ) { TQString tryPath = fullPath.left( pos ); kdDebug() << fullPath << " trying " << tryPath << endl; KDE_struct_stat statbuf; if ( KDE_lstat( TQFile::encodeName(tryPath), &statbuf ) == 0 && !S_ISDIR(statbuf.st_mode) ) { isoFile = tryPath; m_mtime = statbuf.st_mtime; m_mode = statbuf.st_mode; path = fullPath.mid( pos + 1 ); kdDebug() << "fullPath=" << fullPath << " path=" << path << endl; len = path.length(); if ( len > 1 ) { if ( path[ len - 1 ] == '/' ) path.truncate( len - 1 ); } else path = TQString::fromLatin1("/"); kdDebug() << "Found. isoFile=" << isoFile << " path=" << path << endl; break; } } if ( isoFile.isEmpty() ) { kdDebug() << "tdeio_isoProtocol::checkNewFile: not found" << endl; return false; } // Open new file kdDebug() << "Opening KIso on " << isoFile << endl; m_isoFile = new KIso( isoFile ); m_isoFile->setStartSec(startsec); if ( !m_isoFile->open( IO_ReadOnly ) ) { kdDebug() << "Opening " << isoFile << " failed." << endl; delete m_isoFile; m_isoFile = 0L; return false; } return true; }