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

Fix 4 missed instances of setCursorPositionReal( to setCursorPosition(KTextEditor::Cursor(.
Change variables used during search&replace from unsigned to signed to match new KatePart API. Likewise in findOpenFileAtCursor to match Qt 4 API.
Replace uses of cursorLine and cursorColumnReal with cursorPosition().position(line,col).
Fix comparison of QChar with string literal instead of character literal in findOpenFileAtCursor.


git-svn-id: file:///var/svn/tigccpp/trunk@972 9552661e-59e3-4036-b4f2-dbe53926924f

kevinkofler преди 17 години
родител
ревизия
1e58fdbae1
променени са 3 файла, в които са добавени 62 реда и са изтрити 62 реда
  1. 34 34
      ktigcc/mainform.cpp
  2. 1 1
      ktigcc/srcfile.h
  3. 27 27
      ktigcc/srcfilewin.cpp

+ 34 - 34
ktigcc/mainform.cpp

@@ -184,7 +184,7 @@ enum {TIGCCOpenProjectFileFilter,TIGCCAddFilesFilter};
 
 static Q3ListViewItem *currentListItem;
 static Q3ListViewItem *replaceCurrentDocument;
-static unsigned replaceCurrentLine;
+static int replaceCurrentLine;
 static bool compiling;
 class KReplaceWithSelection : public KReplace {
   public:
@@ -209,10 +209,10 @@ class KReplaceWithSelection : public KReplace {
         m_haveSelection=FALSE;
       return m_haveSelection;
     }
-    unsigned selStartLine() {return m_selStartLine;}
-    unsigned selStartCol() {return m_selStartCol;}
-    unsigned selEndLine() {return m_selEndLine;}
-    unsigned selEndCol() {return m_selEndCol;}
+    int selStartLine() {return m_selStartLine;}
+    int selStartCol() {return m_selStartCol;}
+    int selEndLine() {return m_selEndLine;}
+    int selEndCol() {return m_selEndCol;}
     // Override to ask for restarting when replacing in a selection.
     bool shouldRestart(bool forceAsking=FALSE, bool showNumMatches=TRUE)
     {
@@ -229,17 +229,17 @@ class KReplaceWithSelection : public KReplace {
         m_haveSelection=FALSE;
       if (!m_haveSelection) return TRUE;
       if (replaceCurrentLine==m_selStartLine && replaceCurrentLine==m_selEndLine)
-        return ((unsigned)index>=m_selStartCol)&&((unsigned)index+(unsigned)matchedlength<=m_selEndCol);
+        return (index>=m_selStartCol)&&(index+matchedlength<=m_selEndCol);
       else if (replaceCurrentLine==m_selStartLine)
-        return ((unsigned)index>=m_selStartCol);
+        return (index>=m_selStartCol);
       else if (replaceCurrentLine==m_selEndLine)
-        return ((unsigned)index+(unsigned)matchedlength<=m_selEndCol);
+        return (index+matchedlength<=m_selEndCol);
       else
         return (replaceCurrentLine>=m_selStartLine&&replaceCurrentLine<=m_selEndLine);
     }
   private:
     bool m_haveSelection;
-    unsigned m_selStartLine, m_selStartCol, m_selEndLine, m_selEndCol;
+    int m_selStartLine, m_selStartCol, m_selEndLine, m_selEndCol;
 };
 static KReplaceWithSelection *kreplace;
 
@@ -426,7 +426,7 @@ static Q3Accel *accel, *fileTreeAccel;
 static KFindDialog *kfinddialog;
 QStringList findHistory, replacementHistory;
 static Q3ListViewItem *findCurrentDocument;
-static unsigned findCurrentLine;
+static int findCurrentLine;
 Q3PtrList<SourceFile> sourceFiles;
 static Q3PopupMenu *findFunctionsPopup;
 bool have_usb;
@@ -919,10 +919,11 @@ void MainForm::deleteOverwrittenErrorsIn(void *srcFile)
   while ((errorItem=static_cast<ErrorListItem *>(lvit.current()))) {
     ++lvit;
     if (errorItem->srcFile==sourceFile && errorItem->cursor) {
-      unsigned line,col;
+      int line,col;
       errorItem->cursor->position(&line,&col);
-      if (sourceFile->kateView->cursorLine()==line
-          && sourceFile->kateView->cursorColumnReal()==col)
+      int curline,curcol;
+      sourceFile->kateView->cursorPosition().position(curline,curcol);
+      if (curline==line && curcol==col)
         delete errorItem;
     }
   }
@@ -2773,8 +2774,7 @@ void MainForm::findFind_next()
           findCurrentCol=CURRENT_VIEW->document()->selEndCol();
         }
       } else {
-        findCurrentLine=CURRENT_VIEW->cursorLine();
-        findCurrentCol=CURRENT_VIEW->cursorColumnReal();
+        CURRENT_VIEW->cursorPosition().position(findCurrentLine,findCurrentCol);
       }
     } else {
       findCurrentLine=findBackwards?(CURRENT_VIEW->document()->lines()-1):0;
@@ -2790,7 +2790,7 @@ void MainForm::findFind_next()
   // We never have a currBuffer here, the current list item is always either
   // non-editable or instantiated.
   QStringList currBuffer;
-  unsigned currNumLines=0;
+  int currNumLines=0;
   if (CURRENT_VIEW) currNumLines=CURRENT_VIEW->document()->lines();
   do {
     if (kfind->needData()) {
@@ -2988,8 +2988,7 @@ void MainForm::findReplace()
           replaceCurrentCol=CURRENT_VIEW->document()->selEndCol();
         }
       } else {
-        replaceCurrentLine=CURRENT_VIEW->cursorLine();
-        replaceCurrentCol=CURRENT_VIEW->cursorColumnReal();
+        CURRENT_VIEW->cursorPosition().position(replaceCurrentLine,replaceCurrentCol);
         // Don't prompt for restarting if we actually searched the entire document.
         if (findBackwards?(replaceCurrentLine==(CURRENT_VIEW->document()->lines()-1)
                            && replaceCurrentCol==(CURRENT_VIEW->document()->lineLength(replaceCurrentLine)))
@@ -3041,8 +3040,7 @@ void MainForm::findReplace_next(bool firstTime)
           replaceCurrentCol=CURRENT_VIEW->document()->selEndCol();
         }
       } else {
-        replaceCurrentLine=CURRENT_VIEW->cursorLine();
-        replaceCurrentCol=CURRENT_VIEW->cursorColumnReal();
+        CURRENT_VIEW->cursorPosition().position(replaceCurrentLine,replaceCurrentCol);
       }
       kreplace->setData(CURRENT_VIEW->document()->line(replaceCurrentLine),replaceCurrentCol);
     } else replaceCurrentLine=0;
@@ -3055,7 +3053,7 @@ void MainForm::findReplace_next(bool firstTime)
   // We never have a currBuffer here, the current list item is always either
   // non-editable or instantiated.
   QStringList currBuffer;
-  unsigned currNumLines=0;
+  int currNumLines=0;
   if (CURRENT_VIEW) currNumLines=CURRENT_VIEW->document()->lines();
   do {
     if (kreplace->needData()) {
@@ -3217,7 +3215,7 @@ void MainForm::findReplace_replace(const QString &text, int replacementIndex, in
   bool haveSelection=kreplace->haveSelection();
   // The initializations are redundant, but g++ doesn't understand this, and the
   // self-initialization trick doesn't work either (-Wno-init-self is ignored).
-  unsigned selStartLine=0, selStartCol=0, selEndLine=0, selEndCol=0;
+  int selStartLine=0, selStartCol=0, selEndLine=0, selEndCol=0;
   if (haveSelection) {
     selStartLine=kreplace->selStartLine();
     selStartCol=kreplace->selStartCol();
@@ -3228,8 +3226,9 @@ void MainForm::findReplace_replace(const QString &text, int replacementIndex, in
   CURRENT_VIEW->document()->insertText(KTextEditor::Cursor(replaceCurrentLine,replacementIndex),
                                        text.mid(replacementIndex,replacedLength));
   // We can't put the cursor back now because this breaks editBegin/editEnd.
-  bool updateCursor=(CURRENT_VIEW->cursorLine()==replaceCurrentLine
-                     && CURRENT_VIEW->cursorColumnReal()==(unsigned)replacementIndex+(unsigned)replacedLength);
+  int line,col;
+  CURRENT_VIEW->cursorPosition().position(line,col);
+  bool updateCursor=(line==replaceCurrentLine && col==replacementIndex+replacedLength);
   CURRENT_VIEW->document()->removeText(KTextEditor::Range(replaceCurrentLine,replacementIndex+replacedLength,
                                        replaceCurrentLine,replacementIndex+replacedLength+matchedLength));
   CURRENT_VIEW->document()->endEditing();
@@ -3311,8 +3310,8 @@ void MainForm::findFunctions_prototypeButton_clicked()
 {
   int index=functionDialog->functionListBox->currentItem();
   if (index>=0 && sourceFileFunctions[index].prototypeLine>=0) {
-    CURRENT_VIEW->setCursorPositionReal(
-      sourceFileFunctions[index].prototypeLine,0);
+    CURRENT_VIEW->setCursorPosition(KTextEditor::Cursor(
+      sourceFileFunctions[index].prototypeLine,0));
     functionDialog->accept();
   }
 }
@@ -3321,8 +3320,8 @@ void MainForm::findFunctions_implementationButton_clicked()
 {
   int index=functionDialog->functionListBox->currentItem();
   if (index>=0 && sourceFileFunctions[index].implementationLine>=0) {
-    CURRENT_VIEW->setCursorPositionReal(
-      sourceFileFunctions[index].implementationLine,0);
+    CURRENT_VIEW->setCursorPosition(KTextEditor::Cursor(
+      sourceFileFunctions[index].implementationLine,0));
     functionDialog->accept();
   }
 }
@@ -3407,19 +3406,19 @@ void MainForm::findOpenFileAtCursor()
     int line,col,i;
     CURRENT_VIEW->cursorPosition().position(line,col);
     QString textLine=CURRENT_VIEW->document()->line(line);
-    unsigned l=textLine.length();
+    int l=textLine.length();
     bool quotesInLine=textLine.contains("\"");
     QString fileName;
     for (i=col;i>=0;i--) {
       QChar c=textLine[i];
-      if (!((quotesInLine && c==' ') || (c>='A' && c<="Z") || (c>='a' && c<='z')
+      if (!((quotesInLine && c==' ') || (c>='A' && c<='Z') || (c>='a' && c<='z')
             || (c>='0' && c<='9') || QString("_-./\\:").contains(c)))
         break;
       fileName.prepend(c);
     }
     for (i=col+1;i<l;i++) {
       QChar c=textLine[i];
-      if (!((quotesInLine && c==' ') || (c>='A' && c<="Z") || (c>='a' && c<='z')
+      if (!((quotesInLine && c==' ') || (c>='A' && c<='Z') || (c>='a' && c<='z')
             || (c>='0' && c<='9') || QString("_-./\\:").contains(c)))
         break;
       fileName.append(c);
@@ -6001,10 +6000,11 @@ void MainForm::current_view_textChanged()
       while ((errorItem=static_cast<ErrorListItem *>(lvit.current()))) {
         ++lvit;
         if (errorItem->lvFile==lvFile && errorItem->cursor) {
-          unsigned line,col;
+          int line,col;
           errorItem->cursor->position(&line,&col);
-          if (lvFile->kateView->cursorLine()==line
-              && lvFile->kateView->cursorColumnReal()==col)
+          int curline,curcol;
+          lvFile->kateView->cursorPosition().position(curline,curcol);
+          if (curline==line && curcol==col)
             delete errorItem;
         }
       }

+ 1 - 1
ktigcc/srcfile.h

@@ -72,7 +72,7 @@ struct SourceFile : public SourceFileWindow {
   Q3PopupMenu *te_popup;
   Q3Accel *accel;
   KFindDialog *kfinddialog;
-  unsigned findCurrentLine;
+  int findCurrentLine;
   KDirWatch *dirWatch;
   Q3PopupMenu *findFunctionsPopup;
   SourceFileFunctions sourceFileFunctions;

+ 27 - 27
ktigcc/srcfilewin.cpp

@@ -125,13 +125,13 @@ class KReplaceWithSelectionS : public KReplace {
       m_selEndLine=selEndLine;
       m_selEndCol=selEndCol;
     }
-    unsigned replaceCurrentLine;
+    int replaceCurrentLine;
     void invalidateSelection() {m_haveSelection=FALSE;}
     bool haveSelection() {return m_haveSelection;}
-    unsigned selStartLine() {return m_selStartLine;}
-    unsigned selStartCol() {return m_selStartCol;}
-    unsigned selEndLine() {return m_selEndLine;}
-    unsigned selEndCol() {return m_selEndCol;}
+    int selStartLine() {return m_selStartLine;}
+    int selStartCol() {return m_selStartCol;}
+    int selEndLine() {return m_selEndLine;}
+    int selEndCol() {return m_selEndCol;}
     // Override to ask for restarting when replacing in a selection.
     bool shouldRestart(bool forceAsking=FALSE, bool showNumMatches=TRUE)
     {
@@ -143,17 +143,17 @@ class KReplaceWithSelectionS : public KReplace {
       if (!KReplace::validateMatch(text,index,matchedlength)) return FALSE;
       if (!m_haveSelection) return TRUE;
       if (replaceCurrentLine==m_selStartLine && replaceCurrentLine==m_selEndLine)
-        return ((unsigned)index>=m_selStartCol)&&((unsigned)index+(unsigned)matchedlength<=m_selEndCol);
+        return (index>=m_selStartCol)&&(index+matchedlength<=m_selEndCol);
       else if (replaceCurrentLine==m_selStartLine)
-        return ((unsigned)index>=m_selStartCol);
+        return (index>=m_selStartCol);
       else if (replaceCurrentLine==m_selEndLine)
-        return ((unsigned)index+(unsigned)matchedlength<=m_selEndCol);
+        return (index+matchedlength<=m_selEndCol);
       else
         return (replaceCurrentLine>=m_selStartLine&&replaceCurrentLine<=m_selEndLine);
     }
   private:
     bool m_haveSelection;
-    unsigned m_selStartLine, m_selStartCol, m_selEndLine, m_selEndCol;
+    int m_selStartLine, m_selStartCol, m_selEndLine, m_selEndCol;
 };
 
 void SourceFileWindow::initBase()
@@ -743,8 +743,7 @@ void SourceFileWindow::findFind_next()
         findCurrentCol=CURRENT_VIEW->document()->selEndCol();
       }
     } else {
-      THIS->findCurrentLine=CURRENT_VIEW->cursorLine();
-      findCurrentCol=CURRENT_VIEW->cursorColumnReal();
+      CURRENT_VIEW->cursorPosition().position(THIS->findCurrentLine,findCurrentCol);
     }
   } else {
     THIS->findCurrentLine=findBackwards?(CURRENT_VIEW->document()->lines()-1):0;
@@ -756,7 +755,7 @@ void SourceFileWindow::findFind_next()
   // Now find the next occurrence.
   KFind::Result result;
   KTextEditor::View *currView=CURRENT_VIEW;
-  unsigned currNumLines=CURRENT_VIEW->document()->lines();
+  int currNumLines=CURRENT_VIEW->document()->lines();
   do {
     if (kfind->needData()) {
       if (findBackwards?!THIS->findCurrentLine:(THIS->findCurrentLine>=currNumLines)) {
@@ -863,8 +862,7 @@ void SourceFileWindow::findReplace()
           replaceCurrentCol=CURRENT_VIEW->document()->selEndCol();
         }
       } else {
-        THIS->kreplace->replaceCurrentLine=CURRENT_VIEW->cursorLine();
-        replaceCurrentCol=CURRENT_VIEW->cursorColumnReal();
+        CURRENT_VIEW->cursorPosition().position(THIS->kreplace->replaceCurrentLine,replaceCurrentCol);
         // Don't prompt for restarting if we actually searched the entire document.
         if (findBackwards?(THIS->kreplace->replaceCurrentLine==(CURRENT_VIEW->document()->lines()-1)
                            && replaceCurrentCol==(CURRENT_VIEW->document()->lineLength(THIS->kreplace->replaceCurrentLine)))
@@ -909,8 +907,8 @@ void SourceFileWindow::findReplace_next(bool firstTime)
         replaceCurrentCol=CURRENT_VIEW->document()->selEndCol();
       }
     } else {
-      THIS->kreplace->replaceCurrentLine=CURRENT_VIEW->cursorLine();
-      replaceCurrentCol=CURRENT_VIEW->cursorColumnReal();
+      CURRENT_VIEW->cursorPosition().position(THIS->kreplace->replaceCurrentLine,
+                                              replaceCurrentCol);
     }
     THIS->kreplace->setData(CURRENT_VIEW->document()->line(THIS->kreplace->replaceCurrentLine),replaceCurrentCol);
   }
@@ -919,7 +917,7 @@ void SourceFileWindow::findReplace_next(bool firstTime)
   // Now find the next occurrence.
   KFind::Result result;
   KTextEditor::View *currView=CURRENT_VIEW;
-  unsigned currNumLines=0;
+  int currNumLines=0;
   if (CURRENT_VIEW) currNumLines=CURRENT_VIEW->document()->lines();
   do {
     if (THIS->kreplace->needData()) {
@@ -962,7 +960,7 @@ void SourceFileWindow::findReplace_replace(const QString &text, int replacementI
   bool haveSelection=THIS->kreplace->haveSelection();
   // The initializations are redundant, but g++ doesn't understand this, and the
   // self-initialization trick doesn't work either (-Wno-init-self is ignored).
-  unsigned selStartLine=0, selStartCol=0, selEndLine=0, selEndCol=0;
+  int selStartLine=0, selStartCol=0, selEndLine=0, selEndCol=0;
   if (haveSelection) {
     selStartLine=THIS->kreplace->selStartLine();
     selStartCol=THIS->kreplace->selStartCol();
@@ -973,8 +971,10 @@ void SourceFileWindow::findReplace_replace(const QString &text, int replacementI
   CURRENT_VIEW->document()->insertText(KTextEditor::Cursor(THIS->kreplace->replaceCurrentLine,replacementIndex),
                                        text.mid(replacementIndex,replacedLength));
   // We can't put the cursor back now because this breaks editBegin/editEnd.
-  bool updateCursor=(CURRENT_VIEW->cursorLine()==THIS->kreplace->replaceCurrentLine
-                     && CURRENT_VIEW->cursorColumnReal()==(unsigned)replacementIndex+(unsigned)replacedLength);
+  int line,col;
+  CURRENT_VIEW->cursorPosition().position(line,col);
+  bool updateCursor=(line==THIS->kreplace->replaceCurrentLine
+                     && col==replacementIndex+replacedLength);
   CURRENT_VIEW->document()->removeText(KTextEditor::Range(THIS->kreplace->replaceCurrentLine,replacementIndex+replacedLength,
                                        THIS->kreplace->replaceCurrentLine,replacementIndex+replacedLength+matchedLength));
   CURRENT_VIEW->document()->endEditing();
@@ -1050,8 +1050,8 @@ void SourceFileWindow::findFunctions_prototypeButton_clicked()
 {
   int index=THIS->functionDialog->functionListBox->currentItem();
   if (index>=0 && THIS->sourceFileFunctions[index].prototypeLine>=0) {
-    CURRENT_VIEW->setCursorPositionReal(
-      THIS->sourceFileFunctions[index].prototypeLine,0);
+    CURRENT_VIEW->setCursorPosition(KTextEditor::Cursor(
+      THIS->sourceFileFunctions[index].prototypeLine,0));
     THIS->functionDialog->accept();
   }
 }
@@ -1060,8 +1060,8 @@ void SourceFileWindow::findFunctions_implementationButton_clicked()
 {
   int index=THIS->functionDialog->functionListBox->currentItem();
   if (index>=0 && THIS->sourceFileFunctions[index].implementationLine>=0) {
-    CURRENT_VIEW->setCursorPositionReal(
-      THIS->sourceFileFunctions[index].implementationLine,0);
+    CURRENT_VIEW->setCursorPosition(KTextEditor::Cursor(
+      THIS->sourceFileFunctions[index].implementationLine,0));
     THIS->functionDialog->accept();
   }
 }
@@ -1100,19 +1100,19 @@ void SourceFileWindow::findOpenFileAtCursor()
   int line,col,i;
   CURRENT_VIEW->cursorPosition().position(line,col);
   QString textLine=CURRENT_VIEW->document()->line(line);
-  unsigned l=textLine.length();
+  int l=textLine.length();
   bool quotesInLine=textLine.contains("\"");
   QString fileName;
   for (i=col;i>=0;i--) {
     QChar c=textLine[i];
-    if (!((quotesInLine && c==' ') || (c>='A' && c<="Z") || (c>='a' && c<='z')
+    if (!((quotesInLine && c==' ') || (c>='A' && c<='Z') || (c>='a' && c<='z')
           || (c>='0' && c<='9') || QString("_-./\\:").contains(c)))
       break;
     fileName.prepend(c);
   }
   for (i=col+1;i<l;i++) {
     QChar c=textLine[i];
-    if (!((quotesInLine && c==' ') || (c>='A' && c<="Z") || (c>='a' && c<='z')
+    if (!((quotesInLine && c==' ') || (c>='A' && c<='Z') || (c>='a' && c<='z')
           || (c>='0' && c<='9') || QString("_-./\\:").contains(c)))
       break;
     fileName.append(c);