21 #include <QStackedWidget> 
   24 #include <klineedit.h> 
   25 #include <kpushbutton.h> 
   26 #include <knewstuff3/downloaddialog.h> 
   27 #include <kstandarddirs.h> 
   34     bool hasPrefix(QString str, QString prefix) {
 
   35         if( prefix.isEmpty() )
 
   37         return str.startsWith( prefix, Qt::CaseInsensitive );
 
   56     wizardStack = 
new QStackedWidget( 
this );
 
   57     setMainWidget( wizardStack );
 
   58     setCaption( i18n(
"Setup Wizard") );
 
   59     setButtons( KDialog::User1|KDialog::User2|KDialog::Ok|KDialog::Cancel );
 
   60     setButtonGuiItem( KDialog::User1, KGuiItem( i18n(
"&Next >"), QString(), i18n(
"Go to next Wizard page") ) );
 
   61     setButtonGuiItem( KDialog::User2, KGuiItem( i18n(
"< &Back"), QString(), i18n(
"Go to previous Wizard page") ) );
 
   67     wizardStack->addWidget( welcome );
 
   68     wizardStack->addWidget( location );
 
   69     wizardStack->addWidget( download );
 
   70     wizardStack->setCurrentWidget( welcome );
 
   74     if( im.load(KStandardDirs::locate(
"appdata", 
"wzstars.png")) )
 
   75         welcome->Banner->setPixmap( im );
 
   76     if( im.load(KStandardDirs::locate(
"appdata", 
"wzgeo.png")) )
 
   77         location->Banner->setPixmap( im );
 
   78     if( im.load(KStandardDirs::locate(
"appdata", 
"wzdownload.png")) )
 
   79         download->Banner->setPixmap( im );
 
   82     connect( 
this, SIGNAL( user1Clicked() ), 
this, SLOT( slotNextPage() ) );
 
   83     connect( 
this, SIGNAL( user2Clicked() ), 
this, SLOT( slotPrevPage() ) );
 
   84     connect( location->CityListBox, SIGNAL( itemSelectionChanged () ), 
this, SLOT( slotChangeCity() ) );
 
   85     connect( location->CityFilter, SIGNAL( textChanged( 
const QString & ) ), 
this, SLOT( slotFilterCities() ) );
 
   86     connect( location->ProvinceFilter, SIGNAL( textChanged( 
const QString & ) ), 
this, SLOT( slotFilterCities() ) );
 
   87     connect( location->CountryFilter, SIGNAL( textChanged( 
const QString & ) ), 
this, SLOT( slotFilterCities() ) );
 
   88     connect( download->DownloadButton, SIGNAL( clicked() ), 
this, SLOT( slotDownload() ) );
 
   91     enableButton( KDialog::User2, 
false );
 
  101 void KSWizard::setButtonsEnabled() {
 
  102     enableButton( KDialog::User1, wizardStack->currentIndex() < wizardStack->count()-1 );
 
  103     enableButton( KDialog::User2, wizardStack->currentIndex() > 0 );
 
  106 void KSWizard::slotNextPage() {
 
  107     wizardStack->setCurrentIndex( wizardStack->currentIndex() + 1 );
 
  111 void KSWizard::slotPrevPage() {
 
  112     wizardStack->setCurrentIndex( wizardStack->currentIndex() - 1 );
 
  116 void KSWizard::initGeoPage() {
 
  118     location->LongBox->setReadOnly( 
true );
 
  119     location->LatBox->setReadOnly( 
true );
 
  124         location->CityListBox->addItem( loc->
fullName() );
 
  125         filteredCityList.append( loc );
 
  132     location->CityListBox->sortItems();
 
  134     location->CityListBox->setCurrentItem(location->CityListBox->findItems(QString(data->
geo()->
fullName()),
 
  135                                        Qt::MatchExactly).at(0));
 
  138 void KSWizard::slotChangeCity() {
 
  139     if ( location->CityListBox->currentItem() ) {
 
  140         for ( 
int i=0; i < filteredCityList.size(); ++i ) {
 
  141             if ( filteredCityList[i]->fullName() == location->CityListBox->currentItem()->text() ) {
 
  142                 Geo = filteredCityList[i];
 
  146         location->LongBox->showInDegrees( Geo->
lng() );
 
  147         location->LatBox->showInDegrees( Geo->
lat() );
 
  151 void KSWizard::slotFilterCities() {
 
  152     location->CityListBox->clear();
 
  154     filteredCityList.clear();
 
  157         if( hasPrefix( loc->
translatedName(),     location->CityFilter->text()     ) &&
 
  162             location->CityListBox->addItem( loc->
fullName() );
 
  163             filteredCityList.append( loc );
 
  166     location->CityListBox->sortItems();
 
  168     if ( location->CityListBox->count() > 0 )  
 
  169         location->CityListBox->setCurrentItem( location->CityListBox->item(0) );
 
  172 void KSWizard::slotDownload() {
 
  173     KNS3::DownloadDialog dlg;
 
  177 #include "kswizard.moc" 
KStarsData is the backbone of KStars. 
 
QString translatedName() const 
 
WizWelcomeUI(QWidget *parent=0)
 
static KStarsData * Instance()
 
QString translatedProvince() const 
 
KSWizard(QWidget *parent=0)
Constructor parent pointer to the parent widget. 
 
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
 
QList< GeoLocation * > getGeoList()
 
WizLocationUI(QWidget *parent=0)
 
WizDownloadUI(QWidget *parent=0)
 
virtual ~KSWizard()
Destructor. 
 
QString translatedCountry() const