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 | |||
@@ -272,193 +272,198 @@ void KateDocument::doPreHighlight() | |||
272 | PreHighlightedTill = till; | 272 | PreHighlightedTill = till; |
273 | updateLines(from,till); | 273 | updateLines(from,till); |
274 | emit preHighlightChanged(PreHighlightedTill); | 274 | emit preHighlightChanged(PreHighlightedTill); |
275 | if (PreHighlightedTill<RequestPreHighlightTill) | 275 | if (PreHighlightedTill<RequestPreHighlightTill) |
276 | QTimer::singleShot(10,this,SLOT(doPreHighlight())); | 276 | QTimer::singleShot(10,this,SLOT(doPreHighlight())); |
277 | } | 277 | } |
278 | 278 | ||
279 | KateDocument::~KateDocument() | 279 | KateDocument::~KateDocument() |
280 | { | 280 | { |
281 | m_highlight->release(); | 281 | m_highlight->release(); |
282 | writeConfig(); | 282 | writeConfig(); |
283 | 283 | ||
284 | if ( !m_bSingleViewMode ) | 284 | if ( !m_bSingleViewMode ) |
285 | { | 285 | { |
286 | m_views.setAutoDelete( true ); | 286 | m_views.setAutoDelete( true ); |
287 | m_views.clear(); | 287 | m_views.clear(); |
288 | m_views.setAutoDelete( false ); | 288 | m_views.setAutoDelete( false ); |
289 | } | 289 | } |
290 | delete_d(this); | 290 | delete_d(this); |
291 | } | 291 | } |
292 | 292 | ||
293 | void KateDocument::openURL(const QString &filename) | 293 | void KateDocument::openURL(const QString &filename) |
294 | { | 294 | { |
295 | 295 | ||
296 | m_file=filename; | 296 | m_file=filename; |
297 | fileInfo->setFile (m_file); | 297 | fileInfo->setFile (m_file); |
298 | setMTime(); | 298 | setMTime(); |
299 | 299 | ||
300 | if (!fileInfo->exists() || !fileInfo->isReadable()) | 300 | if (!fileInfo->exists() || !fileInfo->isReadable()) |
301 | { | 301 | { |
302 | odebug << "File doesn't exit or couldn't be read" << oendl; | 302 | odebug << "File doesn't exit or couldn't be read" << oendl; |
303 | return ; | 303 | return ; |
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); |
433 | updateViews(); | 438 | updateViews(); |
434 | } | 439 | } |
435 | } | 440 | } |
436 | 441 | ||
437 | int KateDocument::length() const | 442 | int KateDocument::length() const |
438 | { | 443 | { |
439 | return text().length(); | 444 | return text().length(); |
440 | } | 445 | } |
441 | 446 | ||
442 | void KateDocument::setSelection( int , int , int , int ) | 447 | void KateDocument::setSelection( int , int , int , int ) |
443 | { | 448 | { |
444 | } | 449 | } |
445 | 450 | ||
446 | bool KateDocument::hasSelection() const | 451 | bool KateDocument::hasSelection() const |
447 | { | 452 | { |
448 | return (selectEnd >= selectStart); | 453 | return (selectEnd >= selectStart); |
449 | } | 454 | } |
450 | 455 | ||
451 | QString KateDocument::selection() const | 456 | QString KateDocument::selection() const |
452 | { | 457 | { |
453 | uint flags = 0; | 458 | uint flags = 0; |
454 | TextLine::Ptr textLine; | 459 | TextLine::Ptr textLine; |
455 | int len, z, start, end, i; | 460 | int len, z, start, end, i; |
456 | 461 | ||
457 | len = 1; | 462 | len = 1; |
458 | if (!(flags & KateView::cfVerticalSelect)) { | 463 | if (!(flags & KateView::cfVerticalSelect)) { |
459 | for (z = selectStart; z <= selectEnd; z++) { | 464 | for (z = selectStart; z <= selectEnd; z++) { |
460 | textLine = getTextLine(z); | 465 | textLine = getTextLine(z); |
461 | len += textLine->numSelected(); | 466 | len += textLine->numSelected(); |
462 | if (textLine->isSelected()) len++; | 467 | if (textLine->isSelected()) len++; |
463 | } | 468 | } |
464 | QString s; | 469 | QString s; |