コード例 #1
0
ファイル: qt4.cpp プロジェクト: m8a/uim
void GroupPageWidget::setDefault()
{
    foreach ( UimCustomItemIface *iface, m_customIfaceList )
        iface->setDefault();
}
コード例 #2
0
// Returns information on verified peers.
Json::Value
OverlayImpl::json ()
{
    return foreach (get_peer_json());
}
コード例 #3
0
ファイル: ofApp.cpp プロジェクト: AnnaKolla/Kolla075-sims2014
 void rotate(float x, float y, float z) {
     foreach(vv,v) vv.rotate(x,y,z); endfor
 }
コード例 #4
0
void XYInterpolationCurveDock::xDataColumnChanged(const QModelIndex& index) {
	AbstractAspect* aspect = static_cast<AbstractAspect*>(index.internalPointer());
	AbstractColumn* column = 0;
	if (aspect) {
		column = dynamic_cast<AbstractColumn*>(aspect);
		Q_ASSERT(column);
	}

	foreach(XYCurve* curve, m_curvesList)
		dynamic_cast<XYInterpolationCurve*>(curve)->setXDataColumn(column);

	// disable types that need more data points
	if(column != 0) {
		unsigned int n=0;
		for(int row=0;row < column->rowCount();row++)
			if (!std::isnan(column->valueAt(row)) && !column->isMasked(row)) 
				n++;

		const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(uiGeneralTab.cbType->model());
		QStandardItem* item = model->item(XYInterpolationCurve::Polynomial);
		if(n < gsl_interp_type_min_size(gsl_interp_polynomial) || n>100) {	// not good for many points
			item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
			if(uiGeneralTab.cbType->currentIndex() == XYInterpolationCurve::Polynomial)
				uiGeneralTab.cbType->setCurrentIndex(0);
		}
		else
			item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

		item = model->item(XYInterpolationCurve::CSpline);
		if(n < gsl_interp_type_min_size(gsl_interp_cspline)) {
			item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
			if(uiGeneralTab.cbType->currentIndex() == XYInterpolationCurve::CSpline)
				uiGeneralTab.cbType->setCurrentIndex(0);
		}
		else
			item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

		item = model->item(XYInterpolationCurve::CSplinePeriodic);
		if(n < gsl_interp_type_min_size(gsl_interp_cspline_periodic)) {
			item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
			if(uiGeneralTab.cbType->currentIndex() == XYInterpolationCurve::CSplinePeriodic)
				uiGeneralTab.cbType->setCurrentIndex(0);
		}
		else
			item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

		item = model->item(XYInterpolationCurve::Akima);
		if(n < gsl_interp_type_min_size(gsl_interp_akima)) {
			item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
			if(uiGeneralTab.cbType->currentIndex() == XYInterpolationCurve::Akima)
				uiGeneralTab.cbType->setCurrentIndex(0);
		}
		else
			item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

		item = model->item(XYInterpolationCurve::AkimaPeriodic);
		if(n < gsl_interp_type_min_size(gsl_interp_akima_periodic)) {
			item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
			if(uiGeneralTab.cbType->currentIndex() == XYInterpolationCurve::AkimaPeriodic)
				uiGeneralTab.cbType->setCurrentIndex(0);
		}
		else
			item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);

#if GSL_MAJOR_VERSION >= 2
		item = model->item(XYInterpolationCurve::Steffen);
		if(n < gsl_interp_type_min_size(gsl_interp_steffen)) {
			item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
			if(uiGeneralTab.cbType->currentIndex() == XYInterpolationCurve::Steffen)
				uiGeneralTab.cbType->setCurrentIndex(0);
		}
		else
			item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
#endif
		// own types work with 2 or more points
	}
}
コード例 #5
0
ModifyActivityForm::ModifyActivityForm(QWidget* parent, int id, int activityGroupId): QDialog(parent)
{
	setupUi(this);

	durList.clear();
	durList.append(duration1SpinBox);
	durList.append(duration2SpinBox);
	durList.append(duration3SpinBox);
	durList.append(duration4SpinBox);
	durList.append(duration5SpinBox);
	durList.append(duration6SpinBox);
	durList.append(duration7SpinBox);
	durList.append(duration8SpinBox);
	durList.append(duration9SpinBox);
	durList.append(duration10SpinBox);
	durList.append(duration11SpinBox);
	durList.append(duration12SpinBox);
	durList.append(duration13SpinBox);
	durList.append(duration14SpinBox);
	durList.append(duration15SpinBox);
	durList.append(duration16SpinBox);
	durList.append(duration17SpinBox);
	durList.append(duration18SpinBox);
	durList.append(duration19SpinBox);
	durList.append(duration20SpinBox);
	durList.append(duration21SpinBox);
	durList.append(duration22SpinBox);
	durList.append(duration23SpinBox);
	durList.append(duration24SpinBox);
	durList.append(duration25SpinBox);
	durList.append(duration26SpinBox);
	durList.append(duration27SpinBox);
	durList.append(duration28SpinBox);
	durList.append(duration29SpinBox);
	durList.append(duration30SpinBox);
	durList.append(duration31SpinBox);
	durList.append(duration32SpinBox);
	durList.append(duration33SpinBox);
	durList.append(duration34SpinBox);
	durList.append(duration35SpinBox);
	
	for(int i=0; i<MAX_SPLIT_OF_AN_ACTIVITY; i++)
		dur(i)->setMaximum(gt.rules.nHoursPerDay);
	
	activList.clear();
	activList.append(active1CheckBox);
	activList.append(active2CheckBox);
	activList.append(active3CheckBox);
	activList.append(active4CheckBox);
	activList.append(active5CheckBox);
	activList.append(active6CheckBox);
	activList.append(active7CheckBox);
	activList.append(active8CheckBox);
	activList.append(active9CheckBox);
	activList.append(active10CheckBox);
	activList.append(active11CheckBox);
	activList.append(active12CheckBox);
	activList.append(active13CheckBox);
	activList.append(active14CheckBox);
	activList.append(active15CheckBox);
	activList.append(active16CheckBox);
	activList.append(active17CheckBox);
	activList.append(active18CheckBox);
	activList.append(active19CheckBox);
	activList.append(active20CheckBox);
	activList.append(active21CheckBox);
	activList.append(active22CheckBox);
	activList.append(active23CheckBox);
	activList.append(active24CheckBox);
	activList.append(active25CheckBox);
	activList.append(active26CheckBox);
	activList.append(active27CheckBox);
	activList.append(active28CheckBox);
	activList.append(active29CheckBox);
	activList.append(active30CheckBox);
	activList.append(active31CheckBox);
	activList.append(active32CheckBox);
	activList.append(active33CheckBox);
	activList.append(active34CheckBox);
	activList.append(active35CheckBox);
	
	allTeachersListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	selectedTeachersListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	allStudentsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	selectedStudentsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	allActivityTagsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	selectedActivityTagsListWidget->setSelectionMode(QAbstractItemView::SingleSelection);

	connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
	connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
	connect(clearTeacherPushButton, SIGNAL(clicked()), this, SLOT(clearTeachers()));
	connect(clearStudentsPushButton, SIGNAL(clicked()), this, SLOT(clearStudents()));
	connect(allTeachersListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addTeacher()));
	connect(selectedTeachersListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(removeTeacher()));
	connect(allStudentsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addStudents()));
	connect(selectedStudentsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(removeStudents()));
	connect(clearActivityTagPushButton, SIGNAL(clicked()), this, SLOT(clearActivityTags()));
	connect(allActivityTagsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addActivityTag()));
	connect(selectedActivityTagsListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(removeActivityTag()));
	connect(showYearsCheckBox, SIGNAL(toggled(bool)), this, SLOT(showYearsChanged()));
	connect(showGroupsCheckBox, SIGNAL(toggled(bool)), this, SLOT(showGroupsChanged()));
	connect(showSubgroupsCheckBox, SIGNAL(toggled(bool)), this, SLOT(showSubgroupsChanged()));
	connect(helpPushButton, SIGNAL(clicked()), this, SLOT(help()));

	centerWidgetOnScreen(this);
	restoreFETDialogGeometry(this);

	QSize tmp3=subjectsComboBox->minimumSizeHint();
	Q_UNUSED(tmp3);
	
	this->_id=id;
	this->_activityGroupId=activityGroupId;
	for(int i=0; i<gt.rules.activitiesList.size(); i++){
		Activity* act=gt.rules.activitiesList[i];
		if(act->activityGroupId==this->_activityGroupId && act->id==this->_id)
			this->_activity=act;
	}
			
	this->_teachers=this->_activity->teachersNames;
	this->_subject = this->_activity->subjectName;
	this->_activityTags = this->_activity->activityTagsNames;
	this->_students=this->_activity->studentsNames;
	
	int nSplit;
	
	if(this->_activityGroupId!=0){
		nSplit=0;
		for(int i=0; i<gt.rules.activitiesList.size(); i++){
			Activity* act=gt.rules.activitiesList[i];
			if(act->activityGroupId==this->_activityGroupId){
				if(nSplit>=MAX_SPLIT_OF_AN_ACTIVITY){
					assert(0);
				}
				else{
					if(this->_id==act->id)
						subactivitiesTabWidget->setCurrentIndex(nSplit);
					dur(nSplit)->setValue(act->duration);
					activ(nSplit)->setChecked(act->active);
					nSplit++;
				}
			}
		}
	}
	else{
		nSplit=1;
		dur(0)->setValue(this->_activity->duration);
		activ(0)->setChecked(this->_activity->active);
		subactivitiesTabWidget->setCurrentIndex(0);
	}

	splitSpinBox->setMinimum(nSplit);
	splitSpinBox->setMaximum(nSplit);
	splitSpinBox->setValue(nSplit);
	
	nStudentsSpinBox->setMinimum(-1);
	nStudentsSpinBox->setMaximum(MAX_ROOM_CAPACITY);
	nStudentsSpinBox->setValue(-1);
	
	if(this->_activity->computeNTotalStudents==false)
		nStudentsSpinBox->setValue(this->_activity->nTotalStudents);
	
	updateStudentsListWidget();
	updateTeachersListWidget();
	updateSubjectsComboBox();
	updateActivityTagsListWidget();
	
	selectedStudentsListWidget->clear();
	for(QStringList::Iterator it=this->_students.begin(); it!=this->_students.end(); it++)
		selectedStudentsListWidget->addItem(*it);

	for(int i=0; i<MAX_SPLIT_OF_AN_ACTIVITY; i++)
		if(i<nSplit)
			subactivitiesTabWidget->setTabEnabled(i, true);
		else
			subactivitiesTabWidget->setTabEnabled(i, false);
			
	okPushButton->setDefault(true);
	okPushButton->setFocus();

	foreach(Teacher* tch, gt.rules.teachersList)
		teacherNamesSet.insert(tch->name);
	foreach(Subject* sbj, gt.rules.subjectsList)
		subjectNamesSet.insert(sbj->name);
	foreach(ActivityTag* at, gt.rules.activityTagsList)
		activityTagNamesSet.insert(at->name);
	/*foreach(StudentsYear* year, gt.rules.yearsList){
		numberOfStudentsHash.insert(year->name, year->numberOfStudents);
		foreach(StudentsGroup* group, year->groupsList){
			numberOfStudentsHash.insert(group->name, group->numberOfStudents);
			foreach(StudentsSubgroup* subgroup, group->subgroupsList){
				numberOfStudentsHash.insert(subgroup->name, subgroup->numberOfStudents);
			}
		}
	}*/
}
コード例 #6
0
bool QtUiApplication::init()
{
    if (Quassel::init()) {
        // FIXME: MIGRATION 0.3 -> 0.4: Move database and core config to new location
        // Move settings, note this does not delete the old files
#ifdef Q_OS_MAC
        QSettings newSettings("quassel-irc.org", "quasselclient");
#else

# ifdef Q_OS_WIN
        QSettings::Format format = QSettings::IniFormat;
# else
        QSettings::Format format = QSettings::NativeFormat;
# endif

        QString newFilePath = Quassel::configDirPath() + "quasselclient"
                              + ((format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini"));
        QSettings newSettings(newFilePath, format);
#endif /* Q_OS_MAC */

        if (newSettings.value("Config/Version").toUInt() == 0) {
#     ifdef Q_OS_MAC
            QString org = "quassel-irc.org";
#     else
            QString org = "Quassel Project";
#     endif
            QSettings oldSettings(org, "Quassel Client");
            if (oldSettings.allKeys().count()) {
                qWarning() << "\n\n*** IMPORTANT: Config and data file locations have changed. Attempting to auto-migrate your client settings...";
                foreach(QString key, oldSettings.allKeys())
                newSettings.setValue(key, oldSettings.value(key));
                newSettings.setValue("Config/Version", 1);
                qWarning() << "*   Your client settings have been migrated to" << newSettings.fileName();
                qWarning() << "*** Migration completed.\n\n";
            }
        }

        // MIGRATION end

        // check settings version
        // so far, we only have 1
        QtUiSettings s;
        if (s.version() != 1) {
            qCritical() << "Invalid client settings version, terminating!";
            return false;
        }

        // Set the icon theme
        if (Quassel::isOptionSet("icontheme"))
            QIcon::setThemeName(Quassel::optionValue("icontheme"));
        else if (QIcon::themeName().isEmpty())
            // Some platforms don't set a default icon theme; chances are we can find our bundled Oxygen theme though
            QIcon::setThemeName("oxygen");

        // session resume
        QtUi *gui = new QtUi();
        Client::init(gui);
        // init gui only after the event loop has started
        // QTimer::singleShot(0, gui, SLOT(init()));
        gui->init();
        resumeSessionIfPossible();
        return true;
    }
    return false;
}
コード例 #7
0
ファイル: device.cpp プロジェクト: stbuehler/nut
	Environment::~Environment() {
		foreach (Interface* iface, m_ifs)
			delete iface;
		m_ifs.clear();
	}
コード例 #8
0
ファイル: neuronslayer.cpp プロジェクト: mnowator/NN-XOR
void NeuronsLayer::setTeachingFactor(double teachningFactor)
{
    foreach( Neuron* neuron, m_neurons )
        neuron->setTeachingFactor(teachningFactor);
}
コード例 #9
0
ファイル: UBMimeData.cpp プロジェクト: Ascaf0/Sankore-3.1
UBMimeDataGraphicsItem::~UBMimeDataGraphicsItem()
{
        foreach(UBItem* item, mItems)
            delete item;
}
コード例 #10
0
ファイル: main.cpp プロジェクト: eriser/mmsynth
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QString audiosystem="alsa";

    QStringList synths;
    QStringList args=a.arguments();
    args.removeAt(0);
    // Load just synth4k or as many synths as passed as args.
    foreach(QString opt, args) {
        if (opt=="--help") {
            help(argv[0]);
            exit(1);
        }
        else if (opt=="--license") {
            license();
            exit(1);
        }
        else if (opt.startsWith("--midi=")) {
            WARNING("--midi Not yet");
            exit(1);
        }
        else if (opt.startsWith("--audio=")) {
            audiosystem=opt.section("=",1);
            if (audiosystem=="help") {
                audioHelp();
                exit(1);
            }
        }
        else if (opt.startsWith("--")) {
            WARNING("Unknown option");
            help(argv[0]);
            exit(2);
        }
        else
            synths.append(opt);
    }

    if (synths.count()==0)
        synths.append("synth4k");

    MainWindow w;

    bool ok;
    AlsaMidi alsamidi(&w);
    ok=alsamidi.init();
    if (!ok) {
        ERROR("Cant initialize MIDI device!");
        exit(1);
    }


    Audio *audio=Audio::createAudio(audiosystem, &w);
    ok=audio && audio->init();
    if (!ok) {
        ERROR("Cant initialize AUDIO device!");
        exit(1);
    }

    w.setMidi(&alsamidi);
    w.setAudio(audio);

    foreach(QString s, synths)
        w.addSynth(s);

    w.show();
    return a.exec();
}
コード例 #11
0
ファイル: predindex.cpp プロジェクト: grote/oclingo
void PredIndex::bind(Grounder *grounder, int binder)
{
	ValVec::const_iterator j = bindVec_.begin() + *current_;
	foreach(uint32_t var, bind_)
		grounder->val(var, *j++, binder);
}
コード例 #12
0
void OpenPdfPresenter::printAvailableTransitions() {
	cout << "Possible transitions:\n";

	foreach(SlideTransition* transition, TransitionFactory::getInstance()->getAllTransitions())
		cout << "\t" << transition->getName() << "\t" << transition->getDesc() << "\n";
}
コード例 #13
0
ファイル: maneuvering.cpp プロジェクト: popkc/QSanguosha-v2
ManeuveringPackage::ManeuveringPackage()
    : Package("maneuvering", Package::CardPack)
{
    QList<Card *> cards;

    // spade
    cards << new GudingBlade(Card::Spade, 1)
        << new Vine(Card::Spade, 2)
        << new Analeptic(Card::Spade, 3)
        << new ThunderSlash(Card::Spade, 4)
        << new ThunderSlash(Card::Spade, 5)
        << new ThunderSlash(Card::Spade, 6)
        << new ThunderSlash(Card::Spade, 7)
        << new ThunderSlash(Card::Spade, 8)
        << new Analeptic(Card::Spade, 9)
        << new SupplyShortage(Card::Spade, 10)
        << new IronChain(Card::Spade, 11)
        << new IronChain(Card::Spade, 12)
        << new Nullification(Card::Spade, 13);
    // club
    cards << new SilverLion(Card::Club, 1)
        << new Vine(Card::Club, 2)
        << new Analeptic(Card::Club, 3)
        << new SupplyShortage(Card::Club, 4)
        << new ThunderSlash(Card::Club, 5)
        << new ThunderSlash(Card::Club, 6)
        << new ThunderSlash(Card::Club, 7)
        << new ThunderSlash(Card::Club, 8)
        << new Analeptic(Card::Club, 9)
        << new IronChain(Card::Club, 10)
        << new IronChain(Card::Club, 11)
        << new IronChain(Card::Club, 12)
        << new IronChain(Card::Club, 13);

    // heart
    cards << new Nullification(Card::Heart, 1)
        << new FireAttack(Card::Heart, 2)
        << new FireAttack(Card::Heart, 3)
        << new FireSlash(Card::Heart, 4)
        << new Peach(Card::Heart, 5)
        << new Peach(Card::Heart, 6)
        << new FireSlash(Card::Heart, 7)
        << new Jink(Card::Heart, 8)
        << new Jink(Card::Heart, 9)
        << new FireSlash(Card::Heart, 10)
        << new Jink(Card::Heart, 11)
        << new Jink(Card::Heart, 12)
        << new Nullification(Card::Heart, 13);

    // diamond
    cards << new Fan(Card::Diamond, 1)
        << new Peach(Card::Diamond, 2)
        << new Peach(Card::Diamond, 3)
        << new FireSlash(Card::Diamond, 4)
        << new FireSlash(Card::Diamond, 5)
        << new Jink(Card::Diamond, 6)
        << new Jink(Card::Diamond, 7)
        << new Jink(Card::Diamond, 8)
        << new Analeptic(Card::Diamond, 9)
        << new Jink(Card::Diamond, 10)
        << new Jink(Card::Diamond, 11)
        << new FireAttack(Card::Diamond, 12);

    DefensiveHorse *hualiu = new DefensiveHorse(Card::Diamond, 13);
    hualiu->setObjectName("hualiu");

    cards << hualiu;

    foreach(Card *card, cards)
        card->setParent(this);

    skills << new GudingBladeSkill << new FanSkill
        << new VineSkill << new SilverLionSkill;
}
コード例 #14
0
void OutputPaneManager::init()
{
    ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
    const Context globalContext(Constants::C_GLOBAL);

    // Window->Output Panes
    ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
    mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
    mpanes->menu()->setTitle(tr("Output &Panes"));
    mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
    mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");

    Command *cmd;

    cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext);
    m_clearButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext);
    cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
    m_prevToolButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext);
    m_nextToolButton->setDefaultAction(cmd->action());
    cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext);
    cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9")));
    cmd->setAttribute(Command::CA_UpdateText);
    cmd->setAttribute(Command::CA_UpdateIcon);
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
    connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
    m_minMaxButton->setDefaultAction(cmd->action());

    mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup");

    QFontMetrics titleFm = m_titleLabel->fontMetrics();
    int minTitleWidth = 0;

    m_panes = ExtensionSystem::PluginManager::getObjects<IOutputPane>();
    qSort(m_panes.begin(), m_panes.end(), &comparePanes);
    const int n = m_panes.size();

    int shortcutNumber = 1;
    const Id baseId = Id("QtCreator.Pane.");
    for (int i = 0; i != n; ++i) {
        IOutputPane *outPane = m_panes.at(i);
        const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
        QTC_CHECK(idx == i);

        connect(outPane, SIGNAL(showPage(int)), this, SLOT(showPage(int)));
        connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
        connect(outPane, SIGNAL(togglePage(int)), this, SLOT(togglePage(int)));
        connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
        connect(outPane, SIGNAL(flashButton()), this, SLOT(flashButton()));
        connect(outPane, SIGNAL(setBadgeNumber(int)), this, SLOT(setBadgeNumber(int)));

        QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
        QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
        toolButtonsLayout->setMargin(0);
        toolButtonsLayout->setSpacing(0);
        foreach (QWidget *toolButton, outPane->toolBarWidgets())
            toolButtonsLayout->addWidget(toolButton);
        toolButtonsLayout->addStretch(5);
        toolButtonsContainer->setLayout(toolButtonsLayout);

        m_opToolBarWidgets->addWidget(toolButtonsContainer);

        minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName()));

        QString suffix = outPane->displayName().simplified();
        suffix.remove(QLatin1Char(' '));
        const Id id = baseId.withSuffix(suffix);
        QAction *action = new QAction(outPane->displayName(), this);
        Command *cmd = ActionManager::registerAction(action, id, globalContext);

        mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
        m_actions.append(cmd->action());
        m_ids.append(id);

        cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
        OutputPaneToggleButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
                                                                    cmd->action());
        ++shortcutNumber;
        m_buttonsWidget->layout()->addWidget(button);
        m_buttons.append(button);
        connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered()));

        bool visible = outPane->priorityInStatusBar() != -1;
        button->setVisible(visible);

        connect(cmd->action(), SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
    }

    m_titleLabel->setMinimumWidth(minTitleWidth + m_titleLabel->contentsMargins().left()
                                  + m_titleLabel->contentsMargins().right());
    m_buttonsWidget->layout()->addWidget(m_manageButton);
    connect(m_manageButton, SIGNAL(clicked()), this, SLOT(popupMenu()));

    readSettings();
}
コード例 #15
0
ファイル: obj_npc.cpp プロジェクト: lighthouse64/PGE-Project
bool ConfigManager::loadLevelNPC()
{
    unsigned int i;

    obj_npc snpc;
    unsigned long npc_total=0;
    PGESTRING npc_ini = config_dir + "lvl_npc.ini";

    if(!QFile::exists(npc_ini))
    {
        addError(PGESTRING("ERROR LOADING lvl_npc.ini: file does not exist"), QtCriticalMsg);
        PGE_MsgBox msgBox(NULL, PGESTRING("ERROR LOADING lvl_npc.ini: file does not exist"),
                          PGE_MsgBox::msg_fatal);
        msgBox.exec();
        return false;
    }


    QSettings npcset(npc_ini, QSettings::IniFormat);
    npcset.setIniCodec("UTF-8");

    lvl_npc_indexes.clear();   //Clear old

    npcset.beginGroup("npc-main");
        npc_total =                 npcset.value("total", "0").toInt();
        marker_npc.bubble =         npcset.value("bubble", "283").toInt();
        marker_npc.egg =            npcset.value("egg", "96").toInt();
        marker_npc.lakitu =         npcset.value("lakitu", "284").toInt();
        marker_npc.buried =         npcset.value("buried", "91").toInt();
        marker_npc.ice_cube =       npcset.value("icecube", "91").toInt();
        marker_npc.iceball =        npcset.value("iceball", "265").toInt();
        marker_npc.fireball =       npcset.value("fireball", "13").toInt();
        marker_npc.hammer =         npcset.value("hammer", "171").toInt();
        marker_npc.boomerang =      npcset.value("boomerang", "292").toInt();
        marker_npc.coin_in_block =  npcset.value("coin-in-block", "10").toInt();

      marker_npc.phs_gravity_accel= npcset.value("physics-gravity-acceleration", 16.25).toFloat();
      marker_npc.phs_max_fall_speed=npcset.value("physics-max-fall-speed", 8).toFloat();

        marker_npc.eff_lava_burn =  npcset.value("effect-lava-burn", "13").toInt();
    npcset.endGroup();

    /*************Buffers*********************/
    int defGFX_h = 0;
    int combobox_size = 0;
    /*************Buffers*********************/

    if(npc_total==0)
    {
        PGE_MsgBox::error(PGESTRING("ERROR LOADING lvl_npc.ini: number of items not define, or empty config"));
        return false;
    }

    for(i=1; i<= npc_total; i++)
    {

        snpc.isInit = false;
        snpc.image = NULL;
        snpc.textureArrayId = 0;
        snpc.animator_ID = 0;
        npcset.beginGroup( PGESTRING("npc-"+PGESTRING::number(i)) );
        snpc.name =         npcset.value("name", "").toString();
        if(snpc.name.isEmpty())
        {
            PGE_MsgBox::warn(PGESTRING("NPC-%1 Item name isn't defined").arg(i));
            goto skipNPC;
        }

        snpc.group =        npcset.value("group", "_NoGroup").toString();
        snpc.category =     npcset.value("category", "_Other").toString();

        snpc.image_n =           npcset.value("image", "").toString();
        /***************Load image*******************/
        imgFile = npcset.value("image", "").toString();
        {
            PGESTRING err;
            GraphicsHelps::loadMaskedImage(npcPath, imgFile, snpc.mask_n, err, &snpc.image_size);
            snpc.image_n = imgFile;
            if( imgFile=="" )
            {
                addError(PGESTRING("NPC-%1 Image filename isn't defined.\n%2").arg(i).arg(err));
                goto skipNPC;
            }
        }
        /***************Load image*end***************/

        snpc.algorithm_script = npcset.value("algorithm", PGESTRING("npc-%1.lua").arg(i) ).toString();
        snpc.effect_1 =     npcset.value("default-effect", "10").toInt();
        snpc.effect_2 =     npcset.value("shell-effect", "10").toInt();

        //Physics
        snpc.height =               npcset.value("fixture-height", "0").toInt();//Leaved for compatibility
        snpc.height =               npcset.value("physical-height", snpc.height).toInt();
            NumberLimiter::apply(snpc.height, 1u);
        snpc.width =                npcset.value("fixture-width", "0").toInt();//Leaved for compatibility
        snpc.width =                npcset.value("physical-width", snpc.width).toInt();
            NumberLimiter::apply(snpc.width, 1u);
        snpc.block_npc =            npcset.value("block-npc", false).toBool();
        snpc.block_npc_top =        npcset.value("block-npc-top", false).toBool();
        snpc.block_player =         npcset.value("block-player", false).toBool();
        snpc.block_player_top =     npcset.value("block-player-top", false).toBool();
        snpc.collision_with_blocks= npcset.value("collision-blocks", false).toBool();
        snpc.gravity =              npcset.value("gravity", false).toBool();
        snpc.adhesion =             npcset.value("adhesion", false).toBool();

        snpc.container =                  npcset.value("container", false).toBool();
        snpc.contents_id =                (unsigned long)npcset.value("contents-id", "0").toULongLong();
        snpc.container_elastic =          npcset.value("container-elastic", false).toBool();
        snpc.container_elastic_border_w = npcset.value("container-elastic-border-w", "4").toInt();
            NumberLimiter::apply(snpc.container_elastic_border_w, 0);
        snpc.container_show_contents    = npcset.value("container-show-contents", true).toBool();
        snpc.container_content_z_offset = npcset.value("container-content-z-offset", "-0.00001").toFloat();
        snpc.container_crop_contents    = npcset.value("container-crop-contents", false).toBool();
        snpc.container_align_contents   = npcset.value("container-align-contents", "0").toInt();

        snpc.no_npc_collions =      npcset.value("no-npc-collisions", "0").toBool();

        //Graphics
        snpc.gfx_offset_x = npcset.value("gfx-offset-x", "0").toInt();
        snpc.gfx_offset_y = npcset.value("gfx-offset-y", "0").toInt();
        snpc.framestyle = npcset.value("frame-style", "0").toInt();
            NumberLimiter::apply(snpc.framestyle, 0, 4);
        snpc.frames = npcset.value("frames", "1").toInt();
            NumberLimiter::apply(snpc.frames, 1u);

        /****************Calculating of default frame height******************/
        switch(snpc.framestyle)
        {
            case 0: defGFX_h = (int)round(snpc.image_size.h() / snpc.frames); break;
            case 1: defGFX_h = (int)round((snpc.image_size.h() / snpc.frames)/2 ); break;
            case 2: defGFX_h = (int)round((snpc.image_size.h()/snpc.frames)/4); break;
            case 3: defGFX_h = (int)round((snpc.image_size.h()/snpc.frames)/4); break;
            case 4: defGFX_h = (int)round((snpc.image_size.h()/snpc.frames)/8); break;
            default:defGFX_h = 0; break;
        }
        /****************Calculating of default frame height**end*************/

        snpc.custom_physics_to_gfx= npcset.value("physics-to-gfx", true).toBool();
        snpc.gfx_h =                npcset.value("gfx-height", PGESTRING::number(defGFX_h) ).toInt();
            NumberLimiter::apply(snpc.gfx_h, 1);
        snpc.gfx_w =                npcset.value("gfx-width", PGESTRING::number(snpc.image_size.w()) ).toInt();
            NumberLimiter::apply(snpc.gfx_w, 1);
        snpc.framespeed =           npcset.value("frame-speed", "128").toInt();
            NumberLimiter::apply(snpc.framespeed, 1u);
        snpc.display_frame =        npcset.value("display-frame", "0").toInt();
            NumberLimiter::apply(snpc.display_frame, 0u);
        snpc.foreground =           npcset.value("foreground", false).toBool();
        snpc.background =           npcset.value("background", false).toBool();
        snpc.ani_directed_direct =  npcset.value("animation-directed-direction", false).toBool();
        snpc.ani_direct =           npcset.value("animation-direction", false).toBool();
        snpc.ani_bidir =            npcset.value("animation-bidirectional", false).toBool();

        snpc.custom_animate =   npcset.value("custom-animation", false).toBool();
        snpc.custom_ani_alg =   npcset.value("custom-animation-alg", "0").toInt();
        snpc.custom_ani_fl =    npcset.value("custom-animation-fl", "0").toInt();
        snpc.custom_ani_el =    npcset.value("custom-animation-el", "-1").toInt();
        snpc.custom_ani_fr =    npcset.value("custom-animation-fr", "0").toInt();
        snpc.custom_ani_er =    npcset.value("custom-animation-er", "-1").toInt();

        /*************Build custom animation settings***************/
        snpc.frames_left.clear();
        snpc.frames_right.clear();
        if(snpc.custom_ani_alg==2)
        {
            PGESTRINGList tmp;
            PGESTRING common = npcset.value("ani-frames-cmn", "0").toString(); // Common frames list
            tmp = npcset.value("ani-frames-left", common).toString().remove(' ').split(","); //left direction
            foreach(PGESTRING x, tmp)
                snpc.frames_left.push_back(x.toInt());
            tmp = npcset.value("ani-frames-right", common).toString().remove(' ').split(","); //right direction
            foreach(PGESTRING x, tmp)
                snpc.frames_right.push_back(x.toInt());

        }
        /*************Build custom animation settings**end**********/


        /***************GRID And snap*********************************/
        snpc.grid = npcset.value("grid", default_grid).toInt();
            NumberLimiter::apply(snpc.grid, 1);
        snpc.grid_attach_style = npcset.value("grid-attachement-style", "0").toInt();
            NumberLimiter::apply(snpc.grid_attach_style, 0);

        /***************Calculate the grid offset********************/
        if(((int)snpc.width>=(int)snpc.grid))
            snpc.grid_offset_x = -1 * qRound( qreal((int)snpc.width % snpc.grid)/2 );
        else
            snpc.grid_offset_x = qRound( qreal( snpc.grid - (int)snpc.width )/2 );

        if(snpc.grid_attach_style==1) snpc.grid_offset_x += 16;

        snpc.grid_offset_y = -snpc.height % snpc.grid;
        /***************Calculate the grid offset********************/

            /*************Manual redefinition of the grid offset if not set******************/
        snpc.grid_offset_x = npcset.value("grid-offset-x", snpc.grid_offset_x).toInt();
        snpc.grid_offset_y = npcset.value("grid-offset-y", snpc.grid_offset_y).toInt();
            /*************Manual redefinition of the grid offset if not set******************/
        /***************GRID And snap***end***************************/

        snpc.special_option =   npcset.value("have-special", "0").toBool();
        snpc.special_name =     npcset.value("special-name", "Special option value").toString();
        snpc.special_type =     npcset.value("special-type", "1").toInt();
        combobox_size =         npcset.value("special-combobox-size", "0").toInt();


        /*************Build special value combobox***********/
        snpc.special_combobox_opts.clear();
        for(int j=0; j<combobox_size; j++)
        {
            snpc.special_combobox_opts.push_back(
                        npcset.value(PGESTRING("special-option-%1").arg(j), "0").toString()
                        );
        }

        snpc.special_spin_min = npcset.value("special-spin-min", "0").toInt();
        snpc.special_spin_max = npcset.value("special-spin-max", "1").toInt();
        snpc.special_spin_value_offset = npcset.value("special-spin-value-offset", "0").toInt();


        snpc.special_option_2 = npcset.value("have-special-2", "0").toBool();
        snpc.special_2_name = npcset.value("special-2-name", "Special option value").toString();;

        if(snpc.special_option_2)
        {
            PGESTRINGList tmp1 = npcset.value("special-2-npc-spin-required", "-1").toString().split(QChar(','));

            if(!tmp1.isEmpty())
                if(tmp1.first()!="-1")
                foreach(PGESTRING x, tmp1)
                    snpc.special_2_npc_spin_required.push_back(x.toInt());

            PGESTRINGList tmp2 = npcset.value("special-2-npc-box-required", "-1").toString().split(QChar(','));

            if(!tmp2.isEmpty())
                if(tmp2.first()!="-1")
                foreach(PGESTRING x, tmp2)
                    snpc.special_2_npc_box_required.push_back(x.toInt());
        }

        snpc.special_2_type = npcset.value("special-2-type", "1").toInt();;
        combobox_size = npcset.value("special-2-combobox-size", "0").toInt();
        for(int j=0; j<combobox_size; j++)
        {
            snpc.special_2_combobox_opts.push_back(
                        npcset.value(PGESTRING("special-2-option-%1").arg(j), "0").toString()
                        );
        }
        snpc.special_2_spin_min = npcset.value("special-2-spin-min", "0").toInt();
        snpc.special_2_spin_max = npcset.value("special-2-spin-max", "1").toInt();
        snpc.special_2_spin_value_offset = npcset.value("special-2-spin-value-offset", "0").toInt();
        /*************Build special value combobox***end*****/


        snpc.score =        npcset.value("score", "0").toInt();
        snpc.coins =        npcset.value("coins", "0").toInt();
        snpc.speed =        npcset.value("speed", "64").toInt();
        snpc.movement =     npcset.value("moving", "1").toBool();
        snpc.activity =     npcset.value("activity", "1").toBool();
        snpc.scenery =      npcset.value("scenery", "0").toBool();
        snpc.shared_ani =   npcset.value("shared-animation", "0").toBool();
        snpc.immortal =     npcset.value("immortal", "0").toBool();
        snpc.can_be_eaten = npcset.value("can-be-eaten", "0").toBool();
        snpc.can_be_eaten = npcset.value("yoshicaneat", snpc.can_be_eaten).toBool();
        snpc.takable =      npcset.value("takable", "0").toBool();
        snpc.takable_snd =  npcset.value("takable-sound-id", "0").toInt();

        snpc.grab_side =    npcset.value("grab-side", "0").toBool();
        snpc.grab_top =     npcset.value("grab-top", "0").toBool();
        snpc.grab_any =     npcset.value("grab-any", "0").toBool();
        snpc.health =       npcset.value("default-health", "0").toInt();
        snpc.hurt_player =  npcset.value("hurtplayer", "0").toBool();
        snpc.hurt_npc =     npcset.value("hurtnpc", "0").toBool();

        //Editor features
        snpc.direct_alt_title =      npcset.value("direction-alt-title", "").toString();
        snpc.direct_alt_left =       npcset.value("direction-alt-left-field", "").toString();
        snpc.direct_alt_right =      npcset.value("direction-alt-right-field", "").toString();
        snpc.direct_disable_random = npcset.value("direction-no-rand-field", "0").toBool();

        //Legacy SMBX64 features
        snpc.allow_bubble = npcset.value("allow-bubble", "0").toBool();
        snpc.allow_egg =    npcset.value("allow-egg", "0").toBool();
        snpc.allow_lakitu = npcset.value("allow-lakitu", "0").toBool();
        snpc.allow_buried = npcset.value("allow-buried", "0").toBool();

        //Events
        snpc.deactivation =         npcset.value("deactivate", false).toBool();
        snpc.deactivetionDelay =    npcset.value("deactivate-delay", 4000).toInt();
            NumberLimiter::applyD(snpc.deactivetionDelay, 4000, 0);
        snpc.kill_slide_slope =     npcset.value("kill-slside", false).toBool();
        snpc.kill_on_jump =         npcset.value("kill-onjump", false).toBool();
        snpc.kill_by_npc =          npcset.value("kill-bynpc", false).toBool();
        snpc.kill_by_fireball =     npcset.value("kill-fireball", false).toBool();
        snpc.freeze_by_iceball =    npcset.value("kill-iceball", false).toBool();
        snpc.kill_hammer =          npcset.value("kill-hammer", false).toBool();
        snpc.kill_tail =            npcset.value("kill-tail", false).toBool();
        snpc.kill_by_spinjump =     npcset.value("kill-spin", false).toBool();
        snpc.kill_by_statue =       npcset.value("kill-statue", false).toBool();
        snpc.kill_by_mounted_item = npcset.value("kill-with-mounted", false).toBool();
        snpc.kill_on_eat =          npcset.value("kill-on-eat", false).toBool();
        snpc.turn_on_cliff_detect = npcset.value("cliffturn", false).toBool();
        snpc.lava_protect =         npcset.value("lava-protection", false).toBool();

        snpc.is_star =              npcset.value("is-star", false).toBool();

        snpc.exit_is =              npcset.value("is-exit", false).toBool();
        snpc.exit_walk_direction =  npcset.value("exit-direction", "0").toInt();
        snpc.exit_code       =      npcset.value("exit-code", "0").toInt();
        snpc.exit_delay      =      npcset.value("exit-delay", "0").toInt();
        snpc.exit_snd        =      npcset.value("exit-sound-id", "0").toInt();

        snpc.climbable       =      npcset.value("is-climbable", "0").toBool();


        //Editor specific flags
        long iTmp;
        iTmp =      npcset.value("default-friendly", "-1").toInt();
            snpc.default_friendly = (iTmp>=0);
            snpc.default_friendly_value = (iTmp>=0)?(bool)iTmp:false;

        iTmp =      npcset.value("default-no-movable", "-1").toInt();
            snpc.default_nomovable = (iTmp>=0);
            snpc.default_nomovable_value = (iTmp>=0)?(bool)iTmp:false;

        iTmp =      npcset.value("default-is-boss", "-1").toInt();
            snpc.default_boss = (iTmp>=0);
            snpc.default_boss_value = (iTmp>=0) ? (bool)iTmp : false;

        iTmp =      npcset.value("default-special-value", "-1").toInt();
            snpc.default_special = (iTmp>=0);
            snpc.default_special_value = (iTmp>=0) ? iTmp : 0;


        snpc.id = i;
        lvl_npc_indexes[i] = snpc;

    skipNPC:
    npcset.endGroup();
        if( npcset.status() != QSettings::NoError )
        {
            PGE_MsgBox::fatal(PGESTRING("ERROR LOADING lvl_npc.ini N:%1 (npc-%2)").arg(npcset.status()).arg(i));
            return false;
        }
    }

    if((unsigned int)lvl_npc_indexes.size()<npc_total)
    {
        PGE_MsgBox::warn(PGESTRING("Not all NPCs loaded! Total: %1, Loaded: %2)").arg(npc_total).arg(lvl_npc_indexes.size()));
    }
    return true;
}
コード例 #16
0
ファイル: mediaview.cpp プロジェクト: PatMart/minitube
void MediaView::activeRowChanged(int row) {
    if (stopped) return;

    errorTimer->stop();

#ifdef APP_PHONON
    mediaObject->stop();
#endif
    if (downloadItem) {
        downloadItem->stop();
        delete downloadItem;
        downloadItem = 0;
        currentVideoSize = 0;
    }

    Video *video = playlistModel->videoAt(row);
    if (!video) return;

    videoAreaWidget->showLoading(video);

    connect(video, SIGNAL(gotStreamUrl(QUrl)),
            SLOT(gotStreamUrl(QUrl)), Qt::UniqueConnection);
    connect(video, SIGNAL(errorStreamUrl(QString)),
            SLOT(skip()), Qt::UniqueConnection);
    video->loadStreamUrl();

    // video title in titlebar
    MainWindow::instance()->setWindowTitle(video->title() + " - " + Constants::NAME);

    // ensure active item is visible
    if (row != -1) {
        QModelIndex index = playlistModel->index(row, 0, QModelIndex());
        playlistView->scrollTo(index, QAbstractItemView::EnsureVisible);
    }

    // enable/disable actions
    The::globalActions()->value("download")->setEnabled(
        DownloadManager::instance()->itemForVideo(video) == 0);
    The::globalActions()->value("previous")->setEnabled(row > 0);
    The::globalActions()->value("stopafterthis")->setEnabled(true);
    The::globalActions()->value("related-videos")->setEnabled(true);

    bool enableDownload = video->license() == Video::LicenseCC;
#ifdef APP_ACTIVATION
    enableDownload = enableDownload || Activation::instance().isLegacy();
#endif
#ifdef APP_DOWNLOADS
    enableDownload = true;
#endif
    QAction *a = The::globalActions()->value("download");
    a->setEnabled(enableDownload);
    a->setVisible(enableDownload);

    updateSubscriptionAction(video, YTChannel::isSubscribed(video->channelId()));

    foreach (QAction *action, currentVideoActions)
        action->setEnabled(true);

#ifndef APP_PHONON_SEEK
    QSlider *slider = MainWindow::instance()->getSlider();
    slider->setEnabled(false);
    slider->setValue(0);
#endif

    if (snapshotSettings) {
        delete snapshotSettings;
        snapshotSettings = 0;
        MainWindow::instance()->adjustStatusBarVisibility();
    }

    // see you in gotStreamUrl...
}
コード例 #17
0
void
MinimalImpactTEDWriter::write(std::string filename) {

	updateInputs();

	initPipeline();

	int limitToISI = -1;
	if (optionLimitToISI)
		limitToISI = optionLimitToISI.as<int>() - SliceHashConfiguration::sectionOffset;

	if (optionWriteTedConditions)
		filename = "minimalImpactTEDconditions.txt";

	// append ISI number to output filename
	if (limitToISI >= 0)
		filename = filename + "_" + optionLimitToISI.as<std::string>();

	if (optionWriteTedConditions) {
		LOG_USER(minimalImpactTEDlog) << "writing ted conditions to " << filename << std::endl;
	} else {
		LOG_USER(minimalImpactTEDlog) << "writing ted coefficients to " << filename << std::endl;
	}

	// Remove the old file
	if( remove( filename.c_str() ) != 0 ) {
		LOG_DEBUG(minimalImpactTEDlog) << "Old file to output minimal impact TED approximation sucessfully deleted." << std::endl;
	} 
	else {
		LOG_DEBUG(minimalImpactTEDlog) << "Could not delete old file to output minimal impact TED approximation." << std::endl;
	}

	// Open file for writing
	std::ofstream outfile;

	outfile.open(filename.c_str());
	
	 // Get a vector with all gold standard segments.
	const std::vector<boost::shared_ptr<Segment> > goldStandard = _goldStandard->getSegments();

	int constant = 0;

	// Loop through variables
	std::set<unsigned int> variables = _problemConfiguration->getVariables();

	LOG_USER(minimalImpactTEDlog) << "computing ted coefficients for " << variables.size() << " variables" << std::endl;

	if (optionWriteTedConditions) {

		outfile << "# hash: [hashes of flipped segments]" << std::endl;

	} else {

		outfile << "numVar " << variables.size() << std::endl;
		outfile << "# var_num costs # hash value_in_gs fs fm fp fn ( <- when flipped )" << std::endl;
	}

	std::set<unsigned int> goldStandardIds;
	foreach (boost::shared_ptr<Segment> s, goldStandard)
		goldStandardIds.insert(s->getId());

	// create a map from segment ids to segment pointers
	std::map<unsigned int, boost::shared_ptr<Segment> > idToSegment;
	foreach (boost::shared_ptr<Segment> segment, _segments->getSegments())
		idToSegment[segment->getId()] = segment;

	for ( unsigned int varNum = 0 ; varNum < variables.size() ; varNum++ ) {

		unsigned int segmentId = _problemConfiguration->getSegmentId(varNum);

		int interSectionInterval = _problemConfiguration->getInterSectionInterval(varNum);

		if (limitToISI >= 0)
			if (interSectionInterval != limitToISI)
				continue;

		std::string timerMessage = "\n\nMinimalImpactTEDWriter: variable " + boost::lexical_cast<std::string>(varNum) + ", %ws\n\n";
		boost::timer::auto_cpu_timer timer(timerMessage);

		// re-create the pipeline for the current segment and its inter-section 
		// interval
		if (!optionWriteTedConditions)
			updatePipeline(interSectionInterval, optionNumAdjacentSections.as<int>());
	
		// Is the segment that corresponds to the variable part of the gold standard?
		bool isContained = (goldStandardIds.count(segmentId) > 0);

		// get the hash value of this segment
		SegmentHash segmentHash = idToSegment[segmentId]->hashValue();

		// pin the value of the current variable to its opposite
		_linearSolver->pinVariable(varNum, (isContained ? 0 : 1));

		if (!optionWriteTedConditions) {

			pipeline::Value<TolerantEditDistanceErrors> errors = _teDistance->getOutput("errors");
			int sumErrors = errors->getNumSplits() + errors->getNumMerges() + errors->getNumFalsePositives() + errors->getNumFalseNegatives();

			outfile << "c" << varNum << " ";
			outfile << (isContained ? -sumErrors : sumErrors) << " ";
			outfile << "# ";
			outfile << segmentHash << " ";
			outfile << (isContained ? 1 : 0) << " ";
			outfile << errors->getNumSplits() << " ";
			outfile << errors->getNumMerges() << " ";
			outfile << errors->getNumFalsePositives() << " ";
			outfile << errors->getNumFalseNegatives() << std::endl;

			if (isContained) {

				// Forced segment to not be part of the reconstruction.
				// This resulted in a number of errors that are going to be stored in the constant.
				// To make net 0 errors when the variable is on, minus the number of errors will be written to the file.

				constant += sumErrors;
			}

		} else {

			pipeline::Value<Solution> solution = _linearSolver->getOutput("solution");

			outfile << segmentHash << ":";
			for (unsigned int i = 0; i < variables.size(); i++) {

				unsigned int id = _problemConfiguration->getSegmentId(i);

				// was flipped?
				if ((*solution)[i] != goldStandardIds.count(id))
					outfile << " " << idToSegment[id]->hashValue();
			}
			outfile << std::endl;
		}

		// Remove constraint
		_linearSolver->unpinVariable(varNum);
	}

	if (!optionWriteTedConditions) {

		// Write constant to file
		outfile << "constant " << constant << std::endl;
	}

	outfile.close();
}
コード例 #18
0
void SettingsDialog::ensureAllCategoryWidgets()
{
    foreach (Category *category, m_model->categories())
        ensureCategoryWidget(category);
}
コード例 #19
0
ファイル: device.cpp プロジェクト: stbuehler/nut
	void Device::startEnvSelect() {
		m_waitForEnvSelects = m_envs.size();
		foreach (Environment* env, m_envs)
			env->startSelect();
	}
コード例 #20
0
void QQuickCustomAffector::affectSystem(qreal dt)
{
    //Acts a bit differently, just emits affected for everyone it might affect, when the only thing is connecting to affected(x,y)
    bool justAffected = (m_acceleration == &m_nullVector
        && m_velocity == &m_nullVector
        && m_position == &m_nullVector
        && isAffectedConnected());
    if (!isAffectConnected() && !justAffected) {
        QQuickParticleAffector::affectSystem(dt);
        return;
    }
    if (!m_enabled)
        return;
    updateOffsets();

    QList<QQuickParticleData*> toAffect;
    foreach (QQuickParticleGroupData* gd, m_system->groupData)
        if (activeGroup(m_system->groupData.key(gd)))
            foreach (QQuickParticleData* d, gd->data)
                if (shouldAffect(d))
                    toAffect << d;

    if (toAffect.isEmpty())
        return;

    if (justAffected) {
        foreach (QQuickParticleData* d, toAffect) {//Not postAffect to avoid saying the particle changed
            if (m_onceOff)
                m_onceOffed << qMakePair(d->group, d->index);
            emit affected(d->curX(), d->curY());
        }
        return;
    }

    if (m_onceOff)
        dt = 1.0;

    v8::HandleScope handle_scope;
    v8::Context::Scope scope(QQmlEnginePrivate::getV8Engine(qmlEngine(this))->context());
    v8::Handle<v8::Array> array = v8::Array::New(toAffect.size());
    for (int i=0; i<toAffect.size(); i++)
        array->Set(i, toAffect[i]->v8Value().toHandle());

    if (dt >= simulationCutoff || dt <= simulationDelta) {
        affectProperties(toAffect, dt);
        emit affectParticles(QQmlV8Handle::fromHandle(array), dt);
    } else {
        int realTime = m_system->timeInt;
        m_system->timeInt -= dt * 1000.0;
        while (dt > simulationDelta) {
            m_system->timeInt += simulationDelta * 1000.0;
            dt -= simulationDelta;
            affectProperties(toAffect, simulationDelta);
            emit affectParticles(QQmlV8Handle::fromHandle(array), simulationDelta);
        }
        m_system->timeInt = realTime;
        if (dt > 0.0) {
            affectProperties(toAffect, dt);
            emit affectParticles(QQmlV8Handle::fromHandle(array), dt);
        }
    }

    foreach (QQuickParticleData* d, toAffect)
        if (d->update == 1.0)
            postAffect(d);
}
コード例 #21
0
bool ClassInstanceData::tool_cmd(ToolCom * com, const char * args,
                                 BrowserNode * bn, const QString & comment)
{
    if (((unsigned char) args[-1]) >= firstSetCmd) {
        if (!bn->is_writable() && !root_permission())
            com->write_ack(FALSE);
        else {
            switch ((unsigned char) args[-1]) {
            case setTypeCmd:
                set_class((BrowserClass *) com->get_id(args));
                break;

            case setAttributeCmd: {
                BrowserAttribute * at = (BrowserAttribute *) com->get_id(args);
                bool find = FALSE;
                Q3ValueList<SlotAttr>::Iterator it_attr;

                for (it_attr = attributes.begin(); it_attr != attributes.end(); ++it_attr) {
                    SlotAttr & slot_attr = *it_attr;

                    if (slot_attr.att == at) {
                        find = TRUE;

                        if (*args == 0)
                            // remove it
                            attributes.remove(it_attr);
                        else
                            // replace it
                            slot_attr.value = args;

                        break;
                    }
                }

                if (! find) {
                    // add it
                    QList<BrowserClass *> l;

                    cl->get_all_parents(l);
                    l.append(cl);

                    if (at->deletedp() ||
                        (! l.contains((BrowserClass *)at->parent()))) {
                        // illegal
                        com->write_ack(FALSE);
                        return TRUE;
                    }

                    attributes.append(SlotAttr(at, args));
                }
            }
            break;

            case addRelationCmd:
                if (! change_rel(com, args, TRUE))
                    return TRUE;

                break;

            case removeRelationCmd:
                if (! change_rel(com, args, FALSE))
                    return TRUE;

                break;

            default:
                return BasicData::tool_cmd(com, args, bn, comment);
            }

            // ok case
            bn->modified();
            modified();
            com->write_ack(TRUE);
        }
    }
    else {
        switch ((unsigned char) args[-1]) {
        case attributesCmd:
            if (args[0] == 0) {
                com->write_unsigned(attributes.count());

                Q3ValueList<SlotAttr>::Iterator it;

                for (it = attributes.begin(); it != attributes.end(); ++it) {
                    const SlotAttr & slot = *it;

                    slot.att->write_id(com);
                    com->write_string(slot.value);
                }
            }
            else {
                // get all available attributes
                BrowserNodeList l;

                cl->get_attrs(l);
                com->write_unsigned(l.count());

                foreach (BrowserNode * node, l)
                    node->write_id(com);
            }

            break;

        case relationsCmd: {
            BrowserClassInstance * other =
                (BrowserClassInstance *) com->get_id(args);

            if (other == 0) {
                com->write_unsigned(relations.count());

                Q3ValueList<SlotRel>::Iterator it;

                for (it = relations.begin(); it != relations.end(); ++it) {
                    const SlotRel & slot = *it;

                    ((slot.is_a) ? slot.rel->get_start() : slot.rel->get_end())
                    ->write_id(com);
                    slot.value->write_id(com);
                }
            }
            else {
                // get all available relations
                QList<BrowserRelation *> l;

                cl->get_rels(((ClassInstanceData *)other->get_data())->cl, l);
                com->write_unsigned(l.count());

                foreach (BrowserRelation *r, l)
                    r->write_id(com);
            }
        }
        break;

        default:
            return BasicData::tool_cmd(com, args, bn, comment);
        }
    }

    return TRUE;
}
コード例 #22
0
void PreviewForm::setCodecList(const QList<QTextCodec *> &list)
{
    encodingComboBox->clear();
    foreach (QTextCodec *codec, list)
        encodingComboBox->addItem(codec->name(), codec->mibEnum());
}
コード例 #23
0
ファイル: main.cpp プロジェクト: amd00/meduzzza
int main(int argc, char *argv[])
{
 	
	QCoreApplication app(argc, argv);
	
	option long_opts[] =
	{
			{"update", no_argument, 0, 'u'},
			{"full-update", no_argument, 0, 'U'},
			{"memory", no_argument, 0, 'm'},
			{"file", required_argument, 0, 'f'},
			{"dir", required_argument, 0, 'd'},
			{"full-scan", no_argument, 0, 'F'},
			{"help", no_argument, 0, 'h'},
			{0, 0, 0, 0}
	};
	char c = 0;
	int opt_index;
	optind = 1;
	opterr = 0;
	
	bool update = false;
	bool full_update = false;
	bool memory = false;
	QStringList files;
	QStringList dirs;
	bool full = false;
	
	while((c = getopt_long(argc, argv, "-u -U -m -f: -d: -F -h", long_opts, &opt_index)) >= 0)
	{
		switch(c)
		{
			case 'u':
			{
				update = true;
				break;
			}
			case 'U':
			{
				full_update = true;
				break;
			}
			case 'm':
			{
				memory = true;
				break;
			}
			case 'f':
			{
				files << optarg;
				break;
			}
			case 'd':
			{
				dirs << optarg;
				break;
			}
			case 'F':
			{
				full = true;
				break;
			}
			case 'h':
			{
				qDebug("Usage: meduzzza [-umhF] [-f <file name>] [-d <dir name>]");
				return 0;
			}
		}
	}
	
	if(full)
	{
		files.clear();
		dirs.clear();
		memory = false;
	}
	
	Meduzzza::Manager *m = Meduzzza::Manager::get();
	if(full_update)
	  m -> downloadDb(false);
	else if(update)
		m -> updateDb(false);
	m -> init();
	if(memory)
		m -> scanMemory(false);
	foreach(QString file, files)
		m -> scanFile(file, false);
	foreach(QString dir, dirs)
		m -> scanDir(dir, QStringList(), true);
	if(full)
		m -> fullScan();
	
	return app.exec();
}
コード例 #24
0
/*!
    Clears the content managed by all content managers known to the factory.
*/
void QMailContentManagerFactory::clearContent()
{
    foreach (QMailContentManager *manager, contentPlugins().values())
        manager->clearContent();
}
コード例 #25
0
ファイル: main.cpp プロジェクト: Karry/monavsailfish
int main( int argc, char *argv[] )
{
	QString serverPath = "";
	QString packagePath = "";
	OPERATION listOperation = DEFAULT;

	int c;
	while ( ( c = getopt( argc, argv, "c:r:a:p:d:u" ) ) != -1 )
	{
		switch(c)
		{
			case 'c':
				listOperation = CREATE_LIST;
				serverPath = optarg;
				break;
			case 'd':
				listOperation = DELETE_LIST;
				break;
			case 'a':
				listOperation = ADD_PACKAGE;
				packagePath = optarg;
				break;
			case 'r':
				listOperation = DELETE_PACKAGE;
				packagePath = optarg;
				break;
			case 'p':
				listOperation = AUTO_CREATE;
				serverPath = optarg;
				break;
			case 'u':
				listOperation = AUTO_UPDATE;
				serverPath = optarg;
				break;
			default:
				printf( "operation not recognized\n" );
				return 0;
		}
	}

	if( argc < 2 || ( argc != 3 && listOperation != DELETE_LIST ) )
	{
		printf( "usage:\n" );
		printf( "-p server_url : create list automatically by recursively parsing mapmanager directory\n" );
		printf( "-u server_url : update list automatically by recursively parsing mapmanager directory\n" );
		printf( "-c server_url : create list\n" );
		printf( "-d server_url : delete list\n" );
		printf( "-a package_path_and_name : add package to list\n" );
		printf( "-r package_path_and_name : delete package from list\n" );

		return 0;
	}

	if( !serverPath.endsWith( "/" ) )
		serverPath.append( "/" );

	if( packagePath.startsWith( "." ) )
		packagePath.remove( 0, 1 );

	if( packagePath.startsWith( "/" ) )
		packagePath.remove( 0, 1 );

	QString packageName = packagePath;
	packageName.remove( 0, packageName.lastIndexOf( '/' ) + 1 );
	packageName.truncate( packageName.lastIndexOf( '.' ) );

	QDomDocument list;
	QFile listFile( "packageList.xml" );

	if( listOperation == CREATE_LIST )
		return createList( &list, &listFile, serverPath );

	if( listOperation == AUTO_CREATE )
	{
		if( !createList( &list, &listFile, serverPath ) )
			return 0;

		QStringList localPackages = parseForPackages( QDir() );

		foreach( QString packagePath, localPackages )
			processPackage( &list, packagePath );
	}

	else
	{
		if ( !listFile.exists() )
		{
			printf( "create list file first using -c or -p\n" );
			return 0;
		}

		if( listOperation == DELETE_LIST )
		{
			if ( !listFile.remove() )
			{
				printf( "error deleting list file\n" );
				return 0;
			}

			printf( "deleted list\n" );
			return 1;
		}


		if ( !listFile.open( QIODevice::ReadOnly ) )
		{
			printf( "failed to open list file\n" );
			return 0;
		}

		if ( !list.setContent( &listFile ) )
		{
			printf("error parsing list file\n");
			listFile.close();
			return 0;
		}
		listFile.close();
	}

	if( listOperation == DELETE_PACKAGE )
	{
		if ( !deletePackage( &list, packagePath ) )
			return 0;
	}

	if( listOperation == ADD_PACKAGE )
	{
		if ( !processPackage( &list, packagePath ) )
			return 0;
	}

	if( listOperation == AUTO_UPDATE )
	{
		QStringList localPackages = parseForPackages( QDir() );

		foreach( QString packagePath, localPackages )
			processPackage( &list, packagePath );
	}

	if (!listFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) return 1;
	listFile.write(list.toString().toUtf8());
	listFile.close();

	return 1;
}
コード例 #26
0
ファイル: contact-manager.cpp プロジェクト: ziemniak/kadu
void ContactManager::groupRemoved(Group *group)
{
	foreach (Contact contact, Contacts)
		contact.removeFromGroup(group);
}
コード例 #27
0
ファイル: pMolStackObject.cpp プロジェクト: mxpule/pMol0174
void pMolStackList :: treeOut(QTreeWidgetItem *tree)
{
  QTreeWidgetItem* branch = treeItem(tree,"pMolCmd::LIST");
  foreach (pMolStackObject* object, list) object->treeOut(branch);
};
コード例 #28
0
ファイル: client.cpp プロジェクト: KDE/kde-workspace
KSMClient::~KSMClient()
{
    foreach( SmProp *prop, properties )
        SmFreeProperty( prop );
    if (id) free((void*)id);
}
コード例 #29
0
ファイル: ofApp.cpp プロジェクト: AnnaKolla/Kolla075-sims2014
 void translate(float x, float y, float z) {
     foreach(vv,v) vv += ofVec3f(x,y,z); endfor
 }
