Esempio n. 1
0
bool MatrixModel::setData(const QModelIndex &index, const QVariant &value,
                          int role) {
  if (!index.isValid())
    return false;

  int i = d_cols * index.row() + index.column();
  double valBefore = d_data[i];
  if (role == Qt::EditRole) {
    if (value.toString().isEmpty())
      d_data[i] = GSL_NAN;
    else
      d_data[i] = value.toDouble();
  }

  if (index.row() + 1 >= d_rows) {
    insertRows(d_rows, 1);
    d_matrix->resetView();
  }

  d_matrix->undoStack()->push(new MatrixEditCellCommand(
      this, index, valBefore, d_data[i],
      tr("Edited cell") + " (" + QString::number(index.row() + 1) + "," +
          QString::number(index.column() + 1) + ")"));
  d_matrix->notifyChanges();
  d_matrix->moveCell(index);
  return false;
}
/*!
    \fn void QTextTable::resize(int rows, int columns)

    Resizes the table to contain the required number of \a rows and \a columns.

    \sa insertRows() insertColumns() removeRows() removeColumns()
*/
void QTextTable::resize(int rows, int cols)
{
    Q_D(QTextTable);
    if (d->dirty)
        d->update();

    d->pieceTable->beginEditBlock();

    int nRows = this->rows();
    int nCols = this->columns();

    if (rows == nRows && cols == nCols)
	return;

    if (nCols < cols)
        insertColumns(nCols, cols - nCols);
    else if (nCols > cols)
        removeColumns(cols, nCols - cols);

    if (nRows < rows)
        insertRows(nRows, rows-nRows);
    else if (nRows > rows)
        removeRows(rows, nRows-rows);

    d->pieceTable->endEditBlock();
}
Esempio n. 3
0
/*!
    Add urls \a list into the list at \a row.  If move then movie
    existing ones to row.

    \sa dropMimeData()
*/
void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
{
    if (row == -1)
        row = rowCount();
    row = qMin(row, rowCount());
    for (int i = list.count() - 1; i >= 0; --i) {
        QUrl url = list.at(i);
        if (!url.isValid() || url.scheme() != QLatin1String("file"))
            continue;
        //this makes sure the url is clean
        const QString cleanUrl = QDir::cleanPath(url.toLocalFile());
        url = QUrl::fromLocalFile(cleanUrl);

        for (int j = 0; move && j < rowCount(); ++j) {
            const QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile();
            if (local == cleanUrl) {
                removeRow(j);
                if (j <= row)
                    row--;
                break;
            }
        }
        row = qMax(row, 0);
        const QModelIndex idx = fileSystemModel->index(cleanUrl);
        if (!fileSystemModel->isDir(idx))
            continue;
        insertRows(row, 1);
        setUrl(index(row, 0), url, idx);
        watching.append(qMakePair(idx, cleanUrl));
    }
}
PlaylistModel::PlaylistModel():QAbstractListModel()
{
m_manager = new QNetworkAccessManager();
m_handler = new Handler();
connect(m_handler,&Handler::itemFound,this,&PlaylistModel::addXmlItem);
connect(m_handler,&Handler::mEndDocument,[this] {
    QModelIndex m = QModelIndex();
    dataItems.count();
    insertRows(0,dataItems.count(),m);
});
connect(m_manager,&QNetworkAccessManager::finished,this,&PlaylistModel::requestReceived);
connect(m_manager,&QNetworkAccessManager::authenticationRequired,this,&PlaylistModel::authenticate);
connect(this,&PlaylistModel::searchChanged,[this]() {


    m_proxyModel->setFilterRegExp(QRegExp(search(), Qt::CaseInsensitive));

;

});
        m_proxyModel = new QSortFilterProxyModel(this);
        m_proxyModel->setFilterRole(NameRole);
        m_proxyModel->setSourceModel(this);
        connect(this,&PlaylistModel::remoteUrlChanged,this,&PlaylistModel::fetchFromUrl);


}
Esempio n. 5
0
LanguageListModel::LanguageListModel(ModelType type, QObject* parent)
 : QStringListModel(parent)
 , m_sortModel(new QSortFilterProxyModel(this))
#ifndef NOKDE
 , m_systemLangList(new KConfig(QLatin1String("locale/kf5_all_languages"), KConfig::NoGlobals, QStandardPaths::GenericDataLocation))
