Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed quickInsert

  • Loading branch information...
commit 580905b96eab437c6ce2834dcb760fcf249d3eec 1 parent bb6ef4b
xept90 authored
View
6 CodeRoom.pro.user
@@ -15,7 +15,7 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
- <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">1</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
<value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
<valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
<valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
@@ -46,7 +46,7 @@
<value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Debug</value>
<value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
- <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">D:/Documents and Settings/Nils/My Documents/Development/CodeRoom-build-desktop</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">C:/Documents and Settings/Nils/Dokumenter/Development/Programmering/C++/QT/CodeRoom-build-desktop</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">2</value>
<value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
@@ -97,7 +97,7 @@
<valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
<value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">true</value>
- <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString">D:\Documents and Settings\Nils\My Documents\Development\CodeRoom</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString">C:\Documents and Settings\Nils\Dokumenter\Development\Programmering\C++\QT\CodeRoom-build-desktop</value>
</valuemap>
<value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
</valuemap>
View
BIN  icon/Thumbs.db
Binary file not shown
View
33 textedit.cpp
@@ -124,6 +124,7 @@ void TextEdit::keyPressEvent(QKeyEvent * event){
void TextEdit::quickInsert(QTextCursor & updateCursor, QString tmp, QString sep){
// Needed variables
QString sel,lin;
+ QString data = this->toPlainText();
int i,j,k,start;
// Get selection
sel = updateCursor.selectedText();
@@ -131,16 +132,36 @@ void TextEdit::quickInsert(QTextCursor & updateCursor, QString tmp, QString sep)
// Start position
start = updateCursor.position();
// Get line
- while (!updateCursor.atBlockStart()) updateCursor.movePosition(QTextCursor::Left);
- i = updateCursor.position();
- while (!updateCursor.atBlockEnd()) updateCursor.movePosition(QTextCursor::Right);
- j = updateCursor.position();
- lin = this->toPlainText().mid(i,j-i+1);
+ i = updateCursor.position()-1;
+ j = i;
+ while (data.mid(i,1) != "\n" && i != -1) i--;
+ i++;
+ while (data.mid(j,1) != "\n" && j <= data.size()) j++;
+ j--;
+ /*
+ while (this->toPlainText().mid(updateCursor.position(),1) != "\n" && !updateCursor.atStart()) updateCursor.movePosition(QTextCursor::Left);
+ if (updateCursor.atStart()) i = updateCursor.position();
+ else i = updateCursor.position()+1;
+ updateCursor.movePosition(QTextCursor::Right);
+ while (this->toPlainText().mid(updateCursor.position(),1) != "\n" && !updateCursor.atEnd()) updateCursor.movePosition(QTextCursor::Right);
+ if (updateCursor.atEnd()) j = updateCursor.position();
+ else j = updateCursor.position()-1;
+ */
+ lin = data.mid(i,j-i+1);
// Replace parameters and fix space
tmp.replace(sep,"\x99");
tmp.replace("\x99\x99\x99","\x92").replace("\x99\x99","\x91").replace("\x99","\x90");
tmp.replace(" ","").replace("\\\\s","\x98").replace("\\s"," ").replace("\x98","\\s");
- while (!updateCursor.atBlockStart() && tmp.indexOf("\x92") != -1) updateCursor.deletePreviousChar();
+ // Delete line if lin exists
+ if (tmp.indexOf("\x92")){
+ j++;
+ updateCursor.setPosition(j);
+ }
+ while (j != i && tmp.indexOf("\x92") != -1) {
+ updateCursor.deletePreviousChar();
+ j--;
+ }
+ if (tmp.indexOf("\x92") != -1) start = updateCursor.position();
tmp.replace("\x92",lin).replace("\x91",sel);
k = tmp.size()-tmp.indexOf("\x90")-1;
tmp.replace("\x90","");

0 comments on commit 580905b

Please sign in to comment.
Something went wrong with that request. Please try again.