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

List:       kde-commits
Subject:    KDE/kdeedu/kalgebra
From:       Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date:       2010-09-29 2:22:33
Message-ID: 20100929022233.B2C23AC88E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1180813 by apol:

Remove dead code, try to use information provided by Qt instead of playing with \
QFontMetrics to place things.


 M  +0 -1      analitzagui/algebrahighlighter.h  
 M  +7 -13     src/expressionedit.cpp  
 M  +1 -0      src/expressionedit.h  


--- trunk/KDE/kdeedu/kalgebra/analitzagui/algebrahighlighter.h #1180812:1180813
@@ -34,7 +34,6 @@
 	public:
 		/** Defines the format status that could be used. */
 		typedef enum {
-			Disabled,	/**< No highlighting. */
 			Expression,	/**< String expression format. */
 			MathML,		/**< MathML format. */
 			Autodetect	/**< Try to guess which format is being used. */
--- trunk/KDE/kdeedu/kalgebra/src/expressionedit.cpp #1180812:1180813
@@ -101,7 +101,8 @@
 // 	connect(m_completer, SIGNAL(activated(const QModelIndex&)), this, \
SLOT(completed(const QModelIndex&)));  
 	setMode(inimode);
-	this->setFixedHeight(QFontMetrics(currentCharFormat().font()).height()+15);
+	m_lineHeight = QFontMetrics(currentCharFormat().font()).height();
+	setFixedHeight(m_lineHeight+15);
 }
 
 ExpressionEdit::~ExpressionEdit()
@@ -230,6 +231,8 @@
 				tc.setPosition(m_ans.length());
 				this->setTextCursor(tc);
 			}
+			QPlainTextEdit::keyPressEvent(e);
+			break;
 		case Qt::Key_Alt:
 			QPlainTextEdit::keyPressEvent(e);
 			break;
@@ -238,10 +241,6 @@
 			m_history.last() = this->toPlainText();
 			QString last = lastWord(textCursor().selectionStart());
 			if(!last.isEmpty()) {
-				QFontMetrics fm(font());
-				int curPos = this->textCursor().position();
-				int pixelsOffset = fm.width(toPlainText(), curPos);
-				QPoint pos(pixelsOffset+10, height());
 				m_completer->setCompletionPrefix(last);
 				m_completer->complete();
 			} else {
@@ -263,7 +262,7 @@
 	}
 	
 	int lineCount=toPlainText().count('\n')+1;
-	setFixedHeight(QFontMetrics(currentCharFormat().font()).height()*lineCount+15);
+	setFixedHeight(m_lineHeight*lineCount+15);
 	setCorrect(m_highlight->isCorrect());
 }
 
@@ -388,12 +387,7 @@
 
 void ExpressionEdit::helper(const QString& msg)
 {
-	QFontMetrics fm( font() );
-	int curPos = 0;
-	curPos=this->textCursor().position();
-	int pixelsOffset = fm.width( toPlainText(), curPos );
-// 	pixelsOffset -= contentsX();
-	QPoint pos = mapToGlobal( QPoint( pixelsOffset, height() ) );
+	QPoint pos = mapToGlobal( QPoint( cursorRect().left(), height() ) );
 	
 	if(msg.isEmpty()) {
 		if(!m_hideHelpTip->isActive())
@@ -425,7 +419,7 @@
 
 void ExpressionEdit::setCorrect(bool correct)
 {
-	QPalette p=qApp->palette();
+	QPalette p=palette();
 	QColor c;
 	m_correct=correct;
 	
--- trunk/KDE/kdeedu/kalgebra/src/expressionedit.h #1180812:1180813
@@ -164,6 +164,7 @@
 		
 		QStringList m_examples;
 		QTimer* m_hideHelpTip;
+		int m_lineHeight;
 };
 
 #endif


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

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