[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdeutils/kedit
From:       Aaron J. Seigo <aseigo () olympusproject ! org>
Date:       2003-06-30 23:26:39
[Download RAW message or body]

CVS commit by aseigo: 

warn a user when they are going to open a large file (>2MB), which is
something that kedit is remarkably (though expectedly) poor at doing

fix session management so that it reloads a file even if it wasn't
modified

fixes a couple BRs.


  M +39 -25    kedit.cpp   1.180


--- kdeutils/kedit/kedit.cpp  #1.179:1.180
@@ -28,4 +28,5 @@
 
 #include <kcursor.h>
+#include <kfileitem.h>
 #include "ktextfiledlg.h"
 #include <kio/netaccess.h>
@@ -284,30 +284,32 @@ void TopLevel::readProperties(KConfig* c
     int line = config->readNumEntry("current_line", 0);
     int col = config->readNumEntry("current_column", 0);
+    int result = KEDIT_RETRY;
 
-    if(!filename.isEmpty() && modified){
-        int result = openFile(filename, OPEN_READWRITE, url.fileEncoding());
-        if (result == KEDIT_OK)
+    if(!filename.isEmpty())
         {
-          m_url = url;
-          eframe->setModified(TRUE);
-          eframe->setCursorPosition(line, col);
-          setFileCaption();
-          statusbar_slot();
+        if (modified)
+        {
+            result = openFile(filename, OPEN_READWRITE, url.fileEncoding());
+        }
+        else
+        {
+            result = openFile(filename, OPEN_READWRITE, url.fileEncoding());
         }
     }
-    else{
+    else
+    {
+        openURL(url, OPEN_READWRITE);
+        modified = false;
+        result = KEDIT_OK;
+    }
 
-      if(!filename.isEmpty()){
-        int result = openFile(filename, OPEN_READWRITE, url.fileEncoding());
         if (result == KEDIT_OK)
         {
           m_url = url;
-          eframe->setModified(false);
+        eframe->setModified(modified);
           eframe->setCursorPosition(line, col);
           setFileCaption();
           statusbar_slot();
         }
-      }
-    }
 }
 
@@ -466,4 +468,18 @@ void TopLevel::file_open( void )
     }
 
+    KIO::UDSEntry entry;
+    KIO::NetAccess::stat(url, entry);
+    KFileItem fileInfo(entry, url);
+    if (fileInfo.size() > 2097152 && // 2MB large/small enough? 
+        KMessageBox::warningContinueCancel(this, 
+                         i18n("The file you have requested is larger than KEdit is \
designed for. " +                              "Please ensure you have enough system \
resources available to safely load this file, " +                              "or \
consider using a program that is designed to handle large files such as KWrite."), +  \
i18n("Attempting To Open Large File"), +                        KStdGuiItem::cont(), \
"attemptingToOpenLargeFile") == KMessageBox::Cancel) +    {
+        return;
+    }
+
     TopLevel *toplevel;
     if( !m_url.isEmpty() || eframe->isModified() )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic