[Kstars-devel] branches/kstars/summer/kstars/kstars/comast
Prakash Mohan
prak902000 at gmail.com
Mon Jul 27 05:55:46 CEST 2009
SVN commit 1002827 by prakash:
Adding documentation to the observerAdd class. Using the warningOverwrite() call instead of the passing all parameters to the KMessageBox all over again.
Adding comments in the observeradd.cpp file. Pop up an error message when the file cannot be opened for saving the list of observers.
CCMAIL:kstars-devel at kde.org
M +10 -6 observeradd.cpp
M +12 -0 observeradd.h
--- branches/kstars/summer/kstars/kstars/comast/observeradd.cpp #1002826:1002827
@@ -27,14 +27,18 @@
#include "comast/observer.h"
ObserverAdd::ObserverAdd() {
+ // Setting up the widget from the .ui file and adding it to the KDialog
QWidget *widget = new QWidget;
ui.setupUi( widget );
setMainWidget( widget );
setCaption( i18n( "Add Observer" ) );
setButtons( KDialog::Close );
ks = KStars::Instance();
+
+ // Load the observers list from the file
loadObservers();
+ // Make connections
connect( ui.AddObserver, SIGNAL( clicked() ), this, SLOT( slotAddObserver() ) );
}
@@ -43,13 +47,13 @@
KMessageBox::sorry( 0, i18n("The Name field cannot be empty"), i18n("Invalid Input") );
return;
}
- Comast::Observer *o = ks->data()->logObject()->findObserverByName( ui.Name->text() + ui.Surname->text() );
+ Comast::Observer *o = ks->data()->logObject()->findObserverByName( ui.Name->text() + ui.Surname->text() ); //The findObserverByName uses the fullName for searching
if( o ) {
- if( KMessageBox::warningYesNo( 0, i18n("Another Observer already exists with the given Name and Surname, Overwrite?"), i18n( "Overwrite" ), KGuiItem( i18n("Overwrite") ), KGuiItem( i18n( "Cancel" ) ) ) == KMessageBox::Yes ) {
+ if( Comast::warningOverwrite( i18n( "Another Observer already exists with the given Name and Surname, Overwrite?" ) ) == KMessageBox::Yes ) {
o->setObserver( o->name(), o->surname(), ui.Contact->text() );
} else
return; //Do nothing
- } else {
+ } else { // No such observer exists, so create a new observer object and append to file
o = new Comast::Observer( ui.Name->text(), ui.Surname->text(), ui.Contact->text() );
ks->data()->logObject()->observerList()->append( o );
}
@@ -65,9 +69,9 @@
void ObserverAdd::saveObservers() {
QFile f;
- f.setFileName( KStandardDirs::locateLocal( "appdata", "observerlist.xml" ) );
+ f.setFileName( KStandardDirs::locateLocal( "appdata", "observerlist.xml" ) );
if ( ! f.open( QIODevice::WriteOnly ) ) {
- kDebug() << "Cannot write list to file";
+ KMessageBox::sorry( 0, i18n( "Could not save the observer list to the file" ), i18n( "Write Error!" ) );
return;
}
QTextStream ostream( &f );
@@ -84,5 +88,5 @@
ks->data()->logObject()->readBegin( istream.readAll() );
f.close();
}
-
+
#include "observeradd.moc"
--- branches/kstars/summer/kstars/kstars/comast/observeradd.h #1002826:1002827
@@ -29,11 +29,23 @@
class ObserverAdd : public KDialog {
Q_OBJECT
public:
+ //The default constructor
ObserverAdd();
+
+ /*@short function to load the list of
+ * observers from the file
+ */
void loadObservers();
+
+ /*@short function to save the list of
+ * observers to the file
+ */
void saveObservers();
public slots:
+ /*@short function to add the new observer
+ * to the observerList of the global logObject
+ */
void slotAddObserver();
private:
More information about the Kstars-devel
mailing list