예제 #1
0
void ShapeSelector::setCurrentShapeType( int type )
{
	QAbstractItemModel *model = shapeType->model();
	QModelIndexList indexes = model->match ( model->index(0,1), Qt::DisplayRole, type );
	QModelIndex index  = indexes.value(0);
	shapeType->setCurrentIndex( index.row() );
}
예제 #2
0
void SensorBrowserTreeWidget::disconnect()
{
    QModelIndexList indexlist = selectionModel()->selectedRows();
    for(int i=0; i < indexlist.size(); i++)
    {
        mSensorBrowserModel.disconnectHost(indexlist.value(i).internalId());
    }
}
예제 #3
0
void CourseEditUI::tableViewSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
{
	if(selected.count() > 0)
	{
		QModelIndexList selectedList = selected.at(0).indexes();
		if(selectedList.count() > 0)
		{
			QString question = selectedList.value(0).data().toString();
			QString answer = selectedList.value(1).data().toString();
			txtQuestion->setText(question);
			txtAnswer->setText(answer);
			for(Items::const_iterator it = _items.begin(); it != _items.end(); ++it)
			{
				if(it->get()->GetQuestion() == question.toStdString() && it->get()->GetAnswer() == answer.toStdString())
				{
					_currentItem = *it;
					return;
				}
				
			}
			_currentItem = ItemPtr();
		}
	}
}
Font* FontManagerDialog::GetSelectedFont(QItemSelectionModel *selectionModel)
{
	Font *returnFont = NULL;
	// Get selected item
	QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
    //Get selected font name and type
	QString fontName = selectedIndexes.value(0).data().toString();
    QString fontType = selectedIndexes.value(1).data().toString();
	// Created font according to its type
	if (fontType == FONT_TYPE_GRAPHIC)
    {
		// Get sprites directory to open
		QString currentFontSpriteDir = ResourcesManageHelper::GetDefaultFontSpritesPath(currentFontPath);
    	QString fontSpritePath = QFileDialog::getOpenFileName(this, tr( "Select font sprite" ),
																	currentFontSpriteDir,
																	tr( "Sprites (*.txt)" ));
             
        if (!fontSpritePath.isNull() && !fontSpritePath.isEmpty())
        {
			// Convert file path into Unix-style path
			fontSpritePath = ResourcesManageHelper::ConvertPathToUnixStyle(fontSpritePath);

			if (ResourcesManageHelper::ValidateResourcePath(fontSpritePath))
			{
				// Get font definition relative path by it's name
				QString fontDefinition = ResourcesManageHelper::GetFontRelativePath(fontName, true);
				// Get sprite file relative path
				QString fontSprite = ResourcesManageHelper::GetResourceRelativePath(fontSpritePath);
				// Create Graphics font to validate it - but first truncate "*.txt" extension of sprite
				returnFont = GraphicsFont::Create(fontDefinition.toStdString(), fontSprite.toStdString());
			}
			else
			{
				ResourcesManageHelper::ShowErrorMessage(fontName);
				return returnFont;
			}
		}
	}
    else if (fontType == FONT_TYPE_BASIC)
    {
    	//Actions for simple font
        //Get font absolute path
        QString fontPath = ResourcesManageHelper::GetFontRelativePath(fontName);
        //Try to create font to validate it
        returnFont = FTFont::Create(fontPath.toStdString());
	}
	
	if (!returnFont)
	{
    	//If font was not created - show error message
        //No dialog result will be set in this case
         QString message;
         QMessageBox messageBox;
         messageBox.setText(message.append(QString(LOAD_FONT_ERROR_MESSAGE).arg(fontName)));
         messageBox.setInformativeText(LOAD_FONT_ERROR_INFO_TEXT);
         messageBox.setStandardButtons(QMessageBox::Ok);
         messageBox.exec();
	}
	
	return returnFont;
}
예제 #5
0
void deleteCategoryDialog::deleteCategory() {
    QModelIndexList indexList = ui->tableView_Category->selectionModel()->selection().indexes();
    QString index = indexList.value(0).data().toString();
    m_db->deleteCategory(index.toInt());
    this->close();
}