Diffstat (limited to 'noncore/apps/tinykate/libkate/document/katedocument.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katedocument.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp index 10bc976..df1de8d 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp @@ -307,48 +307,49 @@ void KateDocument::openURL(const QString &filename) #warning fixme // buffer->insertFile(0, m_file, KGlobal::charsets()->codecForName(myEncoding)); qDebug("Telling buffer to open file"); buffer->insertFile(0, m_file, QTextCodec::codecForLocale()); setMTime(); if (myWordWrap) wrapText (myWordWrapAt); int hl = hlManager->wildcardFind( m_file ); setHighlight(hl); updateLines(); updateViews(); emit fileNameChanged(); return ; } bool KateDocument::saveFile() { + QFile f( m_file ); if ( !f.open( IO_WriteOnly ) ) return false; // Error QTextStream stream(&f); stream.setEncoding(QTextStream::RawUnicode); // disable Unicode headers #warning fixme // stream.setCodec(KGlobal::charsets()->codecForName(myEncoding)); stream.setCodec(QTextCodec::codecForLocale()); // this line sets the mapper to the correct codec int maxLine = numLines(); int line = 0; while(true) { stream << getTextLine(line)->getString(); line++; if (line >= maxLine) break; if (eolMode == KateDocument::eolUnix) stream << "\n"; else if (eolMode == KateDocument::eolDos) stream << "\r\n"; else if (eolMode == KateDocument::eolMacintosh) stream << '\r'; }; f.close(); @@ -1904,49 +1905,50 @@ void KateDocument::tagAll() { } void KateDocument::updateLines(int startLine, int endLine, int flags, int cursorY) { TextLine::Ptr textLine; int line, last_line; int ctxNum, endCtx; // kdDebug(13020)<<"******************KateDocument::updateLines Checkpoint 1"<<endl; if (buffer->line(startLine)==0) {kdDebug(13020)<<"********************No buffer for line " << startLine << " found**************"<<endl; return;}; // kdDebug(13020)<<"KateDocument::updateLines Checkpoint 2"<<endl; last_line = lastLine(); // if (endLine >= last_line) endLine = last_line; line = startLine; ctxNum = 0; if (line > 0) ctxNum = getTextLine(line - 1)->getContext(); do { // kdDebug(13020)<<QString("**************Working on line: %1").arg(line)<<endl; textLine = getTextLine(line); if (textLine==0) kdDebug(13020)<<"****updateLines()>> error textLine==0"<<endl; if (line <= endLine && line != cursorY) { if (flags & KateView::cfRemoveSpaces) textLine->removeSpaces(); updateMaxLength(textLine); } endCtx = textLine->getContext(); - qDebug("DOHIGHLIGHT"); +// qDebug("DOHIGHLIGHT"); + ctxNum = m_highlight->doHighlight(ctxNum,textLine); textLine->setContext(ctxNum); line++; } while ((buffer->line(line)!=0) && (line <= endLine || endCtx != ctxNum)); // kdDebug(13020)<<"updateLines :: while loop left"<<endl; tagLines(startLine, line - 1); } void KateDocument::updateMaxLength(TextLine::Ptr &textLine) { int len; len = textWidth(textLine,textLine->length()); if (len > maxLength) { longestLine = textLine; maxLength = len; newDocGeometry = true; } else { if (!longestLine || (textLine == longestLine && len <= maxLength*3/4)) { maxLength = -1; for (int i = 0; i < numLines();i++) { textLine = getTextLine(i); len = textWidth(textLine,textLine->length()); @@ -3009,48 +3011,54 @@ void KateDocument::clipboardChanged() { //slot if (m_singleSelection) { disconnect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardChanged())); deselectAll(); updateViews(); } //#endif } #if 0 void KateDocument::guiActivateEvent( KParts::GUIActivateEvent *ev ) { KParts::ReadWritePart::guiActivateEvent( ev ); if ( ev->activated() ) emit selectionChanged(); } #endif void KateDocument::setDocName (QString docName) { myDocName = docName; emit nameChanged (this); } +void KateDocument::setDocFile (QString docFile) +{ + m_file = docFile; + emit fileNameChanged (); +} + void KateDocument::setMTime() { if (fileInfo && !fileInfo->fileName().isEmpty()) { fileInfo->refresh(); mTime = fileInfo->lastModified(); } } void KateDocument::isModOnHD(bool forceReload) { if (fileInfo && !fileInfo->fileName().isEmpty()) { fileInfo->refresh(); if (fileInfo->lastModified() > mTime) { if ( forceReload || (KMessageBox::warningContinueCancel(0, (i18n("The file %1 has changed on disk.\nDo you want to reload it?\n\nIf you cancel you will lose these changes next time you save this file")).arg(m_url), i18n("File has changed on Disk"), i18n("Yes") ) == KMessageBox::Continue) ) reloadFile(); else setMTime(); } } |