Esempio n. 1
0
void UVSearchModel::addUv(const UV &uv)
{
    //Q_ASSERT(false);
    /*QList<QStandardItem*> newRow;
    newRow.push_back(new QStandardItem(uv.getCode()));
    newRow.push_back(new QStandardItem(uv.getTitre()));
    newRow.push_back(new QStandardItem(UTManager::categorieUVEnumToText(uv.getCategorie())));
    newRow.push_back(new QStandardItem(QString::number(uv.getNombreCredit())));
    newRow.push_back(new QStandardItem("NYI"));
    appendRow(newRow);*/

    int row = rowCount();
    setItem(row, 0, new QStandardItem(uv.getCode()));
    setItem(row, 1, new QStandardItem(uv.getTitre()));
    setItem(row, 2, new QStandardItem(UTManager::categorieUVEnumToText(uv.getCategorie())));
    setItem(row, 3, new QStandardItem(QString::number(uv.getNombreCredit())));
    setItem(row, 4, new QStandardItem("NYI"));
}
Esempio n. 2
0
void Table::clearContents()
{
    // We need to create new cells upon clearing
    for(int i=0; i < rowCount(); i++)
    {
        for(int j=0; j < columnCount(); j++)
            setItem(i, j, new Cell(""));
    }
}
void InnerNode::addElt( Item& itm, int at )
{
    PRECONDITION( 0 <= at && at <= last+1 );
    PRECONDITION( last < maxIndex() );
    for( int i = last+1; i > at ; i-- )
        getItem(i) = getItem(i-1);
    setItem( at, itm );
    last++;
}
Esempio n. 4
0
void SpreadSheet::setFormula(int row, int column, const QString &formula)
{
    Cell *c = cell(row, column);
    if(!c){
        c = new Cell;
        setItem(row, column, c);
    }
    c->setFormula(formula);
}
Esempio n. 5
0
/** should be called in constructor for basic setup of 
 * table cells.
 */