#endif
{
#ifndef NOKDE
    setStringList(m_systemLangList->groupList());
#else
    QStringList ll;
    QList<QLocale> allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
    foreach(const QLocale& l, allLocales)
        ll.append(l.name());
    ll=ll.toSet().toList();
    setStringList(ll);
#endif

    if (type==WithEmptyLang) insertRows(rowCount(), 1);
#if 0 //KDE5PORT
    KIconLoader::global()->addExtraDesktopThemes();
#endif
    //qWarning()<<KIconLoader::global()->hasContext(KIconLoader::International);
    //qDebug()<<KIconLoader::global()->queryIconsByContext(KIconLoader::NoGroup,KIconLoader::International);
    m_sortModel->setSourceModel(this);
    m_sortModel->sort(0);
}
Esempio n. 6
0
void KCompletionModel::Private::slotMatches(const QStringList &matches)
{   
    QModelIndexList indexesToRemove;
    QHashIterator<QString, QPersistentModelIndex> it(m_reverseIndexes);
    
    while (it.hasNext()) {
        it.next();
        if (!matches.contains(it.key())) {
            indexesToRemove.append(it.value());
        }
    }
    
    if (!indexesToRemove.empty()) {
        removeRows(indexesToRemove);
    }
    
    QList<QPair<QModelIndex, QVariant> > indexesToAppend;
    QList<QString>::const_iterator strIt;
    int count = m_strings.size();
    for (strIt = matches.constBegin(); strIt != matches.constEnd(); ++strIt) {
        if (!m_reverseIndexes.contains(*strIt)) {
            QPair<QModelIndex, QVariant> indexPair;
            indexPair.first = q->createIndex(count++, 0);
            indexPair.second = *strIt;
            
            indexesToAppend.append(indexPair);
        }
    }

    if (!indexesToAppend.empty()) {
        insertRows(indexesToAppend);
    }
}
Esempio n. 7
0
bool SpriteModel::insertRows(int position, int rows, const QModelIndex &parent)
{
    if (mSpr == Q_NULLPTR)
    {
        bool ok1;
        int width = QInputDialog::getInt(mParent, tr("Input Width"),
                                         tr("Width:"), 25, 1, 2147483647, 1, &ok1);

        bool ok2;
        int height = QInputDialog::getInt(mParent, tr("Input Height"),
                                          tr("Height:"), 25, 1, 2147483647, 1, &ok2);
        if (!ok1 || !ok2)
            insertRows(position, rows, parent);

        QImage img(width, height, QImage::Format_RGBA8888);
        img.fill(Qt::gray);
        mDefault = SubImage(img);

        mSpr = new Sprite();
    }

    beginInsertRows(QModelIndex(), position, position+rows-1);

    for (int row = 0; row < rows; ++row)
        mSpr->mSubimg.insert(position, mDefault);

    endInsertRows();
    return true;
}
Esempio n. 8
0
/*!
    Add urls \a list into the list at \a row.  If move then movie
    existing ones to row.

    \sa dropMimeData()
*/
void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
{
    if (row == -1)
        row = rowCount();
    row = qMin(row, rowCount());
    for (int i = list.count() - 1; i >= 0; --i) {
        QUrl url = list.at(i);
        if (!url.isValid() || url.scheme() != QLatin1String("file"))
            continue;
        for (int j = 0; move && j < rowCount(); ++j) {
            if (index(j, 0).data(UrlRole) == url) {
                removeRow(j);
                if (j <= row)
                    row--;
                break;
            }
        }
        row = qMax(row, 0);
        QModelIndex idx = fileSystemModel->index(url.toLocalFile());
        if (!fileSystemModel->isDir(idx))
            continue;
        insertRows(row, 1);
        setUrl(index(row, 0), url, idx);
        watching.append(QPair<QModelIndex, QString>(idx, url.toLocalFile()));
    }
}
Esempio n. 9
0
  bool TreeModel::appendSubtree(const TreeItem * subtree, const QModelIndex &parent)
  {
      //subtree->setParent(getItem(parent));
      if (!insertRows(rowCount(parent),1,parent))
      {
          qDebug() << "no insertRow";
          return false;
      }
      for (int col = 0; col < columnCount(); ++col)
      {
          if (!setData(index(rowCount(parent)-1,col,parent),subtree->data(col)))
          {
              qDebug() << "no setData";
              return false;
          }

      }
      QModelIndex index_subtree = index(rowCount(parent)-1,0,parent);
      for (int ci = 0; ci < subtree->childCount(); ++ci)
      {
          if (!appendSubtree(subtree->child(ci),index_subtree))
              return false;

      }
      return true;
  }
