author | paule <paule> | 2007-01-13 07:24:51 (UTC) |
---|---|---|
committer | paule <paule> | 2007-01-13 07:24:51 (UTC) |
commit | 4892c61a3e76c031d7b882854dcb0dfbd575f045 (patch) (unidiff) | |
tree | 5c5de924caf9683ad844fd1ef6d27aff433a560b | |
parent | 80d1934bbbfaea40ee08cf6be738c6517de9477c (diff) | |
download | opie-4892c61a3e76c031d7b882854dcb0dfbd575f045.zip opie-4892c61a3e76c031d7b882854dcb0dfbd575f045.tar.gz opie-4892c61a3e76c031d7b882854dcb0dfbd575f045.tar.bz2 |
Clear document modified flag on save
-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 | |||
@@ -304,129 +304,134 @@ void KateDocument::openURL(const QString &filename) | |||
304 | } | 304 | } |
305 | 305 | ||
306 | buffer->clear(); | 306 | buffer->clear(); |
307 | #warning fixme | 307 | #warning fixme |
308 | // buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); | 308 | // buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); |
309 | odebug << "Telling buffer to open file" << oendl; | 309 | odebug << "Telling buffer to open file" << oendl; |
310 | buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); | 310 | buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); |
311 | 311 | ||
312 | setMTime(); | 312 | setMTime(); |
313 | 313 | ||
314 | if (myWordWrap) | 314 | if (myWordWrap) |
315 | wrapText (myWordWrapAt); | 315 | wrapText (myWordWrapAt); |
316 | 316 | ||
317 | int hl = hlManager->wildcardFind( m_file ); | 317 | int hl = hlManager->wildcardFind( m_file ); |
318 | 318 | ||
319 | setHighlight(hl); | 319 | setHighlight(hl); |
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 |
417 | insert( c, s ); | 422 | insert( c, s ); |
418 | } | 423 | } |
419 | 424 | ||
420 | void KateDocument::removeLine( int line ) { | 425 | void KateDocument::removeLine( int line ) { |
421 | remove_Line(line,true); | 426 | remove_Line(line,true); |
422 | } | 427 | } |
423 | 428 | ||
424 | void KateDocument::remove_Line(int line,bool update) | 429 | void KateDocument::remove_Line(int line,bool update) |
425 | { | 430 | { |
426 | kdDebug(13020)<<"KateDocument::removeLine "<<QString("%1").arg(line)<<endl; | 431 | kdDebug(13020)<<"KateDocument::removeLine "<<QString("%1").arg(line)<<endl; |
427 | buffer->removeLine(line); | 432 | buffer->removeLine(line); |
428 | // newDocGeometry=true; | 433 | // newDocGeometry=true; |
429 | // if line==0) | 434 | // if line==0) |
430 | if (update) | 435 | if (update) |
431 | { | 436 | { |
432 | updateLines(line); | 437 | updateLines(line); |