void RatingsTable::setupCells()
{
  PlayerList players = _group->const_players();
  int plCnt = players.count();
  setRowCount( plCnt + 1 );
  setColumnCount( plCnt + 1 + 1 ); // 1 column for total rating results

  for ( int i = 0; i < rowCount(); i ++ ) {
    for ( int j = 0; j < plCnt + 1; j ++ ) {
      QTableWidgetItem *item = new QTableWidgetItem( );
      QString text;
      if ( i == j ) {
        item->setBackground( palette().brush( QPalette::Disabled,
                                              QPalette::Background ) );
        
        if ( i == 0 )  {
          text = _group->name();
        }
        item->setFlags( Qt::NoItemFlags );
      } else if ( i == 0 ) { // 0th row
        text = players.at( j - 1 ).name();
        item->setFlags( Qt::NoItemFlags );
      } else if ( j == 0 ) { // 0th column
        Player p = players.at( i - 1 );
        text = p.name();
        text += " (" + QString::number( p.rating(), 'f', 1 ) + ")";
        item->setFlags( Qt::NoItemFlags );
      } else {
        item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
      }

      item->setText( text );

      setItem( i, j, item );
    }
  
    QTableWidgetItem *item = new QTableWidgetItem( );
    if ( i == 0 ) {
      item->setText( tr( "New rating" ) );
    }
    item->setFlags( Qt::NoItemFlags );
    setItem( i, plCnt + 1, item );
  }
}
Esempio n. 6
0
bool Player::setItemInFreeSlot(size_t invIdx, std::unique_ptr<Item>& item,
	InventoryPosition invPos, bool splitIntoMultiple)
{
	if (invIdx < inventories.size())
	{
		auto& inventory = inventories[invIdx];

		// if item has the quantity/capacity peoperties
		if (item != nullptr &&
			item->hasIntByHash(ItemProp::Capacity) == true)
		{
			// first, try and fit the item into the smallest existing item of the same class
			auto quantityNeeded = item->getIntByHash(ItemProp::Quantity);
			Item* quantItem;
			if (inventory.findBiggestFreeQuantity(
				item->Class()->IdHash16(), quantItem, quantityNeeded) > 0)
			{
				LevelObjValue transferedQuantity;
				if (Inventory::updateQuantities(
					quantItem, item.get(), transferedQuantity, true) == true)
				{
					updateItemQuantityCache(item->Class()->IdHash16(), transferedQuantity);
					return true;
				}
			}

			// if SplitIntoMultiple is true, try and add to all free items
			// and create new items, if possible (should not create more then 1 item)
			if (splitIntoMultiple == true)
			{
				// add full quantity
				LevelObjValue itemSlots;
				auto freeSlots = inventory.getMaxCapacity(*item->Class());
				if (item->getIntByHash(ItemProp::Quantity, itemSlots) == true &&
					itemSlots >= 0 &&
					(unsigned)itemSlots <= freeSlots)
				{
					inventory.addQuantity(*item->Class(), itemSlots, invPos, this);
					updateItemQuantityCache(item->Class()->IdHash16(), itemSlots);
					return true;
				}
				// if you can't add all of it, add none and return.
				return false;
			}
			// if it doesn't fit into the smallest, try and add it in a free slot
		}

		// try and add item to free slot
		size_t itemIdx = 0;
		if (inventory.getFreeSlot(*item, itemIdx, invPos) == true)
		{
			return setItem(invIdx, itemIdx, item);
		}
	}
	return false;
}
/** Move the selected track downward. */
void Playlist::moveTrackDown()
{
	if (currentItem()) {
		int currentRow = currentItem()->row();
		if (currentRow < rowCount()-1) {
			for (int c=0; c < columnCount(); c++) {
				QTableWidgetItem *currentItem = takeItem(currentRow, c);
				QTableWidgetItem *nextItem = takeItem(currentRow+1, c);
				setItem(currentRow, c, nextItem);
				setItem(currentRow+1, c, currentItem);
			}
			sources.swap(currentRow, currentRow+1);
			this->setCurrentIndex(model()->index(currentRow+1, 0));
			if (currentRow == track) {
				track++;
			}
		}
	}
}
/** Move the selected track upward. */
void Playlist::moveTrackUp()
{
	if (currentItem()) {
		int currentRow = currentItem()->row();
		if (currentRow > 0) {
			for (int c=0; c < columnCount(); c++) {
				QTableWidgetItem *currentItem = takeItem(currentRow, c);
				QTableWidgetItem *previousItem = takeItem(currentRow-1, c);
				setItem(currentRow, c, previousItem);
				setItem(currentRow-1, c, currentItem);
			}
			sources.swap(currentRow, currentRow-1);
			setCurrentIndex(model()->index(currentRow-1, 0));
			if (currentRow == track) {
				track--;
			}
		}
	}
}
Esempio n. 9
0
void LC_DlgSplinePoints::updatePoints()
{
    bool const useSpline = ui->rbSplinePoints->isChecked();

    auto const& bData = bezier->getData();
    auto const& pts = useSpline?bData.splinePoints:bData.controlPoints;
    auto model = new QStandardItemModel(pts.size(), 2, this);
    model->setHorizontalHeaderLabels({"x", "y"});

    //set spline data
    for (size_t row = 0; row < pts.size(); ++row) {
        auto const& vp = pts.at(row);
        QStandardItem* x = new QStandardItem(QString::number(vp.x));
        model->setItem(row, 0, x);
        QStandardItem* y = new QStandardItem(QString::number(vp.y));
        model->setItem(row, 1, y);
    }
    ui->tvPoints->setModel(model);
}
Esempio n. 10
0
ItemSupplier::ItemSupplier(Supplier* s, Item* r, int u)
{
  setSupplier(s);
  setItem(r);
  setPriority(u);
  initType(metadata);

  // Trigger level and cluster recomputation
  HasLevel::triggerLazyRecomputation();
}
Esempio n. 11
0
void PartsBinView::setPaletteModel(PaletteModel * model, bool clear) {
	if (clear) {
		doClear();
	}

	if (model->root() == NULL) return;

	setItemAux(model->root());
	setItem(model->root());
}
Esempio n. 12
0
    void addPreview(QUrl previewfile)
    {
        QTableWidgetItem *previewitem = new QTableWidgetItem();
        previewitem->setSizeHint(QSize(64, 64));
        previewitem->setIcon(QIcon(previewfile.path()));

        setItem(m_previewentries, 4, previewitem);
        m_previewentries++;
        // FIXME: mapping from entry to url and to vertical position(s)
    }
