KMemAid-improvement

Carsten Niehaus <[email protected]> Thu, 29 Jan 2004 17:57:27 +0100
Newsgroups gmane.comp.tools.memaid.devel
Message-ID <[email protected]>
--Boundary-00=_3tTGAaefSgdLCh1
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi List

I retested KMemAid this week and think it improved since 
my last closer look. I think I have an idea how to improve
the editor without to much work:

As of now you have to type the html-tag like <b>bold word</b>
by yourself. If you apply my patch you will notice a new KPushButton.
Type a Question in the editor and select some letters or words.
Now click on the "bold"-button. 
You will notive that the <b></b>-tags will be inserted at the 
correct place. Note: This will only work for the question and
the bold-button is misplaced. This is only a patch for 
demonstration-purpose. 

I think buttons for all possible tags should be on the right
side of the QTextEdit (which should be KTextEdit by the way)
or in some kind of toolbar.

What do you think about my proposal? I think this way the
editor will be far more usable!

Cheers,
        Carsten

--Boundary-00=_3tTGAaefSgdLCh1
Content-Type: text/x-diff;
  charset="us-ascii";
  name="editor.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="editor.patch"

diff -u kmemaid_diff/kqadialog.cpp kmemaid/kqadialog.cpp
--- kmemaid_diff/kqadialog.cpp	2004-01-28 21:28:41.000000000 +0100
+++ kmemaid/kqadialog.cpp	2004-01-28 22:39:03.000000000 +0100
@@ -19,6 +19,7 @@
 #include <klocale.h>
 #include <qvbox.h>
 #include <kpushbutton.h>
+#include <kdebug.h>
 #include <qlabel.h>
 #include <kmessagebox.h>
 
@@ -30,6 +31,9 @@
 	, element(el)
 	, corr_close(!adding && el)
 {
 	QVBox*	page	= makeVBoxMainWidget();
 
     QHButtonGroup*  qbox    = new QHButtonGroup(i18n("Question"), page, "questiongroup");
@@ -42,6 +46,10 @@
 	{
 		viceversa	= new QCheckBox(i18n("Add Vice Versa too"), page, "viceversa");
 		grades		= new QHButtonGroup(i18n("Grade Select"), page, "GradeSelect");
+		m_boldButton	= new KPushButton(i18n("Bold") , page , "boldButton");
+		connect( m_boldButton , SIGNAL(clicked()), this, SLOT(slotMakeTextBold()) );
 
 		for(int i = 0 ; i < 6 ; ++i)
 		{
@@ -148,3 +156,26 @@
 	question->setFont(q);
 	answer->setFont(a);
 }
+
+void KQADialog::slotMakeTextBold()
+{
+	QString sel = QString::null;
+	
+	if(question->hasSelectedText())
+	{
+		sel = question->selectedText();
+	}
+	else 
+		return;
+	
+	sel.prepend("<b>");
+	sel.append("</b>");
+
+	question->insert(sel);
+}
diff -u kmemaid_diff/kqadialog.h kmemaid/kqadialog.h
--- kmemaid_diff/kqadialog.h	2004-01-28 21:28:41.000000000 +0100
+++ kmemaid/kqadialog.h	2004-01-28 21:44:48.000000000 +0100
@@ -52,6 +52,7 @@
 	QCheckBox*		viceversa;
 	QHButtonGroup*	grades;
 	KPushButton*	fcbutton;
+	KPushButton*	m_boldButton;
 	int				ngrade;
 	elem*			element;
 	bool			corr_close;
@@ -66,6 +67,8 @@
   void findCorrect();
   /** Setting the Font for the input-fields */
   void setFonts(const QFont& q, const QFont& a);
+
+  void slotMakeTextBold();
 //Del by KDevelop: 
 };
 

--Boundary-00=_3tTGAaefSgdLCh1--




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn