예제 #1
0
void TableView::addRow(types::Data &data, int fid)
{
    QTableWidget* table =  getTableWidget();

    if(0!=table)
    {
        if(fid>=table->rowCount())
        {
            table->setRowCount(fid+50);
        }
        unsigned int size = data.size();
        if(table->columnCount()<(int)size)
        {
            size = table->columnCount();
        }
        for(unsigned int i=0;i<size;i++)
        {
            table->setItem(fid,i,new QTableWidgetItem(QString("%1").arg(data[i])));
        }
        table->selectRow(fid);
        if(_realcount<fid)
        {
            _realcount = fid;
        }
   }
}
예제 #2
0
void TableView::coloringRows(QList<double> x,int start,int end)
{
    QList<QColor> colors;
    colors << QColor(255,255,255) << QColor(255,0,0) << QColor(0,255,0) << QColor(0,0,255) << QColor(255,255,0);
    QTableWidget* table =  getTableWidget();
    if(start<0||start>table->columnCount())
    {
        start = 0;
    }
    if(end<0||end>table->columnCount())
    {
        end = table->columnCount();
    }
    if(0!=table){
        for(int i=0;i<x.length();i++)
        {
            if(table->item(i,0))
            {
                for(int j=start;j<end;j++)
                {
                    int idx = ((int)x[i])%colors.length();
                    table->item(i,j)->setBackgroundColor( colors[idx]);

                }
            }
        }
    }
}
예제 #3
0
파일: uiutil.cpp 프로젝트: nordewal/sfm
Mat UIUtil::getMatFromQtable(QTableWidget &table) {
  Mat_<double> mat(table.rowCount(), table.columnCount());
  for (int row = 0; row < table.rowCount(); row++) {
    for (int col = 0; col < table.columnCount(); col++) {
      if (table.item(row, col) != NULL)
        mat(row, col) = table.item(row, col)->text().toDouble();
      else
        mat(row, col) = 0;
    }
  }
  return mat;
}
예제 #4
0
void tablewidget::selectTableRow( QTableWidgetItem * current,QTableWidgetItem * previous )
{
	QTableWidget * table ;

	int col = 0 ;
	int i   = 0 ;
	int j   = 0 ;

	if( current && previous ){

		if( previous->row() == current->row() ){
			table = current->tableWidget() ;
			table->setCurrentCell( current->row(),table->columnCount() - 1 ) ;
			table->setFocus() ;
			return ;
		}
	}

	if( current ){

		table = current->tableWidget() ;

		if( table->rowCount() > 0 ){

			col = table->columnCount() ;
			j = current->row() ;

			for( i = 0 ; i < col ; i++ ){
				table->item( j,i )->setSelected( true ) ;
			}
		}

		table->setCurrentCell( j,table->columnCount() -1 ) ;
		table->setFocus() ;
	}

	if( previous ){

		table = previous->tableWidget() ;

		if( table->rowCount() > 0 ){

			col = table->columnCount() ;
			j = previous->row() ;

			for( i = 0 ; i < col ; i++ ){
				table->item( j,i )->setSelected( false ) ;
			}
		}

		table->setFocus() ;
	}
}
예제 #5
0
///
/// \brief Form_PlatformConfiguration::traversalControl
/// \param q
/// save
///
void Form_PlatformConfiguration::traversalControl(const QObjectList& q)
{
    for(int i=0;i<q.length();i++)
    {

        if(!q.at(i)->children().empty())
        {
            traversalControl(q.at(i)->children());
        }

        QObject* o = q.at(i);
        if (o->inherits("QLineEdit"))
        {
            QLineEdit* b = qobject_cast<QLineEdit*>(o);
            QDomElement qe= doc_config.createElement(b->objectName());
            qe.setAttribute("Value",b->text());
            qe.setAttribute("Type","QLineEdit");
            doc_config.firstChildElement("root").appendChild(qe);
        }
        else if (o->inherits("QGroupBox"))
        {
            QGroupBox* b = qobject_cast<QGroupBox*>(o);
            QDomElement qe= doc_config.createElement(b->objectName());
            qe.setAttribute("Value",b->isChecked());
            qe.setAttribute("Type","QGroupBox");
            doc_config.firstChildElement("root").appendChild(qe);
        }
        else if (o->inherits("QTableWidget"))
        {
            QTableWidget * b = qobject_cast<QTableWidget*>(o);
            int col_rate = b->objectName() == "table_labels" ? 1:0;
            QDomElement qe= doc_config.createElement(b->objectName());
            qe.setAttribute("Value_R",b->rowCount());
            qe.setAttribute("Value_C",b->columnCount());
            qe.setAttribute("Type","QTableWidget");
            for(int i =0 ; i<b->rowCount() ;i++)
            {
                QDomElement item= doc_config.createElement("R"+QString::number(i));
                for(int j=0 ;j <b->columnCount()  - col_rate; j++)
                {
                    item.setAttribute("C"+QString::number(j), b->item(i,j)->text());
                }
                qe.appendChild(item);
            }
            doc_config.firstChildElement("root").appendChild(qe);
        }
    }

}
예제 #6
0
void SkillEditFrame::onCurrentItemChanged(DataContainerItem *current) {
	if (current == 0)
		return;
	QTableWidget *skillTable = this->findChild<QTableWidget *>("skillTable");
	DataContainerItem *item = current;
	if (item->getStringData().size() > 0) {
		StatsContainer *skill = GenStatsReader::getContainer(*skillStats, item->getStringData());
		if (skill != 0) {
			typedef std::map<std::string, std::string> StringMap;
			StringMap dataMap = skill->getBaseDataMap();
			for (int i=0; i<skillTable->rowCount(); ++i) {
				for (int j=0; j<skillTable->columnCount(); ++j) {
					delete skillTable->item(i, j);
				}
			}
			
			skillTable->setRowCount(0);
			int row = 0;
			for (StringMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it) {
				QTableWidgetItem *nameItem = new QTableWidgetItem();
				nameItem->setText(it->first.c_str());
				QTableWidgetItem *valueItem = new QTableWidgetItem();
				valueItem->setText(it->second.c_str());
				skillTable->insertRow(row);
				skillTable->setItem(row, 0, nameItem);
				skillTable->setItem(row, 1, valueItem);
				++row;
			}

			skillTable->resizeRowsToContents();
			skillTable->resizeColumnsToContents();
		}
	}
}
예제 #7
0
void model_import_dlg::on_texture_dialog_done(bool add, QString path, QString type)
{
	QTableWidget * table = mesh_tab->findChild<QTableWidget*>("texturesTable");

	int row = 0;

	if (add)
	{
		row = table->rowCount();
		table->insertRow(row);
	}
	else
	{
		row = table->currentRow();
	}

	table->setItem(row, 0, new QTableWidgetItem(path));
	table->setItem(row, 1, new QTableWidgetItem(type));
	table->setColumnWidth(0, 350);
	table->setColumnWidth(1, 150);

	for (int i = 0; i < table->rowCount(); i++)
		for (int j = 0; j < table->columnCount(); j++)
			table->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
예제 #8
0
unsigned long TableView::getColumnCount()
{
    QTableWidget* table =  getTableWidget();
    if(0!=table)
    {
        return table->columnCount();
    }
    return 0;
}
void NotifyItemDelegate::selectRow(const QString & text)
{
    QComboBox *combo    = qobject_cast<QComboBox *>(sender());
    QTableWidget *table = new QTableWidget;

    table = (QTableWidget *)(combo->parent());

    qNotifyDebug() << table->columnCount();
    qNotifyDebug() << table->rowCount();
    qNotifyDebug() << table->currentRow();
}
예제 #10
0
StatsView::~StatsView()
{
	QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
	QTableWidget *modTable = this->findChild<QTableWidget *>("modTable");
	for (int i=0; i<statsTree->topLevelItemCount(); ++i) {
		delete statsTree->topLevelItem(i);
		--i;
	}
	for (int i=0; i<modTable->rowCount(); ++i) {
		for (int j=0; j<modTable->columnCount(); ++j) {
			delete modTable->item(i, j);
		}
	}
	delete ui;
}
예제 #11
0
ScheduleTable::ScheduleTable(QWidget *parent, const QTableWidget &tableWidget) :
    QWidget(parent),
    _ui(new Ui::ScheduleTable)
{
    _ui->setupUi(this);

    this->setWindowTitle("Schedule Table");

    _ui->tableWidget->setRowCount(tableWidget.rowCount());
    _ui->tableWidget->setColumnCount(tableWidget.columnCount());

    for(int i = 0; i < tableWidget.rowCount(); ++i)
        _ui->tableWidget->setVerticalHeaderItem(i, tableWidget.verticalHeaderItem(i)->clone());

    for(int i = 0; i < tableWidget.rowCount(); ++i) {
        for(int j = 0; j < tableWidget.columnCount(); ++j)
            _ui->tableWidget->setItem(i, j, tableWidget.item(i, j)->clone());
    }

    this->resize(_ui->tableWidget->columnWidth(0) * _ui->tableWidget->columnCount() + 100,
                 _ui->tableWidget->rowHeight(0)   * (_ui->tableWidget->rowCount() + 1) + 50);

    QObject::connect(_ui->pushButtonDone, &QPushButton::clicked, this, &QWidget::close);
}
예제 #12
0
StakeReportDialog::StakeReportDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::StakeReportDialog)
{
    ui->setupUi(this);

    QTableWidget *TableW = ui->StakeReportTable;

    alreadyConnected = false;

    // fill the table with clone of row 0
    for(int y=TableW->rowCount(); --y >= 1;)
        for(int x=TableW->columnCount(); --x >= 0;)
            TableW->setItem(y, x,
                TableW->item(0, x)->clone());

    TableW->horizontalHeader()->resizeSection(1,160);

    QApplication::processEvents();

    updateStakeReportNow();  // 1st update
}
예제 #13
0
void ParameterWidget::applySaved(int pId, int filter_id)
{
  QWidget *found = 0;
  QDate tempdate;
  XSqlQuery qry;
  QString query;
  QString filterValue;
	QDate today = QDate::currentDate();
  int xid, init_filter_id;

	init_filter_id = filter_id;

  QMapIterator<int, QPair<QString, QVariant> > j(_filterValues);
	QPair<QString, ParameterWidgetTypes> tempPair;

  clearFilters();

  if (!parent())
    return;

  if (_filterList->id() == -1)
  {
    emit updated();
    return;
  }

  if (filter_id == 0 && _filterList->id() != -1)
    filter_id = _filterList->id(_filterList->currentIndex());

  QString classname(parent()->objectName());
  if (classname.isEmpty())
    classname = parent()->metaObject()->className();

  query = " SELECT filter_value, "
          "  CASE WHEN (filter_username IS NULL) THEN true "
          "  ELSE false END AS shared "
          " FROM filter "
          " WHERE filter_id=:id ";

  qry.prepare(query);
  qry.bindValue(":id", filter_id );

  qry.exec();

  if (qry.first())
  {
    filterValue = qry.value("filter_value").toString();
    _shared = qry.value("shared").toBool();
  }

	
  QStringList filterRows = filterValue.split("|");
  QString tempFilter = QString();

  int windowIdx = _filtersLayout->rowCount();

	if (filterRows.size() == 1  && pId == 0 && filter_id != 0)
	{
		emit updated();
		return;
	}

  for (int i = 0; i < filterRows.size(); ++i)
  {
    tempFilter = filterRows[i];
    if ( !(tempFilter.isEmpty()) )
    {
      //0 is filterType, 1 is filterValue, 2 is parameterwidgettype
      QStringList tempFilterList = tempFilter.split(":");
			QString key = this->getParameterTypeKey(tempFilterList[0]);
			if (key.isEmpty())
			{
				//parametertype is no longer found, prompt user to delete filter
				if (QMessageBox::question(this, tr("Invalid Filter Set"), tr("This filter set contains an obsolete filter and will be deleted. Do you want to do this?"),
					  QMessageBox::No | QMessageBox::Default,
            QMessageBox::Yes) == QMessageBox::No)
				return;
				else
				{
					QString query = "delete from filter where filter_id=:filter_id";
					XSqlQuery qry;

					qry.prepare(query);
					qry.bindValue(":filter_id", filter_id);
					qry.exec();

					setSavedFilters();
					return;
				}
			}
			else
			{
				this->addParam();

				QLayoutItem *test = _filtersLayout->itemAtPosition(windowIdx, 0)->layout()->itemAt(0);
				XComboBox *mybox = (XComboBox*)test->widget();

      
				int idx = mybox->findText(key);

				mybox->setCurrentIndex(idx);
	
		    found = getFilterWidget(windowIdx);

			  int widgetType = tempFilterList[2].toInt();

			  //grab pointer to newly created filter object
				switch (widgetType)
				{
					case Date:
						DLineEdit *dLineEdit;
						dLineEdit = qobject_cast<DLineEdit*>(found);
						if (dLineEdit != 0)
							dLineEdit->setDate(today.addDays(tempFilterList[1].toInt()), true);
						break;
					case User:
						UsernameCluster *usernameCluster;
							usernameCluster = qobject_cast<UsernameCluster*>(found);
						if (usernameCluster != 0)
							usernameCluster->setUsername(tempFilterList[1]);
						break;
					case Crmacct:
						CRMAcctCluster *crmacctCluster;
						crmacctCluster = qobject_cast<CRMAcctCluster*>(found);
						if (crmacctCluster != 0)
							crmacctCluster->setId(tempFilterList[1].toInt());
							break;
					case Contact:
						ContactCluster *contactCluster;
						contactCluster = qobject_cast<ContactCluster*>(found);
						if (contactCluster != 0)
							contactCluster->setId(tempFilterList[1].toInt());
						break;
					case XComBox:
						XComboBox *xBox;
						xBox = qobject_cast<XComboBox*>(found);
						if (xBox != 0)
						{
							//fix for setid not emitting id signal if id found for filter is first in list
							//set to any other valid id first to fix it
							xBox->setId(2);

							xid = tempFilterList[1].toInt();
							xBox->setId(xid);
						}
						break;
					case Multiselect:
					{
						QTableWidget *tab;
						tab = qobject_cast<QTableWidget*>(found);
						if (tab != 0)
						{
							QStringList   savedval = tempFilterList[1].split(",");
							bool oldblk = tab->blockSignals(true);
							/* the obvious, loop calling tab->selectRow(), gives one selected row,
							 so try this to get multiple selections:
							   make only the desired values selectable,
							   select everything, and
							   connect to a slot that can clean up after us.
							 yuck.
						*/
							for (int j = 0; j < tab->rowCount(); j++)
							{
								if (! savedval.contains(tab->item(j, 0)->data(Qt::UserRole).toString()))
									tab->item(j, 0)->setFlags(tab->item(j, 0)->flags() & (~ Qt::ItemIsSelectable));
							}
							QTableWidgetSelectionRange range(0, 0, tab->rowCount() - 1,
							                               tab->columnCount() - 1);
							tab->setRangeSelected(range, true);
							connect(tab, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(resetMultiselect(QTableWidgetItem*)));

							tab->blockSignals(oldblk);
							storeFilterValue(-1, tab);
						}
					}
					break;
					default:
					{
						QLineEdit *lineEdit;
						lineEdit = qobject_cast<QLineEdit*>(found);
						if (lineEdit != 0)
						{
							lineEdit->setText(tempFilterList[1]);
							storeFilterValue(-1, lineEdit);
						}
						}
								break;
				}//end of switch
				
			}//end of not empty key else
			windowIdx++;
		}//end of if tempfilter not empty
예제 #14
0
void model_import_dlg::create_mesh_tab(QTabWidget * parent, size_t index, render::lod lod)
{
	QWidget * tab = new QWidget(parent);
	tab->setObjectName("meshTab");

	auto & geometry = conv.get(index).geometry.at(lod);
	auto & material = conv.get(index).materials.at(lod);

	QGroupBox * geometry_box = new QGroupBox(tab);
	geometry_box->setGeometry(10, 10, 561, 115);
	geometry_box->setTitle("Geometry");

	QLabel * vertices = new QLabel(geometry_box);
	vertices->setGeometry(20, 20, 200, 20);
	vertices->setText("Vertices: " + QString::number(geometry.vertex_count));

	QLabel * faces = new QLabel(geometry_box);
	faces->setGeometry(20, 40, 200, 20);
	faces->setText("Faces: " + QString::number(geometry.index_count / 3));

	QLabel * indices = new QLabel(geometry_box);
	indices->setGeometry(20, 60, 200, 20);
	indices->setText("Indices: " + QString::number(geometry.index_count));

	QLabel * layout = new QLabel(geometry_box);
	layout->setGeometry(20, 80, 200, 20);
	layout->setText("Layout: " + QString::fromStdString(render::vertex::str(geometry.vertex_type)));

	QGroupBox * material_box = new QGroupBox(tab);
	material_box->setGeometry(10, 130, 561, 400);
	material_box->setTitle("Material");

	QGroupBox * colors_box = new QGroupBox(material_box);
	colors_box->setGeometry(15, 20, 455, 134);
	colors_box->setTitle("Colors");

	QTableWidget * colorsTable = new QTableWidget(colors_box);
	colorsTable->setGeometry(15, 25, 237, 92);
	colorsTable->setObjectName("colorsTable");
	colorsTable->setRowCount(3);
	colorsTable->setColumnCount(3);
	colorsTable->setFrameShape(QFrame::NoFrame);
	colorsTable->setShowGrid(false);
	colorsTable->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
	colorsTable->setEditTriggers(QAbstractItemView::DoubleClicked);
	colorsTable->horizontalHeader()->setDefaultSectionSize(60);
	colorsTable->verticalHeader()->setDefaultSectionSize(23);
	colorsTable->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);

	QStringList color_types;
	color_types.append("Ambient");
	color_types.append("Diffuse");
	color_types.append("Specular");

	QStringList color_channels;
	color_channels.append("R");
	color_channels.append("G");
	color_channels.append("B");

	colorsTable->setVerticalHeaderLabels(color_types);
	colorsTable->setHorizontalHeaderLabels(color_channels);

	colorsTable->setItem(0, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.x))));
	colorsTable->setItem(0, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.y))));
	colorsTable->setItem(0, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.z))));
	colorsTable->setItem(1, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.x))));
	colorsTable->setItem(1, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.y))));
	colorsTable->setItem(1, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.z))));
	colorsTable->setItem(2, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.x))));
	colorsTable->setItem(2, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.y))));
	colorsTable->setItem(2, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.z))));

	QPushButton * colorPick = new QPushButton(colors_box);
	colorPick->setGeometry(290, 24, 75, 23);
	colorPick->setObjectName("colorPick");
	colorPick->setText("Pick");

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			colorsTable->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

	QObject::connect(colorsTable, SIGNAL(itemSelectionChanged()), this, SLOT(on_color_table_changed()));
	QObject::connect(colorPick, SIGNAL(pressed()), this, SLOT(on_color_pick()));

	QLabel * spec_power = new QLabel(colors_box);
	spec_power->setGeometry(290, 89, 80, 23);
	spec_power->setText("Specular power: ");

	QDoubleSpinBox * spec_power_box = new QDoubleSpinBox(colors_box);
	spec_power_box->setObjectName("specularSpinBox");
	spec_power_box->setDecimals(2);
	spec_power_box->setSingleStep(0.05);
	spec_power_box->setFrame(false);
	spec_power_box->setGeometry(390, 89, 50, 23);
	spec_power_box->setValue(material.specular_power);

	QGroupBox * textures_box = new QGroupBox(material_box);
	textures_box->setGeometry(15, 159, 531, 225);
	textures_box->setTitle("Textures");

	QTableWidget * texturesTable = new QTableWidget(textures_box);
	texturesTable->setObjectName("texturesTable");
	texturesTable->setGeometry(15, 25, 500, 150);
	texturesTable->setRowCount(material.textures.size());
	texturesTable->setColumnCount(2);
	texturesTable->setFrameShape(QFrame::NoFrame);
	texturesTable->setShowGrid(false);
	texturesTable->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
	texturesTable->setEditTriggers(QAbstractItemView::DoubleClicked);
	texturesTable->horizontalHeader()->setDefaultSectionSize(60);
	texturesTable->verticalHeader()->setDefaultSectionSize(23);
	texturesTable->verticalHeader()->setVisible(false);

	QStringList texture_headers;
	texture_headers.append("File");
	texture_headers.append("Type");
	texturesTable->setHorizontalHeaderLabels(texture_headers);

	int i = 0;
	assimp::texture_type_map texture_map;

	for (auto texture : material.textures)
	{
		texturesTable->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(texture.second.texture_path.generic_string())));
		texturesTable->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(texture_map.get(texture.first))));
		texturesTable->setColumnWidth(0, 350);
		texturesTable->setColumnWidth(1, 150);

		i++;
	}

	for (i = 0; i < texturesTable->rowCount(); i++)
	for (int j = 0; j < texturesTable->columnCount(); j++)
		texturesTable->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

	QPushButton * add_texture = new QPushButton(textures_box);
	add_texture->setGeometry(15, 185, 75, 23);
	add_texture->setText("Add");

	QPushButton * edit_texture = new QPushButton(textures_box);
	edit_texture->setGeometry(100, 185, 75, 23);
	edit_texture->setObjectName("textureEditButton");
	edit_texture->setText("Edit");
	edit_texture->setEnabled(false);

	QPushButton * delete_texture = new QPushButton(textures_box);
	delete_texture->setGeometry(185, 185, 75, 23);
	delete_texture->setObjectName("textureDeleteButton");
	delete_texture->setText("Delete");
	delete_texture->setEnabled(false);

	QObject::connect(texturesTable, SIGNAL(itemSelectionChanged()), this, SLOT(on_texture_table_changed()));
	QObject::connect(add_texture, SIGNAL(pressed()), this, SLOT(on_texture_add()));
	QObject::connect(edit_texture, SIGNAL(pressed()), this, SLOT(on_texture_edit()));
	QObject::connect(delete_texture, SIGNAL(pressed()), this, SLOT(on_texture_delete()));

	QString title = "Mesh " + QString::number(index);
	parent->addTab(tab, title);
}
예제 #15
0
void StatsView::on_statsTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
	if (current == 0)
		return;
	std::string data = "";
	if (current->childCount() == 0) {
		DataContainerTreeItem *treeData = (DataContainerTreeItem *)current;
		data = treeData->getData();
	}
	QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
	QLabel *modName = this->findChild<QLabel *>("modName");
	QTableWidget *modTable = this->findChild<QTableWidget *>("modTable");
	modTable->blockSignals(true);
	StatsContainer *itemStats = GenStatsReader::getContainer(allItemStats, data.c_str());
	if (itemStats != 0) {
		modName->setText(itemStats->getArg(0).c_str());
		std::map<std::string, std::string> baseData = itemStats->getBaseDataMap();
		if (itemStats->getUsing() != 0) {
			std::map<std::string, std::string> parentData = itemStats->getUsing()->getBaseDataMap();
			for (std::map<std::string, std::string>::iterator it = parentData.begin(); it != parentData.end(); ++it) {
				if (baseData.find(it->first) == baseData.end()) {
					baseData[it->first] = it->second;
				}
			}
		}
		for (int i=0; i<modTable->rowCount(); ++i) {
			for (int j=0; j<modTable->columnCount(); ++j) {
				delete modTable->item(i, j);
			}
		}
		modTable->setRowCount(0);
		int row = 0;
		if (itemStats->getContainerType() == "deltamod") {
			StatsContainer *boost = GenStatsReader::getContainer(allItemStats, itemStats->getBoostName());
			if (boost != 0) {
				std::map<std::string, std::string> boostMap = boost->getBaseDataMap();
				for (std::map<std::string, std::string>::iterator it = boostMap.begin(); it != boostMap.end(); ++it) {
					if (baseData.find(it->first) == baseData.end()) {
						baseData[it->first] = it->second;
					}
				}
			}
			for (int i=0; i<itemStats->getPrefixList().size(); ++i) {
				QTableWidgetItem *nameItem = new QTableWidgetItem();
				nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
				nameItem->setText("Prefix");
				QTableWidgetItem *valueItem = new QTableWidgetItem();
				valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
				valueItem->setText(itemStats->getPrefixList()[i].c_str());
				modTable->insertRow(row);
				modTable->setItem(row, 0, nameItem);
				modTable->setItem(row, 1, valueItem);
				++row;
			}
			for (int i=0; i<itemStats->getSuffixList().size(); ++i) {
				QTableWidgetItem *nameItem = new QTableWidgetItem();
				nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
				nameItem->setText("Suffix");
				QTableWidgetItem *valueItem = new QTableWidgetItem();
				valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
				valueItem->setText(itemStats->getSuffixList()[i].c_str());
				modTable->insertRow(row);
				modTable->setItem(row, 0, nameItem);
				modTable->setItem(row, 1, valueItem);
				++row;
			}
		}
		for (std::map<std::string, std::string>::iterator it = baseData.begin(); it != baseData.end(); ++it) {
			QTableWidgetItem *nameItem = new QTableWidgetItem();
			nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
			nameItem->setText(it->first.c_str());
			QTableWidgetItem *valueItem = new QTableWidgetItem();
			valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
			valueItem->setText(it->second.c_str());
			modTable->insertRow(row);
			modTable->setItem(row, 0, nameItem);
			modTable->setItem(row, 1, valueItem);
			++row;
		}
		
		modTable->resizeRowsToContents();
		modTable->resizeColumnsToContents();
	} else if (current->childCount() == 0) {
		bool canEdit = true;
		if (current->text(0) == "Abilities") {
			canEdit = false;
		}
		QStringList headerList;
		headerList.push_back("Name");
		if (canEdit) {
			headerList.push_back("Editable Value");
		} else {
			headerList.push_back("Value");
		}
		modTable->setHorizontalHeaderLabels(headerList);
		for (int i=0; i<modTable->rowCount(); ++i) {
			for (int j=0; j<modTable->columnCount(); ++j) {
				delete modTable->item(i, j);
			}
		}
		modTable->setRowCount(0);
		int row = 0;
		modTable->insertRow(row);
		QTableWidgetItem *nameItem = new QTableWidgetItem();
		nameItem->setText(current->text(0));
		nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
		modTable->setItem(row, 0, nameItem);
		QTableWidgetItem *valueItem = new QTableWidgetItem();
		if (!canEdit) {
			valueItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
		}
		valueItem->setText(data.c_str());
		modTable->setItem(row, 1, valueItem);
		
		modTable->resizeRowsToContents();
		modTable->resizeColumnsToContents();
	}
	modTable->blockSignals(false);
}
예제 #16
0
void PrintingController::printObjects(FWObject *firewall_to_print,
                                      bool newPageForSection)
{
    if (fwbdebug) qDebug("******** Objects");

    if (newPageForSection)
    {
        pr->flushPage();
        pr->beginPage();   // resets yPos
    } else
        pr->printText("\n");

    pr->printText(QObject::tr("Objects"));
    pr->printText(" ");

    bool haveObjGroups = false;
    bool haveSrvGroups = false;

    QTableWidget *fwObjTbl = new QTableWidget(1,3);
    configureQTableForPrint(fwObjTbl);

    QString descr;

    int row = 0;
    int col = 0;

    addObjectsByTypeToTable(firewall_to_print, Firewall::TYPENAME,
                            fwObjTbl, row, col);

    for (int i=0; i<fwObjTbl->columnCount(); ++i)
        fwObjTbl->resizeColumnToContents(i);
    for (int i=0; i<fwObjTbl->rowCount(); ++i)
        fwObjTbl->resizeRowToContents(i);

    QSize sh = fwObjTbl->sizeHint();
    fwObjTbl->resize(sh.width(), sh.height());
    pr->printQTable(fwObjTbl, false, false);
    pr->printText(" ");

    QTableWidget *objTbl = new QTableWidget(1,6);
    configureQTableForPrint(objTbl);

    row = 0;
    col = 0;

    addObjectsByTypeToTable(firewall_to_print, Host::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print, Network::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print, NetworkIPv6::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print, IPv4::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print, IPv6::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print,
                            AddressRange::TYPENAME,
                            objTbl, row, col);

    haveObjGroups = addObjectsByTypeToTable(
        firewall_to_print, ObjectGroup::TYPENAME,
        objTbl, row, col);

    addObjectsByTypeToTable(firewall_to_print, IPService::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print,
                            ICMPService::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print,
                            ICMP6Service::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print, TCPService::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print, UDPService::TYPENAME,
                            objTbl, row, col);
    addObjectsByTypeToTable(firewall_to_print,
                            CustomService::TYPENAME,
                            objTbl, row, col);

    haveSrvGroups = addObjectsByTypeToTable(
        firewall_to_print, ServiceGroup::TYPENAME,
        objTbl, row, col);

    addObjectsByTypeToTable(firewall_to_print, Interval::TYPENAME,
                            objTbl, row, col);

    for (int i=0; i<objTbl->columnCount(); ++i)
        objTbl->resizeColumnToContents(i);
    for (int i=0; i<objTbl->rowCount(); ++i)
        objTbl->resizeRowToContents(i);

    sh = objTbl->sizeHint();
    objTbl->resize(sh.width(), sh.height());
    pr->printQTable(objTbl, false, false);

    if (haveObjGroups || haveSrvGroups)
    {
        if (fwbdebug) qDebug("******** Groups");

        pr->printText("\n");
        pr->printText(QObject::tr("Groups"));
        pr->printText(" ");

        list<FWObject*> groups;
        list<FWObject*> objects;

        findAllUsedByType(objects, firewall_to_print,
                          ObjectGroup::TYPENAME);
        findAllGroups(objects,groups);

        objects.clear();
        findAllUsedByType(objects, firewall_to_print,
                          ServiceGroup::TYPENAME);
        findAllGroups(objects,groups);

        for (FWObject::iterator obj=groups.begin();
             obj!=groups.end(); ++obj)
        {
            QTableWidget *objTbl = new QTableWidget(1,6);
            configureQTableForPrint(objTbl);

            row = 0;
            col = 0;
            list<FWObject*> groupMembers;

            for (FWObject::iterator j=(*obj)->begin();
                 j!=(*obj)->end(); ++j)
            {
                FWObject *o = *j;
                if (FWReference::cast(o)!=NULL)
                    o=FWReference::cast(o)->getPointer();
                groupMembers.push_back(o);
            }

            int added = addObjectsToTable(
                groupMembers, objTbl, row, col);
            if (fwbdebug) qDebug("Group %s: added %d group members",
                                 (*obj)->getName().c_str(),added);

            if (added == 0)
            {
                objTbl->setItem(row, col,
                                new QTableWidgetItem(QObject::tr("EMPTY")) );
            }

            for (int i=0; i<objTbl->columnCount(); ++i)
                objTbl->resizeColumnToContents(i);
            for (int i=0; i<objTbl->rowCount(); ++i)
                objTbl->resizeRowToContents(i);

            pr->printText((*obj)->getName().c_str());
            pr->printQTable(objTbl, false, false);
            pr->printText("\n");
        }
    }

}
예제 #17
0
int Table::getColumnCount()
{
    QTableWidget *tablewidget = static_cast<QTableWidget*>(getQWidget());
    return tablewidget->columnCount();
}