예제 #1
0
void SevenZipArch::addFile( const TQStringList & urls )
{
  TDEProcess *kp = m_currentProcess = new TDEProcess;

  kp->clearArguments();
  *kp << m_archiver_program << "a" ;

  if ( !m_password.isEmpty() )
    *kp << "-p" + m_password;

  KURL url( urls.first() );
  TQDir::setCurrent( url.directory() );

  *kp << m_filename;

  TQStringList::ConstIterator iter;
  for ( iter = urls.begin(); iter != urls.end(); ++iter )
  {
    KURL url( *iter );
    *kp << url.fileName();
  }

  connect( kp, TQT_SIGNAL( receivedStdout(TDEProcess*, char*, int) ),
           TQT_SLOT( slotReceivedOutput(TDEProcess*, char*, int) ) );
  connect( kp, TQT_SIGNAL( receivedStderr(TDEProcess*, char*, int) ),
           TQT_SLOT( slotReceivedOutput(TDEProcess*, char*, int) ) );
  connect( kp, TQT_SIGNAL( processExited(TDEProcess*) ),
           TQT_SLOT( slotAddExited(TDEProcess*) ) );

  if ( !kp->start( TDEProcess::NotifyOnExit, TDEProcess::AllOutput ) )
  {
    KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
    emit sigAdd( false );
  }
}
예제 #2
0
uint CpuConfig::addCpus()
{
#ifdef Q_OS_LINUX
  TQStringList output;
  TQString parser;
  TQFile file("/proc/stat");
  if (!file.open(IO_ReadOnly))
    return 0;

  // Parse the proc file
  TQTextStream procStream(&file);
  while (!procStream.atEnd()) {
    parser = procStream.readLine();
    if (TQRegExp("cpu").search(parser, 0) != -1
          && TQRegExp("cpu0").search(parser, 0) == -1) {
      output.append(parser);
    }
  }

  return output.count();
#endif

#ifdef Q_OS_BSD4
  int mib[] = { CTL_HW, HW_NCPU }; // hw.ncpu
  uint cpu;
  size_t cpuLen = sizeof(cpu);
  if (sysctl(mib, 2, &cpu, &cpuLen, NULL, 0) < 0)
    return 0;

  return cpu;
#endif
}
예제 #3
0
  TQStringList
KStringHandler::perlSplit(const TQRegExp & sep, const TQString & s, uint max)
{
  bool ignoreMax = 0 == max;

  TQStringList l;

  int searchStart = 0;
  int tokenStart = sep.search(s, searchStart);
  int len = sep.matchedLength();

  while (-1 != tokenStart && (ignoreMax || l.count() < max - 1))
  {
    if (!s.mid(searchStart, tokenStart - searchStart).isEmpty())
      l << s.mid(searchStart, tokenStart - searchStart);

    searchStart = tokenStart + len;
    tokenStart = sep.search(s, searchStart);
    len = sep.matchedLength();
  }

  if (!s.mid(searchStart, s.length() - searchStart).isEmpty())
    l << s.mid(searchStart, s.length() - searchStart);

  return l;
}
예제 #4
0
void KfindTabWidget::setURL( const KURL & url )
{
  TDEConfig *conf = TDEGlobal::config();
  conf->setGroup("History");
  m_url = url;
  TQStringList sl = conf->readPathListEntry("Directories");
  dirBox->clear(); // make sure there is no old Stuff in there

  if(!sl.isEmpty()) {
    dirBox->insertStringList(sl);
    // If the _searchPath already exists in the list we do not
    // want to add it again
    int indx = sl.findIndex(m_url.prettyURL());
    if(indx == -1)
      dirBox->insertItem(m_url.prettyURL(), 0); // make it the first one
    else
      dirBox->setCurrentItem(indx);
  }
  else {
    TQDir m_dir("/lib");
    dirBox ->insertItem( m_url.prettyURL() );
    dirBox ->insertItem( "file:" + TQDir::homeDirPath() );
    dirBox ->insertItem( "file:/" );
    dirBox ->insertItem( "file:/usr" );
    if (m_dir.exists())
      dirBox ->insertItem( "file:/lib" );
    dirBox ->insertItem( "file:/home" );
    dirBox ->insertItem( "file:/etc" );
    dirBox ->insertItem( "file:/var" );
    dirBox ->insertItem( "file:/mnt" );
  }
}
예제 #5
0
TQStringList IconThemesConfig::findThemeDirs(const TQString &archiveName)
{
  TQStringList foundThemes;

  KTar archive(archiveName);
  archive.open(IO_ReadOnly);
  const KArchiveDirectory* themeDir = archive.directory();

  KArchiveEntry* possibleDir = 0L;
  KArchiveDirectory* subDir = 0L;

  // iterate all the dirs looking for an index.theme or index.desktop file
  TQStringList entries = themeDir->entries();
  for (TQStringList::Iterator it = entries.begin();
       it != entries.end();
       ++it) {
    possibleDir = const_cast<KArchiveEntry*>(themeDir->entry(*it));
    if (possibleDir->isDirectory()) {
      subDir = dynamic_cast<KArchiveDirectory*>( possibleDir );
      if (subDir && (subDir->entry("index.theme") != NULL ||
                     subDir->entry("index.desktop") != NULL))
        foundThemes.append(subDir->name());
    }
  }

  archive.close();
  return foundThemes;
}
예제 #6
0
파일: main.cpp 프로젝트: Fat-Zer/tdebase
KURL *decodeImgDrop(TQDropEvent *e, TQWidget *wdg)
{
    KURL::List uris;

    if (KURLDrag::decode(e, uris) && (uris.count() > 0)) {
	KURL *url = new KURL(uris.first());

	KImageIO::registerFormats();
	if( KImageIO::canRead(KImageIO::type(url->fileName())) )
	    return url;

	TQStringList qs = TQStringList::split('\n', KImageIO::pattern());
	qs.remove(qs.begin());

	TQString msg = i18n( "%1 "
			    "does not appear to be an image file.\n"
			    "Please use files with these extensions:\n"
			    "%2")
			    .arg(url->fileName())
			    .arg(qs.join("\n"));
	KMessageBox::sorry( wdg, msg);
	delete url;
    }
    return 0;
}
예제 #7
0
파일: kssld.cpp 프로젝트: Fat-Zer/tdelibs
void KSSLD::searchAddCert(KSSLCertificate *cert) {
	skMD5Digest.insert(cert->getMD5Digest(), cert, true);

	TQStringList mails;
	cert->getEmails(mails);
	for(TQStringList::const_iterator iter = mails.begin(); iter != mails.end(); ++iter) {
		TQString email = static_cast<const TQString &>(*iter).lower();
		TQMap<TQString, TQPtrVector<KSSLCertificate> >::iterator it = skEmail.find(email);

		if (it == skEmail.end())
			it = skEmail.insert(email, TQPtrVector<KSSLCertificate>());

		TQPtrVector<KSSLCertificate> &elem = *it;
		
		if (elem.findRef(cert) == -1) {
			unsigned int n = 0;
			for(; n < elem.size(); n++) {
				if (!elem.at(n)) {
					elem.insert(n, cert);
					break;
				}
			}
			if (n == elem.size()) {
				elem.resize(n+1);
				elem.insert(n, cert);
			}
		}
	}	
}
예제 #8
0
void KMDriverDB::init(TQWidget *parent)
{
	TQFileInfo	dbfi(dbFile());
	TQString		dirname = KMFactory::self()->manager()->driverDirectory();
	TQStringList	dbDirs = TQStringList::split(':', dirname, false);
	bool	createflag(false);

	for (TQStringList::ConstIterator it=dbDirs.begin(); it!=dbDirs.end() && !createflag; ++it)
		if (!(*it).startsWith("module:") && !m_creator->checkDriverDB(*it, dbfi.lastModified()))
			createflag = true;

	if (createflag)
	{
		// starts DB creation and wait for creator signal
		if (!m_creator->createDriverDB(dirname,dbfi.absFilePath(),parent))
			KMessageBox::error(parent, KMFactory::self()->manager()->errorMsg().prepend("<qt>").append("</qt>"));
	}
	else if (m_entries.count() == 0)
	{
		// call directly the slot as the DB won't be re-created
		// this will (re)load the driver DB
		slotDbCreated();
	}
	else
		// no need to refresh, and already loaded, just emit signal
		emit dbLoaded(false);
}
예제 #9
0
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);
	}
}
예제 #10
0
void ShortcutsModule::readSchemeNames()
{
	TQStringList schemes = TDEGlobal::dirs()->findAllResources("data", "kcmkeys/*.kksrc");

	m_pcbSchemes->clear();
	m_rgsSchemeFiles.clear();

	i18n("User-Defined Scheme");
	m_pcbSchemes->insertItem( i18n("Current Scheme") );
	m_rgsSchemeFiles.append( "cur" );

	// This for system files
	for ( TQStringList::ConstIterator it = schemes.begin(); it != schemes.end(); ++it) {
	// KPersonalizer relies on .kksrc files containing all the keyboard shortcut
	//  schemes for various setups.  It also requires the TDE defaults to be in
	//  a .kksrc file.  The TDE defaults shouldn't be listed here.
		//if( r.search( *it ) != -1 )
		//   continue;

		KSimpleConfig config( *it, true );
		config.setGroup( "Settings" );
		TQString str = config.readEntry( "Name" );

		m_pcbSchemes->insertItem( str );
		m_rgsSchemeFiles.append( *it );
	}
}
예제 #11
0
  TQStringList
