// createRootXmlTags
//
// This function creates three QStrings, one being an <?xml .. ?> processing
// instruction, and the others being the opening and closing tags of an
// element, <foo> and </foo>.  This basically allows us to get the raw XML
// text needed to open/close an XML stream, without resorting to generating
// the XML ourselves.  This function uses QDom to do the generation, which
// ensures proper encoding and entity output.
static void createRootXmlTags(const QDomElement &root, QString *xmlHeader, QString *tagOpen, QString *tagClose)
{
	QDomElement e = root.cloneNode(false).toElement();

	// insert a dummy element to ensure open and closing tags are generated
	QDomElement dummy = e.ownerDocument().createElement("dummy");
	e.appendChild(dummy);

	// convert to xml->text
	QString str;
	{
		QTextStream ts(&str, QIODevice::WriteOnly);
		e.save(ts, 0);
	}

	// parse the tags out
	int n = str.find('<');
	int n2 = str.find('>', n);
	++n2;
	*tagOpen = str.mid(n, n2-n);
	n2 = str.findRev('>');
	n = str.findRev('<');
	++n2;
	*tagClose = str.mid(n, n2-n);

	// generate a nice xml processing header
	*xmlHeader = "<?xml version=\"1.0\"?>";
}
Example #2
0
QString Util::longestCommonPath( const QStrList& files )
{
    QStrListIterator i( files );

    uint minLen = strlen( i.toFirst() );
    for ( ; i.current(); ++i ) {
        if ( minLen > strlen( i.current() ) ) {
            minLen = strlen( i.current() );
        }
    }
    uint j;
    for ( j = 0; j < minLen; j++ ) {
        const char* first = i.toFirst();
        for ( ; i.current(); ++i ) {
            if ( strncmp( first, i.current(), j ) ) {
                // Prefixes are NOT the same.
                break;
            }
        }
        if ( i.current() ) {
            // The common prefix is 0 to j-1, inclusive.
            break;
        }
    }
    QString prefix = i.toFirst();
    int idx = prefix.findRev( '/', j );
    if ( idx > -1 ) {
        prefix = prefix.left( prefix.findRev( '/', j ) );
    } else {
        prefix = "";
    }

    return prefix;
}
Example #3
0
/** Sets a field's layout attributes */
void MReportEngine::setFieldAttributes( MFieldObject * field,
                                        QDomNamedNodeMap * attr ) {
  field->setFieldName( attr->namedItem( "Field" ).nodeValue() );
  field->setDataType( attr->namedItem( "DataType" ).nodeValue().toInt() );
  field->setDateFormat( attr->namedItem( "DateFormat" ).nodeValue().toInt() );
  field->setPrecision( attr->namedItem( "Precision" ).nodeValue().toInt() );
  field->setCurrency( attr->namedItem( "Currency" ).nodeValue().toInt() );
  field->setCommaSeparator( attr->namedItem( "CommaSeparator" ).nodeValue().
                            toInt() );
  field->setCodBarType( attr->namedItem( "CodBarType" ).nodeValue() );
  int res = attr->namedItem( "CodBarRes" ).nodeValue().toInt();
  field->setCodBarRes( res > 0 ? res : 72 );
  field->setBlankZero( attr->namedItem( "BlankZero" ).nodeValue().toInt() );

  QString tmp = attr->namedItem( "NegValueColor" ).nodeValue();

  field->setNegValueColor( tmp.left( tmp.find( "," ) ).toInt(),
                           tmp.mid( tmp.find( "," ) + 1,
                                    ( tmp.findRev( "," ) - tmp.find( "," ) ) -
                                    1 ).toInt(),
                           tmp.right( tmp.length() - tmp.findRev( "," ) -
                                      1 ).toInt() );

  setLabelAttributes(( MLabelObject * ) field, attr );
}
Example #4
0
void ZGui::CargarMenu1()
{
  QPixmap p1;
  QString line;
  QFile entrada("/ezxlocal/LinXtend/usr/bin/cron/user.txt");
  QTextStream stentrada(&entrada);
  if ( entrada.open(IO_ReadOnly | IO_Translate) )
  {
	while ( !stentrada.eof() )
	{
	  line = stentrada.readLine();
	  if ( line != "" )
	  {
		  ZListBoxItem* autoitem = new ZListBoxItem ( zllb1, QString ( "%I%M" ) );
		  p1=QPixmap(iconReader.getIcon("calen_schedule_tab", false));
		  QImage image; image = p1.convertToImage(); 
		  image = image.smoothScale(18, 17); p1.convertFromImage(image);
		  autoitem->setPixmap ( 0, p1 );
		  QString name = line;
		  int i = name.find("/",0); name.remove(0,i);
		  i= name.findRev("/"); if ( i!=name.length() ) name.remove(0,i+1);
		  autoitem->appendSubItem ( 1, name, false, NULL );
		  QString campos = line;
		  i = campos.findRev( QChar(' ') ); campos.remove(i,campos.length()-i);
		  autoitem->appendSubItem ( 1, campos, false, NULL );
		  zllb1->insertItem ( autoitem,-1,true );
      }
	}
  }

}
Example #5
0
void DocLnk::init(const QString &file)
{
    if ( isValid() ) {
#ifndef FORCED_DIR_STRUCTURE_WAY
  if ( mType.isNull() )
      // try to infer it
#endif
  {
      int s0 = file.findRev('/');
      if ( s0 > 0 ) {
    int s1 = file.findRev('/',s0-1);
    if ( s1 > 0 ) {
        int s2 = file.findRev('/',s1-1);
        if ( s2 > 0 ) {
      mType = file.mid(s2+1,s0-s2-1);
        }
    }
      }
  }
    } else if ( QFile::exists(file) ) {
  QString n = file;
  n.replace(QRegExp(".*/"),"");
  n.replace(QRegExp("\\..*"),"");
  setName( n );
  setFile( file );
    }
    MimeType mt(mType);
    if( mt.application() )
  mExec = mt.application()->exec();
}
QString QtGuiSignal::signalType(QString& signal)
{
#if QT_VERSION >= 300
  return signal.right(signal.length()-signal.findRev(QRegExp("\\(.*\\)")));
#else
  return signal.right(signal.length()-signal.findRev(QRegExp("(.*)")));
#endif
}
Example #7
0
/**
 * @internal
 */