Esempio n. 13
0
void WorkflowView::showItem(const QList<QString> & items)
{
	// Setting row count to zero destroys all rows
	setRowCount(0);

    for(int i = 0; i < items.count(); i+=2) {
        int newRow = rowCount();
        insertRow(newRow);
        QTableWidgetItem *variable = new QTableWidgetItem;
        QTableWidgetItem *value = new QTableWidgetItem;
        variable->setText(items[i]);
        value->setText(items[i+1]);
        setItem(newRow, 0, variable);
        setItem(newRow, 1, value);
    }

	// Insert the last empty row for custom info
	insertRow(rowCount());
}
Esempio n. 14
0
ZoneItem::ZoneItem (QGraphicsScene *scene, TriggerItem *parent, int x, int y, int w, int h) :
    MyItem (NULL, ""),
    m_parent (parent)
{
    Q_UNUSED (scene);
    m_width = w;
    m_height = h;
    setItem (addRect (0, 0, m_width, m_height) );
    setPos (x, y);
}
Esempio n. 15
0
void NShortcutEditorWidget::init(const QList<NAction *> &actionList)
{
    if (m_init)
        return;
    m_init = true;

    m_actionList = actionList;
    setRowCount(m_actionList.size());
    for (int i = 0; i < m_actionList.size(); ++i) {
        NAction *action = m_actionList.at(i);

        QTableWidgetItem *nameItem = new QTableWidgetItem(action->text());
        nameItem->setFlags(Qt::NoItemFlags);
        nameItem->setData(Qt::UserRole, action->objectName());
        setItem(i, Name, nameItem);

        QTableWidgetItem *descriptionItem = new QTableWidgetItem(action->statusTip());
        descriptionItem->setFlags(Qt::NoItemFlags);
        setItem(i, Description, descriptionItem);

        QList<QKeySequence> shortcut = action->shortcuts();
        QStringList shortcutStr;
        foreach (QKeySequence seq, shortcut)
            shortcutStr << seq.toString();
        QTableWidgetItem *shortcutItem = new QTableWidgetItem(shortcutStr.join(", "));
        setItem(i, Shortcut, shortcutItem);

        QList<QKeySequence> globalShortcut = action->globalShortcuts();
        QStringList globalShortcutStr;
        foreach (QKeySequence seq, globalShortcut)
            globalShortcutStr << seq.toString();
        QTableWidgetItem *globalShortcutItem = new QTableWidgetItem(globalShortcutStr.join(", "));
        setItem(i, GlobalShortcut, globalShortcutItem);
    }

    resizeColumnToContents(Name);
    resizeColumnToContents(Description);
    horizontalHeader()->setResizeMode(Name, QHeaderView::Fixed);
    horizontalHeader()->setResizeMode(Description, QHeaderView::Fixed);
    horizontalHeader()->setResizeMode(Shortcut, QHeaderView::Stretch);
    horizontalHeader()->setResizeMode(GlobalShortcut, QHeaderView::Stretch);
    horizontalHeader()->setStretchLastSection(true);
}
void ViewTableListWidget::sortByFrequencyCustom(bool ascend)
{
    QList<SortItem> list;
    for(int i = 0; i < rowCount(); i++)
    {
        SortItem newitem;
        newitem.row = i;
        newitem.frequecy = item(i,2)->text().toInt();
        int j = 0;
        if(ascend)
            for(j = list.count() - 1; j >=0 ; j--)
            {
                if(newitem.frequecy >= list.at(j).frequecy) break;
            }
        else
            for(j = list.count() - 1; j >=0 ; j--)
            {
                if(newitem.frequecy <= list.at(j).frequecy) break;
            }
        list.insert(j + 1,newitem);
    }
    QTableWidgetItem * tempitem;
    int temprowcount = rowCount();
    for(int i = 0; i < temprowcount; i++)
    {
        this->insertRow(temprowcount + i);
        tempitem = new QTableWidgetItem(item(list.at(i).row,0)->text());
        tempitem->setIcon(item(list.at(i).row,0)->icon());
        tempitem->setToolTip(item(list.at(i).row,0)->toolTip());
        setItem(temprowcount + i,0,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,1)->text());
        setItem(temprowcount + i,1,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,2)->text());
        tempitem->setTextAlignment(Qt::AlignCenter);
        setItem(temprowcount + i,2,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,3)->text());
        tempitem->setTextAlignment(Qt::AlignCenter);
        setItem(temprowcount + i,3,tempitem);
    }
    for(int i = 0; i < temprowcount; i++)
        removeRow(0);
    list.clear();
}
Esempio n. 17
0
	TooltipItem::TooltipItem(const Item *item) :
		Tooltip(item),
		mGraphic(new Sprite()),
		mText(new TextField2()),
		mLayer(new Layer())
	{
		init();

		setItem(item);
	}
