void CpuPlugin::showAbout() { TQString version = kapp->aboutData()->version(); TDEAboutData aboutData(instanceName(), I18N_NOOP("KSim CPU Plugin"), version.latin1(), I18N_NOOP("A cpu monitor plugin for KSim"), TDEAboutData::License_GPL, "(C) 2001 Robbie Ward"); aboutData.addAuthor("Robbie Ward", I18N_NOOP("Author"), "*****@*****.**"); TDEAboutApplication(&aboutData).exec(); }
TQString ArkUtils::getTimeStamp(const TQString &_month, const TQString &_day, const TQString &_yearOrTime) { // Make the date format sortable. // Month is in _month, day is in _day. // In _yearOrTime is either a year or a time. // If it's March, we'll see the year for all dates up to October 1999. // (five months' difference - e.g., if it's Apr, then get years up to Nov) char month[4]; strncpy(month, _month.ascii(), 3); month[3] = '\0'; int nMonth = getMonth(month); int nDay = _day.toInt(); kdDebug(1601) << "Month is " << nMonth << ", Day is " << nDay << endl; time_t t = time(0); if (t == -1) exit(1); struct tm *now = localtime(&t); int thisYear = now->tm_year + 1900; int thisMonth = now->tm_mon + 1; TQString year, timestamp; if (_yearOrTime.contains(":")) // it has a timestamp so we have to figure out the year { year.sprintf("%d", ArkUtils::getYear(nMonth, thisYear, thisMonth)); timestamp = _yearOrTime; } else { year = _yearOrTime; if (year.right(1) == " ") year = year.left(4); if (year.left(1) == " ") year = year.right(4); timestamp = "??:??"; } TQString retval; retval.sprintf("%s-%.2d-%.2d %s", year.utf8().data(), nMonth, nDay, timestamp.utf8().data()); return retval; }
void I8KPlugin::showAbout() { TQString version = kapp->aboutData()->version(); TDEAboutData aboutData(instanceName(), I18N_NOOP("KSim I8K Plugin"), version.latin1(), I18N_NOOP("Dell I8K Hardware Monitor plugin"), TDEAboutData::License_GPL, "(C) 2003 Nadeem Hasan"); aboutData.addAuthor("Nadeem Hasan", I18N_NOOP("Author"), "*****@*****.**"); TDEAboutApplication(&aboutData).exec(); }
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
TQString AddresseeItem::key( int column, bool ) const { if (column == Email) { TQString value = text(Email); TQRegExp emailRe("<\\S*>"); int match = emailRe.search(value); if (match > -1) value = value.mid(match + 1, emailRe.matchedLength() - 2); return value.lower(); } return text(column).lower(); }
void IconThemesConfig::installNewTheme() { KURL themeURL = KURLRequesterDlg::getURL(TQString::null, this, i18n("Drag or Type Theme URL")); kdDebug() << themeURL.prettyURL() << endl; if (themeURL.url().isEmpty()) return; TQString themeTmpFile; // themeTmpFile contains the name of the downloaded file if (!TDEIO::NetAccess::download(themeURL, themeTmpFile, this)) { TQString sorryText; if (themeURL.isLocalFile()) sorryText = i18n("Unable to find the icon theme archive %1."); else sorryText = i18n("Unable to download the icon theme archive;\n" "please check that address %1 is correct."); KMessageBox::sorry(this, sorryText.arg(themeURL.prettyURL())); return; } TQStringList themesNames = findThemeDirs(themeTmpFile); if (themesNames.isEmpty()) { TQString invalidArch(i18n("The file is not a valid icon theme archive.")); KMessageBox::error(this, invalidArch); TDEIO::NetAccess::removeTempFile(themeTmpFile); return; } if (!installThemes(themesNames, themeTmpFile)) { //FIXME: make me able to know what is wrong.... // TQStringList instead of bool? TQString somethingWrong = i18n("A problem occurred during the installation process; " "however, most of the themes in the archive have been installed"); KMessageBox::error(this, somethingWrong); } TDEIO::NetAccess::removeTempFile(themeTmpFile); TDEGlobal::instance()->newIconLoader(); loadThemes(); TQListViewItem *item=iconThemeItem(TDEIconTheme::current()); m_iconThemes->setSelected(item, true); updateRemoveButton(); }
bool KPartSaver::openURL( KURL url ) { closeURL(); // find mime type TQString mime = KMimeType::findByURL( url )->name(); // find fitting kparts KTrader::OfferList offers; offers = KTrader::self()->query( mime, "'KParts/ReadOnlyPart' in ServiceTypes" ); if( offers.count()==0 ) { kdDebug() << "Can't find proper kpart for " << mime << endl; return false; } // load kpart library TQString lib = offers.first()->library(); KLibFactory *factory = KLibLoader::self()->factory( lib.latin1() ); if( !factory ) { kdDebug() << "Library " << lib << " not found." << endl; return false; } // create kpart m_part = (KParts::ReadOnlyPart *)factory->create( TQT_TQOBJECT(this), "kpart", "KParts::ReadOnlyPart" ); if( !m_part ) { kdDebug() << "Part for " << url.url() << " can't be constructed" << endl; return false; } else embed( m_part->widget() ); // show kpart delete m_back; m_back = 0; show(); m_part->widget()->show(); // load url if( !m_part->openURL( url ) ) { kdDebug() << "Can't load " << url.url() << endl; closeURL(); return false; } return true; }
AutoStart::AutoStart( bool new_startup ) : m_newStartup( new_startup ), m_phase( new_startup ? -1 : 0), m_phasedone(false) { m_startList = new AutoStartList; m_startList->setAutoDelete(true); TDEGlobal::dirs()->addResourceType("autostart", "share/autostart"); TQString xdgdirs = getenv("XDG_CONFIG_DIRS"); if (xdgdirs.isEmpty()) xdgdirs = "/etc/xdg"; TQStringList xdgdirslist = TQStringList::split( ':', xdgdirs ); for ( TQStringList::Iterator itr = xdgdirslist.begin(); itr != xdgdirslist.end(); ++itr ) { TDEGlobal::dirs()->addResourceDir("autostart", (*itr) +"/autostart"); } }
void KDecimalByteCodec::encodeShort( TQString &Digits, unsigned int Pos, unsigned char Char ) const { unsigned char C; if( (C = Char / 100) ) { Digits.at(Pos++) = '0'+C; Char -= C * 100; } if( (C = Char / 10) ) { Digits.at(Pos++) = '0'+C; Char -= C * 10; } Digits.at(Pos) = '0'+Char; }
KCheckAccelerators::KCheckAccelerators( TQObject* parent ) : TQObject( parent, "kapp_accel_filter" ), key(0), block( false ), drklash(0) { parent->installEventFilter( this ); TDEConfigGroupSaver saver( TDEGlobal::config(), "Development" ); TQString sKey = TDEGlobal::config()->readEntry( "CheckAccelerators" ).stripWhiteSpace(); if( !sKey.isEmpty() ) { TDEShortcut cuts( sKey ); if( cuts.count() > 0 ) key = int(cuts.seq(0).qt()); } alwaysShow = TDEGlobal::config()->readBoolEntry( "AlwaysShowCheckAccelerators", false ); autoCheck = TDEGlobal::config()->readBoolEntry( "AutoCheckAccelerators", true ); connect( &autoCheckTimer, TQT_SIGNAL( timeout()), TQT_SLOT( autoCheckSlot())); }
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++; } }
TQString KStringHandler::remrange( 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 ); // // Remove that range of words // int wordsToDelete = cnt-pos+1; TQStringList::Iterator it = list.at( pos); while ( (it != list.end()) && (wordsToDelete-- > 0)) it = list.remove( it ); return list.join( " " ); }
void kSpaceSaver::readSettings() { KConfig *config = klock_config(); config->setGroup( "Settings" ); TQString str; str = config->readEntry( "Speed" ); if ( !str.isNull() ) speed = MAXSPEED - str.toInt(); else speed = DEFSPEED; warpinterval = config->readNumEntry( "WarpInterval", 15 ); delete config; }
TQVariant KJSProxyImpl::evaluate(TQString filename, int baseLine, const TQString&str, const DOM::Node &n, Completion *completion) { // evaluate code. Returns the JS return value or an invalid QVariant // if there was none, an error occurred or the type couldn't be converted. initScript(); // inlineCode is true for <a href="javascript:doSomething()"> // and false for <script>doSomething()</script>. Check if it has the // expected value in all cases. // See smart window.open policy for where this is used. bool inlineCode = filename.isNull(); //kdDebug(6070) << "KJSProxyImpl::evaluate inlineCode=" << inlineCode << endl; #ifdef KJS_DEBUGGER if (inlineCode) filename = "(unknown file)"; if (KJSDebugWin::debugWindow()) { KJSDebugWin::debugWindow()->attach(m_script); KJSDebugWin::debugWindow()->setNextSourceInfo(filename,baseLine); // KJSDebugWin::debugWindow()->setMode(KJSDebugWin::Step); } #else Q_UNUSED(baseLine); #endif m_script->setInlineCode(inlineCode); Window* window = Window::retrieveWindow( m_frame->m_part ); KJS::Value thisNode = n.isNull() ? Window::retrieve( m_frame->m_part ) : getDOMNode(m_script->globalExec(),n); UString code( str ); KJSCPUGuard guard; guard.start(); Completion comp = m_script->evaluate(code, thisNode); guard.stop(); bool success = ( comp.complType() == Normal ) || ( comp.complType() == ReturnValue ); if (completion) *completion = comp; #ifdef KJS_DEBUGGER // KJSDebugWin::debugWindow()->setCode(TQString::null); #endif window->afterScriptExecution(); // let's try to convert the return value if (success && comp.value().isValid()) return ValueToVariant( m_script->globalExec(), comp.value()); else { if ( comp.complType() == Throw ) { UString msg = comp.value().toString(m_script->globalExec()); kdDebug(6070) << "WARNING: Script threw exception: " << msg.qstring() << endl; } return TQVariant(); } }
void HostConfig::writeIfNotEmpty( TDEConfigBase &config, const TQString &name, const TQString &value ) { if ( value.isEmpty() ) return; config.writeEntry( name, value ); }
void AddresseeDialog::addCompletionItem( const TQString &str, TQListViewItem *item ) { if ( str.isEmpty() ) return; mItemDict.insert( str, item ); mAddresseeEdit->completionObject()->addItem( str ); }
// show but don't set into selColor, nor emit colorSelected void KColorDialog::showColor( const KColor &color, const TQString &name ) { d->bRecursion = true; if (name.isEmpty()) d->colorName->setText( i18n("-unnamed-")); else d->colorName->setText( name ); d->patch->setColor( color ); setRgbEdit( color ); setHsvEdit( color ); setHtmlEdit( color ); int h, s, v; color.hsv( &h, &s, &v ); d->hsSelector->setValues( h, s ); d->valuePal->blockSignals(true); d->valuePal->setHue( h ); d->valuePal->setSaturation( s ); d->valuePal->setValue( v ); d->valuePal->updateContents(); d->valuePal->blockSignals(false); d->valuePal->repaint( false ); d->bRecursion = false; }
bool KSSLD::cacheAddHost(KSSLCertificate cert, TQString host) { KSSLCNode *node; if (host.isEmpty()) return true; for (node = certList.first(); node; node = certList.next()) { if (cert == *(node->cert)) { if (!node->permanent && node->expires < TQDateTime::currentDateTime()) { certList.remove(node); cfg->deleteGroup(node->cert->getMD5Digest()); searchRemoveCert(node->cert); delete node; cacheSaveToDisk(); return false; } if (!node->hosts.contains(host)) { node->hosts << host; } certList.remove(node); certList.prepend(node); cacheSaveToDisk(); return true; } } return false; }
void KgpgView::updatetxt(TQString newtxt) { if (!newtxt.isEmpty()) editor->setText(newtxt); else KMessageBox::sorry(this,i18n("Encryption failed.")); }
void TESession::setUserTitle( int what, const TQString &caption ) { // (btw: what=0 changes title and icon, what=1 only icon, what=2 only title if ((what == 0) || (what == 2)) userTitle = caption; if ((what == 0) || (what == 1)) iconText = caption; if (what == 11) { TQString colorString = caption.section(';',0,0); TQColor backColor = TQColor(colorString); if (backColor.isValid()){// change color via \033]11;Color\007 if (backColor != modifiedBackground) { modifiedBackground = backColor; te->setDefaultBackColor(backColor); } } } if (what == 30) renameSession(caption); if (what == 31) { cwd=caption; cwd=cwd.replace( TQRegExp("^~"), TQDir::homeDirPath() ); emit openURLRequest(cwd); } if (what == 32) { // change icon via \033]32;Icon\007 iconName = caption; te->update(); } emit updateTitle(this); }
void KPCMCIAInfo::prepareCards() { if (!_pcmcia) { // FIXME: display error return; } for (int i = 0; i < _pcmcia->getCardCount(); i++) { TQString tabname = i18n("Card Slot %1"); KPCMCIAInfoPage *tp = new KPCMCIAInfoPage(_pcmcia->getCard(i), _mainTab); connect(this, TQT_SIGNAL(updateNow()), tp, TQT_SLOT(update())); connect(tp, TQT_SIGNAL(setStatusBar(const TQString&)), this, TQT_SLOT(slotTabSetStatus(const TQString&))); tp->resize(_mainTab->sizeHint()); _mainTab->addTab(tp, tabname.arg(i+1)); _pages.insert(i, tp); } }
TQString KateSearch::getSearchText() { // SelectionOnly: use selection // WordOnly: use word under cursor // SelectionWord: use selection if available, else use word under cursor // WordSelection: use word if available, else use selection TQString str; int getFrom = view()->config()->textToSearchMode(); switch (getFrom) { case KateViewConfig::SelectionOnly: // (Windows) //kdDebug() << "getSearchText(): SelectionOnly" << endl; if( m_view->hasSelection() ) str = m_view->selection(); break; case KateViewConfig::SelectionWord: // (classic Kate behavior) //kdDebug() << "getSearchText(): SelectionWord" << endl; if( m_view->hasSelection() ) str = m_view->selection(); else str = view()->currentWord(); break; case KateViewConfig::WordOnly: // (weird?) //kdDebug() << "getSearchText(): WordOnly" << endl; str = view()->currentWord(); break; case KateViewConfig::WordSelection: // (persistent selection lover) //kdDebug() << "getSearchText(): WordSelection" << endl; str = view()->currentWord(); if (str.isEmpty() && m_view->hasSelection() ) str = m_view->selection(); break; default: // (nowhere) //kdDebug() << "getSearchText(): Nowhere" << endl; break; } str.replace( TQRegExp("^\\n"), "" ); str.replace( TQRegExp("\\n.*"), "" ); return str; }
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 KMdiDockContainer::save( TDEConfig* cfg, const TQString& group_or_prefix ) { TQString grp = cfg->group(); cfg->deleteGroup( group_or_prefix + TQString( "::%1" ).arg( parent() ->name() ) ); cfg->setGroup( group_or_prefix + TQString( "::%1" ).arg( parent() ->name() ) ); if ( isOverlapMode() ) cfg->writeEntry( "overlapMode", "true" ); else cfg->writeEntry( "overlapMode", "false" ); // try to save the splitter position if ( parentDockWidget() && parentDockWidget() ->parent() ) { KDockSplitter * sp = ::tqqt_cast<KDockSplitter*>( parentDockWidget() -> parent() ); if ( sp ) cfg->writeEntry( "separatorPosition", m_separatorPos ); } TQPtrList<KMultiTabBarTab>* tl = m_tb->tabs(); TQPtrListIterator<KMultiTabBarTab> it( *tl ); TQStringList::Iterator it2 = itemNames.begin(); int i = 0; for ( ;it.current() != 0;++it, ++it2 ) { // cfg->writeEntry(TQString("widget%1").arg(i),m_ws->widget(it.current()->id())->name()); cfg->writeEntry( TQString( "widget%1" ).arg( i ), ( *it2 ) ); TQString s = tabCaptions[ *it2 ]; if ( !s.isEmpty() ) { cfg->writeEntry( TQString( "widget%1-tabCaption" ).arg( i ), s ); } s = tabTooltips[ *it2 ]; if ( !s.isEmpty() ) { cfg->writeEntry( TQString( "widget%1-tabTooltip" ).arg( i ), s ); } // kdDebug(760)<<"****************************************Saving: "<<m_ws->widget(it.current()->id())->name()<<endl; if ( m_tb->isTabRaised( it.current() ->id() ) ) cfg->writeEntry( m_ws->widget( it.current() ->id() ) ->name(), true ); ++i; } cfg->sync(); cfg->setGroup( grp ); }
TQString TokenizerString::toString() const { TQString result; if (!m_pushedChar1.isNull()) { result.append(m_pushedChar1); if (!m_pushedChar2.isNull()) result.append(m_pushedChar2); } m_currentString.appendTo(result); if (m_composite) { TQValueListConstIterator<TokenizerSubstring> i = m_substrings.begin(); TQValueListConstIterator<TokenizerSubstring> e = m_substrings.end(); for (; i != e; ++i) (*i).appendTo(result); } return result; }
TQCString KRemoteEncoding::encode(const TQString& name) const { TQCString result = codec->fromUnicode(name); if (codec->toUnicode(result) != name) return name.latin1(); return result; }
void KfindTabWidget::getDirectory() { TQString result = KFileDialog::getExistingDirectory( dirBox->text(dirBox->currentItem()).stripWhiteSpace(), this ); if (!result.isEmpty()) { for (int i = 0; i < dirBox->count(); i++) if (result == dirBox->text(i)) { dirBox->setCurrentItem(i); return; } dirBox->insertItem(result, 0); dirBox->setCurrentItem(0); } }
static void updatePoliciesConfig(TDEConfig *cfg) { TQStringList groups = cfg->groupList(); for (TQStringList::Iterator i = groups.begin(); i != groups.end(); ++i) { if ((*i).isEmpty() || *i == "General") { continue; } cfg->setGroup(*i); // remove it if it has expired if (!cfg->readBoolEntry("Permanent") && cfg->readDateTimeEntry("Expires") < TQDateTime::currentDateTime()) { cfg->deleteGroup(*i); continue; } TQString encodedCertStr = cfg->readEntry("Certificate"); TQCString encodedCert = encodedCertStr.local8Bit(); KSSLCertificate *newCert = KSSLCertificate::fromString(encodedCert); if (!newCert) { cfg->deleteGroup(*i); continue; } KSSLCertificateCache::KSSLCertificatePolicy policy = (KSSLCertificateCache::KSSLCertificatePolicy) cfg->readNumEntry("Policy"); bool permanent = cfg->readBoolEntry("Permanent"); TQDateTime expires = cfg->readDateTimeEntry("Expires"); TQStringList hosts = cfg->readListEntry("Hosts"); TQStringList chain = cfg->readListEntry("Chain"); cfg->deleteGroup(*i); cfg->setGroup(newCert->getMD5Digest()); cfg->writeEntry("Certificate", encodedCertStr); cfg->writeEntry("Policy", policy); cfg->writeEntry("Permanent", permanent); cfg->writeEntry("Expires", expires); cfg->writeEntry("Hosts", hosts); cfg->writeEntry("Chain", chain); delete newCert; } cfg->setGroup("General"); cfg->writeEntry("policies version", 2); cfg->sync(); }
void kSwarmSetup::slotOk() { KConfig *config = klock_config(); config->setGroup( "Settings" ); TQString sspeed; sspeed.setNum( speed ); config->writeEntry( "Speed", sspeed ); TQString slevels; slevels.setNum( maxLevels ); config->writeEntry( "MaxLevels", slevels ); config->sync(); delete config; accept(); }
void KSaveIOConfig::setProxyFor( const TQString& protocol, const TQString& _proxy ) { TDEConfig* cfg = config (); cfg->setGroup( "Proxy Settings" ); cfg->writeEntry( protocol.lower() + "Proxy", _proxy ); cfg->sync(); }