TelemetrySchedulerGadgetWidget::TelemetrySchedulerGadgetWidget(QWidget *parent) : QWidget(parent)
{
    m_telemetryeditor = new Ui_TelemetryScheduler();
    m_telemetryeditor->setupUi(this);

    // In case GCS is not in expert mode, hide the apply button
    ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance();
    Core::Internal::GeneralSettings * settings=pm->getObject<Core::Internal::GeneralSettings>();
    if(!settings->useExpertMode())
        m_telemetryeditor->bnApplySchedule->setVisible(false);

    schedulerModel = new SchedulerModel(0, 0, this); //0 Rows and 0 Columns

    telemetryScheduleView = new QFrozenTableViewWithCopyPaste(schedulerModel);
    telemetryScheduleView->setObjectName(QString::fromUtf8("telemetryScheduleView"));
    telemetryScheduleView->setAlternatingRowColors(true);
    telemetryScheduleView->horizontalHeader()->setCascadingSectionResizes(false);
    telemetryScheduleView->horizontalHeader()->setSectionsMovable(true);


    // The dummy table exists only to force the other widgets into the correct place.
    // It is removed and replaced tby the custom copy/paste-enabled table
    int dummyIndex = m_telemetryeditor->gridLayout->indexOf(m_telemetryeditor->tableWidgetDummy);
    int row, col, rowSpan, colSpan;
    m_telemetryeditor->gridLayout->getItemPosition(dummyIndex, &row, &col, &rowSpan, &colSpan);
    m_telemetryeditor->gridLayout->removeWidget(m_telemetryeditor->tableWidgetDummy);
    m_telemetryeditor->tableWidgetDummy->setVisible(false);
    m_telemetryeditor->gridLayout->addWidget(telemetryScheduleView, row, col, rowSpan, colSpan);
    connect(m_telemetryeditor->hideNotPresent, SIGNAL(clicked(bool)), this, SLOT(onHideNotPresent(bool)));
    // Sets the fields in the table to spinboxes
    SpinBoxDelegate *delegate = new SpinBoxDelegate();
    telemetryScheduleView->setItemDelegate(delegate);

    // Connect the before setting any signals
    connect(m_telemetryeditor->bnSaveTelemetryToFile, SIGNAL(clicked()), this, SLOT(saveTelemetryToFile()));
    connect(m_telemetryeditor->bnLoadTelemetryFromFile, SIGNAL(clicked()), this, SLOT(loadTelemetryFromFile()));
    connect(m_telemetryeditor->bnApplySchedule, SIGNAL(clicked()), this, SLOT(applySchedule()));
    connect(m_telemetryeditor->bnSaveSchedule, SIGNAL(clicked()), this, SLOT(saveSchedule()));
    connect(m_telemetryeditor->bnAddTelemetryColumn, SIGNAL(clicked()), this, SLOT(addTelemetryColumn()));
    connect(m_telemetryeditor->bnRemoveTelemetryColumn, SIGNAL(clicked()), this, SLOT(removeTelemetryColumn()));
    connect(schedulerModel, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(dataModel_itemChanged(QStandardItem *)));
    connect(telemetryScheduleView->horizontalHeader(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(changeHorizontalHeader(int)));
    connect(telemetryScheduleView->verticalHeader(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(changeVerticalHeader(int)));
    connect(telemetryScheduleView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(customMenuRequested(QPoint)));
    telemetryScheduleView->setContextMenuPolicy(Qt::CustomContextMenu);

    // Generate the list of UAVOs on left side
    objManager = pm->getObject<UAVObjectManager>();
    Q_ASSERT(objManager != NULL);

    QVector< QVector<UAVDataObject*> > objList = objManager->getDataObjectsVector();
    QStringList strList;
    foreach (QVector<UAVDataObject*> list, objList) {
            if(!list.first()->isSettings()) {
                strList.append(list.first()->getName());
                connect(list.first(), SIGNAL(presentOnHardwareChanged(UAVDataObject*)), this, SLOT(uavoPresentOnHardwareChanged(UAVDataObject*)), Qt::UniqueConnection);
            }
    }
Beispiel #2
0
	void BWSPrefPageWidget::btnSave_clicked()
	{
		QString sf = KFileDialog::getSaveFileName("/home","*",this,i18n("Choose a filename to save under"));

		if(sf.isEmpty())
			return;

		saveSchedule(sf);
	}
 /*private*/ void ScheduleEditFrame::saveNewSchedule() {
     if (!checkName(tr("add"))) {
         return;
     }
     Schedule* schedule = manager->newSchedule(scheduleNameTextField->text());
     scheduleModel->initTable(this, scheduleTable, schedule, _location, _track);
     _schedule = schedule;
     // enable checkboxes
     enableButtons(true);
     saveSchedule();
 }