void RKVarEditModel::setTextMatrix (const QModelIndex& offset, const RKTextMatrix& text, const QItemSelectionRange& confine_to) {
	RK_TRACE (EDITOR);

// NOTE: of course, when the range is small, this is terribly inefficient. On the other hand, it doesn't really matter, then, either. Single cells will be set using setData()
	if ((!offset.isValid ()) || text.isEmpty ()) return;

	int top = offset.row ();
	int left = offset.column ();
	int bottom = top + text.numRows () - 1;
	int right = left + text.numColumns () - 1;
	if (confine_to.isValid ()) {
		if (confine_to.top () > top) return;	// can't confine top-left. Should have been set by caller
		if (confine_to.left () > left) return;
		bottom = qMin (confine_to.bottom (), bottom);
		right = qMin (confine_to.right (), right);
	}

// TODO: some models might not support column addition.
	if (right >= trueCols ()) doInsertColumns (objects.size (), right - trueCols () + 1);
	RK_ASSERT (right < trueCols ());
	int current_rows = objects[0]->getLength ();
	if (bottom >= current_rows) insertRows (current_rows, bottom - current_rows + 1);

	int tcol = 0;
	for (int col = left; col <= right; ++col) {
		RKVariable* var = objects[col];
		int trow = 0;
		for (int row = top; row <= bottom; ++row) {
			var->setText (row, text.getText (trow, tcol));
			++trow;
		}
		++tcol;
	}
}
bool RKVarEditModel::setData (const QModelIndex& index, const QVariant& value, int role) {
	RK_TRACE (EDITOR);

	if (!index.isValid ()) return false;
	int row = index.row ();
	int col = index.column ();
	if (edit_blocks || (role != Qt::EditRole) || (col >= apparentCols ()) || (row >= apparentRows ())) {
		RK_ASSERT (false);
		return false;
	}

	if (col >= objects.size ()) {		// trailing col
		// somebody should add a column for us
		doInsertColumns (objects.size (), 1);

		if (col >= objects.size ()) {
			// apparently, no column has been added in the above signal
			return false;
		}
	}
	if (row >= objects[0]->getLength ()) {		// trailing row
		insertRows (objects[0]->getLength (), 1);
	}

	// edit of normal cells
	RKVariable* var = objects[col];
	RK_ASSERT (var);
	var->setText (row, value.toString ());
	return true;
}
Esempio n. 12
0
bool folderModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    std::cerr << "role: " << role << "\n";

    if (!index.isValid())
        return false;
    
    if (role == Qt::CheckStateRole && index.column() == COL_NOTIFICATION &&
        index.row() < folders.count()) {
        folders[index.row()].set_doNotification(value.toBool());
        return true;
    }
        
    if (role == Qt::EditRole) {
        QString tmpname;
        
        if (index.row() >= folders.count())
            insertRows(folders.count(), index.row()-folders.count()+1, index);
        switch (index.column()) {

        case COL_FOLDERNAME:
            tmpname = value.toString();
            folders[index.row()].set_folderName(tmpname);
            break;

        default:
            return false;
        }
        emit dataChanged(index, index);
        return true;
    }
    return false;
}
Esempio n. 13
0
void GUITabla::ajustarTamano(int fila, int columna)
{
	adjustColumn(columna);
	if (fila + 1 == numRows())
	{
		insertRows ( fila+1, 10);
	}
}
Esempio n. 14
0
void NotifyTableModel::entryAdded(NotificationItem* item)
{
    insertRows(rowCount(), 1, QModelIndex());
    NotificationItem* tmp = _list.at(rowCount() - 1);
    _list.replace(rowCount() - 1, item);
    delete tmp;
    entryUpdated(rowCount() - 1);
}
Esempio n. 15
0
void WAbstractItemModel::dropEvent(const WDropEvent& e, DropAction action,
				   int row, int column,
				   const WModelIndex& parent)
{
  // TODO: For now, we assumes selectionBehavior() == RowSelection !

  WItemSelectionModel *selectionModel
    = dynamic_cast<WItemSelectionModel *>(e.source());
  if (selectionModel) {
    WAbstractItemModel *sourceModel = selectionModel->model();

    /*
     * (1) Insert new rows (or later: cells ?)
     */
    if (action == MoveAction || row == -1) {
      if (row == -1)
	row = rowCount(parent);

      insertRows(row, selectionModel->selectedIndexes().size(), parent);
    }

    /*
     * (2) Copy data
     */
    WModelIndexSet selection = selectionModel->selectedIndexes();

    int r = row;
    for (WModelIndexSet::const_iterator i = selection.begin();
	 i != selection.end(); ++i) {
      WModelIndex sourceIndex = *i;
      if (selectionModel->selectionBehavior() == SelectRows) {
	WModelIndex sourceParent = sourceIndex.parent();

	for (int col = 0; col < sourceModel->columnCount(sourceParent); ++col) {
	  WModelIndex s = sourceModel->index(sourceIndex.row(), col,
					     sourceParent);
	  WModelIndex d = index(r, col, parent);
	  copyData(sourceModel, s, this, d);
	}

	++r;
      } else {
	  
      }
    }

    /*
     * (3) Remove original data
     */
    if (action == MoveAction) {
      while (!selectionModel->selectedIndexes().empty()) {
	WModelIndex i = Utils::last(selectionModel->selectedIndexes());

	sourceModel->removeRow(i.row(), i.parent());
      }
    }
  }
}
Esempio n. 16
0
bool NotifyTableModel::dropMimeData( const QMimeData * data, Qt::DropAction action, int row,
                   int column, const QModelIndex& parent)
{
    Q_UNUSED(column);
    if (action == Qt::IgnoreAction)
        return true;

    if (!data->hasFormat(mime_type_notify_table))
        return false;

    int beginRow = -1;

    if (row != -1)
        beginRow = row;
    else {
        if (parent.isValid())
            beginRow = parent.row();
        else
            beginRow = rowCount(QModelIndex());
    }

    if (-1 == beginRow)
        return false;

    QByteArray encodedData = data->data(mime_type_notify_table);
    QDataStream stream(&encodedData, QIODevice::ReadOnly);
    int rows = beginRow;
    // read next item from input MIME and drop into the table line by line
    while(!stream.atEnd()) {
        quintptr ptr;
        stream >> ptr;
        NotificationItem* item = reinterpret_cast<NotificationItem*>(ptr);
        int dragged = _list.indexOf(item);
        // we can drag item from top rows to bottom (DOWN_DIRECTION),
        // or from bottom rows to top rows (UP_DIRECTION)
        enum { UP_DIRECTION, DOWN_DIRECTION };
        int direction = (dragged < rows) ? DOWN_DIRECTION : (dragged += 1, UP_DIRECTION);
        // check drop bounds
        if (dragged < 0 || ((dragged + 1) >= _list.size() && direction == DOWN_DIRECTION)  || dragged == rows) {
            qNotifyDebug() << "no such item";
            continue;
        }
        // addiional check in case dropping of multiple rows
        if(rows + direction > _list.size()) continue;

        insertRows(rows + direction, 1, QModelIndex());
        _list.replace(rows + direction, item);
        removeRows(dragged, 1, QModelIndex());
        if (direction == UP_DIRECTION)
            ++rows;
    };

    QModelIndex idxTopLeft = index(beginRow, 0, QModelIndex());
    QModelIndex idxBotRight = index(beginRow, columnCount(QModelIndex()), QModelIndex());
    emit dataChanged(idxTopLeft, idxBotRight);
    return true;
}
Esempio n. 17
0
void pgpid_item_model::data_updated(std::list<RsPgpId> &new_neighs)
{

    //shit code follow (rewrite this please)
    size_t old_size = neighs.size(), new_size = 0;
    std::list<RsPgpId> old_neighs = neighs;

    new_size = new_neighs.size();
    //set model data to new cleaned up data
    neighs = new_neighs;
    neighs.sort();
    neighs.unique(); //remove possible dups

    //reflect actual row count in model
    if(old_size < new_size)
    {
        beginInsertRows(QModelIndex(), old_size, new_size);
        insertRows(old_size, new_size - old_size);
        endInsertRows();
    }
    else if(new_size < old_size)
    {
        beginRemoveRows(QModelIndex(), new_size, old_size);
        removeRows(old_size, old_size - new_size);
        endRemoveRows();
    }
    //update data in ui, to avoid unnecessary redraw and ui updates, updating only changed elements
    //TODO: libretroshare should implement a way to obtain only changed elements via some signalling non-blocking api.
    {
        size_t ii1 = 0;
        for(auto i1 = neighs.begin(), end1 = neighs.end(), i2 = old_neighs.begin(), end2 = old_neighs.end(); i1 != end1; ++i1, ++i2, ii1++)
        {
            if(i2 == end2)
                break;
            if(*i1 != *i2)
            {
                QModelIndex topLeft = createIndex(ii1,0), bottomRight = createIndex(ii1, COLUMN_COUNT-1);
                emit dataChanged(topLeft, bottomRight);
            }
        }
    }
    if(new_size > old_size)
    {
        QModelIndex topLeft = createIndex(old_size ? old_size -1 : 0 ,0), bottomRight = createIndex(new_size -1, COLUMN_COUNT-1);
        emit dataChanged(topLeft, bottomRight);
    }
    //dirty solution for initial data fetch
    //TODO: do it properly!
    if(!old_size)
    {
        beginResetModel();
        endResetModel();
    }

    //shit code end
}
Esempio n. 18
0
void KWMapEditor::addEntry() {
	int x = numRows();
	insertRows(x, 1);
	TQPushButton *b = new TQPushButton("X", this);
	connect(b, TQT_SIGNAL(clicked()), this, TQT_SLOT(erase()));
	setCellWidget(x, 0, b);
	ensureCellVisible(x, 1);
	setCurrentCell(x, 1);
	emit dirty();
}
Esempio n. 19
0
void BaseTableModel::insertRecord(record_t &rec, int position)
{
	beginInsertRows( QModelIndex(), position, position );

	m_pApp->getDbMgr().insertRecord(rec, m_table);
	m_entries.insert(position, rec);
	insertRows(position, 1);

	endInsertRows();
}
Esempio n. 20
0
void ezQtFileserveActivityModel::UpdateView()
{
  if (m_uiAddedItems == 0)
    return;

  beginInsertRows(QModelIndex(), m_Items.GetCount() - m_uiAddedItems, m_Items.GetCount() - 1);
  insertRows(m_Items.GetCount(), m_uiAddedItems, QModelIndex());
  m_uiAddedItems = 0;
  endInsertRows();
}
Esempio n. 21
0
void ParamModelBase::AddParameter(const std::string& param, const std::string& value)
{
    std::lock_guard<std::mutex> lock(_mutex);
    int row = (int)_parameters.size();
    QModelIndex row_index = createIndex(row, 0);
    insertRows(row, 1, QModelIndex());
    _parameters[row] = new Param(param, value);
    emit dataChanged(row_index, row_index);
    emit headerDataChanged(Qt::Vertical, row, row);
}
Esempio n. 22
0
void ConfMat::setRowCount(int newRowCount)
{
    int curRowCount = this->getRowCount();
    if (curRowCount == newRowCount)
        return;
    if (curRowCount < newRowCount)
        insertRows(qMax(curRowCount, 0), newRowCount - curRowCount);
    else
        removeRows(qMax(newRowCount, 0), curRowCount - newRowCount);
}
Esempio n. 23
0
int QAbstractItemModel_insertRows(lua_State* const state)
{
    auto self = lua::get<QAbstractItemModel*>(state, 1);

    // virtual bool     insertRows(int row, int count, const QModelIndex & parent = QModelIndex())
    if (lua_gettop(state) == 3) {
        lua::push(state, self->insertRows(
            lua::get<int>(state, 2),
            lua::get<int>(state, 3)
        ));
    } else {
        lua::push(state, self->insertRows(
            lua::get<int>(state, 2),
            lua::get<int>(state, 3),
            lua::get<const QModelIndex&>(state, 4)
        ));
    }
    return 1;
}
Esempio n. 24
0
bool TreeModel::addRows(const QModelIndexList rowList, openstudio::IddObjectType type)
{
  if(type == openstudio::IddObjectType::UserCustom){
    return false;
  }

  const QModelIndex row = rowList.at(0);

  return insertRows(row, rowList, type);
}
Esempio n. 25
0
    void MagnetModel::onUpdateQueue(bt::Uint32 idx, bt::Uint32 count)
    {
        int rows = mman->count();
        if (currentRows < rows)  // add new rows
            insertRows(idx, rows - currentRows, QModelIndex());
        else if (currentRows > rows) // delete rows
            removeRows(idx, currentRows - rows, QModelIndex());

        currentRows = rows;
        emit dataChanged(index(idx, 0), index(count, columnCount(QModelIndex())));
    }