Esempio n. 18
0
void MyTable::setText(int row, int col, const QString & text) {
  QTableItem * itm = item(row, col);
  
  if (itm != 0) {
    itm->setText(text);
    updateCell(row, col);
  }
  else
    setItem(row, col, new TableItem(this, QTableItem::OnTyping, text));
}
Esempio n. 19
0
void SharedUiItemWidgetMapper::itemChanged(SharedUiItem newItem,
                                           SharedUiItem oldItem) {
  // refresh mapping on rename or update (newItem contains new id and data)
  // stop following on delete (newItem is null)
  // do nothing on creation (oldItem is null, which cannot == non null _item)
  if (!_item.isNull() // mapper is currently following an item
      && oldItem == _item) { // related to followed item (same qualified id)
    setItem(newItem);
  }
}
Esempio n. 20
0
void VarTableModel::update()
{
    static int first_update = 1;

    quint32 index = 0;
    estats_val_data* tmp;
 
    estats::Check(estats_read_vars(newdata, cid, nl_client));

    for (int i = 0; i < newdata->length; i++) {
	ESTATS_VAL_TYPE valtype = estats_var_array[i].valtype;
	ESTATS_TYPE type = estats_var_array[i].type;
	char* valstr;

	estats::Check(estats_val_as_string(&valstr, &newdata->val[i], valtype));

        QStandardItem* item = new QStandardItem(valstr); 
//        QStandardItem* item = new QStandardItem(newdata->val[i]); 
        setItem(index, 1, item);

        free((void*)valstr);

        if (!first_update && (type == ESTATS_TYPE_COUNTER32 || type == ESTATS_TYPE_COUNTER64)) {
            estats::Check(estats_val_data_delta(deldata, newdata, olddata));

	    estats::Check(estats_val_as_string(&valstr, &deldata->val[i], valtype));

            QStandardItem* item = new QStandardItem(valstr);
//            QStandardItem* item = new QStandardItem(QString::number(deldata->val[i]));

            setItem(index, 2, item);

            free((void*)valstr);
        }
	index++;
    }
    tmp = olddata;
    olddata = newdata;
    newdata = tmp;

    if (first_update) first_update = 0;
}
Esempio n. 21
0
void TimerView::addTimer(InsteonTimer timer)
{
	static QString dow[7] = { "S ", "M ", "T ", "W ", "Th ", "F ", "Sa" };
	QString mode;
	QString dowText;

	int row = rowCount() - 1;

	if (row == -1) {
		addBlankRow();
		row = 0;
	}

	insertRow(row);

	setItem(row, 0, new QTableWidgetItem(timer.name));
    if (timer.mode == INSTEON_TIMER_MODE_TOD)
        setItem(row, 1, new QTableWidgetItem(timer.time.toString("hh:mm")));
    else
        setItem(row, 1, new QTableWidgetItem("---"));

	for (int i = 0; i < 7; i++) {
		if (timer.daysOfWeek & (0x01 << i))
			dowText += dow[i];
	}

	setItem(row, 2, new QTableWidgetItem(dowText));

	if (timer.mode == INSTEON_TIMER_MODE_TOD)
		mode = "DOW";
	else if (timer.mode == INSTEON_TIMER_MODE_SUNRISE)
		mode = "Sunrise";
	else if (timer.mode == INSTEON_TIMER_MODE_SUNSET)
		mode = "Sunset";

	setItem(row, 3, new QTableWidgetItem(mode));
	setItem(row, 4, new QTableWidgetItem(QString::number(timer.deltaTime)));
	setItem(row, 5, new QTableWidgetItem(timer.randomMode ? "true" : "false"));
	setItem(row, 6, new QTableWidgetItem(timer.armed ? "true" : "false"));
	setItem(row, 7, new QTableWidgetItem(QString::number(timer.devices.count())));
	setItem(row, 8, new QTableWidgetItem(timer.triggerTime.toString("hh:mm")));
}
Esempio n. 22
0
void FileListModel::setPath( const QString &path )
{
    dir.setPath( path );
    if ( !dir.exists() )
    {
        QMessageBox::information( nullptr, tr( "info" ), tr( "Dir Not Exist!" ) );
        return;
    }
    fileInfoHash.clear();
    clear();
    QStringList columnLabels;
    columnLabels.push_back( tr( "Name" ) );
    columnLabels.push_back( tr( "Size" ) );
    columnLabels.push_back( tr( "Kind" ) );
    columnLabels.push_back( tr( "Date Modified" ) );
    setHorizontalHeaderLabels( columnLabels );
    QList<QFileInfo> fileList = dir.entryInfoList();
    int rowCount = 0;
    for ( const QFileInfo &entry : fileList )
    {
        QString fileName = entry.fileName();
        if ( fileName == "." )
        {
            continue;
        }
        QStandardItem *c1 = new QStandardItem( entry.fileName() );
        QStandardItem *c2 = new QStandardItem( QString::number( entry.size() ) );
        c2->setFlags(Qt::ItemIsSelectable);
        QStandardItem *c3 = new QStandardItem( entry.suffix() );
        c3->setFlags(Qt::ItemIsSelectable);
        QStandardItem *c4 = new QStandardItem( entry.lastModified().toString() );
        c4->setFlags(Qt::ItemIsSelectable);

        setItem( rowCount, 0, c1 );
        setItem( rowCount, 1, c2 );
        setItem( rowCount, 2, c3 );
        setItem( rowCount, 3, c4 );

        fileInfoHash.insert( rowCount, entry );
        ++rowCount;
    }
}
Esempio n. 23
0
void TableWidget::populateTable(const openstudio::WorkspaceObject& obj)
{
  clear();
  setCurrentCell(0,0);
  setRowCount(1);

  openstudio::IddObject iddObj = obj.iddObject();
  for(unsigned i=0; i<obj.numFields(); ++i){
    bool defaultText = false;
    OptionalString val = obj.getString(i);
    if(!val){
      defaultText = true;
      val = obj.getString(i, true);
      // if still no value it is just blank
      if (!val){
        val = "";
      }
    }
    // setItem causes QTableWIdget to take ownership of newItem
    QTableWidgetItem * newItem = new QTableWidgetItem((*val).c_str());
    if(defaultText){
      newItem->setTextColor(Qt::gray);
    }
    setItem(rowCount()-1, 1, newItem);

    openstudio::OptionalIddField iddField = iddObj.getField(i);
    if(!iddField){
      // log error
    }
    else{
      *val = iddField->name();
    }
    // setItem causes QTableWIdget to take ownership of newItem
    newItem = new QTableWidgetItem((*val).c_str());
    setItem(rowCount()-1, 0, newItem);

    setRowCount(rowCount() + 1);
  }

  resizeColumnsToContents();
  resizeRowsToContents();
}
Esempio n. 24
0
    void addEntry(KNS::Entry *entry) {
        QTableWidgetItem *nameitem = new QTableWidgetItem();
        nameitem->setText(entry->name().representation());

        QTableWidgetItem *authoritem = new QTableWidgetItem();
        authoritem->setText(entry->author().name());

        QTableWidgetItem *downloadsitem = new QTableWidgetItem();
        downloadsitem->setText(QString::number(entry->downloads()));

        QTableWidgetItem *ratingitem = new QTableWidgetItem();
        ratingitem->setText(QString::number(entry->rating()));

        setItem(m_entries, 0, nameitem);
        setItem(m_entries, 1, authoritem);
        setItem(m_entries, 2, downloadsitem);
        setItem(m_entries, 3, ratingitem);

        m_entries++;
    }