コード例 #30
0
ファイル: SettingsWindow.cpp プロジェクト: ntfreak/MediaElch
void SettingsWindow::loadSettings()
{
    m_settings->loadSettings();

    // Stream Details
    ui->chkAutoLoadStreamDetails->setChecked(m_settings->autoLoadStreamDetails());

    // Proxy
    ui->chkUseProxy->setChecked(m_settings->useProxy());
    ui->proxyType->setCurrentIndex(m_settings->proxyType());
    ui->proxyHost->setText(m_settings->proxyHost());
    ui->proxyPort->setValue(m_settings->proxyPort());
    ui->proxyUsername->setText(m_settings->proxyUsername());
    ui->proxyPassword->setText(m_settings->proxyPassword());
    onUseProxy();

    ui->usePlotForOutline->setChecked(m_settings->usePlotForOutline());
    ui->chkDownloadActorImages->setChecked(m_settings->downloadActorImages());
    ui->chkIgnoreArticlesWhenSorting->setChecked(m_settings->ignoreArticlesWhenSorting());
    ui->chkCheckForUpdates->setChecked(m_settings->checkForUpdates());
    ui->chkEnableAdultScrapers->setChecked(m_settings->showAdultScrapers());
    onShowAdultScrapers();

    // Directories
    ui->dirs->setRowCount(0);
    ui->dirs->clearContents();
    QList<SettingsDir> movieDirectories = m_settings->movieDirectories();
    for (int i=0, n=movieDirectories.count() ; i<n ; ++i)
        addDir(movieDirectories.at(i).path, movieDirectories.at(i).separateFolders, movieDirectories.at(i).autoReload, DirTypeMovies);
    QList<SettingsDir> tvShowDirectories = m_settings->tvShowDirectories();
    for (int i=0, n=tvShowDirectories.count() ; i<n ; ++i)
        addDir(tvShowDirectories.at(i).path, tvShowDirectories.at(i).separateFolders, tvShowDirectories.at(i).autoReload, DirTypeTvShows);
    QList<SettingsDir> concertDirectories = m_settings->concertDirectories();
    for (int i=0, n=concertDirectories.count() ; i<n ; ++i)
        addDir(concertDirectories.at(i).path, concertDirectories.at(i).separateFolders, concertDirectories.at(i).autoReload, DirTypeConcerts);
    QList<SettingsDir> downloadDirectories = m_settings->downloadDirectories();
    for (int i=0, n=downloadDirectories.count() ; i<n ; ++i)
        addDir(downloadDirectories.at(i).path, false, false, DirTypeDownloads);

    dirListRowChanged(ui->dirs->currentRow());

    // Exclude words
    ui->excludeWordsText->setPlainText(m_settings->excludeWords());

    ui->useYoutubePluginUrls->setChecked(m_settings->useYoutubePluginUrls());

    // XBMC
    ui->xbmcHost->setText(m_settings->xbmcHost());
    if (m_settings->xbmcPort() != 0)
        ui->xbmcPort->setText(QString::number(m_settings->xbmcPort()));
    else
        ui->xbmcPort->clear();

    foreach (QLineEdit *lineEdit, findChildren<QLineEdit*>()) {
        if (lineEdit->property("dataFileType").isNull())
            continue;
        int dataFileType = lineEdit->property("dataFileType").toInt();
        QList<DataFile> dataFiles = m_settings->dataFiles(dataFileType);
        QStringList filenames;
        foreach (DataFile dataFile, dataFiles)
            filenames << dataFile.fileName();
        lineEdit->setText(filenames.join(","));
    }

    // Movie set artwork
    for (int i=0, n=ui->comboMovieSetArtwork->count() ; i<n ; ++i) {
        if (ui->comboMovieSetArtwork->itemData(i).toInt() == m_settings->movieSetArtworkType()) {
            ui->comboMovieSetArtwork->setCurrentIndex(i);
            break;
        }
    }
    ui->movieSetArtworkDir->setText(m_settings->movieSetArtworkDirectory());
    onComboMovieSetArtworkChanged();


    QList<int> infos = QList<int>() << MovieScraperInfos::Title << MovieScraperInfos::Set << MovieScraperInfos::Tagline
                                    << MovieScraperInfos::Rating << MovieScraperInfos::Released << MovieScraperInfos::Runtime
                                    << MovieScraperInfos::Director << MovieScraperInfos::Writer << MovieScraperInfos::Certification
                                    << MovieScraperInfos::Trailer << MovieScraperInfos::Overview << MovieScraperInfos::Poster
                                    << MovieScraperInfos::Backdrop << MovieScraperInfos::Actors << MovieScraperInfos::Genres
                                    << MovieScraperInfos::Studios << MovieScraperInfos::Countries << MovieScraperInfos::Logo
                                    << MovieScraperInfos::ClearArt << MovieScraperInfos::CdArt << MovieScraperInfos::Banner
                                    << MovieScraperInfos::Thumb;

    ui->customScraperTable->clearContents();
    ui->customScraperTable->setRowCount(0);

    foreach (const int &info, infos) {
        int row = ui->customScraperTable->rowCount();
        ui->customScraperTable->insertRow(row);
        ui->customScraperTable->setItem(row, 0, new QTableWidgetItem(titleForMovieScraperInfo(info)));
        ui->customScraperTable->setCellWidget(row, 1, comboForMovieScraperInfo(info));
    }