Example #1
0
void cddb_playlist_encode(QStrList& list,QString& playstr){

    playstr = "";
    for( uint i = 0; i < list.count(); i++){
	playstr += list.at(i);
	if(i < list.count() -1)
	    playstr += ",";
    }
}
Example #2
0
void CDDB::queryCD(unsigned long _magicID,QStrList& querylist)
{
//    if(state == DO_NOTHING)
//        return;
//    state = DO_NOTHING;
    if((sock == 0L || sock->socket() < 0) && protocol==CDDBP)
	return;

    QString str;
    title = "";
    category = "";
    magicID = _magicID;

    str = str.sprintf("cddb query %08lx %u ",magicID,querylist.count()-1);
    for(int i = 0; i <(int) querylist.count(); i++) 
    {
	str += querylist.at(i);
	str += " ";
    }

    if(protocol==CDDBHTTP)
    {
	cddb_connect_internal();
	if(connected)
	{
	    QString param = str;
	    send_http_command(param);
	    if(use_http_proxy)
	    {
		saved_state = QUERY;
		state       = HTTP_REQUEST;
	    } else {
		state  = QUERY;
	    }
	}
    }
    else
    {
	// CDDB
	timeouttimer.stop();
	timeouttimer.start(timeout*1000,TRUE);
	str += "\n";
	if(debugflag)
		fprintf(stderr, "strdata: %s\n", str.data());
	write(sock->socket(),str.data(),str.length());
        state  = QUERY;
    }

  
}
Example #3
0
void KFMServer::slotCopyClients( const char *_src_urls, const char *_dest_url )
{
    QString s = _src_urls;
    s.detach();
    QStrList urlList;

    QString dest = _dest_url;
    if ( dest == "trash:/" )
        dest = "file:" + KFMPaths::TrashPath();

    int i;
    while ( ( i = s.find( "\n" ) ) != -1 )
    {
        QString t = s.left( i );
        urlList.append( t.data() );
        s = s.mid( i + 1, s.length() );
    }

    urlList.append( s.data() );

    KIOJob *job = new KIOJob();
    if ( urlList.count() == 1 )
        job->copy( urlList.first(), dest.data() );
    else
        job->copy( urlList, dest.data() );
}
Example #4
0
void KFMClient::slotMove( const char *_src_urls, const char *_dest_url )
{
    QString s = _src_urls;
    s.detach();
    QStrList urlList;

    QString dest = _dest_url;
    if ( dest == "trash:/" )
        dest = "file:" + KFMPaths::TrashPath();

    int i;
    while ( ( i = s.find( "\n" ) ) != -1 )
    {
        QString t = s.left( i );
        urlList.append( t.data() );
        s = s.mid( i + 1, s.length() );
    }

    urlList.append( s.data() );

    KIOJob *job = new KIOJob();
    connect( job, SIGNAL( finished( int ) ), this, SLOT( finished( int ) ) );
    if ( urlList.count() == 1 )
        job->move( urlList.first(), dest.data() );
    else
        job->move( urlList, dest.data() );
}
Example #5
0
KIconTemplateContainer::KIconTemplateContainer() : QObject()
{
  QString path;
  instances++;
  debug("KIconTemplateContainer: instances %d", instances);
  if(templatelist)
    return;

  debug("KIconTemplateContainer: Creating templates");

  templatelist = new QList<KIconTemplate>;
  templatelist->setAutoDelete(true);

  QStrList names;
  KConfig *k = kapp->getConfig();
  k->setGroup("Templates");
  k->readListEntry("Names", names);
  for(int i = 0; i < (int)names.count(); i++)
  {
    KIconTemplate *it = new KIconTemplate;
    it->path = k->readEntry(names.at(i));
    it->title = names.at(i);
    //debug("Template: %s\n%s", names.at(i), path.data());
    templatelist->append(it);
  }

  if(templatelist->count() == 0)
  {
    createStandardTemplates(templatelist);
  }
}
Example #6
0
bool cddb_playlist_decode(QStrList& list, QString& str){
 
    bool isok = true;
    int pos1, pos2;
    pos1 = 0;
    pos2 = 0;

    list.clear();

    while((pos2 = str.find(",",pos1,true)) != -1){

	if(pos2 > pos1){
	    list.append(str.mid(pos1,pos2 - pos1));
	}
    
	pos1 = pos2 + 1;
    }
  
    if(pos1 <(int) str.length())
	list.append(str.mid(pos1,str.length()));

    QString check;
    bool 	ok1;
    int   num;

    for(uint i = 0; i < list.count(); i++){
	check = list.at(i);
	check = check.stripWhiteSpace();

	if(check.isEmpty()){
	    list.remove(i);
	    i--;
	    continue;
	}

	if(check == QString (",")){
	    list.remove(i);
	    i--;
	    continue;
	}
    
	num = check.toInt(&ok1);
	if(!ok1 || num < 1){
	    list.remove(i);
	    i--;
	    isok = false;
	    continue;
	}
    
	list.remove(i);
	list.insert(i, check);

    }

    /*  for(uint i = 0; i < list.count(); i++){
	printf("playlist %d=%s\n",i,list.at(i));
	}*/
    return isok;
}
Example #7
0
static void clearAlignList( QStrList &l )
{
    if ( l.count() == 1 )
	return;
    if ( l.find( "AlignAuto" ) != -1 )
	l.remove( "AlignAuto" );
    if ( l.find( "WordBreak" ) != -1 )
	l.remove( "WordBreak" );
}
bool StringListSelectSetDialog::setValues(const QStrList& values)
{
  // ############################################################################
  lbStrings->clear();
  lbStrings->insertStrList(&values);
  assert(lbStrings->count()==values.count());
  return true;
  // ############################################################################
}
Example #9
0
static bool matchExcludedSymbols(const char *name)
{
  static QStrList exclSyms;
  if (exclSyms.count()==0) return FALSE; // nothing specified
  const char *pat = exclSyms.first();
  QCString symName = name;
  while (pat)
  {
    QCString pattern = pat;
    bool forceStart=FALSE;
    bool forceEnd=FALSE;
    if (pattern.at(0)=='^') 
      pattern=pattern.mid(1),forceStart=TRUE;
    if (pattern.at(pattern.length()-1)=='$') 
      pattern=pattern.left(pattern.length()-1),forceEnd=TRUE;
    if (pattern.find('*')!=-1) // wildcard mode
    {
      QRegExp re(substitute(pattern,"*",".*"),TRUE);
      int i,pl;
      i = re.match(symName,0,&pl);
      //printf("  %d = re.match(%s) pattern=%s\n",i,symName.data(),pattern.data());
      if (i!=-1) // wildcard match
      {
        int sl=symName.length();
        // check if it is a whole word match
        if ((i==0     || pattern.at(0)=='*'    || (!isId(symName.at(i-1))  && !forceStart)) &&
            (i+pl==sl || pattern.at(i+pl)=='*' || (!isId(symName.at(i+pl)) && !forceEnd))
           )
        {
          //printf("--> name=%s pattern=%s match at %d\n",symName.data(),pattern.data(),i);
          return TRUE;
        }
      }
    }
    else if (!pattern.isEmpty()) // match words
    {
      int i = symName.find(pattern);
      if (i!=-1) // we have a match!
      {
        int pl=pattern.length();
        int sl=symName.length();
        // check if it is a whole word match
        if ((i==0     || (!isId(symName.at(i-1))  && !forceStart)) &&
            (i+pl==sl || (!isId(symName.at(i+pl)) && !forceEnd))
           )
        {
          //printf("--> name=%s pattern=%s match at %d\n",symName.data(),pattern.data(),i);
          return TRUE; 
        }
      }
    }
    pat = exclSyms.next();
  }
  //printf("--> name=%s: no match\n",name);
  return FALSE;
}
bool StringListSelectAndReorderSet::setValues(const QStrList& values)
{ 
  // ############################################################################
  int index;
  // -----
  possible.erase(possible.begin(), possible.end());
  selected.erase(selected.begin(), selected.end());
  lbPossible->clear();
  lbSelected->clear();
  lbPossible->insertStrList(&values);
  assert(values.count()==lbPossible->count());
  // -----
  for(index=0; (unsigned)index<values.count(); index++)
    {
      possible.push_back(index);
    }
  assert(values.count()==possible.size()); 
  enableButtons(0);
  return false; 
  // ############################################################################
}
Example #11
0
void DirectoryView::contentsDropEvent( QDropEvent *e )
{
    autoopen_timer->stop();

    if ( !QUriDrag::canDecode(e) ) {
        e->ignore();
        return;
    }

    QListViewItem *item = itemAt( contentsToViewport(e->pos()) );
    if ( item ) {

        QStrList lst;

        QUriDrag::decode( e, lst );

        QString str;

        switch ( e->action() ) {
            case QDropEvent::Copy:
            str = "Copy";
            break;
            case QDropEvent::Move:
            str = "Move";
            e->acceptAction();
            break;
            case QDropEvent::Link:
            str = "Link";
            e->acceptAction();
            break;
            default:
            str = "Unknown";
        }

        str += "\n\n";

        e->accept();

        for ( uint i = 0; i < lst.count(); ++i ) {
            QString filename = lst.at( i );
            str += filename + "\n";
        }
        str += QString( "\nTo\n\n   %1" )
               .arg( fullPath(item) );

        QMessageBox::information( this, "Drop target", str, "Not implemented" );
    } else
        e->ignore();

}
Example #12
0
void KfmView::slotProperties()
{
	QStrList popupFiles = new QStrList();
	getActiveView()->getSelected ( popupFiles );
	if ( popupFiles.isEmpty() && popupMenuEvent )
	{
		popupFiles.append ( getURL() );
	}
    if ( popupFiles.count() != 1 )
    {
	warning(klocale->translate("ERROR: Can not open properties for multiple files"));
	return;
    }

    (void)new Properties( popupFiles.first() );
}
void K2sendPlayList::write(KConfig * config,k2sendWidget * w)
{
    QListViewItemIterator it( this );
    QStrList list;
    int cnt = 0;
    int total = list.count();
    while ( it.current() ) {
        K2sendPlayListItem *item =(K2sendPlayListItem*) it.current();
        list.append(item->file().latin1());
        ++it;
        cnt++;
        w->setProgress( int((100.0 / total) * cnt));
    }
    config->setGroup("playlist");
    config->writeEntry ("files",list);
    config->sync();
}
Example #14
0
void TEWidget::dropEvent(QDropEvent* event)
{
#if 0
    // The current behaviour when URL(s) are dropped is:
    // * if there is only ONE URL and if it's a LOCAL one, ask for paste or cd
    // * in all other cases, just paste
    //   (for non-local ones, or for a list of URLs, 'cd' is nonsense)
  QStrList strlist;
  int file_count = 0;
  dropText = "";
  bool bPopup = true;

  if(QUriDrag::decode(event, strlist)) {
    if (strlist.count()) {
      for(const char* p = strlist.first(); p; p = strlist.next()) {
        if(file_count++ > 0) {
          dropText += " ";
          bPopup = false; // more than one file, don't popup
        }

/*
        KURL url(p);
        if (url.isLocalFile()) {
          dropText += url.path(); // local URL : remove protocol
        }
        else {
          dropText += url.prettyURL();
          bPopup = false; // a non-local file, don't popup
        }
*/

      }

      if (bPopup)
        // m_drop->popup(pos() + event->pos());
  //m_drop->popup(mapToGlobal(event->pos())); // reserve
      else
  {
    if (currentSession) {
      currentSession->getEmulation()->sendString(dropText.local8Bit());
    }
//    kdDebug() << "Drop:" << dropText.local8Bit() << "\n";
  }
    }
  }
  else if(QTextDrag::decode(event, dropText)) {
Example #15
0
File: main.C Project: xwizard/kde1
void TEDemo::onDrop( KDNDDropZone* _zone )
{
    // The current behaviour when url(s) are dropped is
    // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd
    // * in all other cases, just paste
    //   (for non-local ones, or for a list of URLs, 'cd' is nonsense)
  QStrList strlist;
  KURL *url;
  int file_count = 0;
  char *p;
  dropText = "";
  bool bPopup = true;

  strlist = _zone->getURLList();
  if (strlist.count())
  {
    p = strlist.first();
    while(p != 0)
    {
      if(file_count++ > 0)
      {
        dropText += " ";
        bPopup = false; // more than one file, don't popup
      }
      url = new KURL( p );
      if (!strcmp(url->protocol(),"file"))
      {
        dropText += url->path(); // local URL : remove protocol
      }
      else
      {
        dropText += p;
        bPopup = false; // a non-local file, don't popup
      }
      delete url;
      p = strlist.next();
    }
    if (bPopup)
        m_drop->popup(QPoint(_zone->getMouseX(),_zone->getMouseY()));
    else
        se->getEmulation()->sendString(dropText.data());
  }
}
Example #16
0
int KConfigBase::readListEntry(const char *pKey, QStrList &list, char sep) const
{
    if(!hasKey(pKey))
        return 0;

    QCString str_list = readEntryUtf8(pKey);
    if(str_list.isEmpty())
        return 0;

    list.clear();
    QCString value = "";
    int len = str_list.length();

    for(int i = 0; i < len; i++)
    {
        if(str_list[i] != sep && str_list[i] != '\\')
        {
            value += str_list[i];
            continue;
        }
        if(str_list[i] == '\\')
        {
            i++;
            if(i < len)
                value += str_list[i];
            continue;
        }
        // if we fell through to here, we are at a separator.  Append
        // contents of value to the list
        // !!! Sergey A. Sukiyazov <*****@*****.**> !!!
        // A QStrList may contain values in 8bit locale cpecified
        // encoding
        list.append(value);
        value.truncate(0);
    }

    if(str_list[len - 1] != sep || (len > 1 && str_list[len - 2] == '\\'))
        list.append(value);
    return list.count();
}
Example #17
0
void CDDBSetup::insertData(const QStrList& _serverlist,
                           const QStrList& _submitlist,
			   const QString& _basedir,
			   const QString& _submitaddress,
			   const QString& _current_server,
			   const bool&    remote_enabled,
			   const bool&    http_proxy_enabled,
			   const QString& http_proxy_host,
			   const int&     http_proxy_port)
{

    current_server_string = _current_server.copy();
    currentServerLE->setText(current_server_string.data());

    submitaddressstring = _submitaddress.copy();
    currentSubmitLE->setText(submitaddressstring);

    submitlist.clear();
    for(uint i = 0; i < _submitlist.count(); i++){
        submitlist.append(QStrList(_submitlist).at(i));
    }
    
    insertServerList(_serverlist);
//    server_listbox->setCurrentItem(_serverlist.find(_current_server.data()));
    //server_listbox->find(_current_server.data());
//    server_listbox->centerCurrentItem();

    if(debugflag) fprintf(stderr, "check point: server_listbox->centerCurrentItem()\n");
    
    basedirstring = _basedir.copy();
    basedir_edit->setText(basedirstring);
    
    remote_cddb_cb->setChecked(remote_enabled);
    cddb_http_cb->setChecked(http_proxy_enabled);
    proxy_host_ef->setText(http_proxy_host);
    char port_str[40];
    sprintf(port_str,"%d",http_proxy_port);
    proxy_port_ef->setText(port_str);
    if(debugflag) fprintf(stderr, "check point: ::insertData{...;return;}\n");
}
void K2sendPlayList::read(KConfig * config)
{
    QStrList list;
    config->setGroup("playlist");
    config->readListEntry ("files",list);
    if (list.count()){
        QStrListIterator it( list );
        while (it.current()) {
            QString file = QString::fromUtf8(it.current());
            K2sendPlayListItem * new_item = new K2sendPlayListItem((KListView*)this,file);
            if (new_item->valid()){
                this->insertItem (new_item);
                new_item->moveItem(lastChild());

            } else {
                delete new_item;
            }++it;
        }
    }
    QString msg = QString("%1 Files").arg(this->childCount());
    emit signalChangeStatusbar(msg);
}
bool StringListSelectAndReorderSet::getSelection(QStrList& values)
{ 
  // ############################################################################
  list<int>::iterator pos;
  list<string>::iterator text;
  // -----
  if(selected.empty())
    {
      return false; 
    } else {
      values.clear();
      for(pos=selected.begin(); pos!=selected.end(); pos++)
	{
	  text=original.begin();
	  assert((unsigned)(*pos)<original.size());
	  advance(text, *pos);
	  values.append((*text).c_str());
	}
      assert(values.count()==selected.size());
      return true;
    }
  // ############################################################################
}
Example #20
0
void KmConfig::setHistoryList(QStrList &list)
{
	QString path = QDir::homeDirPath() + "/.kde/share/apps/kmap/history";
        QFile file(path);
	
	// Open file
	if (!file.open(IO_WriteOnly | IO_Truncate))
	{
		warning("Unable to open history file: %s", path.data() );
		return;
	}

	// Write strings
	QString text;

	for (uint i = 0; i < list.count(); i++)
	{
		text += list.at(i);
		text += "\n";
	}

	if (text.isEmpty())
	{
		file.close(); // truncated
		return;
	}

	if (!file.writeBlock(text.data(), text.length()))
	{
		warning("Write error to history file: %s", path.data() );
		file.close();
		return;
	}

	file.close();
}
Example #21
0
KArchie::KArchie(const char *name)
  : KTopLevelWidget (name),
    queryResult( 0 )//,   downloadTmpFileList( 0 )
{
  setMinimumSize(420,200);
  config = KApplication::getKApplication()->getConfig();
  QString currenthost;
  QStrList archiehostlist;
  //  int archiehostlistnumber = 
  KConfigGroupSaver *saveGroup = new KConfigGroupSaver( config, "HostConfig" );

  config->readListEntry( "Hosts", archiehostlist );
  //  QString currenthost = config->readEntry( "CurrentHost", "archie.sura.net" );
  uint currentHostId = config->readUnsignedNumEntry( "CurrentHostId", 0 );
  QString defaulthost = "archie.sura.net" ;
  if ( archiehostlist.isEmpty() ) {
    archiehostlist.append( defaulthost );
    currentHostId = 0;
    //    archiehostlistnumber++;
  }
  else if (archiehostlist.count() < currentHostId) {
    currentHostId = 0;
  }    
  currenthost = archiehostlist.at(currentHostId);
  //  config->setGroup( ConfigEntries::HostConfigGroup );
  //  currenthost = config->readEntry( ConfigEntries::CurrentHostEntry,
  //				   ConfigEntries::CurrentHostDefault );

  //    debug("setup menu");
  menu = new KAMenu( this, "mainmenu" );
  setMenu( menu );
  connect( menu, SIGNAL(sigSettingsAll()),
	   this, SLOT(slotChangeSettings()) );
  connect( menu, SIGNAL(sigFileOpen()),
	   this, SLOT(slotOpenFileSelected()) );
  connect( menu, SIGNAL(sigFileOpenDir()), 
	   this, SLOT(slotOpenDirSelected()) );
  connect( menu, SIGNAL(sigFileGet()), 
	   this, SLOT(slotGetfileSelected()) );
  connect( menu, SIGNAL(sigFileLoadList()), 
	   this, SLOT(slotLoadfilelistSelected()) );
  connect( menu, SIGNAL(sigFileStoreList()), 
	   this, SLOT(slotStorefilelistSelected()) );
  connect( menu, SIGNAL(sigFileWriteList()), 
	   this, SLOT(slotWritefilelistSelected()) );
  connect( menu, SIGNAL(sigQueryFile()), 
	   this, SLOT(slotSearchFile()) );
  connect( menu, SIGNAL(sigQueryPath()), 
	   this, SLOT(slotSearchPath()) );
  connect( menu, SIGNAL(sigQueryHost()), 
	   this, SLOT(slotSearchHost()) );

  connect( menu, SIGNAL(sigSortHostname()), 
	   this, SLOT(slotSortListHostname()) );
  connect( menu, SIGNAL(sigSortDomain()), 
	   this, SLOT(slotSortListDomain()) );  
  connect( menu, SIGNAL(sigSortDate()), 
	   this, SLOT(slotSortListDate()) );
  connect( menu, SIGNAL(sigSortFilesize()), 
	   this, SLOT(slotSortListFilesize()) );
  menu->show();
  menu->setFileGetEnable( FALSE );
  menu->setFileOpenEnable( FALSE );
  menu->setFileOpenDirEnable( FALSE );
  menu->setFileStoreListEnable( FALSE );
  menu->setFileWriteListEnable( FALSE );
  menu->setSortEnable( FALSE );

  //    debug("setup statusbar");
  statbar = new KAStatusBar( this, "statusbar" );
  setStatusBar( statbar );
  statbar->slotChangeHost( currenthost );
  statbar->show();
  connect( menu, SIGNAL(sigArchieHost(const char *)), statbar, SLOT(slotChangeHost(const char *)) );

  delete saveGroup;
  saveGroup = new KConfigGroupSaver( config, "WindowConfig" );

  //  debug( "setup view" );
  view = new KAView( this, "view" );
  setView( view );
  //  view->slotShowFileDiscriptor(config->readBoolEntry("FAttr", true));
  view->show();

  connect( menu, SIGNAL(sigSettingsShowFileDiscription( bool )),
	   view, SLOT(slotShowFileDiscriptor( bool )) );
  connect( &(view->getSearchterm()),
	   SIGNAL(sigTextSelected()),
	   SLOT(slotSearchFile()) );
  connect( &(view->getList()),
	   SIGNAL(sigOpenFileSelected()),
	   SLOT(slotOpenFileSelected()) );
  connect( &(view->getList()),
	   SIGNAL(sigOpenDirSelected()),
	   SLOT(slotOpenDirSelected()) );
  connect( &(view->getList()),
	   SIGNAL(sigGetFileSelected()),
	   SLOT(slotGetfileSelected()) );

  show();

  //  changeSettings();
  delete saveGroup;
}
Example #22
0
void 
KArchie::slotQuerySearch(char type)
{
  //  debug("KArchie::slotQuerySearch");
  QStrList archiehostlist;
  KConfigGroupSaver *saveGroup = new KConfigGroupSaver( config, "HostConfig" );

  config->readListEntry( "Hosts", archiehostlist );

  uint currentHostId = config->readUnsignedNumEntry( "CurrentHostId", 0 );
  QString defaulthost = "archie.sura.net" ;
  if ( archiehostlist.isEmpty() ) {
    archiehostlist.append( defaulthost );
    currentHostId = 0;
    //    archiehostlistnumber++;
  }
  else if (archiehostlist.count() < currentHostId) {
    currentHostId = 0;
  }    

  QString host(archiehostlist.at(currentHostId));
  int retries = config->readNumEntry("Retries", CLIENT_DIRSRV_RETRY);
  int timeout = config->readNumEntry("Timeout", CLIENT_DIRSRV_TIMEOUT);

  delete saveGroup;

  saveGroup = new KConfigGroupSaver( config, "SearchConfig" );

  const QString searchInput = config->readEntry("Search", "=");
  SearchMode searchmode(((const char*)searchInput)[0]);
  NiceLevel nicelevel = NiceLevel::toLevel(config->readNumEntry("Nice", (int)NiceLevel::norm));
  int maxhits = config->readNumEntry("hits", CLIENT_MAX_HITS);

  delete saveGroup;

  //  debug( host );
  QString search;
  switch (type) {
  case 'p': search = "path"; break;
  case 'h': search = "host"; break;
  case 'f': // fall through
  default:  search = "file"; break;
  }
  //  debug( search );

  query = new KAQuery((const char *)host,
		      view->getSearchterm().getText(),
		      searchmode.getMode(),
		      maxhits,
		      retries,
		      nicelevel.getLevel(),
		      timeout);

  connect( query, SIGNAL(sigQueryRunning()),
	   menu, SLOT(slotQueryBegin()) );
  connect( query, SIGNAL(sigQueryFinished()),
	   menu, SLOT(slotQueryEnd()) );
  connect( query, SIGNAL(sigQueryStatus(const char *)),
	   statbar, SLOT(slotChangeStatus(const char *)) );
  connect( query, SIGNAL(sigQueryTryNum(int)),
	   statbar, SLOT(slotChangeTries(int)) );
  connect( query, SIGNAL(sigQueryResults(int)),
	   statbar, SLOT(slotChangeHits(int)) );
  connect ( query, SIGNAL(sigQueryFinished()),
	    this, SLOT(slotReturnQuery()) );
  connect ( menu, SIGNAL(sigQueryStop()),
	    query, SLOT(slotAbort()) );

  // start periodic windowupdates
  //  startTimer(1000);

  QString tmp(search + " query start");
  statbar->slotChangeStatus( tmp );

  // start timer for doing other things while querying
  queryTimer = startTimer(300);

  query->start();

  /*
  if (bSuccess) {
    if (queryResult){ // alte Liste loeschen
      queryResult->setAutoDelete(TRUE);
      delete queryResult;
    }
    statbar->slotChangeStatus( "Success" );
    debug("getfilelist");
    queryResult = &(query->getFileList());
    statbar->slotChangeHits( queryResult->count() );
    debug("displayfilelist");
    view->newFileList( *queryResult );

    bool listitemhighlighted = -1 != view->getList().currentItem();
    menu->setFileOpenEnable( listitemhighlighted );
    menu->setFileOpenDirEnable( listitemhighlighted );
    menu->setFileGetEnable( listitemhighlighted );
    menu->setFileWriteListEnable( view->getList().count > 0 );
  }
  else { // print status on SLine
    const char *cError = query->getError();
    debug( cError );
    statbar->slotChangeStatus( cError );
    statbar->slotChangeHits( 0 );

    // no changes to the view->viewlist
    // so we dont change the filemenu
  }

  //  killTimers();
  // if there is an old list from previous queries
  // enable/disable the file->get menu
  //  QString tmp;
  //  tmp.setNum( view->getList().currentItem() );
  //  tmp += " current list item";
  //  debug( tmp );
  debug("ready");
  delete query;
  */
}
Example #23
0
  void process(const QObject * obj){
	if(obj != NULL){
	  QListViewItem * buf = __current;
	  __current = new QListViewItem(__current,obj->className(),QString(obj->name()));
	  __current->setPixmap(0,__pixgeom);
	  QMetaObject* _m = obj->metaObject();
	  QListViewItem * att = NULL;
	  if(_m != NULL){
		QString _superclass(_m->superClassName());
		if(!_superclass.isEmpty()){
		  att = new QListViewItem(__current,"Inherit",_superclass);
		  att->setPixmap(0,__pixattptr);
		  QMetaObject* _meta = _m->superClass();
		  QListViewItem * att4 = NULL;
		  while((_meta = _meta->superClass())!= NULL){
			att4 = new QListViewItem(att,att4,QString(_meta->className()));
			att4->setPixmap(0,__pixatt);
		  }
		}
		att = new QListViewItem(__current,att,"Priority",(obj->highPriority()?"High":"Normal"));
		att->setPixmap(0,__pixatt);
		att = new QListViewItem(__current,att,"Widget",(obj->isWidgetType()?"True":"False"));
		att->setPixmap(0,__pixatt);
		QStrList _slots = _m->slotNames(true);
		if(!_slots.isEmpty()){
		  att = new QListViewItem(__current,att,"Slots");
		  att->setPixmap(0,__pixtransf);
		  uint sl_size = _slots.count();
		  QListViewItem * att2 = NULL;
		  for(uint j = 0; j < sl_size; j++ ){
			att2 = new QListViewItem(att,att2,_slots.at(j));
			att2->setPixmap(0,__pixatt);
		  }
		}
		QStrList _signals = _m->signalNames(true);
		if(!_signals.isEmpty()){
		  att = new QListViewItem(__current,att,"Signals");
		  att->setPixmap(0,__pixtransf);
		  uint si_size = _signals.count();
		  QListViewItem * att2 = NULL;
		  for(uint j = 0; j < si_size; j++ ){
			att2 = new QListViewItem(att,att2,_signals.at(j));
			att2->setPixmap(0,__pixatt);
		  }
		}
		int numCInfo = _m->numClassInfo(true);
		if(numCInfo !=0){
		  att = new QListViewItem(__current,att,"ClassInfo","List<Info>["+QString::number(numCInfo)+']');
		  att->setPixmap(0,__pixtransf);
		  QListViewItem * att2 = NULL;
		  for(int j = 0; j < numCInfo; j++ ){
			const QClassInfo * _inf = _m->classInfo(j);
			if(_inf != NULL){
			  att2 = new QListViewItem(att,att2,QString(_inf->name),QString(_inf->value));
			  att2->setPixmap(0,__pixatt);
			}
		  }
		}
		QStrList _props = _m->propertyNames(true);
		if(!_props.isEmpty()){
		  att = new QListViewItem(__current,att,"Properties");
		  att->setPixmap(0,__pixtransf);
		  uint p_size = _props.count();
		  QListViewItem * att2 = NULL;
		  for(uint j = 0; j < p_size; j++ ){
			att2 = new QListViewItem(att,att2,_props.at(j));
			att2->setPixmap(0,__pixatt);
			
			QVariant val;
			QString propname(_props.at(j));
#if QT_VERSION >= 300
			const QMetaProperty*  prop = _m->property (j,true);
#else
			const QMetaProperty*  prop = _m->property (propname,true);
#endif
			QString proptype;
			if(prop){
			  proptype = prop->type();
			  att2->setText(2,proptype);
			  /*
			  QListViewItem * att3 = new QListViewItem(att2,"Writable",(prop->writable()?"True":"False"));
			  att3->setPixmap(0,__pixatt);
			  att3 = new QListViewItem(att2,att3,"Designable",(prop->designable()?"True":"False"));
			  att3->setPixmap(0,__pixatt);
			  */
			}
			
			val = obj->property(propname);
			
			if(!val.isValid())att2->setText(1,"Invalid");
			else if(prop->isEnumType()){
			  att2->setText(1,prop->valueToKey(val.toInt()));
			}
			else if(prop->isSetType()){
			  QStrList st = prop->valueToKeys(val.toInt());
			  QString t = st.at(0);
			  for(uint i= 1; i < st.count(); i++)t+='/'+st.at(i);
			  att2->setText(1,t);
			}
			else if(val.type() == QVariant::String)att2->setText(1,'"'+val.toString()+'"');
			else if(val.type() == QVariant::CString)att2->setText(1,'"'+val.toCString()+'"');
			else if(val.type() == QVariant::Bool){
			  if(val.toBool())att2->setText(1,"True");
			  else att2->setText(1,"False");
			}
			else if(val.type() == QVariant::Int)att2->setText(1,QString::number(val.toInt()));
			else if(val.type() == QVariant::UInt)att2->setText(1,QString::number(val.toUInt()));
			else if(val.type() == QVariant::Double)att2->setText(1,QString::number(val.toDouble()));
			else if(val.type() == QVariant::Rect){
			  const QRect r = val.toRect();
			  att2->setText(1,'[' + QString::number(r.left())  + ',' + QString::number(r.top())+
				',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+']');
			}
			else if(val.type() == QVariant::Region){
			  const QRegion reg = val.toRegion();
			  QRect r = reg.boundingRect();
			  att2->setText(1,'[' + QString::number(r.left())  + ',' + QString::number(r.top())+
				',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+"],");
			}
			else if(val.type() == QVariant::Size){
			  const QSize s = val.toSize();
			  att2->setText(1,'[' + QString::number(s.width())  + ',' + QString::number(s.height())+']');
			}
			else if(val.type() == QVariant::Point){
			  const QPoint p = val.toPoint();
			  att2->setText(1,'[' + QString::number(p.x())  + ',' + QString::number(p.y())+']');
			}
			else if(val.type() == QVariant::Color){
			  const QColor c = val.toColor();
			  att2->setText(1,'[' + QString::number(c.red())   + ',' +
				QString::number(c.green()) + ',' +
				QString::number(c.blue())  + ']');
			}
			else if(val.type() == QVariant::ColorGroup){
			  const QColorGroup cg = val.toColorGroup();
			  QColor c  = cg.base();
			  att2->setText(1,'[' + QString::number(c.red())   + ',' +
				QString::number(c.green()) + ',' +
				QString::number(c.blue())  + "], ...");
			}
			else if(val.type() == QVariant::Font){
			  const QFont f = val.toFont();
			  QString text = '\'' + f.family()   + "', " + QString::number(f.pointSize())
				+ ", " + QString::number(f.weight());
			  if(f.italic())text+=", italic";
			  att2->setText(1,text);
			}
			else if(val.type() == QVariant::SizePolicy){
			  QSizePolicy sp = val.toSizePolicy();
			  QString text;
			  if(sp.horData() == QSizePolicy::Fixed)text+="Fixed";
			  else if(sp.horData() == QSizePolicy::Minimum )text+="Minimum";
			  else if(sp.horData() == QSizePolicy::Maximum )text+="Maximum";
			  else if(sp.horData() == QSizePolicy::Preferred )text+="Preferred";
			  else if(sp.horData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding";
			  else if(sp.horData() == QSizePolicy::Expanding )text+="Expanding";
			  text +='/';
			  if(sp.verData() == QSizePolicy::Fixed)text+="Fixed";
			  else if(sp.verData() == QSizePolicy::Minimum )text+="Minimum";
			  else if(sp.verData() == QSizePolicy::Maximum )text+="Maximum";
			  else if(sp.verData() == QSizePolicy::Preferred )text+="Preferred";
			  else if(sp.verData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding";
			  else if(sp.verData() == QSizePolicy::Expanding )text+="Expanding";
			  
			  att2->setText(1,text);
			}
			else if(val.type() == QVariant::Pixmap){
			  QPixmap pix = val.toPixmap();
			  if(!pix.isNull())att2->setPixmap(1,pix);
			}
			else if(val.type() == QVariant::Cursor){
			  const QCursor cur = val.toCursor();
			  const QBitmap * pix = cur.bitmap();
			  if(pix && !pix->isNull())att2->setPixmap(1,*pix);
			  else att2->setText(1,QString::number(cur.shape()));
			}
		  }
		}
       }

	   const QObjectList * roots = obj->children();
	   if(roots != NULL){
		 __current = new QListViewItem(__current,att,"children","ptr="+QString::number((unsigned long)roots),
		   "List<QObject>["+QString::number(roots->count())+"]");
		 __current->setPixmap(0,__pixappe);
		 QObjectList r(*roots);
		 uint size = r.count();
		 for(uint i = 0; i < size; i++ ){
		   QObject * _obj = r.at(i);
		   process(_obj);
		 }
		 
	   }
	   __current = buf;
       }
    }
Example #24
0
void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
{
  static bool clangAssistedParsing = Config_getBool(CLANG_ASSISTED_PARSING);
  static QStrList &includePath = Config_getList(INCLUDE_PATH);
  static QStrList clangOptions = Config_getList(CLANG_OPTIONS);
  static QCString clangCompileDatabase = Config_getList(CLANG_COMPILATION_DATABASE_PATH);
  if (!clangAssistedParsing) return;
  //printf("ClangParser::start(%s)\n",fileName);
  p->fileName = fileName;
  p->index    = clang_createIndex(0, 0);
  p->curLine  = 1;
  p->curToken = 0;
  QDictIterator<void> di(Doxygen::inputPaths);
  int argc=0;
  std::string error;
  // load a clang compilation database (https://clang.llvm.org/docs/JSONCompilationDatabase.html)
  // this only needs to be loaded once, and could be refactored to a higher level function
  static std::unique_ptr<clang::tooling::CompilationDatabase> db =
      clang::tooling::CompilationDatabase::loadFromDirectory(clangCompileDatabase.data(), error);
  int clang_option_len = 0;
  std::vector<clang::tooling::CompileCommand> command;
  if (strcmp(clangCompileDatabase, "0") != 0) {
      if (db == nullptr) {
          // user specified a path, but DB file was not found
          err("%s using clang compilation database path of: \"%s\"\n", error.c_str(),
              clangCompileDatabase.data());
      } else {
          // check if the file we are parsing is in the DB
          command = db->getCompileCommands(fileName);
          if (!command.empty() ) {
              // it's possible to have multiple entries for the same file, so use the last entry
              clang_option_len = command[command.size()-1].CommandLine.size();
          }
      }
  }
  char **argv = (char**)malloc(sizeof(char*)*(4+Doxygen::inputPaths.count()+includePath.count()+clangOptions.count()+clang_option_len));
  if (!command.empty() ) {
      std::vector<std::string> options = command[command.size()-1].CommandLine;
      // copy each compiler option used from the database. Skip the first which is compiler exe.
      for (auto option = options.begin()+1; option != options.end(); option++) {
          argv[argc++] = strdup(option->c_str());
      }
      // this extra addition to argv is accounted for as we are skipping the first entry in
      argv[argc++]=strdup("-w"); // finally, turn off warnings.
  } else {
  // add include paths for input files
  for (di.toFirst();di.current();++di,++argc)
  {
    QCString inc = QCString("-I")+di.currentKey();
    argv[argc]=strdup(inc.data());
    //printf("argv[%d]=%s\n",argc,argv[argc]);
  }
  // add external include paths
  for (uint i=0;i<includePath.count();i++)
  {
    QCString inc = QCString("-I")+includePath.at(i);
    argv[argc++]=strdup(inc.data());
  }
  // user specified options
  for (uint i=0;i<clangOptions.count();i++)
  {
    argv[argc++]=strdup(clangOptions.at(i));
  }
  // extra options
  argv[argc++]=strdup("-ferror-limit=0");
  argv[argc++]=strdup("-x");

  // Since we can be presented with a .h file that can contain C/C++ or
  // Objective C code and we need to configure the parser before knowing this,
  // we use the source file to detected the language. Detection will fail if you
  // pass a bunch of .h files containing ObjC code, and no sources :-(
  SrcLangExt lang = getLanguageFromFileName(fileName);
  if (lang==SrcLangExt_ObjC || p->detectedLang!=ClangParser::Private::Detected_Cpp)
  {
    QCString fn = fileName;
    if (p->detectedLang==ClangParser::Private::Detected_Cpp && 
        (fn.right(4).lower()==".cpp" || fn.right(4).lower()==".cxx" ||
         fn.right(3).lower()==".cc" || fn.right(2).lower()==".c"))
    { // fall back to C/C++ once we see an extension that indicates this
      p->detectedLang = ClangParser::Private::Detected_Cpp;
    }
    else if (fn.right(3).lower()==".mm") // switch to Objective C++
    {
      p->detectedLang = ClangParser::Private::Detected_ObjCpp;
    }
    else if (fn.right(2).lower()==".m") // switch to Objective C
    {
      p->detectedLang = ClangParser::Private::Detected_ObjC;
    }
  }
  switch(p->detectedLang)
  {
    case ClangParser::Private::Detected_Cpp: 
      argv[argc++]=strdup("c++"); 
      break;
    case ClangParser::Private::Detected_ObjC: 
      argv[argc++]=strdup("objective-c"); 
      break;
    case ClangParser::Private::Detected_ObjCpp: 
      argv[argc++]=strdup("objective-c++"); 
      break;
  }

  // provide the input and and its dependencies as unsaved files so we can
  // pass the filtered versions
  argv[argc++]=strdup(fileName);
  }
  static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES);
  //printf("source %s ----------\n%s\n-------------\n\n",
  //    fileName,p->source.data());
  uint numUnsavedFiles = filesInTranslationUnit.count()+1;
  p->numFiles = numUnsavedFiles;
  p->sources = new QCString[numUnsavedFiles];
  p->ufs     = new CXUnsavedFile[numUnsavedFiles];
  p->sources[0]      = detab(fileToString(fileName,filterSourceFiles,TRUE));
  p->ufs[0].Filename = strdup(fileName);
  p->ufs[0].Contents = p->sources[0].data();
  p->ufs[0].Length   = p->sources[0].length();
  QStrListIterator it(filesInTranslationUnit);
  uint i=1;
  for (it.toFirst();it.current() && i<numUnsavedFiles;++it,i++)
  {
    p->fileMapping.insert(it.current(),new uint(i));
    p->sources[i]      = detab(fileToString(it.current(),filterSourceFiles,TRUE));
    p->ufs[i].Filename = strdup(it.current());
    p->ufs[i].Contents = p->sources[i].data();
    p->ufs[i].Length   = p->sources[i].length();
  }

  // let libclang do the actual parsing
  p->tu = clang_parseTranslationUnit(p->index, 0,
                                     argv, argc, p->ufs, numUnsavedFiles, 
                                     CXTranslationUnit_DetailedPreprocessingRecord);
  // free arguments
  for (int i=0;i<argc;++i)
  {
    free(argv[i]);
  }
  free(argv);

  if (p->tu)
  {
    // filter out any includes not found by the clang parser
    determineInputFilesInSameTu(filesInTranslationUnit);

    // show any warnings that the compiler produced
    for (uint i=0, n=clang_getNumDiagnostics(p->tu); i!=n; ++i) 
    {
      CXDiagnostic diag = clang_getDiagnostic(p->tu, i); 
      CXString string = clang_formatDiagnostic(diag,
          clang_defaultDiagnosticDisplayOptions()); 
      err("%s [clang]\n",clang_getCString(string));
      clang_disposeString(string);
      clang_disposeDiagnostic(diag);
    }

    // create a source range for the given file
    QFileInfo fi(fileName);
    CXFile f = clang_getFile(p->tu, fileName);
    CXSourceLocation fileBegin = clang_getLocationForOffset(p->tu, f, 0);
    CXSourceLocation fileEnd   = clang_getLocationForOffset(p->tu, f, p->ufs[0].Length);
    CXSourceRange    fileRange = clang_getRange(fileBegin, fileEnd);

    // produce a token stream for the file
    clang_tokenize(p->tu,fileRange,&p->tokens,&p->numTokens);

    // produce cursors for each token in the stream
    p->cursors=new CXCursor[p->numTokens];
    clang_annotateTokens(p->tu,p->tokens,p->numTokens,p->cursors);
  }
  else
  {
    p->tokens    = 0;
    p->numTokens = 0;
    p->cursors   = 0;
    err("clang: Failed to parse translation unit %s\n",fileName);
  }
}
Example #25
0
void KNNntpClient::doCheckNewGroups()
{
    KNGroupListData *target = static_cast<KNGroupListData *>(job->data());

    sendSignal(TSdownloadNewGroups);
    errorPrefix = i18n("New groups could not be retrieved.\nThe following error occurred:\n");

    progressValue = 100;
    predictedLines = 30;     // rule of thumb ;-)

    QCString cmd;
    cmd.sprintf("NEWGROUPS %.2d%.2d%.2d 000000", target->fetchSince.year() % 100, target->fetchSince.month(), target->fetchSince.day());
    if(!sendCommandWCheck(cmd, 231))      // 231 list of new newsgroups follows
        return;

    char *s, *line;
    QString name;
    KNGroup::Status status;
    QSortedList<KNGroupInfo> tmpList;
    tmpList.setAutoDelete(true);

    while(getNextLine())
    {
        line = getCurrentLine();
        if(line[0] == '.')
        {
            if(line[1] == '.')
                line++;        // collapse double period into one
            else if(line[1] == 0)
                break;   // message complete
        }
        s = strchr(line, ' ');
        if(!s)
        {
#ifndef NDEBUG
            qDebug("knode: retrieved broken group-line - ignoring");
#endif
        }
        else
        {
            s[0] = 0;    // cut string
            name = QString::fromUtf8(line);

            while(s[1] != 0) s++;  // the last character determines the moderation status
            switch(s[0])
            {
                case 'n' :
                    status = KNGroup::readOnly;
                    break;
                case 'y' :
                    status = KNGroup::postingAllowed;
                    break;
                case 'm' :
                    status = KNGroup::moderated;
                    break;
                default  :
                    status = KNGroup::unknown;
            }

            tmpList.append(new KNGroupInfo(name, QString::null, true, false, status));
        }
        doneLines++;
    }

    if(!job->success() || job->canceled())
        return;     // stopped...

    if(target->getDescriptions)
    {
        errorPrefix = i18n("The group descriptions could not be retrieved.\nThe following error occurred:\n");
        progressValue = 100;
        doneLines = 0;
        predictedLines = tmpList.count() * 3;

        sendSignal(TSdownloadDesc);
        sendSignal(TSprogressUpdate);

        cmd = "LIST NEWSGROUPS ";
        QStrList desList;
        char *s;
        int rep;

        for(KNGroupInfo *group = tmpList.first(); group; group = tmpList.next())
        {
            if(!sendCommand(cmd + group->name.utf8(), rep))
                return;
            if(rep != 215)         // 215 informations follows
                break;
            desList.clear();
            if(!getMsg(desList))
                return;

            if(desList.count() > 0)         // group has a description
            {
                s = desList.first();
                while(*s != - '\0' && *s != '\t' && *s != ' ') s++;
                if(*s == '\0')
                {
#ifndef NDEBUG
                    qDebug("knode: retrieved broken group-description - ignoring");
#endif
                }
                else
                {
                    while(*s == ' ' || *s == '\t') s++;     // go on to the description
                    if(target->codecForDescriptions)           // some countries use local 8 bit characters in the tag line
                        group->description = target->codecForDescriptions->toUnicode(s);
                    else
                        group->description = QString::fromLocal8Bit(s);
                }
            }
        }
    }

    sendSignal(TSloadGrouplist);

    if(!target->readIn())
    {
        job->setErrorString(i18n("Unable to read the group list file"));
        return;
    }
    target->merge(&tmpList);
    sendSignal(TSwriteGrouplist);
    if(!target->writeOut())
    {
        job->setErrorString(i18n("Unable to write the group list file"));
        return;
    }
}
Example #26
0
void CDDialog::save_cddb_entry(QString& path,bool upload){


  QString magic;
  magic.sprintf("%08lx",cdinfo.magicID);
  bool have_magic_already = false;

  if(debugflag) printf("::save_cddb_entry(): path: %s upload = %d\n", path.data(), upload);
  // Steve and Ti contacted me and said they have changed the cddb upload specs
  // Now, an uploaded entry must only contain one DISCID namely the one corresponding
  // to the CD the user actually owns.
  if( !upload ){
    for(int i = 0 ; i < (int)discidlist.count();i ++){
      if(magic == (QString)discidlist.at(i)){
	have_magic_already = true;
	break;
      }
    }

    if(!have_magic_already)
      discidlist.insert(0,magic.data());
  }
  else{ // uploading 
    discidlist.clear();
    discidlist.insert(0,magic.data());
  }

  QFile file(path.data());


  if( !file.open( IO_WriteOnly  )) {
    
    QString str;
    str.sprintf(
		klocale->translate("Unable to write to file:\n%s\nPlease check "\
		"your permissions and make your category directories exist."),
		path.data());

    QMessageBox::warning(this,
			 klocale->translate("Kscd Error"),
			 str.data()
			 );
    return;
  }

  QString tmp;
  QTextStream t(&file);


  if(upload && !smtpConfigData->enabled){
      QString subject;
      subject.sprintf("cddb %s %08lx", submitcat.data(), cdinfo.magicID);

      t << "To: " + submitaddress + "\n";
      tmp = tmp.sprintf("Subject: %s\n", subject.data());
      t << tmp.data();
  }

  t << "# xmcd CD database file\n";

  if(!upload)
  t << "# Copyright (C) 1997 - 1998  Bernd Johannes Wuebben\n";

  QString datestr;
  datestr = QDateTime::currentDateTime().toString();
  tmp = tmp.sprintf("# Generated: %s by KSCD\n",datestr.data());
  t << tmp.data();

  t << "# \n";
  t << "# Track frame offsets:\n";

  for(int i = 0 ; i < cdinfo.ntracks;i ++){
    tmp = tmp.sprintf("#       %d\n",cdinfo.cddbtoc[i].absframe);
    t << tmp.data();
  }

  t << "#\n";
  tmp = tmp.sprintf("# Disc length: %d seconds\n",cdinfo.length);
  t << tmp.data();
  t << "#\n";
  if(upload)
    tmp = tmp.sprintf("# Revision: %d\n",++revision);
  else
    tmp = tmp.sprintf("# Revision: %d\n",revision);
  t << tmp.data();
  t << "# Submitted via: Kscd "KSCDVERSION"\n";
  t << "#\n";


  tmp = "DISCID=";
  int counter = 0;

  for(int i = 0 ; i < (int)discidlist.count();i ++){

    tmp += discidlist.at(i);

    if( i < (int) discidlist.count() - 1){
      if( counter++ == 3 ){
	tmp += "\nDISCID=";
	counter = 0;
      }
      else
	tmp += ",";
    }
  }

  tmp += "\n";
  t << tmp.data();

  QStrList returnlist;
  QString tmp2;

  tmp2 = track_list.at(0);
  cddb_encode(tmp2,returnlist);  

  if(returnlist.count() == 0){
    // sanity provision
    tmp = tmp.sprintf("DTITLE=%s\n","");
    t << tmp.data();
  }
  else{
    for(int i = 0; i < (int) returnlist.count();i++){
      tmp = tmp.sprintf("DTITLE=%s\n",returnlist.at(i));
      t << tmp.data();
    }
  }

  for(int i = 1 ; i < (int)track_list.count();i ++){

    tmp2 = track_list.at(i);
    cddb_encode(tmp2,returnlist);  
    
    if(returnlist.count() == 0){
      // sanity provision
      tmp = tmp.sprintf("TTITLE%d=%s\n",i-1,"");
      t << tmp.data();
    }
    else{
      for(int j = 0; j < (int) returnlist.count();j++){
	tmp = tmp.sprintf("TTITLE%d=%s\n",i-1,returnlist.at(j));
	t << tmp.data();
      }
    }
  }

  tmp2 = ext_list.at(0);
  cddb_encode(tmp2,returnlist);  

  if(returnlist.count() == 0){
    // sanity provision
    tmp = tmp.sprintf("EXTD=%s\n","");
    t << tmp.data();
  }
  else{
    for(int i = 0; i < (int) returnlist.count();i++){
      tmp = tmp.sprintf("EXTD=%s\n",returnlist.at(i));
      t << tmp.data();
    }
  }

  for(int i = 1 ; i < (int)ext_list.count();i ++){

    tmp2 = ext_list.at(i);
    cddb_encode(tmp2,returnlist);  

    if(returnlist.count() == 0){
      // sanity provision
      tmp = tmp.sprintf("EXTT%d=%s\n",i-1,"");
      t << tmp.data();
    }
    else{
      for(int j = 0; j < (int) returnlist.count();j++){
	tmp = tmp.sprintf("EXTT%d=%s\n",i-1,returnlist.at(j));
	t << tmp.data();
      }
    }
  }

  if(!upload){
    cddb_encode(playorder,returnlist);  

    for(int i = 0; i < (int) returnlist.count();i++){
      tmp = tmp.sprintf("PLAYORDER=%s\n",returnlist.at(i));
      t << tmp.data();
    }
  }
  else{
    tmp = tmp.sprintf("PLAYORDER=\n");
    t << tmp.data();
  }

  t << "\n";

  file.close();
  chmod(file.name(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
  return;

}
Example #27
0
void TrashProtocol::listDir(const KURL &url)
{
    INIT_IMPL;
    kdDebug() << "listdir: " << url << endl;
    if(url.path().length() <= 1)
    {
        listRoot();
        return;
    }
    int trashId;
    QString fileId;
    QString relativePath;
    bool ok = TrashImpl::parseURL(url, trashId, fileId, relativePath);
    if(!ok)
    {
        error(KIO::ERR_SLAVE_DEFINED, i18n("Malformed URL %1").arg(url.prettyURL()));
        return;
    }
    // was: const QString physicalPath = impl.physicalPath( trashId, fileId, relativePath );

    // Get info for deleted directory - the date of deletion and orig path will be used
    // for all the items in it, and we need the physicalPath.
    TrashedFileInfo info;
    ok = impl.infoForFile(trashId, fileId, info);
    if(!ok || info.physicalPath.isEmpty())
    {
        error(impl.lastErrorCode(), impl.lastErrorMessage());
        return;
    }
    if(!relativePath.isEmpty())
    {
        info.physicalPath += "/";
        info.physicalPath += relativePath;
    }

    // List subdir. Can't use kio_file here since we provide our own info...
    kdDebug() << k_funcinfo << "listing " << info.physicalPath << endl;
    QStrList entryNames = impl.listDir(info.physicalPath);
    totalSize(entryNames.count());
    KIO::UDSEntry entry;
    QStrListIterator entryIt(entryNames);
    for(; entryIt.current(); ++entryIt)
    {
        QString fileName = QFile::decodeName(entryIt.current());
        if(fileName == "..")
            continue;
        const QString filePath = info.physicalPath + "/" + fileName;
        // shouldn't be necessary
        // const QString url = TrashImpl::makeURL( trashId, fileId, relativePath + "/" + fileName );
        entry.clear();
        TrashedFileInfo infoForItem(info);
        infoForItem.origPath += '/';
        infoForItem.origPath += fileName;
        if(ok && createUDSEntry(filePath, fileName, QString::null /*url*/, entry, infoForItem))
        {
            listEntry(entry, false);
        }
    }
    entry.clear();
    listEntry(entry, true);
    finished();
}
Example #28
0
bool CDDialog::checkit(){


  QString title = titleedit->text();
  title = title.stripWhiteSpace();
  if(title.isEmpty()){

    QMessageBox::warning(this,
			 klocale->translate("Invalid Database Entry"),
			 klocale->translate("The Disc Artist / Title field is not filled in.\n"\
			 "Please correct the entry and try again.")
			 );
     return false;
  }




  int pos;
  pos = title.find("/",0,true);
  if(pos == -1){

    QMessageBox::warning(this,
			 klocale->translate("Invalid Database Entry"),
			 klocale->translate("The Disc Artist / Title field is not filled in correctly.\n"\
			 "Please separate the artist from the title of the CD with \n"\
			 "a forward slash, such as in: Peter Gabriel / Greatest Hits\n"
			 ));
     return false;

  }

  

  if(track_list.count() < 2){

    QMessageBox::warning(this,
			 klocale->translate("Invalid Database Entry"),
			 klocale->translate("Not all track titles can be empty.\n"\
			 "Please correct the entry and try again."
			 ));
     return false;
  }


  bool have_nonempty_title = false;
  for(int i = 1; i < (int)track_list.count(); i++){

    title = track_list.at(i);
    title = title.stripWhiteSpace();
    if(!title.isEmpty()){
      have_nonempty_title = true;
      break;
    }
  }

  if(!have_nonempty_title){

    QMessageBox::warning(this,
			 klocale->translate("Invalid Database Entry"),
			 klocale->translate("Not all track titles can be empty.\n"\
			 "Please correct the entry and try again."
			 ));
     return false;

  }

  if(cdinfo.ntracks +1 != (int)track_list.count() ){

    QMessageBox::critical(this,
			 klocale->translate("Internal Error"),
			 klocale->translate("cdinfo.ntracks != title_list->count() + 1\n"
			 "Please email the author."
			 ));
     return false;
  }

  QString str;
  QStrList strlist;
  str = progseq_edit->text();

  bool ret;
  ret = cddb_playlist_decode(strlist, str);
  
  QString teststr;
  bool ok;
  int  num;

  for(uint i = 0; i < strlist.count();i++){

    teststr = strlist.at(i);
    num = teststr.toInt(&ok);

    if( num > cdinfo.ntracks || !ok)
      ret = false;
  }

  if(!ret){
      QMessageBox::warning(this,
			 klocale->translate("Error"),
			 klocale->translate("Invalid Playlist\n")
			 );
      return false;
  }

  cddb_playlist_encode(strlist,playorder);
  return true;

}
Example #29
0
void ClangParser::start(const char *fileName,QStrList &filesInTranslationUnit)
{
  static bool clangAssistedParsing = Config_getBool("CLANG_ASSISTED_PARSING");
  static QStrList &includePath = Config_getList("INCLUDE_PATH");
  static QStrList clangOptions = Config_getList("CLANG_OPTIONS");
  if (!clangAssistedParsing) return;
  //printf("ClangParser::start(%s)\n",fileName);
  p->fileName = fileName;
  p->index    = clang_createIndex(0, 0);
  p->curLine  = 1;
  p->curToken = 0;
  char **argv = (char**)malloc(sizeof(char*)*(4+Doxygen::inputPaths.count()+includePath.count()+clangOptions.count()));
  QDictIterator<void> di(Doxygen::inputPaths);
  int argc=0;
  // add include paths for input files
  for (di.toFirst();di.current();++di,++argc)
  {
    QCString inc = QCString("-I")+di.currentKey();
    argv[argc]=strdup(inc.data());
    //printf("argv[%d]=%s\n",argc,argv[argc]);
  }
  // add external include paths
  for (uint i=0;i<includePath.count();i++)
  {
    QCString inc = QCString("-I")+includePath.at(i);
    argv[argc++]=strdup(inc.data());
  }
  // user specified options
  for (uint i=0;i<clangOptions.count();i++)
  {
    argv[argc++]=strdup(clangOptions.at(i));
  }
  // extra options
  argv[argc++]=strdup("-ferror-limit=0");
  argv[argc++]=strdup("-x");

  // Since we can be presented with a .h file that can contain C/C++ or
  // Objective C code and we need to configure the parser before knowing this,
  // we use the source file to detected the language. Detection will fail if you
  // pass a bunch of .h files containing ObjC code, and no sources :-(
  SrcLangExt lang = getLanguageFromFileName(fileName);
  if (lang==SrcLangExt_ObjC || p->detectedLang!=ClangParser::Private::Detected_Cpp)
  {
    QCString fn = fileName;
    if (p->detectedLang==ClangParser::Private::Detected_Cpp && 
        (fn.right(4).lower()==".cpp" || fn.right(4).lower()==".cxx" ||
         fn.right(3).lower()==".cc" || fn.right(2).lower()==".c"))
    { // fall back to C/C++ once we see an extension that indicates this
      p->detectedLang = ClangParser::Private::Detected_Cpp;
    }
    else if (fn.right(3).lower()==".mm") // switch to Objective C++
    {
      p->detectedLang = ClangParser::Private::Detected_ObjCpp;
    }
    else if (fn.right(2).lower()==".m") // switch to Objective C
    {
      p->detectedLang = ClangParser::Private::Detected_ObjC;
    }
  }
  switch(p->detectedLang)
  {
    case ClangParser::Private::Detected_Cpp: 
      argv[argc++]=strdup("c++"); 
      break;
    case ClangParser::Private::Detected_ObjC: 
      argv[argc++]=strdup("objective-c"); 
      break;
    case ClangParser::Private::Detected_ObjCpp: 
      argv[argc++]=strdup("objective-c++"); 
      break;
  }

  // provide the input and and its dependencies as unsaved files so we can
  // pass the filtered versions
  argv[argc++]=strdup(fileName);
  static bool filterSourceFiles = Config_getBool("FILTER_SOURCE_FILES");
  //printf("source %s ----------\n%s\n-------------\n\n",
  //    fileName,p->source.data());
  uint numUnsavedFiles = filesInTranslationUnit.count()+1;
  p->numFiles = numUnsavedFiles;
  p->sources = new QCString[numUnsavedFiles];
  p->ufs     = new CXUnsavedFile[numUnsavedFiles];
  p->sources[0]      = detab(fileToString(fileName,filterSourceFiles,TRUE));
  p->ufs[0].Filename = strdup(fileName);
  p->ufs[0].Contents = p->sources[0].data();
  p->ufs[0].Length   = p->sources[0].length();
  QStrListIterator it(filesInTranslationUnit);
  uint i=1;
  for (it.toFirst();it.current() && i<numUnsavedFiles;++it,i++)
  {
    p->fileMapping.insert(it.current(),new uint(i));
    p->sources[i]      = detab(fileToString(it.current(),filterSourceFiles,TRUE));
    p->ufs[i].Filename = strdup(it.current());
    p->ufs[i].Contents = p->sources[i].data();
    p->ufs[i].Length   = p->sources[i].length();
  }

  // let libclang do the actual parsing
  p->tu = clang_parseTranslationUnit(p->index, 0,
                                     argv, argc, p->ufs, numUnsavedFiles, 
                                     CXTranslationUnit_DetailedPreprocessingRecord);
  // free arguments
  for (int i=0;i<argc;++i)
  {
    free(argv[i]);
  }
  free(argv);

  if (p->tu)
  {
    // filter out any includes not found by the clang parser
    determineInputFilesInSameTu(filesInTranslationUnit);

    // show any warnings that the compiler produced
    for (uint i=0, n=clang_getNumDiagnostics(p->tu); i!=n; ++i) 
    {
      CXDiagnostic diag = clang_getDiagnostic(p->tu, i); 
      CXString string = clang_formatDiagnostic(diag,
          clang_defaultDiagnosticDisplayOptions()); 
      err("%s [clang]\n",clang_getCString(string));
      clang_disposeString(string);
      clang_disposeDiagnostic(diag);
    }

    // create a source range for the given file
    QFileInfo fi(fileName);
    CXFile f = clang_getFile(p->tu, fileName);
    CXSourceLocation fileBegin = clang_getLocationForOffset(p->tu, f, 0);
    CXSourceLocation fileEnd   = clang_getLocationForOffset(p->tu, f, p->ufs[0].Length);
    CXSourceRange    fileRange = clang_getRange(fileBegin, fileEnd);

    // produce a token stream for the file
    clang_tokenize(p->tu,fileRange,&p->tokens,&p->numTokens);

    // produce cursors for each token in the stream
    p->cursors=new CXCursor[p->numTokens];
    clang_annotateTokens(p->tu,p->tokens,p->numTokens,p->cursors);
  }
  else
  {
    p->tokens    = 0;
    p->numTokens = 0;
    p->cursors   = 0;
    err("clang: Failed to parse translation unit %s\n",fileName);
  }
}
Example #30
0
static void createDescription( const QValueList<Widget> &l, QTextStream &ts )
{
    int indent = 0;
    ts << "<!DOCTYPE CW><CW>" << endl;
    ts << makeIndent( indent ) << "<customwidgets>" << endl;
    indent++;

    for ( QValueList<Widget>::ConstIterator it = l.begin(); it != l.end(); ++it ) {
	Widget w = *it;
	ts << makeIndent( indent ) << "<customwidget>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<class>" << w.w->className() << "</class>" << endl;
	ts << makeIndent( indent ) << "<header location=\"" << w.location << "\">" << w.include << "</header>" << endl;
	ts << makeIndent( indent ) << "<sizehint>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<width>" << w.w->sizeHint().width() << "</width>" << endl;
	ts << makeIndent( indent ) << "<height>" << w.w->sizeHint().height() << "</height>" << endl;
	indent--;
	ts << makeIndent( indent ) << "</sizehint>" << endl;
	ts << makeIndent( indent ) << "<container>" << ( w.w->inherits( "QGroupBox" ) || w.w->inherits( "QWidgetStack" ) ) << "</container>" << endl;
	ts << makeIndent( indent ) << "<sizepolicy>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<hordata>" << (int)w.w->sizePolicy().horData() << "</hordata>" << endl;
	ts << makeIndent( indent ) << "<verdata>" << (int)w.w->sizePolicy().verData() << "</verdata>" << endl;
	indent--;
	ts << makeIndent( indent ) << "</sizepolicy>" << endl;
	
	QStrList sigs = w.w->metaObject()->signalNames( TRUE );
	if ( !sigs.isEmpty() ) {
	    for ( int i = 0; i < (int)sigs.count(); ++i )
		ts << makeIndent( indent ) << "<signal>" << entitize( sigs.at( i ) ) << "</signal>" << endl;
	}
	QStrList slts = w.w->metaObject()->slotNames( TRUE );
	if ( !slts.isEmpty() ) {
	    for ( int i = 0; i < (int)slts.count(); ++i ) {
		QMetaData::Access data = w.w->metaObject()->slot( i, TRUE )->access;
		if ( data == QMetaData::Private )
		    continue;
		ts << makeIndent( indent ) << "<slot access=\""
		   << ( data == QMetaData::Protected ? "protected" : "public" )
		   << "\">" << entitize( slts.at( i ) ) << "</slot>" << endl;
	    }
	}	
	QStrList props = w.w->metaObject()->propertyNames( TRUE );
	if ( !props.isEmpty() ) {
	    for ( int i = 0; i < (int)props.count(); ++i ) {
		const QMetaProperty *p = w.w->metaObject()->
					 property( w.w->metaObject()->
						   findProperty( props.at( i ), TRUE ), TRUE );
		if ( !p )
		    continue;
		if ( !p->writable() || !p->designable( w.w ) )
		    continue;
		ts << makeIndent( indent ) << "<property type=\"" << convert_type( p->type() ) << "\">" << entitize( p->name() ) << "</property>" << endl;
	    }
	}
	indent--;
	ts << makeIndent( indent ) << "</customwidget>" << endl;
    }

    indent--;
    ts << makeIndent( indent ) << "</customwidgets>" << endl;
    ts << "</CW>" << endl;
}