Esempio n. 25
0
void Table::recalcSum( int, int col )
{
    // only recalc if a value in the second or third column changed
    if ( col < 1 || col > 2 )
	return;

    // recalc sum
    int sum = 0;
    for ( int i = 0; i < numRows() - 1; ++i ) {
	if ( text( i, 2 ) == "No" )
	    continue;
	sum += text( i, 1 ).toInt();
    }

    // insert calculated data
    TableItem *i1 = new TableItem( this, QTableItem::Never, tr( "Sum" ) );
    setItem( numRows() - 1, 0, i1 );
    TableItem *i2 = new TableItem( this, QTableItem::Never, QString::number( sum ) );
    setItem( numRows() - 1, 1, i2 );
}
Esempio n. 26
0
void ValueTableWidget::addFullRow()
{
    insertRow(rowCount());

    selectRow(rowCount()-1);
    blockSignals( true );

    QTableWidgetItem * item;
    item = new QTableWidgetItem();
    //connect(
    //item->
    item->setData( Qt::DisplayRole, "Name" );
    setItem( rowCount()-1, 0, item );

    item = new QTableWidgetItem();
    item->setData( Qt::DisplayRole, 0.0 );
    setItem( rowCount()-1, 1, item );

    blockSignals( false );
}
Esempio n. 27
0
void Player::setPlayer(string _id, string _pwd,int _win, int _lose, int _money, int* _item, int* _itemE)
{
	 id=_id;
	 pwd=_pwd;
	 win=_win;
	 lose=_lose;
	 money=_money;
	 setItem(_item);
	 for(int i=0; i<3; i++)
		 setItemE(i,_itemE[i]);
}
Esempio n. 28
0
void TupFramesTable::setAttribute(int row, int col, TupFramesTableItem::Attributes att, bool value)
{
    QTableWidgetItem *item = this->item(row, col);
    
    if (!item) {
        item = new TupFramesTableItem;
        setItem(row, col, item);
    }
    
    item->setData(att, value);
}
Esempio n. 29
0
void MailListView::treeInsert(const QMailIdList& idList, 
			      const QSoftMenuBar::StandardLabel label)
{
    this->clear();
    setRowCount(idList.count());
    for(int i = 0; i < idList.count(); ++i) {
        setItem(i, 0, new EmailListItem(this, idList[i], 0) );
    }

    QSoftMenuBar::setLabel(this, Qt::Key_Select, rowCount() ? label : QSoftMenuBar::NoLabel);
}
void MusicSongsListWidget::updateSongsFileName(const MusicSongs &songs)
{
    int count = rowCount();
    setRowCount(songs.count());    //reset row count
    for(int i=count; i<songs.count(); i++)
    {
        QTableWidgetItem *item = new QTableWidgetItem;
        setItem(i, 0, item);
        //To get the song name
                          item = new QTableWidgetItem;
        item->setText(QFontMetrics(font()).elidedText(songs[i].getMusicName(), Qt::ElideRight, 242));
        item->setTextColor(QColor(50, 50, 50));
        item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        setItem(i, 1, item);
        //add a delete icon
                          item = new QTableWidgetItem(songs[i].getMusicTime());
        item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        setItem(i, 2, item);
    }
}