-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp index a70f3aa..b82a86a 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp | |||
@@ -320,97 +320,102 @@ void KateDocument::openURL(const QString &filename) | |||
320 | 320 | ||
321 | updateLines(); | 321 | updateLines(); |
322 | updateViews(); | 322 | updateViews(); |
323 | 323 | ||
324 | emit fileNameChanged(); | 324 | emit fileNameChanged(); |
325 | 325 | ||
326 | return ; | 326 | return ; |
327 | } | 327 | } |
328 | 328 | ||
329 | bool KateDocument::saveFile() | 329 | bool KateDocument::saveFile() |
330 | { | 330 | { |
331 | 331 | ||
332 | QFile f( m_file ); | 332 | QFile f( m_file ); |
333 | if ( !f.open( IO_WriteOnly ) ) | 333 | if ( !f.open( IO_WriteOnly ) ) |
334 | return false; // Error | 334 | return false; // Error |
335 | 335 | ||
336 | QTextStream stream(&f); | 336 | QTextStream stream(&f); |
337 | 337 | ||
338 | stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers | 338 | stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers |
339 | #warning fixme | 339 | #warning fixme |
340 | // stream.setCodec(KGlobal::charsets()->codecForName(myEncoding)); | 340 | // stream.setCodec(KGlobal::charsets()->codecForName(myEncoding)); |
341 | stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec | 341 | stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec |
342 | 342 | ||
343 | int maxLine = numLines(); | 343 | int maxLine = numLines(); |
344 | int line = 0; | 344 | int line = 0; |
345 | while(true) | 345 | while(true) |
346 | { | 346 | { |
347 | stream << getTextLine(line)->getString(); | 347 | stream << getTextLine(line)->getString(); |
348 | line++; | 348 | line++; |
349 | if (line >= maxLine) break; | 349 | if (line >= maxLine) break; |
350 | 350 | ||
351 | if (eolMode == KateDocument::eolUnix) stream << "\n"; | 351 | if (eolMode == KateDocument::eolUnix) stream << "\n"; |
352 | else if (eolMode == KateDocument::eolDos) stream << "\r\n"; | 352 | else if (eolMode == KateDocument::eolDos) stream << "\r\n"; |
353 | else if (eolMode == KateDocument::eolMacintosh) stream << '\r'; | 353 | else if (eolMode == KateDocument::eolMacintosh) stream << '\r'; |
354 | }; | 354 | }; |
355 | f.close(); | 355 | f.close(); |
356 | 356 | ||
357 | fileInfo->setFile (m_file); | 357 | fileInfo->setFile (m_file); |
358 | setMTime(); | 358 | setMTime(); |
359 | 359 | ||
360 | if (!(d(this)->hlSetByUser)) | 360 | if (!(d(this)->hlSetByUser)) |
361 | { | 361 | { |
362 | int hl = hlManager->wildcardFind( m_file ); | 362 | int hl = hlManager->wildcardFind( m_file ); |
363 | 363 | ||
364 | setHighlight(hl); | 364 | setHighlight(hl); |
365 | } | 365 | } |
366 | emit fileNameChanged (); | 366 | emit fileNameChanged (); |
367 | 367 | ||
368 | return (f.status() == IO_Ok); | 368 | if(f.status() == IO_Ok) { |
369 | setModified(false); | ||
370 | return true; | ||
371 | } | ||
372 | else | ||
373 | return false; | ||
369 | } | 374 | } |
370 | 375 | ||
371 | KTextEditor::View *KateDocument::createView( QWidget *parent, const char *name ) | 376 | KTextEditor::View *KateDocument::createView( QWidget *parent, const char *name ) |
372 | { | 377 | { |
373 | return new KateView( this, parent, name); | 378 | return new KateView( this, parent, name); |
374 | } | 379 | } |
375 | 380 | ||
376 | QString KateDocument::textLine( int line ) const | 381 | QString KateDocument::textLine( int line ) const |
377 | { | 382 | { |
378 | TextLine::Ptr l = getTextLine( line ); | 383 | TextLine::Ptr l = getTextLine( line ); |
379 | if ( !l ) | 384 | if ( !l ) |
380 | return QString(); | 385 | return QString(); |
381 | 386 | ||
382 | return l->getString(); | 387 | return l->getString(); |
383 | } | 388 | } |
384 | 389 | ||
385 | void KateDocument::replaceLine(const QString& s,int line) | 390 | void KateDocument::replaceLine(const QString& s,int line) |
386 | { | 391 | { |
387 | remove_Line(line,false); | 392 | remove_Line(line,false); |
388 | insert_Line(s,line,true); | 393 | insert_Line(s,line,true); |
389 | } | 394 | } |
390 | 395 | ||
391 | void KateDocument::insertLine( const QString &str, int l ) { | 396 | void KateDocument::insertLine( const QString &str, int l ) { |
392 | insert_Line(str,l,true); | 397 | insert_Line(str,l,true); |
393 | } | 398 | } |
394 | 399 | ||
395 | void KateDocument::insert_Line(const QString& s,int line, bool update) | 400 | void KateDocument::insert_Line(const QString& s,int line, bool update) |
396 | { | 401 | { |
397 | kdDebug(13020)<<"KateDocument::insertLine "<<s<<QString(" %1").arg(line)<<endl; | 402 | kdDebug(13020)<<"KateDocument::insertLine "<<s<<QString(" %1").arg(line)<<endl; |
398 | TextLine::Ptr TL=new TextLine(); | 403 | TextLine::Ptr TL=new TextLine(); |
399 | TL->append(s.unicode(),s.length()); | 404 | TL->append(s.unicode(),s.length()); |
400 | buffer->insertLine(line,TL); | 405 | buffer->insertLine(line,TL); |
401 | if (update) | 406 | if (update) |
402 | { | 407 | { |
403 | newDocGeometry=true; | 408 | newDocGeometry=true; |
404 | updateLines(line); | 409 | updateLines(line); |
405 | updateViews(); | 410 | updateViews(); |
406 | } | 411 | } |
407 | } | 412 | } |
408 | 413 | ||
409 | void KateDocument::insertAt( const QString &s, int line, int col, bool ) | 414 | void KateDocument::insertAt( const QString &s, int line, int col, bool ) |
410 | { | 415 | { |
411 | VConfig c; | 416 | VConfig c; |
412 | c.view = 0; // ### FIXME | 417 | c.view = 0; // ### FIXME |
413 | c.cursor.x = col; | 418 | c.cursor.x = col; |
414 | c.cursor.y = line; | 419 | c.cursor.y = line; |
415 | c.cXPos = 0; // ### FIXME | 420 | c.cXPos = 0; // ### FIXME |
416 | c.flags = 0; // ### FIXME | 421 | c.flags = 0; // ### FIXME |