void SlotTester::allTests() { QStrList allSlots = metaObject()->slotNames(); if ( allSlots.contains("setUp()") > 0 ) invokeMember("setUp()"); for ( char *sl = allSlots.first(); sl; sl = allSlots.next() ) { QString str = sl; if ( str.startsWith("test") ) { m_results = results(sl); m_results->clear(); cout << "KUnitTest_Debug_BeginSlot[" << sl << "]" << endl; invokeMember(str); cout << "KUnitTest_Debug_EndSlot[" << sl << "]" << endl; } } if ( allSlots.contains("tearDown()") > 0 ) invokeMember("tearDown()"); m_total->clear(); }
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() ); }
void writeListConf ( KConfig *conf, QString key, QStrList &list ) { if( list.isEmpty() ) { conf->writeEntry(key, ""); return; } QString str_list; QString value; int i; for( value = list.first(); value != ""; value = list.next() ) { for( i = 0; i < (int) value.length(); i++ ) { switch( value[i] ) { case ',': str_list += '\\'; break; case '\\': str_list += '\\'; break; //defaults: //; }; str_list += value[i]; } str_list += ','; } if( str_list.right(1) == "," ) str_list.truncate(str_list.length()-1); conf->writeEntry(key, str_list); }
void KAMenu::slotHostlistChanged() { /* die Liste der erreichbaren Archiehosts hat sich * veraendert. neu einlesen */ // KConfig *config = KApplication::getKApplication()->getConfig(); QStrList archiehostlist; // int archiehostlistnumber = KConfigGroupSaver saveGroup( config, "HostConfig" ); config->readListEntry( "Hosts", archiehostlist ); // QString currenthost = config->readEntry( "CurrentHost", "archie.sura.net" ); QString defaulthost = "archie.sura.net" ; if ( archiehostlist.isEmpty() ) { archiehostlist.append( defaulthost ); // currentHostId = 0; } host->clear(); char *tmpStr; int i = 0; for (tmpStr=archiehostlist.first(); tmpStr; tmpStr=archiehostlist.next()) { host->insertItem( tmpStr, i, i); i++; } slotConfigChanged(); emit sigArchieHost(host->text(host_id)); }
KIconLoader::KIconLoader( KConfig *conf, const QString &app_name, const QString &var_name ){ QStrList list; config = conf; config->setGroup(app_name); config->readListEntry( var_name, list, ':' ); for (const char *it=list.first(); it; it = list.next()) addPath(it); initPath(); name_list.setAutoDelete(TRUE); pixmap_dirs.setAutoDelete(TRUE); pixmap_list.setAutoDelete(TRUE); /* for(char* c = pixmap_dirs.first(); c ; c = pixmap_dirs.next()){ printf("in path:%s\n",pixmap_dirs.current()); } */ }
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() ); }
void KMix::onDrop( KDNDDropZone* _zone ) { QStrList strlist; KURL *url; strlist = _zone->getURLList(); url = new KURL( strlist.first() ); delete url; }
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; }
/*! Decodes URIs from \a e, converts them to Unicode URIs (only useful for displaying to humans), placing them in \a l (which is first cleared). Returns TRUE if the event contained a valid list of URIs. */ bool QUriDrag::decodeToUnicodeUris( const QMimeSource* e, QStringList& l ) { QStrList u; if ( !decode( e, u ) ) return FALSE; l.clear(); for (const char* s=u.first(); s; s=u.next()) l.append( uriToUnicodeUri(s) ); return TRUE; }
void KfmView::slotBookmarks() { char *s; QStrList popupFiles = new QStrList(); getActiveView()->getSelected ( popupFiles ); // get the selected URL(s) if ( popupFiles.isEmpty() && popupMenuEvent ) { popupFiles.append ( getURL() ); } for ( s = popupFiles.first(); s != 0L; s = popupFiles.next() ) gui->addBookmark( s, s ); }
/*! Changes the list of \a urls to be dragged. */ void QUrlDrag::setUrls( QStrList urls ) { QByteArray a; int c=0; for (const char* s = urls.first(); s; s = urls.next() ) { int l = strlen(s)+1; a.resize(c+l); memcpy(a.data()+c,s,l); c+=l; } a.resize(c-1); // chop off last nul setEncodedData(a); }
/*! Returns TRUE if the information in \a e can be decoded into an image. \sa decode() */ bool QImageDrag::canDecode( const QMimeSource* e ) { QStrList fileFormats = QImageIO::inputFormats(); fileFormats.first(); while ( fileFormats.current() ) { QCString format = fileFormats.current(); QCString type = "image/" + format.lower(); if ( e->provides( type.data() ) ) return TRUE; fileFormats.next(); } return FALSE; }
/*! Changes the list of \a uris to be dragged. */ void QUriDrag::setUris( QStrList uris ) { QByteArray a; int c=0; for ( const char* s = uris.first(); s; s = uris.next() ) { int l = qstrlen(s); a.resize(c+l+2); memcpy(a.data()+c,s,l); memcpy(a.data()+c+l,"\r\n",2); c+=l+2; } setEncodedData(a); }
void KfmView::slotNewView() { char *s; QStrList popupFiles = new QStrList(); getActiveView()->getSelected ( popupFiles ); // get the selected URL(s) if ( popupFiles.isEmpty() && popupMenuEvent ) popupFiles.append ( getURL() ); for ( s = popupFiles.first(); s != 0L; s = popupFiles.next() ) { KfmGui *m = new KfmGui( 0L, 0L, s ); m->show(); } }
void Rule::updateGlobals() { ruleList.clear(); ruleFile->setGroup("Index"); QStrList names; ruleFile->readListEntry("GlobalRules",names); for (char *iter=names.first(); iter!=0; iter=names.next()) { Rule *r=new Rule(0,0,Rule::Sender,false,false); r->load(iter); ruleList.append(r); } }
void KNNetAccess::startJobSmtp() { if(smtpJobQueue.isEmpty()) return; currentSmtpJob = smtpJobQueue.first(); smtpJobQueue.remove(smtpJobQueue.begin()); currentSmtpJob->prepareForExecution(); if(currentSmtpJob->success()) { KNLocalArticle *art = static_cast<KNLocalArticle *>(currentSmtpJob->data()); // create url query part QString query("headers=0&from="); query += KURL::encode_string(art->from()->email()); QStrList emails; art->to()->emails(&emails); for(char *e = emails.first(); e; e = emails.next()) { query += "&to=" + KURL::encode_string(e); } // create url KURL destination; KNServerInfo *account = currentSmtpJob->account(); if(account->encryption() == KNServerInfo::SSL) destination.setProtocol("smtps"); else destination.setProtocol("smtp"); destination.setHost(account->server()); destination.setPort(account->port()); destination.setQuery(query); if(account->needsLogon()) { destination.setUser(account->user()); destination.setPass(account->pass()); } KIO::Job *job = KIO::storedPut(art->encodedContent(true), destination, -1, false, false, false); connect(job, SIGNAL(result(KIO::Job *)), SLOT(slotJobResult(KIO::Job *))); if(account->encryption() == KNServerInfo::TLS) job->addMetaData("tls", "on"); else job->addMetaData("tls", "off"); currentSmtpJob->setJob(job); kdDebug(5003) << "KNNetAccess::startJobSmtp(): job started" << endl; } else { threadDoneSmtp(); } }
QtObject::QtObject(QObject* object, const QString& name) : Kross::Api::Class<QtObject>(name.isEmpty() ? object->name() : name) , m_object(object) { // Walk through the signals and slots the QObject has // and attach them as events to this QtObject. QStrList slotnames = m_object->metaObject()->slotNames(false); for(char* c = slotnames.first(); c; c = slotnames.next()) { QCString s = c; addChild(s, new EventSlot(s, object, s) ); } QStrList signalnames = m_object->metaObject()->signalNames(false); for(char* c = signalnames.first(); c; c = signalnames.next()) { QCString s = c; addChild(s, new EventSignal(s, object, s) ); } // Add functions to wrap QObject methods into callable // Kross objects. addFunction("propertyNames", &QtObject::propertyNames); addFunction("hasProperty", &QtObject::hasProperty); addFunction("getProperty", &QtObject::getProperty); addFunction("setProperty", &QtObject::setProperty); addFunction("slotNames", &QtObject::slotNames); addFunction("hasSlot", &QtObject::hasSlot); addFunction("slot", &QtObject::callSlot); addFunction("signalNames", &QtObject::signalNames); addFunction("hasSignal", &QtObject::hasSignal); addFunction("signal", &QtObject::emitSignal); addFunction("connect", &QtObject::connectSignal); addFunction("disconnect", &QtObject::disconnectSignal); }
/*! Decodes URIs from \a e, converts them to local files if they refer to local files, and places them in \a l (which is first cleared). Returns TRUE if the event contained a valid list of URIs. The list will be empty if no URIs were local files. */ bool QUriDrag::decodeLocalFiles( const QMimeSource* e, QStringList& l ) { QStrList u; if ( !decode( e, u ) ) return FALSE; l.clear(); for (const char* s=u.first(); s; s=u.next()) { QString lf = uriToLocalFile(s); if ( !lf.isNull() ) l.append( lf ); } return TRUE; }
bool DirDef::matchPath(const QCString &path,QStrList &l) { const char *s=l.first(); while (s) { QCString prefix = s; if (qstricmp(prefix.left(path.length()),path)==0) // case insensitive compare { return TRUE; } s = l.next(); } return FALSE; }
void KfmView::slotOpenWith() { QStrList popupFiles = new QStrList(); getActiveView()->getSelected ( popupFiles ); // get selected URL(s) if ( popupFiles.isEmpty() && popupMenuEvent ) { popupFiles.append ( getURL() ); } OpenWithDlg l( klocale->translate("Open With:"), "", this, true ); if ( l.exec() ) { KMimeBind *bind = l.mimeBind(); if ( bind ) { const char *s; for( s = popupFiles.first(); s != 0L; s = popupFiles.next() ) bind->runBinding( s ); return; } QString pattern = l.getText(); if ( pattern.length() == 0 ) return; } else return; printf("KfmView::slotPopupOpenWith starts openWithOldApplication(%s)\n", l.getText()); KURL u(popupFiles.first()); if (u.isLocalFile()) { QString udir(u.directory()); udir.detach(); KURL::decodeURL(udir); // I hate KURL, you never know when it's encoded ... David. openWithOldApplication( l.getText(), popupFiles, udir ); } else openWithOldApplication( l.getText(), popupFiles ); }
void KMediaWin::onDrop( KDNDDropZone* _zone ) { QStrList strlist; strlist = _zone->getURLList(); KURL *url = new KURL( strlist.first() ); QString urlQstr = url->path(); QString &urlQref = urlQstr; KURL::decodeURL(urlQref); FileNameSet( FnamChunk, urlQstr.data()); launchPlayer(urlQstr.data()); delete url; }
/*! Decodes URLs from \a e, converts them to local files if they refer to local files, and places them in \a l (which is first cleared). Returns TRUE if the event contained a valid list of URLs. The list will be empty if no URLs were local files. */ bool QUrlDrag::decodeLocalFiles( QDropEvent* e, QStrList& l ) { QStrList u; if ( !decode( e, u ) ) return FALSE; l.clear(); l.setAutoDelete(TRUE); for (const char* s=u.first(); s; s=u.next()) { QString lf = urlToLocalFile(s); if ( !lf.isNull() ) l.append( lf ); } return TRUE; }
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 KISDNnet::dropEvent(QDropEvent *event) { // this is a very simplistic implementation of a drop event. we // will only accept a dropped URL. the Qt dnd code can do *much* // much more, so please read the docs there QStrList uri; // see if we can decode a URI.. if not, just ignore it if (QUriDrag::decode(event, uri)) { // okay, we have a URI.. process it QString url, target; url = uri.first(); // load in the file } }
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)) {
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()); } }
QStringList opie_imageExtensions() { /* * File extensions (e.g jpeg JPG jpg) are not * parsed yet */ if ( !opie_image_extension_List ) { opie_image_extension_List = new QStringList(); qAddPostRoutine( clean_opie_image_extension_List ); QStrList fileFormats = QImageIO::inputFormats(); QString ff = fileFormats.first(); while ( fileFormats.current() ) { *opie_image_extension_List += MimeType("image/"+ff.lower()).extensions(); ff = fileFormats.next(); } } return *opie_image_extension_List; // QShared so it should be efficient }
void HTMLCache::clear() { QFileInfo finfo(KFMPaths::CachePath().data()); if (finfo.isSymLink() || !finfo.isDir()) { QMessageBox::warning( 0L, i18n("KFM Error"), KFMPaths::CachePath()+i18n( " is not a directory ! Security Alert !\nCheck it before clearing the cache.\n")); return; } QStrList todie; QDictIterator<QString> it( *urlDict ); for ( ; it.current(); ++it ) { if ( unlink( it.current()->data() ) == 0 ) todie.append( it.currentKey() ); } const char *s; for ( s = todie.first(); s != 0L; s = todie.next() ) urlDict->remove( s ); save(); }
bool KCalls::ReadConfig(const char *EntName) { KConfig *config = ((KConnection*) topLevelWidget())->GetConfig(); QStrList List; char *elem; int i = 0; if (config == NULL) return FALSE; config->setGroup(KI_SEC_GLOBAL); config->readListEntry(EntName,List); if ((elem = List.first()) != NULL) do { setColumnWidth(i++,atoi(elem)); } while((elem = List.next()) != NULL); return TRUE; }
void dnd::dropEvent( QDropEvent * e ) { QStrList list; QString str; if ( QUriDrag::decode( e, list ) ) { for(const char* u = list.first(); u; u = list.next()) { if(u) str = u; } } else { str = QString(e->encodedData("text/plain")); } if(str.isEmpty()) return; QApplication::clipboard()->setText(str); dmw->fileNewUrl(); }