Пример #1
0
void
ModelEdit::createWidgets()
{
    setCaption("Model Edit");
    menuBar();

    QFrame* main = new QFrame(this);
    QVBox* body = new QVBox(main);
    QFrame* top = new QFrame(body);
    QVBox* right = new QVBox(main);

    QLabel* versionLabel = new QLabel("&Version:", top);
    _version = new LineEdit(top);
    versionLabel->setBuddy(_version);

    QLabel* descLabel = new QLabel("&Description:", top);
    _desc = new MultiLineEdit(top);
    descLabel->setBuddy(_desc);

    QLabel* fromLabel = new QLabel("&From:", top);
    _from = new LineEdit(top);
    fromLabel->setBuddy(_from);

    QGridLayout* topGrid = new QGridLayout(top);
    topGrid->setSpacing(3);
    topGrid->setMargin(3);
    topGrid->setRowStretch(2, 1);
    topGrid->setColStretch(1, 1);
    topGrid->addWidget(versionLabel, 0, 0);
    topGrid->addWidget(_version, 0, 1, AlignLeft | AlignVCenter);
    topGrid->addWidget(descLabel, 1, 0);
    topGrid->addMultiCellWidget(_desc, 1, 2, 1, 1);
    topGrid->addWidget(fromLabel, 3, 0);
    topGrid->addWidget(_from, 3, 1, AlignLeft | AlignVCenter);

    QTabWidget* tabs = new QTabWidget(body);
    QVBox* objects = new QVBox(tabs);
    QVBox* updates = new QVBox(tabs);
    tabs->addTab(objects, tr("Objects"));
    tabs->addTab(updates, tr("Updates"));

    _objects = new ListView(objects);
    _objects->setAllColumnsShowFocus(true);
    _objects->setShowSortIndicator(true);
    _objects->addTextColumn("Name", 20);
    _objects->addTextColumn("Number", 10);
    _objects->addTextColumn("Description", 40);

    QHBox* objectCmds = new QHBox(objects);
    QPushButton* addObject = new QPushButton("Add Object", objectCmds);
    QPushButton* editObject = new QPushButton("Edit Object", objectCmds);
    QPushButton* removeObject = new QPushButton("Remove Object", objectCmds);

    _updates = new ListView(updates);
    _updates->setAllColumnsShowFocus(true);
    _updates->setShowSortIndicator(true);
    _updates->addTextColumn("Number", 10);
    _updates->addTextColumn("Description", 60);

    QHBox* updateCmds = new QHBox(updates);
    QPushButton* addUpdate = new QPushButton("Add Update", updateCmds);
    QPushButton* editUpdate = new QPushButton("Edit Update", updateCmds);
    QPushButton* removeUpdate = new QPushButton("Remove Update", updateCmds);

    QPushButton* ok = new QPushButton("&Ok", right);
    QPushButton* reset = new QPushButton("&Reset", right);
    QPushButton* cancel = new QPushButton("&Cancel", right);

    QGridLayout* grid = new QGridLayout(main);
    grid->setSpacing(3);
    grid->setMargin(3);
    grid->setColStretch(0, 1);
    grid->addWidget(body, 0, 0);
    grid->addWidget(right, 0, 1, AlignTop | AlignLeft);

    connect(ok, SIGNAL(clicked()), this, SLOT(slotOk()));
    connect(reset, SIGNAL(clicked()), this, SLOT(slotReset()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(slotCancel()));
    connect(addObject, SIGNAL(clicked()), this, SLOT(slotAddObject()));
    connect(editObject, SIGNAL(clicked()), this, SLOT(slotEditObject()));
    connect(removeObject, SIGNAL(clicked()), this, SLOT(slotRemoveObject()));
    connect(_objects, SIGNAL(doubleClicked(QListViewItem*)), this,
	    SLOT(slotEditObject()));
    connect(addUpdate, SIGNAL(clicked()), this, SLOT(slotAddObject()));
    connect(editUpdate, SIGNAL(clicked()), this, SLOT(slotEditObject()));
    connect(removeUpdate, SIGNAL(clicked()), this, SLOT(slotRemoveObject()));
    connect(_updates, SIGNAL(doubleClicked(QListViewItem*)), this,
	    SLOT(slotEditUpdate()));

    setCentralWidget(main);

    QPopupMenu* file = new QPopupMenu(this);
    file->insertItem(tr("&Ok"), this, SLOT(slotOk()));
    file->insertItem(tr("&Reset"), this, SLOT(slotReset()));
    file->insertSeparator();
    file->insertItem(tr("&Cancel"), this, SLOT(slotCancel()), ALT+Key_Q);
    menuBar()->insertItem(tr("&File"), file);
}
Пример #2
0
void KSPopupMenu::initPopupMenu( SkyObject *obj, QString name, QString type, QString info,
                                 bool showDetails, bool showObsList, bool showFlags )
{
    KStarsData* data = KStarsData::Instance();
    SkyMap * map = SkyMap::Instance();

    clear();
    bool showLabel = name != i18n("star") && !name.isEmpty();
    if( name.isEmpty() )
        name = i18n( "Empty sky" );

    addFancyLabel( name );
    addFancyLabel( type );
    addFancyLabel( info );
    addFancyLabel( KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName( obj ) );

    //Insert Rise/Set/Transit labels
    SkyObject* o = obj->clone();
    addSeparator();
    addFancyLabel( riseSetTimeLabel(o, true),  -2 );
    addFancyLabel( riseSetTimeLabel(o, false), -2 );
    addFancyLabel( transitTimeLabel(o),        -2 );
    addSeparator();
    delete o;

    // Show 'Select this object' item when in object pointing mode and when obj is not empty sky
    if(map->isInObjectPointingMode() && obj->type() != 21)
    {
        addAction( i18n( "Select this object"), map, SLOT(slotObjectSelected()));
    }

    //Insert item for centering on object
    addAction( i18n( "Center && Track" ), map, SLOT( slotCenter() ) );

    if ( showFlags )
    {
        //Insert actions for flag operations
        initFlagActions( obj );
    }

    //Insert item for measuring distances
    //FIXME: add key shortcut to menu items properly!
    addAction( i18n( "Angular Distance To...            [" ), map, SLOT(slotBeginAngularDistance()) );
    addAction( i18n( "Starhop from here to...            " ), map, SLOT(slotBeginStarHop()) );

    //Insert item for Showing details dialog
    if ( showDetails )
        addAction( i18nc( "Show Detailed Information Dialog", "Details" ), map, SLOT( slotDetail() ) );
    //Insert "Add/Remove Label" item
    if ( showLabel )
    {
        if ( map->isObjectLabeled( obj ) ) {
            addAction( i18n( "Remove Label" ), map, SLOT( slotRemoveObjectLabel() ) );
        } else {
            addAction( i18n( "Attach Label" ), map, SLOT( slotAddObjectLabel() ) );
        }
    }
    // Should show observing list
    if( showObsList ) {
        if ( data->observingList()->contains( obj ) )
            addAction( i18n("Remove From Observing WishList"), data->observingList(), SLOT( slotRemoveObject() ) );
        else
            addAction( i18n("Add to Observing WishList"), data->observingList(), SLOT( slotAddObject() ) );
    }
    // Should we show trail actions
    TrailObject* t = dynamic_cast<TrailObject*>( obj );
    if( t ) {
        if( t->hasTrail() )
            addAction( i18n( "Remove Trail" ), map, SLOT( slotRemovePlanetTrail() ) );
        else
            addAction( i18n( "Add Trail" ), map, SLOT( slotAddPlanetTrail() ) );
    }

    addAction( i18n("Simulate eyepiece view"), map, SLOT( slotEyepieceView() ) );

    addSeparator();
#ifdef HAVE_XPLANET
    if ( obj->isSolarSystem() && obj->type() != SkyObject::COMET ) { // FIXME: We now have asteroids -- so should this not be isMajorPlanet() || Pluto?
        QMenu *xplanetSubmenu = new QMenu();
        xplanetSubmenu->setTitle( i18n( "Print Xplanet view" ) );
        xplanetSubmenu->addAction( i18n( "To screen" ), map, SLOT( slotXplanetToScreen() ) );
        xplanetSubmenu->addAction( i18n( "To file..." ), map, SLOT( slotXplanetToFile() ) );
        addMenu( xplanetSubmenu );
    }
#endif
    addSeparator();
    addINDI();
}
Пример #3
0
Execute::Execute() {
    QWidget *w = new QWidget;
    ui.setupUi( w );
#ifdef Q_OS_OSX
        setWindowFlags(Qt::Tool| Qt::WindowStaysOnTopHint);
#endif

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(w);
    setLayout(mainLayout);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
    mainLayout->addWidget(buttonBox);
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    QPushButton *execB = new QPushButton(i18n("End Session"));
    QPushButton *addObs = new QPushButton(i18n("Manage Observers"));
    execB->setToolTip(i18n("Save and End the current session"));
    buttonBox->addButton(execB, QDialogButtonBox::ActionRole);
    buttonBox->addButton(addObs, QDialogButtonBox::ActionRole);
    connect(execB, SIGNAL(clicked()), this, SLOT(slotEndSession()));
    connect(addObs,SIGNAL(clicked()),this,SLOT(slotObserverAdd()));

    setWindowTitle( i18n( "Execute Session" ) );

    currentTarget = NULL;
    currentObserver = NULL;
    currentScope = NULL;
    currentEyepiece = NULL;
    currentLens = NULL;
    currentFilter = NULL;
    currentSession = NULL;
    nextSession = 0;
    nextObservation = 0;
    nextSite = 0;

    //initialize the global logObject
    logObject = KStarsData::Instance()->logObject();

    //initialize the lists and parameters
    init();
    ui.Target->hide();
    ui.AddObject->hide();
    ui.RemoveObject->hide();
    ui.NextButton->hide();
    ui.NextButton->setEnabled( false );
    ui.Slew->setEnabled( false );

    //make connections
    connect( ui.NextButton, SIGNAL( clicked() ),
             this, SLOT( slotNext() ) );
    connect( ui.Slew, SIGNAL( clicked() ),
             this, SLOT( slotSlew() ) );
    connect( ui.Location, SIGNAL( clicked() ),
             this, SLOT( slotLocation() ) );
    connect( ui.Target, SIGNAL( currentTextChanged(const QString) ),
             this, SLOT( slotSetTarget(QString) ) );
    connect( ui.SessionURL, SIGNAL( leftClickedUrl() ),
             this, SLOT( slotShowSession() ) );
    connect( ui.ObservationsURL, SIGNAL( leftClickedUrl() ),
             this, SLOT( slotShowTargets() ) );
    connect( ui.AddObject, SIGNAL( leftClickedUrl() ),
             this, SLOT( slotAddObject() ) );
    connect( ui.RemoveObject, SIGNAL( leftClickedUrl() ),
             this, SLOT( slotRemoveObject() ) );
}