Esempio n. 26
0
QModelIndex CObjectModel::insertItem(int row, QString name, const QModelIndex &parent)
{
	insertRows(row, 1, parent) ;

	QModelIndex index = this->index(row, 0, parent) ;
	ObjectItem *p = static_cast<ObjectItem *>(index.internalPointer()) ;
	p->setIndex(index) ;
	setData(index, name, Qt::EditRole) ;
//	qDebug() << "insertItem row:" << row << " name:" << name << " p:" << p ;
	return index ;
}
Esempio n. 27
0
void
TableModel::setRowCount(int rows)
{
    if ( (rows < 0) || (_imp->rowCount == rows) ) {
        return;
    }
    if (_imp->rowCount < rows) {
        insertRows(std::max(_imp->rowCount, 0), rows - _imp->rowCount);
    } else {
        removeRows(std::max(rows, 0), _imp->rowCount - rows);
    }
}
Esempio n. 28
0
void SortedComboBox::append(const QStringList &strings)
{
    auto model = qobject_cast<QStringListModel *>(this->model());

    int row = model->rowCount();
    model->insertRows(row, strings.size());

    for (const auto &string : strings)
        model->setData(model->index(row++), string);

    model->sort(0);
}
void
MFXAddEditTypedTable::setItemFromControl(FXint r, FXint c, FXWindow* control) {
    register FXTableItem* item = cells[r * ncols + c];
    if (item == NULL) {
        cells[r * ncols + c] = item = createItem("", NULL, NULL);
        if (isItemSelected(r, c)) {
            item->setSelected(FALSE);
        }
    }
    switch (getCellType(c)) {
        case CT_UNDEFINED:
        case CT_STRING:
            item->setFromControl(control);
            break;
        case CT_REAL:
            item->setText(toString(static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
            break;
        case CT_INT:
            item->setText(toString((int) static_cast<FXRealSpinDial*>(control)->getValue()).c_str());
            break;
        case CT_BOOL:
//        return myBoolEditor;
        case CT_ENUM:
//        return myEnumEditor;
        default:
            throw 1;
    }
//    current.row = -1;
//    current.col = -1;
    EditedTableItem edited;
    edited.item = item;
    edited.row = r;
    edited.col = c;
    edited.updateOnly = false;
    killSelection(true);
    bool accepted = true;
    if (target) {
        if (!target->handle(this, FXSEL(SEL_CHANGED, ID_TEXT_CHANGED), (void*) &edited)) {
            accepted = false;
            // !!! item->setText(myPreviousText);
        }
    }
    if (accepted) {
        if (edited.row == getNumRows() - 1) {
            insertRows(getNumRows(), 1, true);
            for (int i = 0; i < getNumColumns(); i++) {
                setItemText(getNumRows() - 1, i, "");
                setItemJustify(getNumRows() - 1, i, JUSTIFY_CENTER_X);
            }
        }
    }
    mode = MOUSE_NONE;
}
Esempio n. 30
0
void TestModel::traverseNode(const QDomNode &node)
{
    QDomElement cells = node.toElement().firstChildElement("cells");
    int rows = cells.attribute("rows").toInt();
    int cols = cells.attribute("cols").toInt();

    insertRows(0, rows);
    insertColumns(0, cols);

    if (rows == 0 || cols == 0) {
        return;
    }

    QDomNode rowNode = cells.firstChild();
    while (!rowNode.isNull()) {
        int row = rowNode.nodeName().remove(0, 3).toInt();

         QDomNode colNode = rowNode.firstChild();
         while (!colNode.isNull()) {
            int col = colNode.nodeName().remove(0, 3).toInt();

            QDomElement colEl = colNode.toElement();
            setColumnType(col, QVariant::nameToType(colEl.attribute("type").toLatin1()));
            setItem(row, col, new QStandardItem(colEl.text()));

            colNode = colNode.nextSibling();
         }

        rowNode = rowNode.nextSibling();
    }

    // Fill empty indexes
    for (int row = 0; row < rowCount(); row++) {

        for (int col = 0; col < columnCount(); col++) {

            if(!item(row, col)) {
                setItem(row, col, new QStandardItem(QString()));
            }
        }
    }

    QDomElement titles = node.toElement().firstChildElement("titles");
    QDomNode colNode = titles.firstChild();
    while (!colNode.isNull()) {
        int col = colNode.nodeName().remove(0, 3).toInt();
        setHeaderData(col, Qt::Horizontal, colNode.toElement().text());

        colNode = colNode.nextSibling();
    }

}