void KSPopupMenu::initFlagActions( SkyObject *obj ) { KStars *ks = KStars::Instance(); QList<int> flags = ks->data()->skyComposite()->flags()->getFlagsNearPix( obj, 5 ); if ( flags.size() == 0 ) { // There is no flag around clicked SkyObject addAction( i18n( "Add flag..."), ks->map(), SLOT( slotAddFlag() ) ); } else if( flags.size() == 1) { // There is only one flag around clicked SkyObject addAction ( i18n ("Edit flag"), this, SLOT( slotEditFlag() ) ); addAction ( i18n ("Delete flag"), this, SLOT( slotDeleteFlag() ) ); m_CurrentFlagIdx = flags.first(); } else { // There are more than one flags around clicked SkyObject - we need to create submenus QMenu *editMenu = new QMenu ( i18n ( "Edit flag..."), KStars::Instance() ); QMenu *deleteMenu = new QMenu ( i18n ( "Delete flag..."), KStars::Instance() ); connect( editMenu, SIGNAL( triggered(QAction*) ), this, SLOT( slotEditFlag(QAction*) ) ); connect( deleteMenu, SIGNAL( triggered(QAction*) ), this, SLOT( slotDeleteFlag(QAction*) ) ); if ( m_EditActionMapping ) { delete m_EditActionMapping; } if ( m_DeleteActionMapping ) { delete m_DeleteActionMapping; } m_EditActionMapping = new QHash<QAction*, int>; m_DeleteActionMapping = new QHash<QAction*, int>; foreach ( int idx, flags ) { QIcon flagIcon( QPixmap::fromImage( ks->data()->skyComposite()->flags()->image( idx ) ) ); QString flagLabel = ks->data()->skyComposite()->flags()->label( idx ); if ( flagLabel.size() > 35 ) { flagLabel = flagLabel.left( 35 ); flagLabel.append( "..." ); } QAction *editAction = new QAction( flagIcon, flagLabel, ks ); editAction->setIconVisibleInMenu( true ); editMenu->addAction( editAction ); m_EditActionMapping->insert( editAction, idx ); QAction *deleteAction = new QAction( flagIcon, flagLabel, ks ); deleteAction->setIconVisibleInMenu( true ); deleteMenu->addAction( deleteAction ); m_DeleteActionMapping->insert( deleteAction, idx); } addMenu( editMenu ); addMenu( deleteMenu ); }
void WIView::onDetailsButtonClicked() { ///Code taken from WUTDialog::slotDetails() KStars *kstars = KStars::Instance(); SkyObject* so = m_CurSoItem->getSkyObject(); DetailDialog *detail = new DetailDialog(so, kstars->data()->lt(), kstars->data()->geo(), kstars); detail->exec(); delete detail; }
void FindDialog::filterByType() { KStars *p = (KStars *)parent(); SearchList->clear(); // QListBox QString searchFor = SearchBox->text().lower(); // search string ObjectNameList &ObjNames = p->data()->ObjNames; // check if latin names are used ObjNames.setLanguage( Options::useLatinConstellNames() ); for ( SkyObjectName *name = ObjNames.first( searchFor ); name; name = ObjNames.next() ) { //Special case: match SkyObject Type 0 with Filter==1 (stars) if ( name->skyObject()->type() == Filter || (name->skyObject()->type() == 0 && Filter == 1 ) ) { if ( name->text().lower().startsWith( searchFor ) ) { // for stars, don't show the ones below the faint limit if (Filter!=1 || name->skyObject()->mag() <= Options::magLimitDrawStar() ) { new SkyObjectNameListItem ( SearchList, name ); } } } } setListItemEnabled(); // Automatically highlight first item SearchBox->setFocus(); // set cursor to QLineEdit }
void modCalcAzel::showCurrentDateTime (void) { KStars *ks = (KStars*) parent()->parent()->parent(); KStarsDateTime dt = ks->data()->geo()->LTtoUT( KStarsDateTime::currentDateTime() ); datBox->setDate( dt.date() ); timBox->setTime( dt.time() ); dateBoxBatch->setDate( dt.date() ); utBoxBatch->setTime( dt.time() ); }
MapCanvas::MapCanvas(QWidget *parent, const char *name ) : QWidget(parent,name) { BGColor = "#33A"; setBackgroundColor( QColor( BGColor ) ); setBackgroundMode( QWidget::NoBackground ); Canvas = new QPixmap(); bgImage = new QPixmap(); LocationDialog *ld = (LocationDialog *)topLevelWidget(); KStars *ks = (KStars *)ld->parent(); QString bgFile = ks->data()->stdDirs->findResource( "data", "kstars/geomap.png" ); bgImage->load( bgFile, "PNG" ); }
void FindDialog::filter() { //Filter the list of names with the string in the SearchBox KStars *p = (KStars *)parent(); SearchList->clear(); ObjectNameList &ObjNames = p->data()->ObjNames; // check if latin names are used ObjNames.setLanguage( Options::useLatinConstellNames() ); QString searchFor = SearchBox->text().lower(); for ( SkyObjectName *name = ObjNames.first( searchFor ); name; name = ObjNames.next() ) { if ( name->text().lower().startsWith( searchFor ) ) { new SkyObjectNameListItem ( SearchList, name ); /* if ( i++ >= 5000 ) { //Every 5000 name insertions, kapp->processEvents ( 50 ); //spend 50 msec processing KApplication events i = 0; }*/ } } setListItemEnabled(); // Automatically highlight first item SearchBox->setFocus(); // set cursor to QLineEdit }
void PlanetViewer::slotToday() { KStars *ks = (KStars*)parent(); pw->dateBox->setDate( ks->data()->lt().date() ); }
void MapCanvas::paintEvent( QPaintEvent * ) { QPainter pcanvas; LocationDialog *ld = (LocationDialog *)topLevelWidget(); KStars *ks = (KStars *)ld->parent(); //prepare the canvas pcanvas.begin( Canvas ); // pcanvas.fillRect( 0, 0, width(), height(), QBrush( QColor( BGColor ) ) ); pcanvas.drawPixmap( 0, 0, *bgImage ); // pcanvas.setBrush( white ); pcanvas.setPen( QPen( QColor( "SlateGrey" ) ) ); //Draw cities QPoint o; for ( GeoLocation *g=ks->data()->geoList.first(); g; g = ks->data()->geoList.next() ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) { pcanvas.drawPoint( o.x(), o.y() ); } } //redraw the cities that appear in the filtered list, with a white pen //If the list has not been filtered, skip the redraw. if ( ld->filteredList()->count() ) { pcanvas.setPen( white ); for ( GeoLocation *g=ld->filteredList()->first(); g; g = ld->filteredList()->next() ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) { pcanvas.drawPoint( o.x(), o.y() ); } } } GeoLocation *g = ld->selectedCity(); if ( g ) { o.setX( int( g->lng()->Degrees() + origin.x() ) ); o.setY( height() - int( g->lat()->Degrees() + origin.y() ) ); pcanvas.setPen( red ); pcanvas.setBrush( red ); pcanvas.drawEllipse( o.x()-3, o.y()-3, 6, 6 ); pcanvas.moveTo( o.x()-16, o.y() ); pcanvas.lineTo( o.x()-8, o.y() ); pcanvas.moveTo( o.x()+8, o.y() ); pcanvas.lineTo( o.x()+16, o.y() ); pcanvas.moveTo( o.x(), o.y()-16 ); pcanvas.lineTo( o.x(), o.y()-8 ); pcanvas.moveTo( o.x(), o.y()+8 ); pcanvas.lineTo( o.x(), o.y()+16 ); pcanvas.setPen( white ); pcanvas.setBrush( white ); } pcanvas.end(); bitBlt( this, 0, 0, Canvas ); }