[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Tue Jan 11 05:23:47 CET 2005


CVS commit by harris: 

Fixes to User Log tab of Details dialog (BR #96670):

(1) Removed Save button.  Instead, I subclassed KTextEdit to emit a 
signal when it loses input focus, and this signal is connected to the 
saveLogData() slot.

(2) The user log text was being saved to disk, but was not being written 
to the SkyObject's userLog member variable, so newly entered log text 
was not visible unless KStars was restarted.

BUG: 96670
CCMAIL: kstars-devel at kde.org


  M +11 -10    detaildialog.cpp   1.47
  M +19 -5     detaildialog.h   1.15
  M +4 -1      skyobject.cpp   1.49


--- kdeedu/kstars/kstars/detaildialog.cpp  #1.46:1.47
@@ -41,4 +41,13 @@
 #include "ksmoon.h"
 
+LogEdit::LogEdit( QWidget *parent, const char *name ) : KTextEdit( parent, name ) 
+{
+}
+
+void LogEdit::focusOutEvent( QFocusEvent *e ) {
+        emit focusOut();
+        QWidget::focusOutEvent(e);
+}
+
 DetailDialog::DetailDialog(SkyObject *o, const KStarsDateTime &ut, GeoLocation *geo, 
                 QWidget *parent, const char *name ) : 
@@ -61,5 +70,5 @@ void DetailDialog::createLogTab()
         logTab = addPage(i18n("Log"));
 
-        userLog = new QTextEdit(logTab, "userLog");
+        userLog = new LogEdit(logTab, "userLog");
 //      userLog->setTextFormat(Qt::RichText);
 
@@ -69,16 +78,8 @@ void DetailDialog::createLogTab()
                 userLog->setText(selectedObject->userLog);
 
-        saveLog = new QPushButton(i18n("Save"), logTab, "Save");
-
-        LOGbuttonSpacer = new QSpacerItem(40, 10, QSizePolicy::Expanding, QSizePolicy::Minimum);
-        LOGbuttonLayout = new QHBoxLayout(5, "buttonlayout");
-        LOGbuttonLayout->addWidget(saveLog);
-        LOGbuttonLayout->addItem(LOGbuttonSpacer);
-
         logLayout = new QVBoxLayout(logTab, 6, 6, "logLayout");
         logLayout->addWidget(userLog);
-        logLayout->addLayout(LOGbuttonLayout);
 
-        connect(saveLog, SIGNAL(clicked()), this, SLOT(saveLogData()));
+        connect( userLog, SIGNAL( focusOut() ), this, SLOT( saveLogData() ) );
 }
 

--- kdeedu/kstars/kstars/detaildialog.h  #1.14:1.15
@@ -23,4 +23,5 @@
 #include <qptrlist.h>
 #include <kdialogbase.h>
+#include <ktextedit.h>
 
 #include "skyobject.h"
@@ -34,5 +35,4 @@ class QLineEdit;
 class QString;
 class QStringList;
-class QTextEdit;
 class QListView;
 class KStars;
@@ -46,4 +46,21 @@ struct ADVTreeData
 };
 
+/**@class LogEdit is a simple derivative of KTextEdit, that just adds a 
+        *focusOut() signal, emitted when the edit loses focus.
+        *@author Jason Harris
+        *@version 1.0
+        */
+class LogEdit : public KTextEdit {
+        Q_OBJECT
+public:
+        LogEdit( QWidget *parent=0, const char *name=0 );
+        ~LogEdit() {}
+        
+signals:
+        void focusOut();
+        
+protected:
+        void focusOutEvent( QFocusEvent *e );
+};
 
 /**@class DetailDialog is a window showing detailed information for a selected object.
@@ -198,9 +215,6 @@ private:
         // Log Tab
         QFrame *logTab;
-        QTextEdit *userLog;
-        QPushButton *saveLog;
+        LogEdit *userLog;
         QVBoxLayout *logLayout;
-        QSpacerItem *LOGbuttonSpacer;
-        QHBoxLayout *LOGbuttonLayout;
 
         class NameBox : public QGroupBox {

--- kdeedu/kstars/kstars/skyobject.cpp  #1.48:1.49
@@ -406,4 +406,7 @@ void SkyObject::saveUserLog( const QStri
   outstream << logs;
         
+        //Set the log text in the object itself.
+        userLog = newLog;
+        
   file.close();
 }




More information about the Kstars-devel mailing list