コード例 #1
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
  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;
}
コード例 #2
0
ファイル: mntconfig.cpp プロジェクト: Fat-Zer/tdeutils
void MntConfigWidget::iconChanged(const TQString &iconName)
{
  if( iconName.findRev('_') == 0 ||
      (iconName.right(iconName.length()-iconName.findRev('_'))!="_mount" &&
      iconName.right(iconName.length()-iconName.findRev('_'))!="_unmount"))
    {
      TQString msg = i18n(""
			 "This filename is not valid: %1\n"
			 "It must end with "
			 "\"_mount\" or \"_unmount\".").arg(iconName);
      KMessageBox::sorry( this, msg );
      return;
    }

  TQListViewItem *item = mList->selectedItem();
  for(unsigned i=0 ; i < mDiskList.count() ; ++i) 
    {
      if (mDiskLookup[i] == item) 
	{
	  DiskEntry *disk = mDiskList.at(i);
	  if( disk != 0 )
	    {
	      disk->setIconName(iconName);
	      mIconLineEdit->setText(iconName);
	      TDEIconLoader &loader = *TDEGlobal::iconLoader();
	      item->setPixmap( ICONCOL, loader.loadIcon( iconName, TDEIcon::Small));
	    }
	  break;
	}
    }
}
コード例 #3
0
ファイル: createsmileywindow.cpp プロジェクト: MagicGroup/eva
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();
}
コード例 #4
0
ファイル: kcompletion.cpp プロジェクト: Fat-Zer/tdelibs
// Iteratively removes a string from the tree. The nicer recursive
// version apparently was a little memory hungry (see #56757)
void TDECompTreeNode::remove( const TQString& str )
{
    TQString string = str;
    string += TQChar(0x0);

    TQPtrVector<TDECompTreeNode> deletables( string.length() + 1 );

    TDECompTreeNode *child = 0L;
    TDECompTreeNode *parent = this;
    deletables.insert( 0, parent );
    
    uint i = 0;
    for ( ; i < string.length(); i++ )
    {
        child = parent->find( string.at( i ) );
        if ( child )
            deletables.insert( i + 1, child );
        else
            break;

        parent = child;
    }

    for ( ; i >= 1; i-- )
    {
        parent = deletables.at( i - 1 );
        child = deletables.at( i );
        if ( child->myChildren.count() == 0 )
            delete parent->myChildren.remove( child );
    }
}
コード例 #5
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
  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;
}
コード例 #6
0
ファイル: x11helper.cpp プロジェクト: Fat-Zer/tdebase
// 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;
}
コード例 #7
0
static int heb2num(const TQString& str, int & iLength) {
  TQChar c;
  TQString s = str;
  int result = 0;
  iLength = 0;
  int decadeValues[14] = {10, 20, 20, 30, 40, 40, 50,
                          50, 60, 70, 80, 80, 90, 90};

  uint pos;
  for (pos = 0 ; pos < s.length() ; pos++)
  {
    c = s[pos];
    if (s.length() > pos && (s[pos + 1] == TQChar('\'') ||
                             s[pos + 1] == TQChar('\"')))
    {
      iLength++;
      s.remove(pos + 1, 1);
    }

    if (c >= TQChar(0x05D0) && c <= TQChar(0x05D7))
    {
      if (s.length() > pos && s[pos + 1] >= TQChar(0x05D0) &&
          s[pos + 1] <= TQChar(0x05EA))
        result += (c.unicode() - 0x05D0 + 1) * 1000;
      else
        result += c.unicode() - 0x05D0 + 1;
    }
    else if (c == TQChar(0x05D8))
    {
      if (s.length() > pos && s[pos + 1] >= TQChar(0x05D0) &&
          s[pos + 1] <= TQChar(0x05EA) && s[pos + 1] != TQChar(0x05D5) &&
          s[pos + 1] != TQChar(0x05D6))
        result += 9000;
      else
        result += 9;
    }
    else if (c >= TQChar(0x05D9) && c <= TQChar(0x05E6))
    {
      if (s.length() > pos && s[pos + 1] >= TQChar(0x05D9))
        return -1;
      else
        result += decadeValues[c.unicode() - 0x05D9];
    }
    else if (c >= TQChar(0x05E7) && c <= TQChar(0x05EA))
    {
      result += (c.unicode() - 0x05E7 + 1) * 100;
    }
    else
    {
      break;
    }
  }

  iLength += pos;

  return result;
}
コード例 #8
0
ファイル: kxsconfig.cpp プロジェクト: Fat-Zer/kdeartwork
//---------------------------------------------------------------------------
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();
	}
    }
}
コード例 #9
0
ファイル: tdeio_man.cpp プロジェクト: Fat-Zer/tdebase
static
bool parseUrl(const TQString& _url, TQString &title, TQString &section)
{
    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;
}
コード例 #10
0
ファイル: knumber.cpp プロジェクト: Fat-Zer/tdeutils
static TQString roundNumber(const TQString &numStr, int precision)
{
  TQString tmpString = numStr;
  if (precision < 0  ||
      ! TQRegExp("^[+-]?\\d+(\\.\\d+)*(e[+-]?\\d+)?$").exactMatch(tmpString))
    return numStr;


  // Skip the sign (for now)
  bool neg = (tmpString[0] == '-');
  if (neg  ||  tmpString[0] == '+') tmpString.remove(0, 1);


  // Split off exponential part (including 'e'-symbol)
  TQString mantString = tmpString.section('e', 0, 0,
					 TQString::SectionCaseInsensitiveSeps);
  TQString expString = tmpString.section('e', 1, 1,
					TQString::SectionCaseInsensitiveSeps |
					TQString::SectionIncludeLeadingSep);
  if (expString.length() == 1) expString = TQString();


  _round(mantString, precision);

  if(neg) mantString.prepend('-');

  return mantString +  expString;
}
コード例 #11
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
TQString
KStringHandler::tagURLs( const TQString& text )
{
    /*static*/ TQRegExp urlEx("(www\\.(?!\\.)|(fish|(f|ht)tp(|s))://)[\\d\\w\\./,:_~\\?=&;#@\\-\\+\\%\\$]+[\\d\\w/]");

    TQString richText( text );
    int urlPos = 0, urlLen;
    while ((urlPos = urlEx.search(richText, urlPos)) >= 0)
    {
        urlLen = urlEx.matchedLength();
        TQString href = richText.mid( urlPos, urlLen );
        // Qt doesn't support (?<=pattern) so we do it here
        if((urlPos > 0) && richText[urlPos-1].isLetterOrNumber()){
            urlPos++;
            continue;
        }
        // Don't use TQString::arg since %01, %20, etc could be in the string
        TQString anchor = "<a href=\"" + href + "\">" + href + "</a>";
        richText.replace( urlPos, urlLen, anchor );


        urlPos += anchor.length();
    }
    return richText;
}
コード例 #12
0
ファイル: kcompletion.cpp プロジェクト: Fat-Zer/tdelibs
void TDECompletion::addItem( const TQString& item, uint weight )
{
    if ( item.isEmpty() )
        return;

    TDECompTreeNode *node = myTreeRoot;
    uint len = item.length();

    bool sorted = (myOrder == Sorted);
    bool weighted = ((myOrder == Weighted) && weight > 1);

    // knowing the weight of an item, we simply add this weight to all of its
    // nodes.

    for ( uint i = 0; i < len; i++ ) {
        node = node->insert( item.at(i), sorted );
        if ( weighted )
            node->confirm( weight -1 ); // node->insert() sets weighting to 1
    }

    // add 0x0-item as delimiter with evtl. weight
    node = node->insert( 0x0, true );
    if ( weighted )
        node->confirm( weight -1 );
//     tqDebug("*** added: %s (%i)", item.latin1(), node->weight());
}
コード例 #13
0
ファイル: katesearch.cpp プロジェクト: Fat-Zer/tdelibs
void SearchCommand::processText( Kate::View *view, const TQString &cmd )
{
  static TQRegExp re_ifind("ifind(?::([bcrs]*))?\\s(.*)");
  if ( re_ifind.search( cmd ) > -1 )
  {
    TQString flags = re_ifind.cap( 1 );
    TQString pattern = re_ifind.cap( 2 );


    // if there is no setup, or the text length is 0, set up the properties
    if ( ! m_ifindFlags || pattern.isEmpty() )
      ifindInit( flags );
    // if there is no fromCursor, add it if this is not the first character
    else if ( ! ( m_ifindFlags & KFindDialog::FromCursor ) && ! pattern.isEmpty() )
      m_ifindFlags |= KFindDialog::FromCursor;

    // search..
    if ( ! pattern.isEmpty() )
    {
      KateView *v = (KateView*)view;

      // If it *looks like* we are continuing, place the cursor
      // at the beginning of the selection, so that the search continues.
      // ### check more carefully, like is  the cursor currently at the end
      // of the selection.
      if ( pattern.startsWith( v->selection() ) &&
           v->selection().length() + 1 == pattern.length() )
        v->setCursorPositionInternal( v->selStartLine(), v->selStartCol() );

      v->find( pattern, m_ifindFlags, false );
    }
  }
}
コード例 #14
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
TQString KStringHandler::rPixelSqueeze(const TQString& name, const TQFontMetrics& fontMetrics, uint maxPixels)
{
  uint nameWidth = fontMetrics.width(name);

  if (maxPixels < nameWidth)
  {
    TQString tmp = name;
    const uint em = fontMetrics.maxWidth();
    maxPixels -= fontMetrics.width("...");

    while (maxPixels < nameWidth && !tmp.isEmpty())
    {
      int length = tmp.length();
      int delta = em ? (nameWidth - maxPixels) / em : length;
      delta = kClamp(delta, 1, length) ;

      tmp.remove(length - delta, delta);
      nameWidth = fontMetrics.width(tmp);
    }

    return (tmp + "...");
  }

  return name;
}
コード例 #15
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
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;
}
コード例 #16
0
ファイル: tdebuildsycoca.cpp プロジェクト: Fat-Zer/tdelibs
void KBuildSycoca::processGnomeVfs()
{
   TQString file = locate("app-reg", "gnome-vfs.applications");
   if (file.isEmpty())
   {
//      kdDebug(7021) << "gnome-vfs.applications not found." << endl;
      return;
   }

   TQString app;

   char line[1024*64];

   FILE *f = fopen(TQFile::encodeName(file), "r");
   while (!feof(f))
   {
      if (!fgets(line, sizeof(line)-1, f))
      {
        break;
      }

      if (line[0] != '\t')
      {
          app = TQString::fromLatin1(line);
          app.truncate(app.length()-1);
      }
      else if (strncmp(line+1, "mime_types=", 11) == 0)
      {
          TQString mimetypes = TQString::fromLatin1(line+12);
          mimetypes.truncate(mimetypes.length()-1);
          mimetypes.replace(TQRegExp("\\*"), "all");
          KService *s = g_bsf->findServiceByName(app);
          if (!s)
             continue;

          TQStringList &serviceTypes = s->accessServiceTypes();
          if (serviceTypes.count() <= 1)
          {
             serviceTypes += TQStringList::split(',', mimetypes);
//             kdDebug(7021) << "Adding gnome mimetypes for '" << app << "'.\n";
//             kdDebug(7021) << "ServiceTypes=" << s->serviceTypes().join(":") << endl;
          }
      }
   }
   fclose( f );
}
コード例 #17
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
TQString KStringHandler::rsqueeze( const TQString & str, uint maxlen )
{
  if (str.length() > maxlen) {
    int part = maxlen-3;
    return TQString(str.left(part) + "...");
  }
  else return str;
}
コード例 #18
0
int QtRegexpHighlighter::highlightParagraph( const TQString & text, int endStateOfLastPara )
{
    TQRegExp regexp( _regexp );
    regexp.setCaseSensitive( _caseSensitive );
    regexp.setMinimal( _minimal );

    setFormat( 0, text.length(), _editor->font(), TQt::black );

    if ( !regexp.isValid() || regexp.isEmpty() ) {
        return 0;
    }

    // ------------------------------ Process with the regular expression.
    TQColor colors[] = { TQt::red, TQt::blue };
    int color = endStateOfLastPara;
    if ( color < 0 || color > 1 )
        color = 0;

    int index = 0;
    int start, length;
    while ( (index = regexp.search( text, index ) ) != -1 && index < (int) text.length()) {
        if ( regexp.pos(1) != -1 ) {
            start = regexp.pos(1);
            length = regexp.cap(1).length();
        }
        else {
            start = index;
            length = regexp.matchedLength();
        }

        if ( start != index )
            setFormat( index, start-index, colors[color] );

        TQFont font = _editor->font();
        font.setUnderline( true );
        font.setPointSize( (int) (font.pointSize() * 1.3) );
        setFormat( start, length, font, colors[color] );

        if ( length + (start-index) != regexp.matchedLength() )
            setFormat( start+length, regexp.matchedLength()-length-(start-index), colors[color] );

        index +=  TQMAX( 1, regexp.matchedLength() ); // ensure progress when matching for example ^ or \b
        color = (color+1)%2;
    }
    return color;
}
コード例 #19
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
TQString KStringHandler::lsqueeze( const TQString & str, uint maxlen )
{
  if (str.length() > maxlen) {
    int part = maxlen-3;
    return TQString("..." + str.right(part));
  }
  else return str;
}
コード例 #20
0
ファイル: konsole_wcwidth.cpp プロジェクト: Fat-Zer/tdebase
// single byte char: +1, multi byte char: +2
int string_width( const TQString &txt )
{
  int w = 0;

  for ( uint i = 1; i < txt.length(); ++i ) {
    w += konsole_wcwidth(txt[i].unicode());
  }
 return w;
}
コード例 #21
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
TQString KStringHandler::obscure( const TQString &str )
{
  TQString result;
  const TQChar *unicode = str.unicode();
  for ( uint i = 0; i < str.length(); ++i )
    result += ( unicode[ i ].unicode() < 0x21 ) ? unicode[ i ] :
        TQChar( 0x1001F - unicode[ i ].unicode() );

  return result;
}
コード例 #22
0
ファイル: evaqunmemberpicker.cpp プロジェクト: MagicGroup/eva
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());
	}
}
コード例 #23
0
ファイル: kcompletion.cpp プロジェクト: Fat-Zer/tdelibs
void TDECompletion::findAllCompletions(const TQString& string,
                                     TDECompletionMatchesWrapper *matches,
                                     bool& hasMultipleMatches) const
{
    //kdDebug(0) << "*** finding all completions for " << string << endl;

    if ( string.isEmpty() )
        return;

    if ( myIgnoreCase ) { // case insensitive completion
        extractStringsFromNodeCI( myTreeRoot, TQString::null, string, matches );
        hasMultipleMatches = (matches->count() > 1);
        return;
    }

    TQChar ch;
    TQString completion;
    const TDECompTreeNode *node = myTreeRoot;

    // start at the tree-root and try to find the search-string
    for( uint i = 0; i < string.length(); i++ ) {
        ch = string.at( i );
        node = node->find( ch );

        if ( node )
            completion += ch;
        else
            return; // no completion -> return empty list
    }
    
    // Now we have the last node of the to be completed string.
    // Follow it as long as it has exactly one child (= longest possible
    // completion)

    while ( node->childrenCount() == 1 ) {
        node = node->firstChild();
        if ( !node->isNull() )
            completion += *node;
        // kdDebug() << completion << node->latin1();
    }


    // there is just one single match)
    if ( node->childrenCount() == 0 )
        matches->append( node->weight(), completion );

    else {
        // node has more than one child
        // -> recursively find all remaining completions
        hasMultipleMatches = true;
        extractStringsFromNode( node, completion, matches );
    }
}
コード例 #24
0
ファイル: trashimpl.cpp プロジェクト: Fat-Zer/tdebase
TQString TrashImpl::makeRelativePath( const TQString& topdir, const TQString& path )
{
    const TQString realPath = TDEStandardDirs::realFilePath( path );
    // topdir ends with '/'
    if ( realPath.startsWith( topdir ) ) {
        const TQString rel = realPath.mid( topdir.length() );
        Q_ASSERT( rel[0] != '/' );
        return rel;
    } else { // shouldn't happen...
        kdWarning() << "Couldn't make relative path for " << realPath << " (" << path << "), with topdir=" << topdir << endl;
        return realPath;
    }
}
コード例 #25
0
static TQString num2heb(int num, bool includeMillenium)
{
  const TQChar decade[] = {0x05D8, 0x05D9, 0x05DB, 0x05DC, 0x05DE,
                          0x05E0, 0x05E1, 0x05E2, 0x05E4, 0x05E6};
  TQString result;

  if (num < 1 || num > 9999)
    return TQString::number(num);

  if (num >= 1000) {
    if (includeMillenium || num % 1000 == 0)
      result += TQChar(0x05D0 - 1 + num / 1000);
    num %= 1000;
  }
  if (num >= 100) {
    while (num >= 500) {
      result += TQChar(0x05EA);
      num -= 400;
    }
    result += TQChar(0x05E7 - 1 + num / 100);
    num %= 100;
  }
  if (num >= 10) {
    if (num == 15 || num == 16)
      num -= 9;
    result += decade[num / 10];
    num %= 10;
  }
  if (num > 0)
    result += TQChar(0x05D0 - 1 + num);

  if (result.length() == 1)
    result += "'";
  else
    result.insert(result.length() - 1, '\"');

  return result;
}
コード例 #26
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
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 );
}
コード例 #27
0
ファイル: kstringhandler.cpp プロジェクト: Fat-Zer/tdelibs
bool KStringHandler::matchFileName( const TQString& filename, const TQString& pattern  )
{
   int len = filename.length();
   int pattern_len = pattern.length();

   if (!pattern_len)
      return false;

   // Patterns like "Makefile*"
   if ( pattern[ pattern_len - 1 ] == (QChar)'*' && len + 1 >= pattern_len ) {
      if ( pattern[ 0 ] == (QChar)'*' )
      {
         return filename.find(pattern.mid(1, pattern_len - 2)) != -1;
      }

      const TQChar *c1 = pattern.unicode();
      const TQChar *c2 = filename.unicode();
      int cnt = 1;
      while ( cnt < pattern_len && *c1++ == *c2++ )
         ++cnt;
      return cnt == pattern_len;
   }

   // Patterns like "*~", "*.extension"
   if ( pattern[ 0 ] == (QChar)'*' && len + 1 >= pattern_len )
   {
     const TQChar *c1 = pattern.unicode() + pattern_len - 1;
     const TQChar *c2 = filename.unicode() + len - 1;
     int cnt = 1;
     while ( cnt < pattern_len && *c1-- == *c2-- )
        ++cnt;
     return cnt == pattern_len;
  }

   // Patterns like "Makefile"
   return ( filename == pattern );
}
コード例 #28
0
ファイル: zoneclock.cpp プロジェクト: Fat-Zer/tdetoys
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++;
    }
}
コード例 #29
0
ファイル: kssld.cpp プロジェクト: Fat-Zer/tdelibs
bool KSSLD::caRegenerate() {
TQString path = TDEGlobal::dirs()->saveLocation("kssl") + "/ca-bundle.crt";

TQFile out(path);

	if (!out.open(IO_WriteOnly))
		return false;

TDEConfig cfg("ksslcalist", true, false);

TQStringList x = cfg.groupList();

	for (TQStringList::Iterator i = x.begin();
				   i != x.end();
				   ++i) {
		if ((*i).isEmpty() || *i == "<default>") continue;

		cfg.setGroup(*i);

		if (!cfg.readBoolEntry("site", false)) continue;

		TQString cert = cfg.readEntry("x509", "");
		if (cert.length() <= 0) continue;

		unsigned int xx = cert.length() - 1;
		for (unsigned int j = 0; j < xx/64; j++) {
			cert.insert(64*(j+1)+j, '\n');
		}
		out.writeBlock("-----BEGIN CERTIFICATE-----\n", 28);
		out.writeBlock(cert.latin1(), cert.length());
		out.writeBlock("\n-----END CERTIFICATE-----\n\n", 28);
		out.flush();
	}

return true;
}
コード例 #30
0
ファイル: arkutils.cpp プロジェクト: Fat-Zer/tdeutils
TDEIO::filesize_t
ArkUtils::getSizes(TQStringList *list)
{
  TDEIO::filesize_t sum = 0;
  TQString str;
  KDE_struct_stat st;

  for ( TQStringList::Iterator it = list->begin(); it != list->end(); ++it)
  {
    str = *it;
    str = str.right(str.length()-5);
    if (KDE_stat(TQFile::encodeName(str), &st ) < 0)
       continue;
    sum += st.st_size;
  }
  return sum;
}