QString OGenericPluginLoader::unlibify( const QString& str ) {
    QString st = str.mid( str.find( "lib" )+3 );
#ifdef Q_OS_MACX
    return st.left( st.findRev( ".dylib" ) );
#else
    return st.left( st.findRev( ".so" ) );
#endif
}
Example #8
0
int main(int argc, char** argv)
{
    QString fPath = QString(argv[0]);
    appName = fPath.mid( fPath.findRev("/") +1 );
    appPath = fPath.left( fPath.findRev("/") );

    DBG_OUT("App Name : %s", appName.ascii() );
    DBG_OUT("App Path : %s", appPath.ascii() );

    checkDirectories();
    APPDB_Open();

	ZApplication* app = new ZApplication(argc, argv);

    FullPath_7z = APP_FULLPATH_7Z;

    if ( !detectLanguageFile(appPath) )
    {
        detectLanguageFile( APP_SYSFILES_PATH );
    }

    if ( !LoadCustomizationFile(appPath) )
    {
        LoadCustomizationFile( APP_SYSFILES_PATH );
    }

    srand( (int)getpid() );

    if (argc>1)
    {
        if ( checkParameters(argc,argv) )
        {
            delete app;
            return 0;
        }
    }

    // LoadAllRegisteredApp();

    DBG_OUT("Register Load DONE");

	zBaseGUI *gui = new zBaseGUI(NULL);
//    DBG_OUT("GUI Done (gui = %Xl , app = %Xl )", (uint)gui, (uint)app);
	app->setMainWidget(gui);
//	DBG_OUT("Set Main");
        gui->show();

	int ret=app->exec();
//int ret=0;
	delete gui;
	delete app;

    APPDB_Close();
	return ret;
}
Example #9
0
void KCountryPage::loadCountryList(KLanguageButton *combo) {

	QString sub = QString::fromLatin1("l10n/");

	// clear the list
	combo->clear();

	QStringList regionfiles = KGlobal::dirs()->findAllResources("locale", sub + "*.desktop");
	QMap<QString,QString> regionnames;

	for ( QStringList::ConstIterator it = regionfiles.begin(); it != regionfiles.end(); ++it ) {
		KSimpleConfig entry(*it);
		entry.setGroup(QString::fromLatin1("KCM Locale"));
		QString name = entry.readEntry(QString::fromLatin1("Name"), i18n("without name"));

		QString tag = *it;
		int index;

		index = tag.findRev('/');
		if (index != -1)
			tag = tag.mid(index + 1);

		index = tag.findRev('.');
		if (index != -1)
			tag.truncate(index);

		regionnames.insert(name, tag);
	}

	for ( QMap<QString,QString>::ConstIterator mit = regionnames.begin(); mit != regionnames.end(); ++mit ) {
		combo->insertSubmenu( mit.key(), '-' + mit.data(), sub );
	}

	// add all languages to the list
	QStringList countrylist = KGlobal::dirs()->findAllResources("locale", sub + "*/entry.desktop");
	countrylist.sort();

	for ( QStringList::ConstIterator it = countrylist.begin(); it != countrylist.end(); ++it ) {
		KSimpleConfig entry(*it);
		entry.setGroup(QString::fromLatin1("KCM Locale"));
		QString name = entry.readEntry(QString::fromLatin1("Name"), i18n("without name"));
		QString submenu = '-' + entry.readEntry("Region");

		QString tag = *it;
		int index = tag.findRev('/');
		tag.truncate(index);
		index = tag.findRev('/');
		tag = tag.mid(index+1);

		QPixmap flag( locate( "locale", QString::fromLatin1("l10n/%1/flag.png").arg(tag) ) );
		QIconSet icon( flag );
		combo->insertItem( icon, name, tag, submenu );
	}
}
Example #10
0
QSObject QSStringClass::findRev( QSEnv *env )
{
    QString s = env->thisValue().sVal();
    int idx = env->numArgs() >= 2 ? env->arg( 1 ).toInteger() : -1;
    QSObject arg0 = env->arg(0);
    if ( arg0.objectType() == env->regexpClass() ) {
	QRegExp *re = QSRegExpClass::regExp(&arg0);
	return env->createNumber(s.findRev(*re, idx));
    } else {
	bool cs = env->numArgs() >= 3 ? env->arg( 2 ).toBoolean() : TRUE;
	return env->createNumber( s.findRev(arg0.toString(), idx, cs ));
    }
}
Example #11
0
void GofunHelp::openLink(const QString& link)
{;
	QString final_link = link;
	if(link.find("http") == 0)
	{
		base_url = link;
		base_url.remove(link.findRev("/"),link.length()-link.findRev("/"));
		final_link.remove(0,link.findRev("/"));
		host = QUrl(link).host();
	}
	http->setHost(host);
	http->get(base_url + final_link);
}
Example #12
0
QString KDesktopFile::locateLocal(const QString &path)
{
    QString local;
    if(path.endsWith(".directory"))
    {
        local = path;
        if(!QDir::isRelativePath(local))
        {
            // Relative wrt apps?
            local = KGlobal::dirs()->relativeLocation("apps", path);
        }

        if(QDir::isRelativePath(local))
        {
            local = ::locateLocal("apps", local); // Relative to apps
        }
        else
        {
            // XDG Desktop menu items come with absolute paths, we need to
            // extract their relative path and then build a local path.
            local = KGlobal::dirs()->relativeLocation("xdgdata-dirs", local);
            if(!QDir::isRelativePath(local))
            {
                // Hm, that didn't work...
                // What now? Use filename only and hope for the best.
                local = path.mid(path.findRev('/') + 1);
            }
            local = ::locateLocal("xdgdata-dirs", local);
        }
    }
    else
    {
        if(QDir::isRelativePath(path))
        {
            local = ::locateLocal("apps", path); // Relative to apps
        }
        else
        {
            // XDG Desktop menu items come with absolute paths, we need to
            // extract their relative path and then build a local path.
            local = KGlobal::dirs()->relativeLocation("xdgdata-apps", path);
            if(!QDir::isRelativePath(local))
            {
                // What now? Use filename only and hope for the best.
                local = path.mid(path.findRev('/') + 1);
            }
            local = ::locateLocal("xdgdata-apps", local);
        }
    }
    return local;
}
Example #13
0
/** Load country list */
void KControlHeader::loadCountryList(KLanguageCombo *combo)
{
    QString sub = QString::fromLatin1("l10n/");

    // clear the list
    combo->clear();

    QStringList regionlist = KGlobal::dirs()->findAllResources("locale", sub + QString::fromLatin1("*.desktop"));
    regionlist.sort();

    for ( QStringList::ConstIterator it = regionlist.begin();
          it != regionlist.end();
          ++it )
    {
        QString tag = *it;
        int index;

        index = tag.findRev('/');
        if (index != -1) tag = tag.mid(index + 1);

        index = tag.findRev('.');
        if (index != -1) tag.truncate(index);

        KSimpleConfig entry(*it);
        entry.setGroup(QString::fromLatin1("KCM Locale"));
        QString name = entry.readEntry(QString::fromLatin1("Name"));

        combo->insertSubmenu( name, '-' + tag, sub );
    }

    // add all languages to the list
    QStringList countrylist = KGlobal::dirs()->findAllResources("locale",  sub + QString::fromLatin1("*/entry.desktop"));
    countrylist.sort();

    for ( QStringList::ConstIterator it = countrylist.begin();
          it != countrylist.end(); ++it )
    {
        KSimpleConfig entry(*it);
        entry.setGroup(QString::fromLatin1("KCM Locale"));
        QString name = entry.readEntry(QString::fromLatin1("Name"));
        QString submenu = '-' + entry.readEntry(QString::fromLatin1("Region"));

        QString tag = *it;
        int index = tag.findRev('/');
        tag.truncate(index);
        index = tag.findRev('/');
        tag = tag.mid(index+1);
        combo->insertLanguage(tag, name, sub, submenu);
    }
}
Example #14
0
void setAplDir(QString& path)
{
  path = qApp->applicationDirPath();
  
  int i;
  if(path.right(1)=='/')
  {
    i = path.findRev('/');
    
    path.remove(i,3);
  }
  path+="+";
  i = path.findRev("/bin+");
  path.remove(i,20);
}
/*!
    Returns the filename of the shared library this QLibrary object
    handles, including the platform specific file extension.

    For example:
    \code
    QLibrary lib( "mylib" );
    QString str = lib.library();
    \endcode
    will set \e str to "mylib.dll" on Windows and OS/2, and "libmylib.so" on Linux.
*/
QString QLibrary::library() const
{
    if ( libfile.isEmpty() )
	return libfile;

    QString filename = libfile;

#if defined(Q_WS_WIN) || defined(Q_OS_OS2) 
    if ( filename.findRev( '.' ) <= filename.findRev( '/' ) )
	filename += ".dll";
#else
    QStringList filters = "";
#ifdef Q_OS_MACX
    filters << ".so";
    filters << ".bundle";
    filters << ".dylib"; //the last one is also the default one..
#elif defined(Q_OS_HPUX)
    filters << ".sl";
#else
    filters << ".so";
#endif
    for(QStringList::Iterator it = filters.begin(); TRUE; ) {
	QString filter = (*it);
	++it;

	if(QFile::exists(filename + filter)) {
	    filename += filter;
	    break;
	} else if(!filter.isEmpty()) {
	    QString tmpfilename = filename;
	    const int x = tmpfilename.findRev( "/" );
	    if ( x != -1 ) {
		QString path = tmpfilename.left( x + 1 );
		QString file = tmpfilename.right( tmpfilename.length() - x - 1 );
		tmpfilename = QString( "%1lib%2" ).arg( path ).arg( file );
	    } else {
		tmpfilename = QString( "lib%1" ).arg( filename );
	    }
	    tmpfilename += filter;
	    if(QFile::exists(tmpfilename) || it == filters.end()) {
		filename = tmpfilename;
		break;
	    }
	}
    }
#endif
    return filename;
}
Example #16
0
void MapLoader::load(unsigned int width, const QString &theme, unsigned int height, float opacity)
{
  // find the maps available
  QValueList<uint> sizes;
  QStringList files = maps(theme);
  for (uint i=0; i<files.count(); ++i)
    {
      QString f = files[i];
      int pos = f.findRev("/");
      if (pos >= 0)
        f = f.mid(pos+1);
      pos = f.findRev(".");
      if (pos >= 0)
        f = f.left(pos);
      sizes.append(f.toInt());
    }
  qHeapSort(sizes);

  // find the closest (bigger) size
  uint size=0;
  for (uint i=0; i<sizes.count(); ++i)
    if (sizes[i] >= width)
      {
	size = sizes[i];
	break;
      }
  
  QImage image;
  if (size == 0)
    {
      image = QImage(locate("data", "kworldclock/maps/depths/800.jpg"));
      size = 800;
    }
  else  
    image = QImage(locate("data", QString("kworldclock/maps/%1/%2.jpg").arg(theme).arg(size)));

  if (height == 0)
    height = width/2;

  if ((image.width() != (int)width) || (image.height() != (int)height))
    image = image.smoothScale(width, height);

  // convert to light map
  _light.convertFromImage(image);

  // calculate dark map
  _dark.convertFromImage(KImageEffect::blend(Qt::black, image, opacity));
}
Example #17
0
// message parsing for control strings from WCS/VNS
wcsClient::MessageType wcsClient::analyzeMessage(QString &str, QString &i) {
	MessageType ret = Undefined;
	if (str.find("RESULT=\"1\"")!=-1 ) ret = Result;
	else if (str.find("ERROR")!=-1) ret = Err;
	else if (str.find("PROGRESS")!=-1) {
		i=str.mid(str.findRev(':')+1,str.findRev('%')-str.findRev(':')-1);
		str=str.mid(10,str.findRev(':')-str.find('\"')-1);
		ret = Progress;
	}
	else if (str.find("OUTPUT") != -1) {
		// then we have output to a WCS relative path
		str = str.section("\"", 1, 1);
		ret = Output;
	}
	return ret;
}
Example #18
0
void SlaveConfigPrivate::readConfigProtocolHost(const QString &, SlaveConfigProtocol *scp, const QString &host)
{
   MetaData *metaData = new MetaData;
   scp->host.replace(host, metaData);

   // Read stuff
   // Break host into domains
   QString domain = host;

   if (!domain.contains('.'))
   {
      // Host without domain.
      if (scp->configFile->hasGroup("<local>"))
         readConfig(scp->configFile, "<local>", metaData);
   }

   int pos = 0;
   do
   {
      pos = host.findRev('.', pos-1);

      if (pos < 0)
        domain = host;
      else
        domain = host.mid(pos+1);

      if (scp->configFile->hasGroup(domain))
         readConfig(scp->configFile, domain.lower(), metaData);
   }
   while (pos > 0);
}
//************************************************************************************************
//************************************** class ZFileOpenDialog ***********************************
//************************************************************************************************
ZFileOpenDialog::ZFileOpenDialog()
  :MyBaseDlg()
{
  setMainWidgetTitle ( "Cron" );

  browser = new ZListBox ( QString ( "%C18%I%M" ), this, 0);
  browser->setFixedWidth ( 240 );
  connect(browser, SIGNAL(returnPressed(ZListBoxItem *)), SLOT(brClicked()));

  sPath = "/";
  CargarBrowser( sPath );

  setContentWidget ( browser );
  
  ZSoftKey *softKey = new ZSoftKey ( NULL, this, this );

  QString ProgDir = QString ( qApp->argv() [0] ) ;
  int i = ProgDir.findRev ( "/" );
  ProgDir.remove ( i+1, ProgDir.length() - i );

  QString val; 
  ZConfig readlang("/ezxlocal/download/appwrite/setup/ezx_system.cfg", true);
  Idioma2 = "ezxlocal/download/mystuff/.system/LinXtend/usr/languages/" + readlang.readEntry(QString("SYS_SYSTEM_SET"), QString("LanguageType"), "en-us");
  if ( ! QFileInfo(Idioma2).isFile() ) Idioma2 = "/ezxlocal/download/mystuff/.system/LinXtend/usr/languages/en-us";

  ZConfig IDini(Idioma2, false);
  QString IDval = IDini.readEntry(QString("COMMON"), QString("MENU_SELECT"), "");
  softKey->setText ( ZSoftKey::LEFT, IDval, ( ZSoftKey::TEXT_PRIORITY ) 0 );
  IDval = IDini.readEntry(QString("COMMON"), QString("MENU_CANCEL"), "");
  softKey->setText ( ZSoftKey::RIGHT, IDval, ( ZSoftKey::TEXT_PRIORITY ) 0 );
  softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( reject() ) );
  softKey->setClickedSlot ( ZSoftKey::LEFT, this, SLOT ( accept() ) );
  setCSTWidget ( softKey );
}
QString getAppDir()
{
    QString tmp = QString(qApp->argv()[0]);
    int i = tmp.findRev("/");
    tmp.remove(i+1,tmp.length()-1);
    return tmp;
}
Example #21
0
QString KoStore::expandEncodedPath( QString intern ) const
{
  if ( m_namingVersion == NAMING_VERSION_RAW )
    return intern;

  QString result;
  int pos;

  if ( ( pos = intern.findRev( '/', -1 ) ) != -1 ) {
    result = expandEncodedDirectory( intern.left( pos ) ) + '/';
    intern = intern.mid( pos + 1 );
  }

  // Now process the filename. If the first character is numeric, we have
  // a main document.
  if ( QChar(intern.at(0)).isDigit() )
  {
    // If this is the first part name, check if we have a store with
    // old-style names.
    if ( ( m_namingVersion == NAMING_VERSION_2_2 ) &&
         ( m_mode == Read ) &&
         ( fileExists( result + "part" + intern + ".xml" ) ) )
      m_namingVersion = NAMING_VERSION_2_1;

    if ( m_namingVersion == NAMING_VERSION_2_1 )
      result = result + "part" + intern + ".xml";
    else
      result = result + "part" + intern + "/" + MAINNAME;
  }
  else
    result += intern;
  return result;
}
Example #22
0
void AStylePart::activePartChanged ( KParts::Part *part )
{
	bool enabled = false;

	KParts::ReadWritePart *rw_part = dynamic_cast<KParts::ReadWritePart*> ( part );

	if ( rw_part )
	{
		KTextEditor::EditInterface *iface = dynamic_cast<KTextEditor::EditInterface*> ( rw_part );

		if ( iface )
		{
			// check for the everything case..
			if ( m_searchExtensions.find ( "*" ) == m_searchExtensions.end() )
			{
				QString extension = rw_part->url().path();
				int pos = extension.findRev ( '.' );
				if ( pos >= 0 )
				{
					extension = extension.mid ( pos );
					enabled = ( m_searchExtensions.find ( extension ) != m_searchExtensions.end() );
				}
			}
			else
			{
				enabled = true;
			}
		}
	}

	formatTextAction->setEnabled ( enabled );
}
Example #23
0
void QUrl::setFileName( const QString& name )
{
    QString fn( name );
    slashify( fn );

    while ( fn[ 0 ] == '/' )
	fn.remove( (uint)0, 1 );

    QString p;
    if ( path().isEmpty() ) {
	p = "/";
    } else {
	p = path();
	int slash = p.findRev( QChar( '/' ) );
	if ( slash == -1 ) {
	    p = "/";
	} else if ( p[ (int)p.length() - 1 ] != '/' ) {
	    p.truncate( slash + 1 );
	}
    }

    p += fn;
    if ( !d->queryEncoded.isEmpty() )
	p += "?" + d->queryEncoded;
    setEncodedPathAndQuery( p );
}
Example #24
0
int IMAPwrapper::createMbox(const QString&folder,const FolderP&parentfolder,const QString& delemiter,bool getsubfolder)
{
    if (folder.length()==0) return 0;
    login();
    if (!m_imap) {return 0;}
    QString pre = account->getPrefix();
    if (delemiter.length()>0 && pre.findRev(delemiter)!=pre.length()-1) {
        pre+=delemiter;
    }
    if (parentfolder) {
        pre += parentfolder->getDisplayName()+delemiter;
    }
    pre+=folder;
    if (getsubfolder) {
        if (delemiter.length()>0) {
            pre+=delemiter;
        } else {
            Global::statusMessage(tr("Cannot create folder %1 for holding subfolders").arg(pre));
            return 0;
        }
    }
    odebug << "Creating " << pre.latin1() << "" << oendl;
    int res = mailimap_create(m_imap,pre.latin1());
    if (res != MAILIMAP_NO_ERROR) {
        Global::statusMessage(tr("%1").arg(m_imap->imap_response));
        return 0;
    }
    return 1;
}
Example #25
0
void Core::setupShourtcutTips(KXMLGUIClient * client)
{
  QPtrList<KXMLGUIClient> clients;
  if (client != 0)
    clients.append(client);
  else
    clients = TopLevel::getInstance()->main()->guiFactory()->clients();
  
  for( QPtrListIterator<KXMLGUIClient> it(clients); it.current(); ++it ) {
    KActionCollection *actionCollection = (*it)->actionCollection();
    for (int i = 0; i < actionCollection->count(); i++) {
      KAction *action = actionCollection->action(i);
            
      QString tooltip = action->toolTip();
      if (tooltip.isEmpty())
        tooltip = action->text().remove('&');
      else {
        int i = tooltip.findRev('(');
        if (i > 0) tooltip = tooltip.left(i).stripWhiteSpace();
      }

      QString shortcut = action->shortcutText();
      if (!shortcut.isEmpty())
        tooltip += " (" + shortcut + ")";
        action->setToolTip(tooltip);
      }
  }
}
Example #26
0
static void getNameAndVersion( const QString& str, const QString& lineStart, QString& fileName, QString& version )
{
   if ( str.left( lineStart.length() )==lineStart && fileName.isEmpty() )
   {
      unsigned int pos = lineStart.length();
      while ( pos<str.length() && (str[pos]==' ' || str[pos]=='\t') ) ++pos;
      unsigned int pos2 = str.length()-1;
      while ( pos2>pos )
      { 
         while (pos2>pos && str[pos2]!=' ' && str[pos2]!='\t') --pos2;
         fileName = str.mid( pos, pos2-pos );
         std::cerr << "KDiff3: " << fileName.latin1() << std::endl;
         if ( FileAccess(fileName).exists() ) break;
         --pos2;
      }
      
      int vpos = str.findRev("\t", -1);
      if ( vpos>0 && vpos>(int)pos2 )
      {
         version = str.mid( vpos+1 );
         while( !version.right(1)[0].isLetterOrNumber() )
            version.truncate( version.length()-1 );
      }
   }
}
Example #27
0
bool
HelixEngine::canDecode( const KURL &url ) const
{
   if (!m_inited)
      return false;

   debug() << "In canDecode " << url.prettyURL() << endl;

   if (url.protocol() == "http" || url.protocol() == "rtsp")
      return true;

   const QString path = url.path();
   const QString ext  = path.mid( path.findRev( '.' ) + 1 ).lower();

   if (ext != "txt")
      for (int i=0; i<(int)m_mimes.size(); i++)
      {
         if (m_mimes[i].type.grep("audio").count() ||
             m_mimes[i].type.grep("video").count() ||
             m_mimes[i].type.grep("application").count())
            if (m_mimes[i].ext.grep(ext).count())
            {
               return true;
            }
      }

   return false;
}
Example #28
0
bool
DspMakefileGenerator::openOutput(QFile &file) const
{
    QString outdir;
    if(!file.name().isEmpty()) {
	if(QDir::isRelativePath(file.name()))
	    file.setName(Option::output_dir + file.name()); //pwd when qmake was run
	QFileInfo fi(file);
	if(fi.isDir())
	    outdir = file.name() + QDir::separator();
    }
    if(!outdir.isEmpty() || file.name().isEmpty())
	file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION"));
    if(QDir::isRelativePath(file.name())) {
	QString ofile;
	ofile = file.name();
	int slashfind = ofile.findRev('\\');
	if (slashfind == -1) {
	    ofile = ofile.replace(QRegExp("-"), "_");
	} else {
	    int hypenfind = ofile.find('-', slashfind);
	    while (hypenfind != -1 && slashfind < hypenfind) {
		ofile = ofile.replace(hypenfind, 1, "_");
		hypenfind = ofile.find('-', hypenfind + 1);
	    }
	}
	file.setName(Option::fixPathToLocalOS(QDir::currentDirPath() + Option::dir_sep + ofile));
    }
    return Win32MakefileGenerator::openOutput(file);
}
Example #29
0
QSObject QSStringClass::lastIndexOf( QSEnv *env )
{
    QString s = env->thisValue().sVal();
    QString s2 = env->arg( 0 ).toString();
    int pos = env->numArgs() >= 2 ? env->arg( 1 ).toInteger() : s.length() - 1;
    return env->createNumber( s.findRev( s2, pos ) );
}
MediaBrowser::MEDIA_TYPE MediaBrowser::getFileType(QString filePath)
{
	int i = -1;
	i = filePath.findRev("/");
    filePath = filePath.remove(0, i+1);
	i = -1;
	i = filePath.findRev(".");
	filePath = filePath.remove(0, i+1);	
	filePath = ( QString(".%1").arg(filePath) ).lower();
	if( filePath == ".jpg" || filePath == ".jpeg" || filePath == ".png" || filePath == ".bmp" || filePath == ".gif" )
		return TYPE_IMG;
	else if ( filePath == ".mp3" || filePath == ".midi" || filePath == ".ogg" || filePath == ".wma" || filePath == ".wav" )	
		return TYPE_AUDIO;
	else
		return TYPE_NULL;
}