Преглед на файлове

Clean up setTextSafe (needed for the coming change to invalidate completion info on changes).

git-svn-id: file:///var/svn/tigccpp/trunk@820 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler преди 18 години
родител
ревизия
e4194ee0ed
променени са 5 файла, в които са добавени 26 реда и са изтрити 16 реда
  1. 2 2
      ktigcc/completion.h
  2. 1 0
      ktigcc/ktigcc.h
  3. 9 7
      ktigcc/mainform.ui.h
  4. 0 1
      ktigcc/parsing.cpp
  5. 14 6
      ktigcc/srcfilewin.ui.h

+ 2 - 2
ktigcc/completion.h

@@ -18,6 +18,8 @@
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
 */
 
+#pragma once
+
 #include <qobject.h>
 #include <qpopupmenu.h>
 #include <qmap.h>
@@ -26,8 +28,6 @@
 #include <qvaluelist.h>
 #include <kate/view.h>
 
-#pragma once
-
 struct CompletionInfo {
   bool dirty;
   QStringList includedSystem;

+ 1 - 0
ktigcc/ktigcc.h

@@ -63,3 +63,4 @@ struct Tool {
 typedef QValueVector<Tool> Tools;
 extern Tools tools, tempTools;
 extern int toolIndex;
+extern bool disableViewEvents;

+ 9 - 7
ktigcc/mainform.ui.h

@@ -155,11 +155,9 @@ enum {TIGCCOpenProjectFileFilter,TIGCCAddFilesFilter};
 #define SYSICON(sysname,name) (preferences.useSystemIcons?KGlobal::iconLoader()->loadIcon((sysname),KIcon::Small,KIcon::SizeSmall):QPixmap::fromMimeSource((name)))
 
 #define SET_TEXT_SAFE(doc,text) do { \
-    bool oldModifiedSinceLastCompile=IS_FILE(currentListItem)? \
-      static_cast<ListViewFile *>(currentListItem)->modifiedSinceLastCompile:FALSE; \
+    disableViewEvents=TRUE; \
     (doc)->setText((text)); \
-    if (IS_FILE(currentListItem)) \
-      static_cast<ListViewFile *>(currentListItem)->modifiedSinceLastCompile=oldModifiedSinceLastCompile; \
+    disableViewEvents=FALSE; \
   } while(0)
 
 // For some reason, this flag is not in the public ConfigFlags enum.
@@ -414,6 +412,7 @@ static QPopupMenu *findFunctionsPopup;
 bool have_usb;
 Tools tools, tempTools;
 int toolIndex;
+bool disableViewEvents=FALSE;
 
 class DnDListView : public KListView {
   private:
@@ -1355,6 +1354,7 @@ void MainForm::clearProject()
     delete f;
   }
   fileCount=cFileCount=hFileCount=sFileCount=asmFileCount=qllFileCount=oFileCount=aFileCount=txtFileCount=othFileCount=0;
+  projectCompletion.clear();
   projectIsDirty=FALSE;
   projectNeedsRelink=FALSE;
   menuBar()->setItemVisible(5,preferences.linkTarget==LT_NONE); //debugMenu
@@ -5711,7 +5711,7 @@ void MainForm::updateRightStatusLabel()
 
 void MainForm::current_view_cursorPositionChanged()
 {
-  if (CURRENT_VIEW) {
+  if (CURRENT_VIEW && !disableViewEvents) {
     unsigned int line, col;
     CURRENT_VIEW->cursorPositionReal(&line,&col);
     rowStatusLabel->setText(QString("%1").arg(line+1));
@@ -5721,6 +5721,7 @@ void MainForm::current_view_cursorPositionChanged()
 
 void MainForm::current_view_textChanged()
 {
+  if (disableViewEvents) return;
   if (CURRENT_VIEW) {
     charsStatusLabel->setText(QString("%1 Characters").arg(CURRENT_VIEW->getDoc()->text().length()));
     if (IS_FILE(currentListItem))
@@ -5747,7 +5748,7 @@ void MainForm::current_view_textChanged()
 
 void MainForm::current_view_undoChanged()
 {
-  if (CURRENT_VIEW) {
+  if (CURRENT_VIEW && !disableViewEvents) {
     editUndoAction->setEnabled(!!(CURRENT_VIEW->getDoc()->undoCount()));
     editRedoAction->setEnabled(!!(CURRENT_VIEW->getDoc()->redoCount()));
     accel->setItemEnabled(0,!!(CURRENT_VIEW->getDoc()->undoCount()));
@@ -5757,7 +5758,7 @@ void MainForm::current_view_undoChanged()
 
 void MainForm::current_view_selectionChanged()
 {
-  if (CURRENT_VIEW) {
+  if (CURRENT_VIEW && !disableViewEvents) {
     editClearAction->setEnabled(CURRENT_VIEW->getDoc()->hasSelection());
     editCutAction->setEnabled(CURRENT_VIEW->getDoc()->hasSelection());
     editCopyAction->setEnabled(CURRENT_VIEW->getDoc()->hasSelection());
@@ -6004,6 +6005,7 @@ void MainForm::KDirWatch_dirty(const QString &fileName)
             static_cast<ListViewFile *>(item)->kateView->getDoc()->setModified(FALSE);
             static_cast<ListViewFile *>(item)->kateView->getDoc()->clearUndo();
             static_cast<ListViewFile *>(item)->kateView->getDoc()->clearRedo();
+            updateRightStatusLabel();
           } else {
             static_cast<ListViewFile *>(item)->textBuffer=fileText;
           }

+ 0 - 1
ktigcc/parsing.cpp

@@ -23,7 +23,6 @@
 
 #include "parsing.h"
 #include "ktigcc.h"
-#include "mainform.h"
 #include <qstring.h>
 #include <qstringlist.h>
 #include <qregexp.h>

+ 14 - 6
ktigcc/srcfilewin.ui.h

@@ -97,6 +97,12 @@ enum {TIGCCOpenProjectFileFilter,TIGCCAddFilesFilter};
 #define LOAD_ICON(name) (QIconSet(KGlobal::iconLoader()->loadIcon((name),KIcon::Small),KGlobal::iconLoader()->loadIcon((name),KIcon::MainToolbar)))
 #define SYSICON(sysname,name) (preferences.useSystemIcons?KGlobal::iconLoader()->loadIcon((sysname),KIcon::Small):QPixmap::fromMimeSource((name)))
 
+#define SET_TEXT_SAFE(doc,text) do { \
+    disableViewEvents=TRUE; \
+    (doc)->setText((text)); \
+    disableViewEvents=FALSE; \
+  } while(0)
+
 // For some reason, this flag is not in the public ConfigFlags enum.
 #define CF_REMOVE_TRAILING_DYN 0x4000000
 
@@ -396,7 +402,7 @@ void *SourceFileWindow::createView(const QString &fileName, const QString &fileT
   connect(newView->getDoc(),SIGNAL(charactersInteractivelyInserted(int,int,const QString&)),this,SLOT(current_view_charactersInteractivelyInserted(int,int,const QString&)));
   newView->installPopup(THIS->te_popup);
   // Set text.
-  newView->getDoc()->setText(fileText);
+  SET_TEXT_SAFE(newView->getDoc(),fileText);
   newView->getDoc()->setModified(FALSE);
   newView->getDoc()->clearUndo();
   newView->getDoc()->clearRedo();
@@ -476,7 +482,7 @@ void SourceFileWindow::fileSaveAs()
       CURRENT_VIEW->getDoc()->setModified(FALSE);
       if (CURRENT_VIEW->getDoc()->openStream("text/plain",saveFileName))
         CURRENT_VIEW->getDoc()->closeStream();
-      CURRENT_VIEW->getDoc()->setText(fileText);
+      SET_TEXT_SAFE(CURRENT_VIEW->getDoc(),fileText);
       CURRENT_VIEW->getDoc()->clearUndo();
       CURRENT_VIEW->getDoc()->clearRedo();
       CURRENT_VIEW->getDoc()->setHlMode(hlMode);
@@ -1112,7 +1118,7 @@ void SourceFileWindow::updateRightStatusLabel()
 
 void SourceFileWindow::current_view_cursorPositionChanged()
 {
-  if (CURRENT_VIEW) {
+  if (CURRENT_VIEW && !disableViewEvents) {
     unsigned int line, col;
     CURRENT_VIEW->cursorPositionReal(&line,&col);
     THIS->rowStatusLabel->setText(QString("%1").arg(line+1));
@@ -1122,6 +1128,7 @@ void SourceFileWindow::current_view_cursorPositionChanged()
 
 void SourceFileWindow::current_view_textChanged()
 {
+  if (disableViewEvents) return;
   if (CURRENT_VIEW) {
     THIS->charsStatusLabel->setText(QString("%1 Characters").arg(CURRENT_VIEW->getDoc()->text().length()));
     if (preferences.deleteOverwrittenErrors) MainForm::deleteOverwrittenErrorsIn(THIS);
@@ -1131,7 +1138,7 @@ void SourceFileWindow::current_view_textChanged()
 
 void SourceFileWindow::current_view_undoChanged()
 {
-  if (CURRENT_VIEW) {
+  if (CURRENT_VIEW && !disableViewEvents) {
     editUndoAction->setEnabled(!!(CURRENT_VIEW->getDoc()->undoCount()));
     editRedoAction->setEnabled(!!(CURRENT_VIEW->getDoc()->redoCount()));
     THIS->accel->setItemEnabled(0,!!(CURRENT_VIEW->getDoc()->undoCount()));
@@ -1141,7 +1148,7 @@ void SourceFileWindow::current_view_undoChanged()
 
 void SourceFileWindow::current_view_selectionChanged()
 {
-  if (CURRENT_VIEW) {
+  if (CURRENT_VIEW && !disableViewEvents) {
     editClearAction->setEnabled(CURRENT_VIEW->getDoc()->hasSelection());
     editCutAction->setEnabled(CURRENT_VIEW->getDoc()->hasSelection());
     editCopyAction->setEnabled(CURRENT_VIEW->getDoc()->hasSelection());
@@ -1228,10 +1235,11 @@ void SourceFileWindow::KDirWatch_dirty(const QString &fileName)
         KMessageBox::error(this,QString("Can't open \'%1\'").arg(fileName));
         return;
       }
-      CURRENT_VIEW->getDoc()->setText(fileText);
+      SET_TEXT_SAFE(CURRENT_VIEW->getDoc(),fileText);
       CURRENT_VIEW->getDoc()->setModified(FALSE);
       CURRENT_VIEW->getDoc()->clearUndo();
       CURRENT_VIEW->getDoc()->clearRedo();
+      updateRightStatusLabel();
     }
   }
 }