void KMediaWin::openClicked() { QString fname( KFileDialog::getOpenFileURL(0, "*.wav") ); if (fname.isNull() ) return; KURL *url = new KURL( fname ); QString urlQstr = url->path(); QString &urlQref = urlQstr; KURL::decodeURL(urlQref); FileNameSet( FnamChunk, urlQstr.data() ); launchPlayer(urlQstr.data() ); delete url; }
void CDDialog::trackchanged(){ int i; i = listbox->currentItem(); if (i == -1) return; QTime dml = framestoTime(cdinfo.cddbtoc[i+1].absframe - cdinfo.cddbtoc[i].absframe); QString fmt; fmt.sprintf("%02d %02d:%02d %s",i+1,dml.minute(),dml.second(),trackedit->text()); track_list.insert(i+1,trackedit->text()); track_list.remove(i+2); listbox->setAutoUpdate(false); listbox->insertItem(fmt.data(),i); listbox->removeItem(i+1); listbox->setAutoUpdate(true); listbox->repaint(); if ( i <(int) listbox->count() -1 ){ listbox->setCurrentItem(i+1); listbox->centerCurrentItem(); } }
void MyInputPanel::buttonClicked(QWidget *w) { QPushButton *pushbtn = (QPushButton*)w; QString btntext = pushbtn->text(); QChar chr; if(btntext == "Num") { chr = '*'; SwithToNum(); } else if ( btntext == "Enter") { chr = '~'; SwithToNum(); } else if (btntext == "Clear") { chr = '%'; } else if (btntext == "Back") { chr = '^'; } else if (btntext == "Blank") { chr = ' '; } else { chr = *btntext.data(); } cout << "Current push button is " << btntext.toStdString() << endl; emit characterGenerated(chr); }
/* Copied and pasted from src/declarative/qml/qdeclarativescriptparser.cpp. */ static void replaceWithSpace(QString &str, int idx, int n) { QChar *data = str.data() + idx; const QChar space(QLatin1Char(' ')); for (int ii = 0; ii < n; ++ii) *data++ = space; }
KProtocolProxyFTP::KProtocolProxyFTP () { use_proxy = 0; int port = 80; QString proxyStr; QString tmp; KURL proxyURL; // All right. Now read the proxy settings // KSimpleConfig prxcnf(KApplication::localconfigdir() + "/kfmrc"); // Read Only KSimpleConfig prxcnf(KApplication::localconfigdir() + "/kfmrc", true ); prxcnf.setGroup("Browser Settings/Proxy"); noProxyForStr = prxcnf.readEntry("NoProxyFor"); tmp = prxcnf.readEntry( "UseProxy" ); if ( tmp == "Yes" ) { // Do we need proxy? proxyStr = prxcnf.readEntry( "FTP-Proxy" ); proxyURL = proxyStr.data(); // printf( "Using ftp proxy %s on port %d\n", proxyURL.host(), proxyURL.port() ); port = proxyURL.port(); if ( port == 0 ) port = 80; proxy_user = prxcnf.readEntry( "Proxy-User" ); proxy_pass = prxcnf.readEntry( "Proxy-Pass" ); init_sockaddr(&proxy_name, proxyURL.host(), port); use_proxy = 1; } }
void KAccel::readSettings(KConfig* config) { QString s; KConfig *pConfig = config?config:kapp->getConfig(); pConfig->setGroup( aGroup.data() ); QDictIterator<KKeyEntry> aKeyIt( aKeyDict ); aKeyIt.toFirst(); #define pE aKeyIt.current() while ( pE ) { s = pConfig->readEntry( aKeyIt.currentKey() ); if ( s.isNull() ) pE->aConfigKeyCode = pE->aDefaultKeyCode; else pE->aConfigKeyCode = stringToKey( s.data() ); pE->aCurrentKeyCode = pE->aConfigKeyCode; if ( pE->aAccelId && pE->aCurrentKeyCode ) { pAccel->disconnectItem( pE->aAccelId, pE->receiver, pE->member ); pAccel->removeItem( pE->aAccelId ); pAccel->insertItem( pE->aCurrentKeyCode, pE->aAccelId ); pAccel->connectItem( pE->aAccelId, pE->receiver, pE->member); } ++aKeyIt; } #undef pE }
void Game::start(QString ip, int port) { //Moottori // Luo verkko // conn.connect(ip,port); conn.waitForConnected(3000); QSettings settings; QString name = settings.value("name").toString(); qDebug()<<"sending name"<<name<<name.size(); QDataStream s(&conn); s << 1 + 4 + name.size()*2; s << MSG_INFO << name.size(); s.writeRawData((char*)name.data(), 2*name.size()); conn.flush(); //Luo ikkuna + piirtopinta window.show(); timer->start(FRAMETIME*1000); }
EXPORT void CALL SaveScreenshot(const wchar_t * _folder, const char * _name, int _width, int _height, const unsigned char * _data) { const char * bmp = "bmp"; const char * jpg = "jpg"; const char * fileExt = config.texture.screenShotFormat == 0 ? bmp : jpg; QString folderName = QString::fromWCharArray(_folder); QDir folder; if (!folder.exists(folderName) && !folder.mkpath(folderName)) return; QString romName(_name); romName = romName.replace(' ', '_'); romName = romName.replace(':', ';'); QString fileName; int i; for (i = 0; i < 1000; ++i) { fileName = fileName.sprintf("%lsGLideN64_%ls_%03i.%s", folderName.data(), romName.data(), i, fileExt); QFile f(fileName); if (!f.exists()) break; } if (i == 1000) return; QImage image(_data, _width, _height, QImage::Format_RGB888); QImageWriter writer(fileName, fileExt); writer.write(image.mirrored()); }
void KBookmarkManager::slotNotify( const char *_url ) { if ( !m_bNotify ) return; KURL u( _url ); if ( strcmp( u.protocol(), "file" ) != 0 ) return; QString p = kapp->localkdedir().data(); p += "/share/apps/kfm/bookmarks"; QDir dir2( p ); QDir dir1( u.path() ); QString p1( dir1.canonicalPath() ); QString p2( dir2.canonicalPath() ); if ( p1.isEmpty() ) p1 = u.path(); if ( p2.isEmpty() ) p2 = p.data(); if ( strncmp( p1.data(), p2.data(), p2.length() ) == 0 ) { QString d = kapp->localkdedir().data(); d += "/share/apps/kfm/bookmarks/"; scan( d ); } }
KfmView::~KfmView() { // debugT("Deleting KfmView\n"); if ( dropZone != 0L ) delete dropZone; dropZone = 0L; // MRJ: make sure all requests are cancelled before the cache is deleted slotStop(); delete manager; delete htmlCache; if(getParentView() == 0) { delete backStack; delete forwardStack; } // debugT("Deleted\n"); // Save HTTP Cookies if (cookiejar) { QString cookieFile = kapp->localkdedir().copy(); cookieFile += "/share/apps/kfm/cookies"; cookiejar->saveCookies( cookieFile.data() ); } }
/* Transforms 'int x = 3 + 4' into 'int x=3+4'. A white space is kept between 'int' and 'x' because it is meaningful in C++. */ static void trimWhiteSpace( QString& str ) { enum { Normal, MetAlnum, MetSpace } state = Normal; const int n = str.length(); int j = -1; QChar *d = str.data(); for ( int i = 0; i != n; ++i ) { const QChar c = d[i]; if ( c.isLetterOrNumber() ) { if ( state == Normal ) { state = MetAlnum; } else { if ( state == MetSpace ) str[++j] = c; state = Normal; } str[++j] = c; } else if ( c.isSpace() ) { if ( state == MetAlnum ) state = MetSpace; } else { state = Normal; str[++j] = c; } } str.resize(++j); }
bool CDDB::getValue(QString& key,QString& value, QString& data){ bool found_one = false; int pos1 = 0; int pos2 = 0; value = ""; while(( pos1 = data.find(key.data(),pos1,true)) != -1){ found_one = true; pos2 = data.find("\n",pos1,true); if( (pos2 - pos1 - (int)key.length()) >= 0){ value += data.mid(pos1 + key.length(), pos2 - pos1 - key.length()); } else{ if (debugflag) fprintf(stderr,"GET VALUE ANOMALY 1\n"); } pos1 = pos1 + 1; } if(value.isNull()) value = ""; cddb_decode(value); return found_one; }
void KResourceMan::sync() { if ( !propDict->isEmpty() ) { time_t timestamp; ::time( ×tamp ); QDictIterator <QString> it( *propDict ); QString keyvalue; while ( it.current() ) { QString *value = propDict->find( it.currentKey() ); keyvalue.sprintf( "%s: %s\n", it.currentKey(), value->data() ); propString += keyvalue; // if (it.currentKey() == "font"){ // // dirty hack, makes font to fontList for x-resources // keyvalue.sprintf( "%s: %s\n", it.currentKey(), value->data() ); // propString += keyvalue; // } ++it; } QString fileName; fileName.sprintf(_PATH_TMP"/krdb.%ld", timestamp); QFile f( fileName ); if ( f.open( IO_WriteOnly ) ) { f.writeBlock( propString.data(), propString.length() ); f.close(); } proc.setExecutable("xrdb"); proc << "-merge" << fileName.data(); proc.start( KProcess::Block ); QDir d( _PATH_TMP ); if ( d.exists() ) d.remove( fileName ); propDict->clear(); } }
void Serializable::unregisterObject (const QString &name) { if (!type_table.contains (name)) { qFatal ("unregisterObject failed! name %s has not been registered", (char *)name.data ()); } Serializable::type_table.remove(name); }
const char* HTMLCache::isCached( const char *_url ) { QString *s = (*urlDict)[ _url ]; if ( s != 0L ) return s->data(); return 0L; }
void KResourceMan::setGroup( const QString& rGroup ) { QString s("General"); if ( rGroup == s ) prefix.sprintf( "*" ); else prefix.sprintf( "%s.", rGroup.data() ); }
QString room_sort_key(const QString &n) { int i = 0; while((n[i] == '#' || n[i] == '@') && (i < n.size())) { ++i; } if(i == n.size()) return n.toCaseFolded(); return QString(n.data() + i, n.size() - i).toCaseFolded(); }
void KDMSessionsWidget::moveSession(int d) { int id = sessionslb->currentItem(); QString str = sessionslb->text(id); sessionslb->removeItem(id); sessionslb->insertItem(str.data(), id+d); sessionslb->setCurrentItem(id+d); }
void KSoundPageConfig::soundDropped(KDNDDropZone *zone){ QStrList &list = zone->getURLList(); QString msg; int i, len; // For now, we do only accept FILES ending with .wav... len = list.count(); for ( i = 0; i < len; i++) { QString url = list.at(i); if (strcmp("file:", url.left(5))) { // for now, only file URLs are supported QMessageBox::warning(this, klocale->translate("Unsupported URL"), i18n("Sorry, this type of URL is currently unsupported"\ "by the KDE System Sound Module") ); } else { // Now check for the ending ".wav" if (stricmp(".WAV",url.right(4))) { msg.sprintf(i18n("Sorry, but \n%s\ndoes not seem "\ "to be a WAV--file."), url.data()); QMessageBox::warning(this, klocale->translate("Improper File Extension"), msg); } else { // Hurra! Finally we've got a WAV file to add to the list url = url.right(url.length()-5); // strip the leading "file:" if (!addToSound_List(url)) { // did not add file because it is already in the list msg.sprintf(i18n("The file\n" "%s\n" "is already in the list"), url.data()); QMessageBox::warning(this, klocale->translate("File Already in List"), msg); } } } } }
int Database::FTSOpen(sqlite3_tokenizer* pTokenizer, const char* input, int bytes, sqlite3_tokenizer_cursor** cursor) { UnicodeTokenizerCursor* new_cursor = new UnicodeTokenizerCursor; new_cursor->pTokenizer = pTokenizer; new_cursor->position = 0; QString str = QString::fromUtf8(input, bytes).toLower(); QChar* data = str.data(); // Decompose and strip punctuation. QList<Token> tokens; QString token; int start_offset = 0; int offset = 0; for (int i = 0; i < str.length(); ++i) { QChar c = data[i]; ushort unicode = c.unicode(); if (unicode <= 0x007f) { offset += 1; } else if (unicode >= 0x0080 && unicode <= 0x07ff) { offset += 2; } else if (unicode >= 0x0800) { offset += 3; } // Unicode astral planes unsupported in Qt? /*else if (unicode >= 0x010000 && unicode <= 0x10ffff) { offset += 4; }*/ if (!data[i].isLetterOrNumber()) { // Token finished. if (token.length() != 0) { tokens << Token(token, start_offset, offset - 1); start_offset = offset; token.clear(); } else { ++start_offset; } } else { if (data[i].decompositionTag() != QChar::NoDecomposition) { token.push_back(data[i].decomposition()[0]); } else { token.push_back(data[i]); } } if (i == str.length() - 1) { if (token.length() != 0) { tokens << Token(token, start_offset, offset); token.clear(); } } } new_cursor->tokens = tokens; *cursor = reinterpret_cast<sqlite3_tokenizer_cursor*>(new_cursor); return SQLITE_OK; }
int main(int argc, char *argv[]) { #ifdef Q_WS_X11 if(Library::threadedGL()) { std::cout << "Enabling Threads" << std::endl; XInitThreads(); } #endif // set up groups for QSettings QCoreApplication::setOrganizationName("SourceForge"); QCoreApplication::setOrganizationDomain("sourceforge.net"); QCoreApplication::setApplicationName("Avogadro"); Application app(argc, argv); // Output the untranslated application and library version - bug reports QString versionInfo = "Avogadro version:\t" + QString(VERSION) + "\tGit:\t" + QString(SCM_REVISION) + "\nLibAvogadro version:\t" + Library::version() + "\tGit:\t" + Library::scmRevision(); qDebug() << versionInfo; #ifdef WIN32 // Need to add an environment variable to the current process in order // to load the forcefield parameters in OpenBabel. QString babelDataDir = "BABEL_DATADIR=" + QCoreApplication::applicationDirPath(); qDebug() << babelDataDir; _putenv(babelDataDir.toStdString().c_str()); #endif #ifdef AVO_APP_BUNDLE // Set up the babel data and plugin directories for Mac - relocatable QByteArray babelDataDir(("BABEL_DATADIR=" + QCoreApplication::applicationDirPath() + "/../share/openbabel/2.2.2").toAscii()); QByteArray babelLibDir(("BABEL_LIBDIR=" + QCoreApplication::applicationDirPath() + "/../lib/openbabel").toAscii()); int res1 = putenv(babelDataDir.data()); int res2 = putenv(babelLibDir.data()); if (res1 != 0 || res2 != 0) qDebug() << "Error: putenv failed." << res1 << res2; QString env(getenv("BABEL_LIBDIR")); qDebug() << "getenv(\"BABEL_LIBDIR\")=" << env; #endif // Before we do much else, load translations // This ensures help messages and debugging info will be translated QStringList translationPaths; foreach (const QString &variable, QProcess::systemEnvironment()) { QStringList split1 = variable.split('='); if (split1[0] == "AVOGADRO_TRANSLATIONS") { foreach (const QString &path, split1[1].split(':')) translationPaths << path; }
// return true if the dir already exists static bool testDir2( const char *_name ) { DIR *dp; QString c = getenv( "HOME" ); c += _name; dp = opendir( c.data() ); if ( dp == NULL ) { QString m(_name); //QMessageBox::information( 0, klocale->translate("KFM Information"), // klocale->translate("Creating directory:\n") + m ); ::mkdir( c.data(), S_IRWXU ); return false; } else { closedir( dp ); return true; } }
void KFMClient::slotAuth( const char *_password ) { if ( KFMClient::password == 0L ) KFMClient::password = new QString; if ( KFMClient::password->isNull() ) { QString fn = kapp->localkdedir().copy(); fn += "/share/apps/kfm/magic"; FILE *f = fopen( fn.data(), "rb" ); if ( f == 0L ) { QMessageBox::warning( (QWidget*)0, i18n( "KFM Error" ), i18n( "You dont have the file ~/.kde/share/apps/kfm/magic\nAuthorization failed" ) ); return; } char buffer[ 1024 ]; char *p = fgets( buffer, 1023, f ); fclose( f ); if ( p == 0L ) { QMessageBox::warning( (QWidget*)0, i18n( "KFM Error" ), i18n( "The file ~/.kde/share/apps/kfm/magic is corrupted\nAuthorization failed" ) ); return; } *( KFMClient::password ) = buffer; } if ( *( KFMClient::password ) != _password ) { QMessageBox::warning( (QWidget*)0, i18n( "KFM Error" ), i18n( "Someone tried to authorize himself\nusing a wrong password" ) ); bAuth = false; return; } bAuth = true; connect( this, SIGNAL( list( const char* ) ), this, SLOT( slotList( const char* ) ) ); connect( this, SIGNAL( copy( const char*, const char* ) ), this, SLOT( slotCopy( const char*, const char* ) ) ); connect( this, SIGNAL( move( const char*, const char* ) ), this, SLOT( slotMove( const char*, const char* ) ) ); connect( this, SIGNAL( copyClient( const char*, const char* ) ), server, SLOT( slotCopyClients( const char*, const char* ) ) ); connect( this, SIGNAL( moveClient( const char*, const char* ) ), server, SLOT( slotMoveClients( const char*, const char* ) ) ); connect( this, SIGNAL( refreshDesktop() ), server, SLOT( slotRefreshDesktop() ) ); connect( this, SIGNAL( openURL( const char* ) ), server, SLOT( slotOpenURL( const char *) ) ); connect( this, SIGNAL( refreshDirectory( const char* ) ), server, SLOT( slotRefreshDirectory( const char *) ) ); connect( this, SIGNAL( openProperties( const char* ) ), server, SLOT( slotOpenProperties( const char *) ) ); connect( this, SIGNAL( exec( const char*, const char* ) ), server, SLOT( slotExec( const char *, const char*) ) ); connect( this, SIGNAL( sortDesktop() ), server, SLOT( slotSortDesktop() ) ); connect( this, SIGNAL( configure() ), server, SLOT( slotConfigure() ) ); connect( this, SIGNAL( selectRootIcons( int, int, int, int, bool ) ), server, SLOT( slotSelectRootIcons( int, int, int, int, bool ) ) ); }
void TodoView::changePriority(int pri) { QString s; aTodo->setPriority(pri+1); s.sprintf("%d",pri+1); changeItemPart(s.data(), updatingRow, 2); }
void Connection::sendChat(QString msg) { QDataStream s(this); s << 1 + 4 + msg.size()*2; s << MSG_CHAT; s << msg.size(); s.writeRawData((char*)msg.data(),2*msg.size()); flush(); }
/** * @brief 將字串變成單字的集合 * * 將傳入的字串轉換成一個一個單字的字集 * * @param QString text 輸入的中文字串 * @return 傳回單字的集合 */ QStringList MainWindow::text2List(QString text) { QStringList tmp; for(int i = 0 ; i<( text.size() ); i++) { tmp.append(text.data()[i]); ///< QString 的每個單字,依照 TextCodec的設定,可以用 QString::data()[]取得每一個字的字元,在 Utf-8下可以取出一個中文字,在預設下會取出一個 ascii字元 } return tmp; }
void TodoView::updateItem(int row, int col) { QString tmpStr; int x=0, y=0; int id; updatingRow = row; ASSERT(row >= 0); editingFlag = TRUE; tmpStr = text(row, 0); id = atol(tmpStr.data()); aTodo = calendar->getTodo(id); editor->hide(); editor->setText(aTodo->getSummary()); colXPos(col, &x); rowYPos(row, &y); y += 17; // correct for header size. // first, see if they clicked on the "done/not done column"; if (col == 1) { tmpStr = text(row, 1); if (tmpStr == "CHECKED" || tmpStr == "CHECKEDMASK") { aTodo->setStatus(QString("NEEDS ACTION")); changeItemPart("EMPTY", row, 1); } else { aTodo->setDtEnd(QDateTime::currentDateTime()); aTodo->setStatus(QString("COMPLETED")); changeItemPart("CHECKED", row, 1); } } // see if they clicked on the "priority" column if (col == 2) { priList->move(x, y+2); priList->setCurrentItem(aTodo->getPriority()-1); priList->setFocus(); priList->show(); } // they clicked on the "description" column if (col == 3) { editor->move(x, y+2); editor->setFixedWidth(columnWidth(3)); editor->setFixedHeight(cellHeight(row)); editor->setFocus(); editor->show(); } if (col == 4) { // handle due date stuff } adjustColumns(); }
QString Driver::normalizedName(const QString &name) { QString result = name; QChar *data = result.data(); for (int i = name.size(); --i >= 0; ++data) { if (!data->isLetterOrNumber()) *data = QLatin1Char('_'); } return result; }
IMember::MemberKind map(const QString &s) { int *val = m_map.find(s); if (val==0) { debug(1,"Warning: `%s' is an invalid member type\n",s.data()); return IMember::Invalid; } else return (IMember::MemberKind)*val; }
ISection::SectionKind map(const QString &s) { int *val = m_map.find(s); if (val==0) { debug(1,"Warning: `%s' is an invalid section type\n",s.data()); return ISection::Invalid; } else return (ISection::SectionKind)*val; }