From: <da...@us...> - 2006-03-07 15:20:10
|
Revision: 1916 Author: dandfra Date: 2006-03-07 07:19:49 -0800 (Tue, 07 Mar 2006) ViewCVS: http://svn.sourceforge.net/tora/?rev=1916&view=rev Log Message: ----------- fixed some autocompletion bug Modified Paths: -------------- trunk/tora/NEWS trunk/tora/tohighlightedtext.cpp trunk/tora/tohighlightedtext.h Modified: trunk/tora/NEWS =================================================================== --- trunk/tora/NEWS 2006-03-05 19:38:39 UTC (rev 1915) +++ trunk/tora/NEWS 2006-03-07 15:19:49 UTC (rev 1916) @@ -3,6 +3,7 @@ 2006-03-03: Autocompletion second step 2006-03-03: Fixed bug #1437575 2006-03-03: update to version 1.3.22svn the windows client too +2006-03-07: fixed some bug with completion 1.3.21: Modified: trunk/tora/tohighlightedtext.cpp =================================================================== --- trunk/tora/tohighlightedtext.cpp 2006-03-05 19:38:39 UTC (rev 1915) +++ trunk/tora/tohighlightedtext.cpp 2006-03-07 15:19:49 UTC (rev 1916) @@ -282,7 +282,7 @@ #else && e->text()!="\n" #endif - ) || e->key()==Qt::Key_Backspace){ + && e->text()!=" ") || e->key()==Qt::Key_Backspace){ if ( e->key()==Qt::Key_Backspace){ TO_DEBUGOUT("Backspace"); }else{ @@ -290,6 +290,9 @@ } this->editor->keyPressEvent(e); this->editor->autoCompleteFromAPIs(); + }else if (e->text() && e->text().length()>0 && e->text()==" "){ + this->editor->keyPressEvent(e); + this->hide(); }else QListBox::keyPressEvent(e); @@ -318,7 +321,6 @@ debugMarker=markerDefine(Rectangle,8); setMarkerBackgroundColor(Qt::darkGreen,debugMarker); setMarginMarkerMask(1,0); - setAutoCompletionReplaceWord(true); setAutoIndent(true); connect(this,SIGNAL(cursorPositionChanged(int,int)),this,SLOT(setStatusMessage(void ))); complAPI=new QextScintillaAPIs(); @@ -358,7 +360,11 @@ void toHighlightedText::autoCompleteFromAPIs(){ QString partial; QStringList compleList=this->getCompletionList(&partial); - if(!compleList.isEmpty() || popup->isVisible()){ + if(compleList.count()==1 && compleList.first()==partial){ + this->completeWithText(compleList.first()); + if(popup->isVisible()) + popup->hide(); + }else if(!compleList.isEmpty() || popup->isVisible()){ long position, posx, posy; int curCol, curRow; this->getCursorPosition(&curRow,&curCol); @@ -650,26 +656,38 @@ return toReturn; } +void toHighlightedText::completeWithText(QString itemText){ + int curline, curcol, start,end; + getCursorPosition (&curline, &curcol); + QString line = text(curline); + toSQLParse::editorTokenizer tokens(this, curcol, curline); + if (line[curcol-1]!='.'){ + tokens.getToken(false); + start=tokens.offset(); + }else{ + start=curcol; + } + if(line[curcol].isSpace()){ + end=curcol; + }else{ + tokens.getToken(true); + if(tokens.line()!=curline) + end=line.length(); + else + end=tokens.offset(); + } + disconnect(this,SIGNAL(cursorPositionChanged(int,int)),this,SLOT(positionChanged(int,int))); + setSelection(curline,start,curline,end); + this->removeSelectedText(); + this->insert(itemText); + this->setCursorPosition(curline,start+itemText.length()); + connect (this,SIGNAL(cursorPositionChanged(int,int)),this,SLOT(positionChanged(int,int))); +} + + void toHighlightedText::completeFromAPI(QListBoxItem* item){ if(item){ - int curline, curcol, start,end; - getCursorPosition (&curline, &curcol); - QString line = text(curline); - toSQLParse::editorTokenizer tokens(this, curcol, curline); - if (line[curcol-1]!='.'){ - tokens.getToken(false); - start=tokens.offset(); - }else{ - start=curcol; - } - tokens.getToken(true); - end=tokens.offset(); - disconnect(this,SIGNAL(cursorPositionChanged(int,int)),this,SLOT(positionChanged(int,int))); - setSelection(curline,start,curline,end); - this->removeSelectedText(); - this->insert(item->text()); - this->setCursorPosition(curline,start+item->text().length()); - connect (this,SIGNAL(cursorPositionChanged(int,int)),this,SLOT(positionChanged(int,int))); + this->completeWithText(item->text()); } popup->hide(); } Modified: trunk/tora/tohighlightedtext.h =================================================================== --- trunk/tora/tohighlightedtext.h 2006-03-05 19:38:39 UTC (rev 1915) +++ trunk/tora/tohighlightedtext.h 2006-03-07 15:19:49 UTC (rev 1916) @@ -361,6 +361,7 @@ protected: QStringList getCompletionList(QString* partial); + void completeWithText(QString itemText); private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |