TQString TDEStorageDevice::friendlyName() { // Return the actual storage device name TQString devicevendorid = vendorEncoded(); TQString devicemodelid = modelEncoded(); devicevendorid.replace("\\x20", " "); devicemodelid.replace("\\x20", " "); devicevendorid = devicevendorid.stripWhiteSpace(); devicemodelid = devicemodelid.stripWhiteSpace(); devicevendorid = devicevendorid.simplifyWhiteSpace(); devicemodelid = devicemodelid.simplifyWhiteSpace(); TQString devicename = devicevendorid + " " + devicemodelid; devicename = devicename.stripWhiteSpace(); devicename = devicename.simplifyWhiteSpace(); if (devicename != "") { return devicename; } if (isDiskOfType(TDEDiskDeviceType::Camera)) { return TDEGenericDevice::friendlyName(); } if (isDiskOfType(TDEDiskDeviceType::Floppy)) { return friendlyDeviceType(); } TQString label = diskLabel(); if (label.isNull()) { if (deviceSize() > 0) { if (checkDiskStatus(TDEDiskDeviceStatus::Hotpluggable)) { label = i18n("%1 Removable Device").arg(deviceFriendlySize()); } else { label = i18n("%1 Fixed Storage Device").arg(deviceFriendlySize()); } } } if (!label.isNull()) { return label; } return friendlyDeviceType(); }
TQString KStringHandler::word( const TQString &text , const char *range ) { // Format in: START:END // Note index starts a 0 (zero) // // 0: first word to end // 1:3 second to fourth words TQStringList list = TQStringList::split( " ", text , true ); TQString tmp = ""; TQString r = range; if ( text.isEmpty() ) return tmp; uint pos = 0, cnt = list.count(); parsePythonRange( range, pos, cnt ); // // Extract words // int wordsToExtract = cnt-pos+1; TQStringList::Iterator it = list.at( pos); while ( (it != list.end()) && (wordsToExtract-- > 0)) { tmp += *it; tmp += " "; it++; } return tmp.stripWhiteSpace(); }
//--------------------------------------------------------------------------- void KXSConfigDialog::slotPreviewExited(KProcess *) { if ( mKilled ) { mKilled = false; mPreviewProc->clearArguments(); TQString saver; saver.sprintf( "%s -window-id 0x%lX", mFilename.latin1(), long(mPreview->winId()) ); saver += command(); kdDebug() << "Command: " << saver << endl; unsigned int i = 0; TQString word; saver = saver.stripWhiteSpace(); while ( !saver[i].isSpace() ) word += saver[i++]; //work around a KStandarDirs::findExe() "feature" where it looks in $KDEDIR/bin first no matter what and sometimes finds the wrong executable TQFileInfo checkExe; TQString saverdir = TQString("%1/%2").tqarg(XSCREENSAVER_HACKS_DIR).tqarg(word); TQString path; checkExe.setFile(saverdir); if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile()) { path = saverdir; } if (!path.isEmpty()) { (*mPreviewProc) << path; bool inQuotes = false; while ( i < saver.length() ) { word = ""; while ( saver[i].isSpace() && i < saver.length() ) i++; while ( (!saver[i].isSpace() || inQuotes) && i < saver.length() ) { if ( saver[i] == '\"' ) { inQuotes = !inQuotes; } else { word += saver[i]; } i++; } if (!word.isEmpty()) { (*mPreviewProc) << word; } } mPreviewProc->start(); } } else { // stops us from spawning the hack really fast, but still not the best TQString path = KStandardDirs::findExe(mFilename, XSCREENSAVER_HACKS_DIR); if ( TQFile::exists(path) ) { mKilled = true; slotChanged(); } } }
// // Capitalization routines // TQString KStringHandler::capwords( const TQString &text ) { if ( text.isEmpty() ) { return text; } const TQString strippedText = text.stripWhiteSpace(); const TQStringList words = capwords( TQStringList::split( ' ', strippedText ) ); TQString result = text; result.replace( strippedText, words.join( " " ) ); return result; }
TQString KStringHandler::center( const TQString &text , uint width ) { const TQString s = text.stripWhiteSpace(); const unsigned int length = s.length(); if ( width <= length ) { return s; } TQString result; result.fill( ' ', ( width - length ) / 2 ); result += s; return result.leftJustify( width ); }
KMimeType * KServiceTypeFactory::findFromPattern(const TQString &_filename, TQString *match) { // Assume we're NOT building a database if (!m_str) return 0; // Get stream to the header TQDataStream *str = m_str; str->device()->at( m_fastPatternOffset ); TQ_INT32 nrOfEntries; (*str) >> nrOfEntries; TQ_INT32 entrySize; (*str) >> entrySize; TQ_INT32 fastOffset = str->device()->at( ); TQ_INT32 matchingOffset = 0; // Let's go for a binary search in the "fast" pattern index TQ_INT32 left = 0; TQ_INT32 right = nrOfEntries - 1; TQ_INT32 middle; // Extract extension int lastDot = _filename.findRev('.'); int ext_len = _filename.length() - lastDot - 1; if (lastDot != -1 && ext_len <= 4) // if no '.', skip the extension lookup { TQString extension = _filename.right( ext_len ); extension = extension.leftJustify(4); TQString pattern; while (left <= right) { middle = (left + right) / 2; // read pattern at position "middle" str->device()->at( middle * entrySize + fastOffset ); KSycocaEntry::read(*str, pattern); int cmp = pattern.compare( extension ); if (cmp < 0) left = middle + 1; else if (cmp == 0) // found { (*str) >> matchingOffset; // don't return newServiceType - there may be an "other" pattern that // matches best this file, like *.tar.bz if (match) *match = "*."+pattern.stripWhiteSpace(); break; // but get out of the fast patterns } else
void KateFileSelector::slotFilterChange( const TQString & nf ) { TQString f = nf.stripWhiteSpace(); bool empty = f.isEmpty() || f == "*"; TQToolTip::remove( btnFilter ); if ( empty ) { dir->clearFilter(); filter->lineEdit()->setText( TQString::null ); TQToolTip::add( btnFilter, TQString( i18n("Apply last filter (\"%1\")") ).arg( lastFilter ) ); } else { dir->setNameFilter( f ); lastFilter = f; TQToolTip::add( btnFilter, i18n("Clear filter") ); } btnFilter->setOn( !empty ); dir->updateDir(); // this will be never true after the filter has been used;) btnFilter->setEnabled( !( empty && lastFilter.isEmpty() ) ); }
TQString KStringHandler::rjust( const TQString &text , uint width ) { return text.stripWhiteSpace().rightJustify( width ); }
void KURLRequesterDlg::slotTextChanged(const TQString & text) { bool state = !text.stripWhiteSpace().isEmpty(); enableButtonOK( state ); enableButton( KDialogBase::User1, state ); }