26 #include <QTextStream>
27 #include <QStandardItemModel>
28 #include <QSortFilterProxyModel>
29 #include <QHeaderView>
30 #include <QDirIterator>
32 #include <kpushbutton.h>
33 #include <kstatusbar.h>
34 #include <ktextedit.h>
35 #include <kinputdialog.h>
37 #include <kio/netaccess.h>
38 #include <kmessagebox.h>
39 #include <kfiledialog.h>
40 #include <ktemporaryfile.h>
41 #include <klineedit.h>
42 #include <kplotobject.h>
43 #include <kplotaxis.h>
44 #include <kplotwidget.h>
45 #include <kio/copyjob.h>
46 #include <kstandarddirs.h>
70 #include <config-kstars.h>
73 #include <basedevice.h>
91 ks( _ks ), LogObject(0), m_CurrentObject(0),
92 isModified(false), bIsLarge(true)
96 setCaption( i18n(
"Observation Planner" ) );
97 setButtons( KDialog::Close );
99 setFocusPolicy(Qt::StrongFocus);
105 m_Model =
new QStandardItemModel( 0, 5,
this );
106 m_Session =
new QStandardItemModel( 0, 5 );
107 m_Model->setHorizontalHeaderLabels( QStringList() << i18n(
"Name" )
108 << i18n(
"Alternate Name" )
109 <<
i18nc(
"Right Ascension",
"RA" )
110 <<
i18nc(
"Declination",
"Dec" )
111 <<
i18nc(
"Magnitude",
"Mag" )
113 m_Session->setHorizontalHeaderLabels( QStringList() << i18n(
"Name" )
114 << i18n(
"Alternate Name" )
115 <<
i18nc(
"Right Ascension",
"RA" )
116 <<
i18nc(
"Declination",
"Dec" )
117 <<
i18nc(
"Magnitude",
"Mag" )
120 <<
i18nc(
"Altitude",
"Alt" )
121 <<
i18nc(
"Azimuth",
"Az" ));
123 m_SortModel->setSourceModel( m_Model );
124 m_SortModel->setDynamicSortFilter(
true );
125 ui->TableView->setModel( m_SortModel );
126 ui->TableView->horizontalHeader()->setStretchLastSection(
true );
127 ui->TableView->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
129 m_SortModelSession->setSourceModel( m_Session );
130 m_SortModelSession->setDynamicSortFilter(
true );
131 ui->SessionView->setModel( m_SortModelSession );
132 ui->SessionView->horizontalHeader()->setStretchLastSection(
true );
133 ui->SessionView->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
137 ui->View->setLimits( -12.0, 12.0, -90.0, 90.0 );
138 ui->View->axis(KPlotWidget::BottomAxis)->setTickLabelFormat(
't' );
139 ui->View->axis(KPlotWidget::BottomAxis)->setLabel( i18n(
"Local Time" ) );
140 ui->View->axis(KPlotWidget::TopAxis)->setTickLabelFormat(
't' );
141 ui->View->axis(KPlotWidget::TopAxis)->setTickLabelsShown(
true );
142 ui->DateEdit->setDate(dt.date());
143 ui->SetLocation->setText( geo -> fullName() );
144 ui->ImagePreview->installEventFilter(
this );
145 ui->TableView->viewport()->installEventFilter(
this );
146 ui->TableView->installEventFilter(
this );
147 ui->SessionView->viewport()->installEventFilter(
this );
148 ui->SessionView->installEventFilter(
this );
151 connect(
this, SIGNAL( closeClicked() ),
this, SLOT(
slotClose() ) );
152 connect( ui->TableView, SIGNAL( doubleClicked(
const QModelIndex& ) ),
154 connect( ui->TableView->selectionModel(),
155 SIGNAL( selectionChanged(
const QItemSelection&,
const QItemSelection&) ),
157 connect( ui->SessionView->selectionModel(),
158 SIGNAL( selectionChanged(
const QItemSelection&,
const QItemSelection&) ),
160 connect( ui->WUTButton, SIGNAL( clicked() ),
162 connect( ui->FindButton, SIGNAL( clicked() ),
164 connect( ui->OpenButton, SIGNAL( clicked() ),
166 connect( ui->SaveButton, SIGNAL( clicked() ),
168 connect( ui->SaveAsButton, SIGNAL( clicked() ),
170 connect( ui->WizardButton, SIGNAL( clicked() ),
172 connect( ui->MiniButton, SIGNAL( clicked() ),
174 connect( ui->SetLocation, SIGNAL( clicked() ),
176 connect( ui->Update, SIGNAL( clicked() ),
178 connect( ui->SaveImage, SIGNAL( clicked() ),
180 connect( ui->DeleteImage, SIGNAL( clicked() ),
182 connect( ui->GoogleImage, SIGNAL( clicked() ),
184 connect( ui->SetTime, SIGNAL( clicked() ),
186 connect( ui->tabWidget, SIGNAL( currentChanged(
int) ),
188 connect( ui->saveImages, SIGNAL( clicked() ),
190 connect( ui->DeleteAllImages, SIGNAL( clicked() ),
192 connect( ui->OALExport, SIGNAL( clicked() ),
195 ui->OpenButton->setIcon( KIcon(
"document-open") );
196 ui->SaveButton->setIcon( KIcon(
"document-save") );
197 ui->SaveAsButton->setIcon( KIcon(
"document-save-as") );
198 ui->WizardButton->setIcon( KIcon(
"games-solve") );
199 ui->MiniButton->setIcon( KIcon(
"view-restore") );
202 ui->NotesLabel->setEnabled(
false );
203 ui->NotesEdit->setEnabled(
false );
204 ui->SetTime->setEnabled(
false );
205 ui->TimeEdit->setEnabled(
false );
206 ui->GoogleImage->setEnabled(
false );
207 ui->saveImages->setEnabled(
false );
208 ui->SaveImage->setEnabled(
false );
209 ui->DeleteImage->setEnabled(
false );
210 ui->OALExport->setEnabled(
false );
227 bool addToWishList=
true;
229 obj = ks->map()->clickedObject();
232 kWarning() <<
"Trying to add null object to observing list!";
235 if( obj->
name() ==
"star" ) {
236 KMessageBox::sorry(0, i18n(
"Unnamed stars are not supported in the observing lists"));
241 if ( obsList().contains( obj ) ) {
242 addToWishList =
false;
244 ks->statusBar()->changeItem( i18n(
"%1 is already in your wishlist.", obj->
name() ), 0 );
249 if ( session && sessionList().contains( obj ) ) {
250 ks->statusBar()->changeItem( i18n(
"%1 is already in the session plan.", obj->
name() ), 0 );
255 if ( - 30.0 < obj->
mag() && obj->
mag() < 90.0 )
256 smag = QString::number( obj->
mag(),
'g', 2 );
261 if( addToWishList ) {
262 m_ObservingList.append( obj );
263 m_CurrentObject = obj;
268 if(obj->
name() ==
"star" ) {
269 ra = obj->
ra0().toHMSString();
270 dec = obj->
dec0().toDMSString();
273 ra = p.
ra().toHMSString();
274 dec = p.
dec().toDMSString();
279 <<
new QStandardItem( ra )
280 <<
new QStandardItem( dec )
281 <<
new QStandardItem( smag )
282 <<
new QStandardItem( obj->
typeName() );
284 m_Model->appendRow( itemList );
286 ks->statusBar()->changeItem( i18n(
"Added %1 to observing list.", obj->
name() ), 0 );
287 ui->TableView->resizeColumnsToContents();
288 if( ! update ) slotSaveList();
292 m_SessionList.append(obj);
293 dt.setTime( TimeHash.value( obj->
name(), obj->
transitTime( dt, geo ) ) );
294 dms lst(geo->GSTtoLST( dt.gst() ));
298 QString ra, dec, time =
"--", alt =
"--", az =
"--";
300 QStandardItem *BestTime =
new QStandardItem();
301 if(obj->
name() ==
"star" ) {
302 ra = obj->
ra0().toHMSString();
303 dec = obj->
dec0().toDMSString();
304 BestTime->setData( QString(
"--" ), Qt::DisplayRole );
307 ra = p.
ra().toHMSString();
308 dec = p.
dec().toDMSString();
309 BestTime->setData( TimeHash.value( obj->
name(), obj->
transitTime( dt, geo ) ), Qt::DisplayRole );
310 alt = p.
alt().toDMSString();
311 az = p.
az().toDMSString();
316 <<
new QStandardItem( ra )
317 <<
new QStandardItem( dec )
318 <<
new QStandardItem( smag )
319 <<
new QStandardItem( obj->
typeName() )
321 <<
new QStandardItem( alt )
322 <<
new QStandardItem( az );
324 m_Session->appendRow( itemList );
327 ui->SessionView->resizeColumnsToContents();
329 ks->statusBar()->changeItem( i18n(
"Added %1 to session list.", obj->
name() ), 0 );
331 setSaveImagesButton();
337 o = ks->map()->clickedObject();
338 else if( sessionView )
342 QStandardItemModel *currentModel;
346 currentModel = m_Model;
347 k = obsList().indexOf( o );
350 currentModel = m_Session;
351 k = sessionList().indexOf( o );
354 if ( o == LogObject ) saveCurrentUserLog();
356 if ( o->
name() ==
"star" ) {
358 for (
int irow = 0; irow < currentModel->rowCount(); ++irow ) {
359 QString ra = currentModel->item(irow, 1)->text();
360 QString dc = currentModel->item(irow, 2)->text();
361 if ( o->
ra0().toHMSString() == ra && o->
dec0().toDMSString() == dc ) {
362 currentModel->removeRow(irow);
368 for (
int irow = 0; irow < currentModel->rowCount(); ++irow ) {
369 QString name = currentModel->item(irow, 0)->text();
371 currentModel->removeRow(irow);
378 obsList().removeAt(k);
379 ui->View->removeAllPlotObjects();
380 ui->TableView->resizeColumnsToContents();
385 TimeHash.remove( o->
name() );
386 sessionList().removeAt(k);
388 ui->View->removeAllPlotObjects();
389 ui->SessionView->resizeColumnsToContents();
394 QStandardItemModel *currentModel;
397 currentModel = m_Session;
399 currentModel = m_Model;
403 for (
int irow = currentModel->rowCount()-1; irow >= 0; --irow ) {
406 rowSelected = ui->SessionView->selectionModel()->isRowSelected( irow, QModelIndex() );
408 rowSelected = ui->TableView->selectionModel()->isRowSelected( irow, QModelIndex() );
412 QModelIndex mSortIndex, mIndex;
414 mSortIndex = m_SortModelSession->index( irow, 0 );
415 mIndex = m_SortModelSession->mapToSource( mSortIndex );
416 currList = sessionList();
418 mSortIndex = m_SortModel->index( irow, 0 );
419 mIndex = m_SortModel->mapToSource( mSortIndex );
420 currList = obsList();
423 int irow = mIndex.row();
424 QString ra = currentModel->item(irow, 1)->text();
425 QString dc = currentModel->item(irow, 2)->text();
429 if ( o->
name() ==
"star" ) {
430 if ( o->
ra0().toHMSString() == ra && o->
dec0().toDMSString() == dc ) {
431 slotRemoveObject(o, sessionView);
436 slotRemoveObject(o, sessionView);
446 ui->SessionView->selectionModel()->clear();
448 ks->getExecute()->init();
451 setSaveImagesButton();
452 ui->ImagePreview->setCursor( Qt::ArrowCursor );
457 singleSelection =
false;
460 ui->ImagePreview->clearPreview();
461 ui->ImagePreview->setCursor( Qt::ArrowCursor );
462 QModelIndexList selectedItems;
465 ui->SaveImage->setEnabled(
false );
466 ui->DeleteImage->setEnabled(
false );
468 QStandardItemModel *currentModel;
472 selectedItems = m_SortModelSession->mapSelectionToSource( ui->SessionView->selectionModel()->selection() ).indexes();
473 currentModel = m_Session;
474 currList = sessionList();
476 selectedItems = m_SortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
477 currentModel = m_Model;
478 currList = obsList();
481 if ( selectedItems.size() == currentModel->columnCount() ) {
482 newName = selectedItems[0].data().toString();
483 singleSelection =
true;
487 foreach ( o, currList ) {
495 if( singleSelection ) {
497 ui->ImagePreview->setCursor( Qt::PointingHandCursor );
507 setCurrentImage( o );
508 ui->GoogleImage->setEnabled(
true );
509 if ( newName != i18n(
"star" ) ) {
512 saveCurrentUserLog();
514 LogObject = currentObject();
515 ui->NotesLabel->setEnabled(
true );
516 ui->NotesEdit->setEnabled(
true );
517 ui->NotesLabel->setText( i18n(
"observing notes for %1:", LogObject->translatedName() ) );
518 if ( LogObject->userLog().isEmpty() ) {
519 ui->NotesEdit->setPlainText( i18n(
"Record here observation logs and/or data on %1.", LogObject->translatedName() ) );
521 ui->NotesEdit->setPlainText( LogObject->userLog() );
524 ui->TimeEdit->setEnabled(
true );
525 ui->SetTime->setEnabled(
true );
526 ui->TimeEdit->setTime( TimeHash.value( o->
name(), o->
transitTime( dt, geo ) ) );
530 saveCurrentUserLog();
531 ui->NotesLabel->setText( i18n(
"observing notes (disabled for unnamed star)" ) );
532 ui->NotesLabel->setEnabled(
false );
533 ui->NotesEdit->clear();
534 ui->NotesEdit->setEnabled(
false );
535 ui->GoogleImage->setEnabled(
false );
537 if( QFile( KStandardDirs::locateLocal(
"appdata", CurrentImage ) ).size() > 13000 ) {
538 ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal(
"appdata", CurrentImage ) ) );
539 ui->ImagePreview->show();
540 ui->SaveImage->setEnabled(
false );
541 ui->DeleteImage->setEnabled(
true );
542 }
else if( QFile( KStandardDirs::locateLocal(
"appdata",
"Temp_" + CurrentImage ) ).size() > 13000 ) {
543 ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal(
"appdata",
"Temp_" + CurrentImage ) ) );
544 ui->ImagePreview->show();
545 ui->SaveImage->setEnabled(
true );
546 ui->DeleteImage->setEnabled(
true );
549 kDebug() << i18n(
"Object %1 not found in list.", newName );
552 if ( selectedItems.size() == 0 ) {
555 ui->NotesLabel->setText( i18n(
"Select an object to record notes on it here:" ) );
556 ui->NotesLabel->setEnabled(
false );
557 ui->NotesEdit->setEnabled(
false );
559 ui->TimeEdit->setEnabled(
false );
560 ui->SetTime->setEnabled(
false );
561 ui->GoogleImage->setEnabled(
false );
563 saveCurrentUserLog();
564 ui->NotesEdit->setPlainText(
"");
566 ui->View->removeAllPlotObjects();
568 ui->NotesLabel->setText( i18n(
"Select a single object to record notes on it here:" ) );
569 ui->NotesLabel->setEnabled(
false );
570 ui->NotesEdit->setEnabled(
false );
571 ui->TimeEdit->setEnabled(
false );
572 ui->SetTime->setEnabled(
false );
573 ui->GoogleImage->setEnabled(
false );
576 ui->View->removeAllPlotObjects();
578 saveCurrentUserLog();
579 ui->NotesEdit->setPlainText(
"");
585 QModelIndexList selectedItems;
587 selectedItems = ui->SessionView->selectionModel()->selectedRows();
589 selectedItems = ui->TableView->selectionModel()->selectedRows();
592 if (selectedItems.size() == 1) {
593 ks->map()->setClickedObject( currentObject() );
594 ks->map()->setClickedPoint( currentObject() );
595 ks->map()->slotCenter();
605 KMessageBox::sorry(0, i18n(
"KStars did not find any active telescopes."));
619 if (bd->isConnected() ==
false)
621 KMessageBox::error(0, i18n(
"Telescope %1 is offline. Please connect and retry again.", gd->
getDeviceName()));
635 KMessageBox::sorry(0, i18n(
"KStars did not find any active telescopes."));
643 if ( currentObject() ) {
644 QPointer<DetailDialog> dd =
new DetailDialog( currentObject(), ks->data()->lt(), geo, ks );
653 QPointer<WUTDialog> w =
new WUTDialog( ks, sessionView, geo, lt );
659 QModelIndexList selectedItems = m_SortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
660 if ( selectedItems.size() ) {
661 foreach (
const QModelIndex &i, selectedItems ) {
664 slotAddObject( o,
true );
671 QPointer<FindDialog> fd =
new FindDialog( ks );
672 if ( fd->exec() == QDialog::Accepted ) {
675 slotAddObject( o, sessionView );
682 QModelIndexList selectedItems;
685 QPointer<AltVsTime> avt =
new AltVsTime( ks );
686 for (
int irow = m_Session->rowCount()-1; irow >= 0; --irow ) {
687 if ( ui->SessionView->selectionModel()->isRowSelected( irow, QModelIndex() ) ) {
688 QModelIndex mSortIndex = m_SortModelSession->index( irow, 0 );
689 QModelIndex mIndex = m_SortModelSession->mapToSource( mSortIndex );
690 int irow = mIndex.row();
691 QString ra = m_Session->item(irow, 1)->text();
692 QString dc = m_Session->item(irow, 2)->text();
693 foreach (
SkyObject *o, sessionList() ) {
695 if ( o->
name() ==
"star" ) {
696 if ( o->
ra0().toHMSString() == ra && o->
dec0().toDMSString() == dc ) {
697 avt->processObject( o );
702 avt->processObject( o );
711 selectedItems = m_SortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
712 if ( selectedItems.size() ) {
713 QPointer<AltVsTime> avt =
new AltVsTime( ks );
714 foreach (
const QModelIndex &i, selectedItems ) {
717 avt->processObject( o );
728 saveCurrentUserLog();
729 ui->View->removeAllPlotObjects();
736 if ( ! ui->NotesEdit->toPlainText().isEmpty() &&
737 ui->NotesEdit->toPlainText() !=
738 i18n(
"Record here observation logs and/or data on %1.", LogObject->translatedName() ) ) {
739 LogObject->saveUserLog( ui->NotesEdit->toPlainText() );
740 ui->NotesEdit->clear();
741 ui->NotesLabel->setText( i18n(
"Observing notes for object:" ) );
747 KUrl fileURL = KFileDialog::getOpenUrl( QDir::homePath(),
"*.obslist|KStars Observing List (*.obslist)" );
749 if ( fileURL.isValid() ) {
750 if ( ! fileURL.isLocalFile() ) {
752 KTemporaryFile tmpfile;
753 tmpfile.setAutoRemove(
false);
755 FileName = tmpfile.fileName();
756 if( KIO::NetAccess::download( fileURL, FileName,
this ) )
757 f.setFileName( FileName );
760 FileName = fileURL.toLocalFile();
761 f.setFileName( FileName );
764 if ( ! f.open( QIODevice::ReadOnly) ) {
765 QString message = i18n(
"Could not open file %1", f.fileName() );
766 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
770 ui->tabWidget->setCurrentIndex(1);
772 sessionList().clear();
775 m_Session->removeRows( 0, m_Session->rowCount() );
780 input = istream.readAll();
788 slotAddObject( o,
true );
794 }
else if ( ! fileURL.path().isEmpty() ) {
795 KMessageBox::sorry( 0 , i18n(
"The specified file is invalid" ) );
802 if ( sessionList().size() ) {
804 QString message = i18n(
"Do you want to save the current session?" );
805 if ( KMessageBox::questionYesNo(
this, message,
806 i18n(
"Save Current session?" ), KStandardGuiItem::save(), KStandardGuiItem::discard() ) == KMessageBox::Yes )
813 KUrl fileURL = KFileDialog::getSaveUrl( QDir::homePath(),
"*.obslist|KStars Observing List (*.obslist)" );
814 if ( fileURL.isValid() ) {
815 FileName = fileURL.path();
816 slotSaveSession(nativeSave);
822 f.setFileName( KStandardDirs::locateLocal(
"appdata",
"wishlist.obslist" ) );
823 if ( ! f.open( QIODevice::WriteOnly ) ) {
824 kDebug() <<
"Cannot write list to file";
830 kWarning() <<
"Null entry in observing wishlist!";
833 if ( o->
name() ==
"star" ) {
838 ostream << s->
name2() << endl;
840 ostream << s->
name() << endl;
842 ostream << o->
name() << endl;
850 f.setFileName( KStandardDirs::locateLocal(
"appdata",
"wishlist.obslist" ) );
851 if ( ! f.open( QIODevice::ReadOnly) ) {
852 kDebug() <<
"No WishList Saved yet";
857 while ( ! istream.atEnd() ) {
858 line = istream.readLine();
861 if ( line.startsWith( QLatin1String(
"star" ) ) ) {
862 QStringList fields = line.split(
' ', QString::SkipEmptyParts );
863 dms ra = dms::fromString( fields[1],
false );
864 dms dc = dms::fromString( fields[2],
true );
867 o = ks->data()->skyComposite()->starNearest( &p, maxrad );
869 o = ks->data()->objectNamed( line );
873 if ( ! o ) o = ks->data()->skyComposite()->findStarByGenetiveName( line );
874 if ( o ) slotAddObject( o,
false,
true );
880 if ( FileName.isEmpty() ) {
881 slotSaveSessionAs(nativeSave);
885 if( ! f.open( QIODevice::WriteOnly ) ) {
886 QString message = i18n(
"Could not open file %1. Try a different filename?", f.fileName() );
887 if ( KMessageBox::warningYesNo( 0, message, i18n(
"Could Not Open File" ), KGuiItem(i18n(
"Try Different")), KGuiItem(i18n(
"Do Not Try")) ) == KMessageBox::Yes ) {
889 slotSaveSessionAs(nativeSave);
895 ostream<< log.
writeLog( nativeSave );
901 QPointer<ObsListWizard> wizard =
new ObsListWizard( ks );
902 if ( wizard->exec() == QDialog::Accepted ) {
903 foreach (
SkyObject *o, wizard->obsList() ) {
914 if( TimeHash.value( o->
name(), o->
transitTime( dt, geo ) ).hour() > 12 )
918 ut = geo->LTtoUT(ut);
919 ut = ut.
addSecs( ( 0.5 + DayOffset ) * 86400.0 );
921 double h1 = geo->GSTtoLST( ut.
gst() ).Hours();
925 ui->View->setSecondaryLimits( h1, h1 + 24.0, -90.0, 90.0 );
926 ksal->setLocation(geo);
928 ui->View->setSunRiseSetTimes( ksal->getSunRise(), ksal->getSunSet() );
929 ui->View->setDawnDuskTimes( ksal->getDawnAstronomicalTwilight(), ksal->getDuskAstronomicalTwilight() );
931 KPlotObject *po =
new KPlotObject( Qt::white, KPlotObject::Lines, 2.0 );
932 for (
double h = -12.0; h <= 12.0; h += 0.5 ) {
933 po->addPoint( h, findAltitude( o, ( h + DayOffset * 24.0 ) ) );
935 ui->View->removeAllPlotObjects();
936 ui->View->addPlotObject( po );
942 ut = geo->LTtoUT( ut );
944 dms LST = geo->GSTtoLST( ut.
gst() );
951 ui->MiniButton->setIcon( KIcon(
"view-fullscreen") );
953 ui->FindButton->setText(
i18nc(
"First letter in 'Find'",
"F" ) );
955 ui->TableView->hideColumn(1);
956 ui->TableView->hideColumn(2);
957 ui->TableView->hideColumn(3);
958 ui->TableView->hideColumn(4);
959 ui->TableView->hideColumn(5);
961 ui->TableView->horizontalHeader()->hide();
962 ui->TableView->verticalHeader()->hide();
964 ui->NotesLabel->hide();
965 ui->NotesEdit->hide();
969 int w = 5*ui->MiniButton->width();
970 if ( ui->TableView->columnWidth(0) > w ) {
971 w = ui->TableView->columnWidth(0);
973 ui->TableView->setColumnWidth(0, w);
975 int left, right, top, bottom;
976 ui->layout()->getContentsMargins( &left, &top, &right, &bottom );
977 resize( w + left + right, height() );
980 ui->MiniButton->setIcon( KIcon(
"view-restore" ) );
982 ui->TableView->showColumn(1);
983 ui->TableView->showColumn(2);
984 ui->TableView->showColumn(3);
985 ui->TableView->showColumn(4);
986 ui->TableView->showColumn(5);
988 ui->TableView->horizontalHeader()->show();
990 ui->WUTButton->setText( i18n(
"WUT") );
991 ui->FindButton->setText( i18n(
"Find &Object") );
993 ui->NotesLabel->show();
994 ui->NotesEdit->show();
1003 saveCurrentUserLog();
1004 ui->NotesLabel->setText( i18n(
"Select an object to record notes on it here:" ) );
1005 ui->NotesLabel->setEnabled(
false );
1006 ui->NotesEdit->setEnabled(
false );
1007 ui->TimeEdit->setEnabled(
false );
1008 ui->SetTime->setEnabled(
false );
1009 ui->GoogleImage->setEnabled(
false );
1010 ui->SaveImage->setEnabled(
false );
1011 ui->DeleteImage->setEnabled(
false );
1012 m_CurrentObject = 0;
1013 sessionView = index != 0;
1014 setSaveImagesButton();
1015 ui->WizardButton->setEnabled( ! sessionView );
1016 ui->OALExport->setEnabled( sessionView );
1018 ui->TableView->clearSelection();
1019 ui->SessionView->clearSelection();
1021 saveCurrentUserLog();
1022 ui->NotesEdit->setPlainText(
"");
1023 ui->View->removeAllPlotObjects();
1028 if ( ld->exec() == QDialog::Accepted ) {
1029 geo = ld->selectedCity();
1030 ui->SetLocation -> setText( geo -> fullName() );
1036 dt.setDate( ui->DateEdit->date() );
1037 ui->View->removeAllPlotObjects();
1041 if( o->
name() !=
"star" ) {
1042 slotRemoveObject( o,
false,
true );
1043 slotAddObject( o,
false,
true );
1046 foreach (
SkyObject *obj, _SessionList ) {
1047 if( obj->
name() !=
"star" ) {
1048 slotRemoveObject( obj,
true,
true );
1049 slotAddObject( obj,
true,
true );
1056 slotRemoveObject( o,
true );
1057 TimeHash [o->
name()] = ui->TimeEdit->time();
1058 slotAddObject( o,
true,
true );
1063 ui->GoogleImage->setEnabled(
false );
1064 ui->ImagePreview->clearPreview();
1065 if( ! QFile::exists( KStandardDirs::locateLocal(
"appdata", CurrentImage ) ) )
1066 setCurrentImage( currentObject(),
true );
1067 QFile::remove( KStandardDirs::locateLocal(
"appdata", CurrentImage ) );
1070 url.setUrl( DSSUrl );
1072 url.setUrl( SDSSUrl );
1074 downloadJob = KIO::copy ( url, KUrl( KStandardDirs::locateLocal(
"appdata", CurrentImage ) ) );
1075 connect ( downloadJob, SIGNAL ( result (KJob *) ), SLOT ( downloadReady() ) );
1081 if( QFile( KStandardDirs::locateLocal(
"appdata", CurrentImage ) ).size() > 13000 ) {
1082 ui->ImagePreview->showPreview( KUrl( KStandardDirs::locateLocal(
"appdata", CurrentImage ) ) );
1084 ui->ImagePreview->show();
1085 ui->ImagePreview->setCursor( Qt::PointingHandCursor );
1086 if( CurrentImage.contains(
"Temp" ) ) {
1087 ImageList.append( CurrentImage );
1088 ui->SaveImage->setEnabled(
true );
1090 ui->DeleteImage->setEnabled(
true );
1093 slotGetImage(
true );
1102 CurrentImage =
"Temp_Image_" + o->
name().remove(
' ');
1104 CurrentImage =
"Image_" + o->
name().remove(
' ');
1105 ThumbImage =
"thumb-" + o->
name().toLower().remove(
' ') +
".png";
1106 if( o->
name() ==
"star" ) {
1107 QString RAString( o->
ra0().toHMSString() );
1108 QString DecString( o->
dec0().toDMSString() );
1110 CurrentImage =
"Temp_Image" + RAString.remove(
' ') + DecString.remove(
' ');
1112 CurrentImage =
"Image" + RAString.remove(
' ') + DecString.remove(
' ');
1113 QChar decsgn = ( (o->
dec0().
Degrees() < 0.0 ) ?
'-' :
'+' );
1114 CurrentImage = CurrentImage.remove(
'+').remove(
'-') + decsgn;
1116 CurrentImagePath = KStandardDirs::locateLocal(
"appdata" , CurrentImage );
1117 CurrentTempPath = KStandardDirs::locateLocal(
"appdata",
"Temp_" + CurrentImage );
1119 QString UrlPrefix(
"http://casjobs.sdss.org/ImgCutoutDR6/getjpeg.aspx?");
1120 QString UrlSuffix(
"&scale=1.0&width=600&height=600&opt=GST&query=SR(10,20)");
1123 RA = RA.sprintf(
"ra=%f", o->
ra0().
Degrees() );
1124 Dec = Dec.sprintf(
"&dec=%f", o->
dec0().
Degrees() );
1126 SDSSUrl = UrlPrefix + RA + Dec + UrlSuffix;
1130 ui->GoogleImage->setEnabled(
false );
1131 ui->SaveImage->setEnabled(
false );
1132 ui->DeleteImage->setEnabled(
false );
1133 m_CurrentObject = 0;
1135 ui->TableView->clearSelection();
1136 ui->SessionView->clearSelection();
1140 currList = sessionList();
1142 currList = obsList();
1145 setCurrentImage( o );
1146 QString img( CurrentImagePath );
1149 saveImage( url, img );
1154 if( ! QFile::exists( CurrentImagePath ) && ! QFile::exists( CurrentTempPath ) ) {
1155 if( KIO::NetAccess::download( url, filename, mainWidget() ) ) {
1156 if( QFile( CurrentImagePath ).size() < 13000 ) {
1157 url = KUrl( DSSUrl );
1158 KIO::NetAccess::download( url, filename, mainWidget() );
1162 }
else if( QFile::exists( CurrentTempPath ) ) {
1163 QFile
f( CurrentTempPath );
1164 f.rename( CurrentImagePath );
1169 setCurrentImage( currentObject() );
1170 QFile
f( CurrentTempPath);
1171 f.rename( CurrentImagePath );
1172 ui->SaveImage->setEnabled(
false );
1177 if( QFile::exists( CurrentImagePath ) )
1179 else if( QFile::exists( CurrentTempPath ) )
1187 if( KMessageBox::warningYesNo( 0, i18n(
"This will delete all saved images. Are you sure you want to do this?" ), i18n(
"Delete All Images" ) ) == KMessageBox::No )
1189 ui->ImagePreview->setCursor( Qt::ArrowCursor );
1190 ui->GoogleImage->setEnabled(
false );
1191 ui->SaveImage->setEnabled(
false );
1192 ui->DeleteImage->setEnabled(
false );
1193 m_CurrentObject = 0;
1195 ui->TableView->clearSelection();
1196 ui->SessionView->clearSelection();
1197 ui->ImagePreview->clearPreview();
1198 QDirIterator iterator( KStandardDirs::locateLocal(
"appdata",
"" ) );
1199 while( iterator.hasNext() )
1202 if( iterator.fileName().contains(
"Image" ) && ( ! iterator.fileName().contains(
"dat" ) ) && ( ! iterator.fileName().contains(
"obslist" ) ) ) {
1203 QFile file( iterator.filePath() );
1211 ui->saveImages->setEnabled(
1212 (sessionView && !sessionList().isEmpty()) ||
1213 !obsList().isEmpty()
1222 if( obj == ui->ImagePreview ) {
1223 if( event->type() == QEvent::MouseButtonRelease ) {
1224 if( currentObject() ) {
1225 if( ( ( QFile( CurrentImagePath ).size() < 13000 ) && ( QFile( CurrentTempPath ).size() < 13000 ) ) ) {
1226 if( ! currentObject()->isSolarSystem() )
1237 if( obj == ui->TableView->viewport() && ! noSelection ) {
1238 if( event->type() == QEvent::MouseButtonRelease ) {
1239 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
1240 if( mouseEvent->button() == Qt::RightButton ) {
1241 QPoint pos( mouseEvent->globalX() , mouseEvent->globalY() );
1242 if( singleSelection )
1243 pmenu->initPopupMenu(
true,
true,
true, showScope,
true,
true );
1245 pmenu->initPopupMenu(
true,
false,
false,
false,
true );
1246 pmenu->popup( pos );
1252 if( obj == ui->SessionView->viewport() && ! noSelection ) {
1253 if( event->type() == QEvent::MouseButtonRelease ) {
1254 QMouseEvent *mouseEvent =
static_cast<QMouseEvent*
>(event);
1255 if( mouseEvent->button() == Qt::RightButton ) {
1256 QPoint pos( mouseEvent->globalX() , mouseEvent->globalY() );
1257 if( singleSelection )
1258 pmenu->initPopupMenu(
false,
true,
true, showScope,
true,
true,
true );
1260 pmenu->initPopupMenu(
false,
false,
false,
false,
true,
false,
true );
1261 pmenu->popup( pos );
1267 if( obj == ui->TableView || obj == ui->SessionView)
1269 if (event->type() == QEvent::KeyPress)
1271 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
1272 if (keyEvent->key() == Qt::Key_Delete) {
1273 slotRemoveSelectedObjects();
1284 QPixmap *pm =
new QPixmap;
1285 QPointer<ThumbnailPicker> tp =
new ThumbnailPicker( currentObject(), *pm,
this, 600, 600, i18n(
"Image Chooser" ) );
1286 if ( tp->exec() == QDialog::Accepted ) {
1287 QFile
f( CurrentImagePath );
1290 if ( tp->imageFound() ) {
1291 tp->image()->save( f.fileName(),
"PNG" );
1292 ui->ImagePreview->showPreview( KUrl( f.fileName() ) );
1301 QFile::remove( CurrentImagePath );
1302 QFile::remove( CurrentTempPath );
1307 if( ! QFile::exists( KStandardDirs::locateLocal(
"appdata",
ThumbImage ) ) ) {
1308 QImage img( CurrentImagePath );
1309 img = img.scaled( 200, 200, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
1310 img.save( KStandardDirs::locateLocal(
"appdata",
ThumbImage ) );
1315 slotSaveSessionAs(
false);
1321 QPointer<WUTDialog> w =
new WUTDialog( ks, sessionView, geo, lt );
1323 QModelIndexList selectedItems;
1324 selectedItems = m_SortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
1325 if ( selectedItems.size() )
1326 foreach (
const QModelIndex &i, selectedItems ) {
1328 if ( o->
translatedName() == i.data().toString() && w->checkVisibility( o ) )
1329 slotAddObject( o,
true );
1336 if( o->
name() == name )
1342 ui->tabWidget->setCurrentIndex( 1 );
1343 ui->SessionView->selectionModel()->clear();
1344 for (
int irow = m_Session->rowCount()-1; irow >= 0; --irow ) {
1345 QModelIndex mSortIndex = m_SortModelSession->index( irow, 0 );
1346 QModelIndex mIndex = m_SortModelSession->mapToSource( mSortIndex );
1347 int idxrow = mIndex.row();
1349 ui->SessionView->selectRow( idxrow );
1358 ui->ImagePreview->showPreview( KUrl( file.fileName() ) );
1360 ui->ImagePreview->hide();
1363 #include "observinglist.moc"
Sort best observation times by reimplementing lessThan() to work on the transit times of objects...
void slotSaveAllImages()
Downloads the images of all the objects in the session list Note: This downloads the SDSS image...
void setSaveImagesButton()
decides on whether to enable the SaveImages button or not
Dialog for changing the geographic location of the observer.
window showing detailed information for a selected object.
QString writeLog(bool native=true)
void slotImageViewer()
Shows the image in a ImageViewer window.
void slotSaveSessionAs(bool nativeSave=true)
save the current observing session plan to disk, specify filename.
QString translatedName() const
QList< SkyObject * > * targetList()
virtual bool runCommand(int command, void *ptr=NULL)=0
KStarsDateTime dateTime()
static INDIListener * Instance()
virtual INDI::BaseDevice * getBaseDevice()=0
const double & Degrees() const
virtual const char * getDeviceName()=0
ObservingListUI(QWidget *parent)
Cunstructor.
void setDate(const QDate &d)
Assign the Date according to a QDate object.
A class that implements methods to find sun rise, sun set, twilight begin / end times, moon rise and moon set times.
void slotSaveSession(bool nativeSave=true)
save the current session
QTime transitTime(const KStarsDateTime &dt, const GeoLocation *geo)
The same iteration technique described in riseSetTime() is used here.
This is the main window for KStars.
void slotFind()
Open the Find Dialog.
void slotAddToSession()
Add the object to the Session List.
void slotSlewToObject()
slew the telescope to the selected object
void slotToggleSize()
toggle between the large and small window states
void setTime(const QTime &t)
Assign the Time according to a QTime object.
QHash< QString, QTime > timeHash()
double findAltitude(SkyPoint *p, double hour=0)
Return the altitude of the given SkyObject for the given hour.
void slotWizard()
construct a new observing list using the wizard.
bool openDataFile(QFile &file, const QString &filename)
Attempt to open the data file named filename, using the QFile object "file".
void slotOpenList()
load an observing list from disk.
~ObservingList()
Destuctor (empty)
bool eventFilter(QObject *obj, QEvent *event)
This is the declaration of the event filter function which is installed on the KImageFilePreview and ...
The sky coordinates of a point in the sky.
Image viewer window for KStars.
double getSunRise()
All the functions returns the fraction of the day as their return value.
ObservingList(KStars *_ks)
Constructor.
void saveImage(KUrl url, QString filename)
saves the image syncronously from a given URL into a given file url the url from which the image has ...
QString getDSSURL(const SkyPoint *const p)
Create a URL to obtain a DSS image for a given SkyPoint.
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
void setDefaultImage()
set the default image in the image preview.
void slotAVT()
Show the Altitude vs Time for selecteld objects.
KStarsDateTime addSecs(double s) const
i18nc("string from libindi, used in the config dialog","100x")
void selectObject(const SkyObject *o)
make a selection in the session view
void slotDeleteAllImages()
Removes all the save DSS/SDSS images from the disk.
GeoLocation * geoLocation()
void slotSaveList()
save the current observing list to disk.
void slotNewSelection()
Tasks needed when changing the selected object Save the user log of the previous selected object...
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
bool isSolarSystem() const
static bool obsListPreferDSS()
Get Prefer Digitized Sky Survey imagery in the observing list.
QString translatedLongName() const
void slotSetTime()
Takes the time from the QTimeEdit box and sets it as the time parameter in the tableview of the Sessi...
void saveCurrentUserLog()
Save the user log text to a file.
An angle, stored as degrees, but expressible in many ways.
void slotGetImage(bool _dss=false)
Downloads the corresponding DSS or SDSS image from the web and displays it.
void slotAddObject(SkyObject *o=NULL, bool session=false, bool update=false)
add a new object to list o pointer to the object to add to the list session flag toggle adding the ob...
void slotWUT()
Open the WUT dialog.
void saveThumbImage()
saves a thumbnail image for the details dialog from the downloaded image
void slotChangeTab(int index)
toggle the setEnabled flags according to current view set the m_currentItem to NULL and clear selecti...
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
QString name2(void) const
virtual DeviceFamily getType()=0
void slotRemoveObject(SkyObject *o=NULL, bool session=false, bool update=false)
Remove skyobject from the observing list.
SkyPoint recomputeCoords(const KStarsDateTime &dt, const GeoLocation *geo=0)
The coordinates for the object on date dt are computed and returned, but the object's internal coordi...
void slotSaveImage()
saves the temporary image permanently
SkyObject * findObjectByName(QString name)
return the object with the name as the passed QString from the Session List, return null otherwise ...
static double zoomFactor()
Get Zoom Factor, in pixels per radian.
void slotUpdate()
Updates the tableviews for the new geolocation and date.
virtual bool setProperty(QObject *)=0
void slotOALExport()
Export a target list to the oal compliant format.
void saveCurrentList()
If the current list has unsaved changes, ask the user about saving it.
KStarsData * data() const
void plot(SkyObject *o)
Plot the SkyObject's Altitude vs Time in the AVTPlotWidget.
void slotDetails()
Show the details window for the selected object.
void setCurrentImage(const SkyObject *o, bool temp=false)
Sets the image parameters for the current object o The passed object for setting the parameters temp ...
virtual QString name(void) const
virtual QString name(void) const
If star is unnamed return "star" otherwise return the name.
void slotRemoveSelectedObjects()
Remove skyobjects which are highlighted in the observing list tool from the observing list...
void readBegin(QString input)
void slotCenterObject()
center the selected object in the display
QString gname(bool useGreekChars=true) const
Returns the genetive name of the star.
This is a subclass of SkyObject.
static QString typeName(const int t)
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
void slotDeleteCurrentImage()
Remove the current image.
void slotLoadWishList()
Load the Wish list from disk.
void slotLocation()
Opens the Location dialog to set the GeoLocation for the sessionlist.
void setLocation(GeoLocation *m_geo)
Set the location for computations to the given location.