KStringHandler::perlSplit(const TQChar & sep, const TQString & s, uint max)
{
  bool ignoreMax = 0 == max;

  TQStringList l;

  int searchStart = 0;

  int tokenStart = s.find(sep, searchStart);

  while (-1 != tokenStart && (ignoreMax || l.count() < max - 1))
  {
    if (!s.mid(searchStart, tokenStart - searchStart).isEmpty())
      l << s.mid(searchStart, tokenStart - searchStart);

    searchStart = tokenStart + 1;
    tokenStart = s.find(sep, searchStart);
  }

  if (!s.mid(searchStart, s.length() - searchStart).isEmpty())
    l << s.mid(searchStart, s.length() - searchStart);

  return l;
}
예제 #12
0
void KXmlCommandDlg::setCommand(KXmlCommand *xmlCmd)
{
	setCaption(i18n("Command Edit for %1").arg(xmlCmd->name()));

	m_cmd = xmlCmd;
	m_description->setText(i18n(xmlCmd->description().utf8()));
	m_idname->setText(xmlCmd->name());

	m_requirements->clear();
	TQStringList	list = xmlCmd->requirements();
	TQListViewItem	*item(0);
	for (TQStringList::ConstIterator it=list.begin(); it!=list.end(); ++it)
	{
		item = new TQListViewItem(m_requirements, item, *it);
		item->setRenameEnabled(0, true);
	}

	int	index = m_mimelist.findIndex(xmlCmd->mimeType());
	if (index != -1)
		m_mimetype->setCurrentItem(index);
	else
		m_mimetype->setCurrentItem(0);

	list = xmlCmd->inputMimeTypes();
	m_selectedmime->clear();
	m_availablemime->clear();
	m_availablemime->insertStringList(m_mimelist);
	for (TQStringList::ConstIterator it=list.begin(); it!=list.end(); ++it)
	{
		m_selectedmime->insertItem(*it);
		delete m_availablemime->findItem(*it, TQt::ExactMatch);
	}
}
예제 #13
0
void TDMAppearanceWidget::loadGuiStyles(KBackedComboBox *combo)
{
  // XXX: Global + local schemes
  TQStringList list = TDEGlobal::dirs()->
      findAllResources("data", "tdestyle/themes/*.themerc", false, true);
  for (TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
  {
    KSimpleConfig config(*it, true);

    if (!(config.hasGroup("KDE") && config.hasGroup("Misc")))
	continue;

    config.setGroup("Desktop Entry");
    if (config.readBoolEntry("Hidden", false))
	continue;

    config.setGroup("KDE");
    TQString str2 = config.readEntry("WidgetStyle");
    if (str2.isNull())
	continue;

    config.setGroup("Misc");
    combo->insertItem( str2, config.readEntry("Name") );
  }
}
예제 #14
0
TQString TDECompletion::makeCompletion( const TQString& string )
{
    if ( myCompletionMode == TDEGlobalSettings::CompletionNone )
        return TQString::null;

    //kdDebug(0) << "TDECompletion: completing: " << string << endl;

    d->matches.clear();
    myRotationIndex = 0;
    myHasMultipleMatches = false;
    myLastMatch = myCurrentMatch;

    // in Shell-completion-mode, emit all matches when we get the same
    // complete-string twice
    if ( myCompletionMode == TDEGlobalSettings::CompletionShell &&
         string == myLastString ) {
        // Don't use d->matches since calling postProcessMatches()
        // on d->matches here would interfere with call to
        // postProcessMatch() during rotation
    
        findAllCompletions( string, &d->matches, myHasMultipleMatches );
        TQStringList l = d->matches.list();
        postProcessMatches( &l );
        emit matches( l );

        if ( l.isEmpty() )
            doBeep( NoMatch );
    
        return TQString::null;
    }

    TQString completion;
    // in case-insensitive popup mode, we search all completions at once
    if ( myCompletionMode == TDEGlobalSettings::CompletionPopup ||
         myCompletionMode == TDEGlobalSettings::CompletionPopupAuto ) {
        findAllCompletions( string, &d->matches, myHasMultipleMatches );
        if ( !d->matches.isEmpty() )
            completion = d->matches.first();
    }
    else
        completion = findCompletion( string );

    if ( myHasMultipleMatches )
        emit multipleMatches();

    myLastString = string;
    myCurrentMatch = completion;

    postProcessMatch( &completion );

    if ( !string.isEmpty() ) { // only emit match when string is not empty
        //kdDebug(0) << "TDECompletion: Match: " << completion << endl;
        emit match( completion );
    }

    if ( completion.isNull() )
        doBeep( NoMatch );

    return completion;
}
예제 #15
0
TQStringList KURIFilter::pluginNames() const
{
    TQStringList list;
    for(TQPtrListIterator<KURIFilterPlugin> i = pluginsIterator(); *i; ++i)
        list.append((*i)->name());
    return list;
}
예제 #16
0
static void printList( const TQStringList& list )
{
    TQStringList::ConstIterator it = list.begin();
    for ( ; it != list.end(); ++it )
        cout << (*it).local8Bit().data() << endl;
    cout << endl;
}
예제 #17
0
파일: legacy.cpp 프로젝트: Fat-Zer/tdebase
/*!
  Restores legacy session management data (i.e. restart applications)
*/
void KSMServer::restoreLegacySession( TDEConfig* config )
{
    if( config->hasGroup( "Legacy" + sessionGroup )) {
        TDEConfigGroupSaver saver( config, "Legacy" + sessionGroup );
        restoreLegacySessionInternal( config );
    } else if( wm == "twin" ) { // backwards comp. - get it from twinrc
	TDEConfigGroupSaver saver( config, sessionGroup );
	int count =  config->readNumEntry( "count", 0 );
	for ( int i = 1; i <= count; i++ ) {
    	    TQString n = TQString::number(i);
    	    if ( config->readEntry( TQString("program")+n ) != wm )
                continue;
    	    TQStringList restartCommand =
                config->readListEntry( TQString("restartCommand")+n );
	    for( TQStringList::ConstIterator it = restartCommand.begin();
		 it != restartCommand.end();
		 ++it ) {
		if( (*it) == "-session" ) {
		    ++it;
		    if( it != restartCommand.end()) {
			TDEConfig cfg( "session/" + wm + "_" + (*it), true );
			cfg.setGroup( "LegacySession" );
			restoreLegacySessionInternal( &cfg, ' ' );
		    }
		}
	    }
	}
    }
}
예제 #18
0
파일: kssld.cpp 프로젝트: Fat-Zer/tdelibs
/**
  * @internal
  * Returns a list of certificates as QStrings read from the given file
  */
static TQStringList caReadCerticatesFromFile(TQString filename) {

	TQStringList certificates;
	TQString certificate, temp;
	TQFile file(filename);

	if (!file.open(IO_ReadOnly))
		return certificates;

	while (!file.atEnd()) {
		file.readLine(temp, 999);
		if (temp.startsWith("-----BEGIN CERTIFICATE-----")) {
			certificate = TQString::null;
			continue;
		}

		if (temp.startsWith("-----END CERTIFICATE-----")) {
			certificates.append(certificate);
			certificate = TQString::null;
			continue;
		}

		certificate += temp.stripWhiteSpace();
	}

	file.close();

	return certificates;
}
예제 #19
0
void recursive_transfer(const KArchiveDirectory * dir,
	    const TQString & path, KZip * zip)
{
    TQStringList l = dir->entries();
    TQStringList::Iterator it = l.begin();
    for( ; it != l.end(); ++it )
    {
        const KArchiveEntry* e = dir->entry( (*it) );
	kdDebug() << "actual file: " << e->name() << endl;
	if (e->isFile())
	{
    	    Q_ASSERT( e && e->isFile() );
    	    const KArchiveFile* f = (KArchiveFile*)e;
    	    printf("FILE=%s\n", e->name().latin1());

    	    TQByteArray arr( f->data() );
    	    printf("SIZE=%i\n",arr.size() );
    	    TQString str( arr );
    	    printf("DATA=%s\n", str.latin1());

	    if (e->symlink().isEmpty()) {
	        zip->writeFile( path+e->name().latin1(),
			    "holgi", "holgrp",
			    arr.size() , f->data() );
	    } else
	        zip->writeSymLink(path+e->name(), e->symlink(), "leo", "leo",
				0120777, 1000000000l, 1000000000l, 1000000000l);
	}
	else if (e->isDirectory())
	{
	    recursive_transfer((KArchiveDirectory *)e ,
			path+e->name()+"/", zip);
	}
    }
}
예제 #20
0
void ZoneClock::editClock()
{
  ClockDialog *_dlg = new ClockDialog(this, 0, true);
  CityList cities;
  TQStringList timezones = cities.timezones();
  for (TQStringList::iterator it = timezones.begin(); it != timezones.end(); ++it)
    _dlg->ClockZone->insertItem(i18n((*it).utf8()));

  _dlg->ClockCaption->setText(_nameLabel->text().left(_nameLabel->text().length()-1));
  for (int i=0; i<_dlg->ClockZone->count(); ++i)
    if (_dlg->ClockZone->text(i) == i18n(_zone.utf8()))
      {
        _dlg->ClockZone->setCurrentItem(i);
        break;
      }

  if (_dlg->exec() == TQDialog::Accepted)
    {
      _zone = timezones[_dlg->ClockZone->currentItem()];
      _name = _dlg->ClockCaption->text().append(":");
      _nameLabel->setText(_dlg->ClockCaption->text().append(":"));
      updateTime();
      layout()->invalidate();
      emit changed();
    }

  delete _dlg;
}
예제 #21
0
TQString TDECompletion::previousMatch()
{
    TQString completion;
    myLastMatch = myCurrentMatch;

    if ( d->matches.isEmpty() ) {
        findAllCompletions( myLastString, &d->matches, myHasMultipleMatches );
        completion = d->matches.last();
        myCurrentMatch = completion;
        myRotationIndex = 0;
        postProcessMatch( &completion );
        emit match( completion );
        return completion;
    }

    TQStringList matches = d->matches.list();
    myLastMatch = matches[ myRotationIndex ];
    if ( myRotationIndex == 1 )
        doBeep( Rotation ); // indicate first item -> rotating

    else if ( myRotationIndex == 0 )
        myRotationIndex = matches.count();

    myRotationIndex--;

    completion = matches[ myRotationIndex ];
    myCurrentMatch = completion;
    postProcessMatch( &completion );
    emit match( completion );
    return completion;
}
예제 #22
0
void TDERecentDocument::clear()
{
  TQStringList list = recentDocuments();
  TQDir dir;
  for(TQStringList::Iterator it = list.begin(); it != list.end() ; ++it)
    dir.remove(*it);
}
예제 #23
0
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();
}
예제 #24
0
TQStringList KStringHandler::capwords( const TQStringList &list )
{
    TQStringList tmp = list;
    for ( TQStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it ) {
        *it = ( *it )[ 0 ].upper() + ( *it ).mid( 1 );
    }
    return tmp;
}
예제 #25
0
void KMConfigFonts::loadConfig(TDEConfig *)
{
	TQSettings	settings;
	m_embedfonts->setChecked(settings.readBoolEntry("/qt/embedFonts", true));
	TQStringList	paths = settings.readListEntry("/qt/fontPath", ':');
	TQListViewItem	*item(0);
	for (TQStringList::ConstIterator it=paths.begin(); it!=paths.end(); ++it)
		item = new TQListViewItem(m_fontpath, item, *it);
}
예제 #26
0
void ConfigWidget::setCorrectLanguage( const TQStringList& langs)
{
    int idx = 0;
    for ( TQStringList::const_iterator itr = langs.begin();
          itr != langs.end(); ++itr, ++idx ) {
        if ( *itr == d->broker->settings()->defaultLanguage() )
            d->ui->m_langCombo->setCurrentItem( idx );
    }
}
예제 #27
0
void SevenZipArch::addDir( const TQString & dirName )
{
  if ( !dirName.isEmpty() )
  {
    TQStringList list;
    list.append( dirName );
    addFile( list );
  }
}
예제 #28
0
파일: kssld.cpp 프로젝트: Fat-Zer/tdelibs
TQStringList KSSLD::caList() {
TQStringList x;
TDEConfig cfg("ksslcalist", true, false);

	x = cfg.groupList();
	x.remove("<default>");

return x;
}
예제 #29
0
TQString KMountPoint::devNameFromOptions(const TQStringList &options)
{
   // Search options to find the device name
   for ( TQStringList::ConstIterator it = options.begin(); it != options.end(); ++it)
   {
      if( (*it).startsWith("dev="))
         return TQString(*it).remove("dev=");
   } 
   return TQString("none");
}
예제 #30
0
void EditAction::updateDCOPFunctions()
{
	theDCOPFunctions->clear();
	if(theDCOPApplications->currentText().isNull() || theDCOPApplications->currentText().isEmpty()) return;
	TQStringList functions = AddAction::getFunctions(nameProgramMap[theDCOPApplications->currentText()], theDCOPObjects->currentText());
	if(!functions.size() && theDCOPApplications->currentText() == (*theAction).program()) theDCOPFunctions->insertItem((*theAction).method().prototype());
	for(TQStringList::iterator i = functions.begin(); i != functions.end(); ++i)
		theDCOPFunctions->insertItem(*i);
	updateArguments();
}