void KgpgApp::slotFileSave() { TQString filn=Docname.path(); if (filn.isEmpty()) { slotFileSaveAs(); return; } TQTextCodec*cod=TQTextCodec::codecForName (textEncoding.ascii()); // slotStatusMsg(i18n("Saving file...")); if (!checkEncoding(cod)) { KMessageBox::sorry(this,i18n("The document could not been saved, as the selected encoding cannot encode every unicode character in it.")); return; } KTempFile tmpfile; if (Docname.isLocalFile()) { TQFile f(filn); if ( !f.open( IO_WriteOnly ) ) { KMessageBox::sorry(this,i18n("The document could not be saved, please check your permissions and disk space.")); return; } TQTextStream t( &f ); t.setCodec(cod); //t.setEncoding( TQTextStream::Latin1 ); t << view->editor->text();//.utf8(); f.close(); } else { /*FIXME use following code: TQFile f( fName ); 00983 if ( !f.open( IO_ReadOnly ) ) 00984 return; 00985 TQFileInfo info ( f ); 00986 smModificationTime = new TQTime( info.lastModified().time() ); 00987 TQTextStream t(&f); 00988 t.setEncoding( TQTextStream::Latin1 ); 00989 TQString s = t.readLine(); 00990 f.close(); */ TQTextStream *stream = tmpfile.textStream(); stream->setCodec(cod); *stream << view->editor->text();//.utf8(); tmpfile.close(); if(!TDEIO::NetAccess::upload(tmpfile.name(), Docname,this)) { KMessageBox::sorry(this,i18n("The document could not be saved, please check your permissions and disk space.")); tmpfile.unlink(); return; } tmpfile.unlink(); } fileSave->setEnabled(false); setCaption(Docname.fileName(),false); }
void SVNHandler::processDiff( QString output ) { output.remove( QRegExp( "\\[ .* \\]$" )); output.remove( QRegExp( "^" + i18n("[ Starting command ]" ).replace("[","\\[").replace("]","\\]"))); KTempFile tmpFile; *(tmpFile.textStream()) << output; tmpFile.close(); QString error; if ( KApplication::startServiceByName( "Kompare", tmpFile.name(), &error ) ) KMessageBox::error( 0, error ); }
void subversionCore::diff( const KURL::List& list, const QString& where){ kdDebug(9036) << "diff " << list << endl; KURL servURL = "kdevsvn+svn://this_is_a_fake_URL_and_this_is_normal/"; for ( QValueListConstIterator<KURL> it = list.begin(); it != list.end() ; ++it ) { QByteArray parms; QDataStream s( parms, IO_WriteOnly ); int cmd = 13; kdDebug(9036) << "diffing : " << (*it).prettyURL() << endl; int rev1=-1; int rev2=-1; QString revkind1 = where; QString revkind2 = "WORKING"; s << cmd << *it << *it << rev1 << revkind1 << rev2 << revkind2 << true ; KIO::SimpleJob * job = KIO::special(servURL, parms, true); connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotResult( KIO::Job * ) ) ); KIO::NetAccess::synchronousRun( job, 0 ); if ( diffresult.count() > 0 ) { //check kompare is available if ( !KStandardDirs::findExe( "kompare" ).isNull() ) { if (!KStandardDirs::findExe("patch").isNull()){ // we have patch - so can merge KTempDir tmpDir = KTempDir(diffTmpDir->name()); KTempFile tmpPatch = KTempFile(tmpDir.name()); // write the patch QTextStream *stream = tmpPatch.textStream(); stream->setCodec( QTextCodec::codecForName( "utf8" ) ); for ( QStringList::Iterator it2 = diffresult.begin();it2 != diffresult.end() ; ++it2 ) { ( *stream ) << ( *it2 ) << "\n"; } tmpPatch.close(); QString ourCopy = tmpDir.name()+(*it).fileName(); KProcess copy; copy << "cp" << (*it).prettyURL(0,KURL::StripFileProtocol) << tmpDir.name(); copy.start(KProcess::Block); KProcess patch; patch.setWorkingDirectory(tmpDir.name()); patch << "patch" << "-R" << ourCopy << tmpPatch.name(); patch.start(KProcess::Block, KProcess::All); KProcess *p = new KProcess; *p << "kompare" << ourCopy << (*it).prettyURL(); p->start(); } else{ // only diff KTempFile *tmp = new KTempFile; tmp->setAutoDelete(true); QTextStream *stream = tmp->textStream(); stream->setCodec( QTextCodec::codecForName( "utf8" ) ); for ( QStringList::Iterator it2 = diffresult.begin();it2 != diffresult.end() ; ++it2 ) { ( *stream ) << ( *it2 ) << "\n"; } tmp->close(); KProcess *p = new KProcess; *p << "kompare" << "-n" << "-o" << tmp->name(); p->start(); } } else { //else do it with message box Subversion_Diff df; for ( QStringList::Iterator it2 = diffresult.begin();it2 != diffresult.end() ; ++it2 ) { df.text->append( *it2 ); } QFont f = df.font(); f.setFixedPitch( true ); df.text->setFont( f ); df.exec(); } } else{ QString diffTo = i18n("the local disk checked out copy."); if ( where=="HEAD"){ diffTo=i18n("the current svn HEAD version."); } KMessageBox::information( 0, i18n("No differences between the file and %1").arg(diffTo), i18n("No difference") ); } diffresult.clear(); } }