Пример #1
0
void QQBoardsSettings::addBouchot()
{
	QQBouchotSettingsDialog bouchotSettingsDialog(this);
	bouchotSettingsDialog.setGroups(m_listGroups);
	bouchotSettingsDialog.setNames(m_listNames);

	if(bouchotSettingsDialog.exec() == QDialog::Accepted)
	{
		QQBouchot::QQBouchotSettings bSettings = bouchotSettingsDialog.bouchotSettings();
		QString bouchotName = bouchotSettingsDialog.bouchotName();

		if(m_listNames.contains(bouchotName))
		{
			qWarning() << "Trying to insert a bouchot with an already existing name, that's forbidden";
		}
		else
		{
			m_listNames.append(bouchotName);

			if(! m_listGroups.contains(bSettings.group()))
				m_listGroups.append(bSettings.group());

			QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
			int numRow = model->rowCount();
			model->insertRows(numRow,1);
			model->setData(model->index(numRow), QVariant(bouchotName));
			m_newBouchots.insert(bouchotName, bSettings);
			m_oldBouchots.removeAll(bouchotName);
		}
	}
}
Пример #2
0
void QQBoardsSettings::olccsAddBouchot()
{
	QQBoardWizard wizard(this);
	if(wizard.exec() == QDialog::Accepted)
	{
		QQBouchot::QQBouchotSettings bSettings = wizard.bouchotSettings();
		QString bouchotName = wizard.bouchotName();

		if(m_listNames.contains(bouchotName))
		{
			qWarning() << "Trying to insert a bouchot with an already existing name, that's forbidden";
		}
		else
		{
			m_listNames.append(bouchotName);

			if(! m_listGroups.contains(bSettings.group()))
				m_listGroups.append(bSettings.group());

			QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
			int numRow = model->rowCount();
			model->insertRows(numRow, 1);
			model->setData(model->index(numRow), QVariant(bouchotName));
			m_newBouchots.insert(bouchotName, bSettings);
			m_oldBouchots.removeAll(bouchotName);
		}

		if(wizard.showAdvanced())
		{
			QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
			QItemSelectionModel *selModel = ui->bouchotListView->selectionModel();
			for(int i = 0; i < model->rowCount(); i++)
			{
				QModelIndex mIndex = model->index(i);
				if(model->data(mIndex, Qt::EditRole).toString() == bouchotName)
				{
					selModel->select(mIndex, QItemSelectionModel::ClearAndSelect);
					editBouchot();
				}
			}
		}
	}
}
Пример #3
0
void QQBoardsSettings::setBouchots(const QMap<QString, QQBouchot::QQBouchotSettings> currentListBouchot)
{
	m_bouchots = currentListBouchot;

	QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
	model->removeRows(0, model->rowCount());
	model->insertRows(0, m_bouchots.size());

	m_listNames = currentListBouchot.keys();

	QMapIterator<QString, QQBouchot::QQBouchotSettings> i(m_bouchots);
	int index = 0;
	while(i.hasNext())
	{
		i.next();
		QQBouchot::QQBouchotSettings settings = i.value();
		if(! m_listGroups.contains(settings.group()))
			m_listGroups.append(settings.group());

		model->setData(model->index(index++), QVariant(i.key()));
	}
}