• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • oal
observeradd.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  observeradd.cpp - description
3 
4  -------------------
5  begin : Sunday July 26, 2009
6  copyright : (C) 2009 by Prakash Mohan
7  email : prakash.mohan@kdemail.net
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #include <QFile>
20 
21 #include <kmessagebox.h>
22 #include <kstandarddirs.h>
23 
24 #include "kstarsdata.h"
25 #include "observeradd.h"
26 #include "ui_observeradd.h"
27 #include "observer.h"
28 
29 ObserverAdd::ObserverAdd() {
30  // Setting up the widget from the .ui file and adding it to the KDialog
31  QWidget *widget = new QWidget;
32  ui.setupUi( widget );
33  setMainWidget( widget );
34  setCaption( i18n( "Add Observer" ) );
35  setButtons( KDialog::Close );
36  ks = KStars::Instance();
37  nextObserver = 0;
38 
39  // Load the observers list from the file
40  loadObservers();
41 
42  // Make connections
43  connect( ui.AddObserver, SIGNAL( clicked() ), this, SLOT( slotAddObserver() ) );
44 }
45 
46 void ObserverAdd::slotAddObserver() {
47  if( ui.Name->text().isEmpty() ) {
48  KMessageBox::sorry( 0, i18n("The Name field cannot be empty"), i18n("Invalid Input") );
49  return;
50  }
51 
52  if (KStarsData::Instance()->userdb()->FindObserver(ui.Name->text(),ui.Surname->text())){
53  if( OAL::warningOverwrite( i18n( "Another Observer already exists with the given Name and Surname, Overwrite?" ) ) == KMessageBox::No ) return;
54  }
55 
56  KStarsData::Instance()->userdb()->AddObserver(ui.Name->text(),ui.Surname->text(),ui.Contact->text());
57 
58  //Reload observers into OAL::m_observers
59  loadObservers();
60 
61  // Reset the UI for a fresh addition
62  ui.Name->clear();
63  ui.Surname->clear();
64  ui.Contact->clear();
65 }
66 
67 void ObserverAdd::loadObservers() {
68  ks->data()->logObject()->readObservers();
69 }
70 
71 #include "observeradd.moc"
observeradd.h
ObserverAdd::slotAddObserver
void slotAddObserver()
Definition: observeradd.cpp:46
ObserverAdd::loadObservers
void loadObservers()
Definition: observeradd.cpp:67
QWidget
KStarsData::Instance
static KStarsData * Instance()
Definition: kstarsdata.h:92
KStars::Instance
static KStars * Instance()
Definition: kstars.h:125
observer.h
OAL::warningOverwrite
int warningOverwrite(QString message)
Definition: oal.h:38
KSUserDB::AddObserver
void AddObserver(const QString &name, const QString &surname, const QString &contact)
Adds a new observer into the database.
Definition: ksuserdb.cpp:168
ObserverAdd::ObserverAdd
ObserverAdd()
Definition: observeradd.cpp:29
kstarsdata.h
KStarsData::userdb
KSUserDB * userdb()
Definition: kstarsdata.h:152
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal