void KeyValuesTable::AdjustColumnCount(bool isReadOnly)
{
    int colCount = isReadOnly ? 2 : 3;
    int currentCount = columnCount();

    for(int current = currentCount - 1; current  > -1; current--)
        removeColumn(0);

    for(int current(0); current < colCount ; current++)
    {
        insertColumn(current);
        //horizontalHeader()-> setLabel(current, colNames[current]);
        QTableWidgetItem * item = horizontalHeaderItem(current);
        if(!item)
         {
            item = new QTableWidgetItem();
            setHorizontalHeaderItem(current, item);
        }
         horizontalHeaderItem(current)->setText(colNames[current]);
    }

    setColumnStretchable(1, true);

    if(!isReadOnly)
    {

        setColumnStretchable(2, false);
        resizeColumnToContents(2);
    }
    horizontalHeader()->setSectionResizeMode(0, QHeaderView::Interactive);
    horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive);

}
Beispiel #2
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setupUi(this);

    QStringList headers;
    headers << tr("Title") << tr("Description");

    QFile file(":/default.txt");
    file.open(QIODevice::ReadOnly);
    TreeModel *model = new TreeModel(headers, file.readAll());
    file.close();

    view->setModel(model);
    for (int column = 0; column < model->columnCount(); ++column)
        view->resizeColumnToContents(column);

    connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    connect(view->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));

    connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions()));
    connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow()));
    connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn()));
    connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow()));
    connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn()));
    connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild()));

    updateActions();
}
Beispiel #3
0
void QCustomTableWidget::removeProperty(int index)
{
    if (index != -1)
    {
        removeColumn(logicalColumn(index));
        // updating the she property/character Lists
        std::vector<std::string> values;
        if (pCharacters)
        {
            for (CharacterList::iterator it = pCharacters->begin(); it != pCharacters->end(); it++)
            {
                if ((unsigned int)index < it->propertyNumber())
                {
                    values.push_back(it->property(index));
                    it->removeProperty(index);
                }
            } 
        }
        if (pProperties)
        {
            if (pCharacters)
            {
                emit modificationDone(new CharacterModification(pProperties, (*pProperties)[index], pCharacters, values, index));
            }
            pProperties->remove(index);
        }
        if (index == columnCount())
        {
            index--;
        }
        setCurrentCell(0, index, QItemSelectionModel::Select | QItemSelectionModel::Columns);
    }
}
/**
 * @brief ChordTableWidget::delete_selected_column
 *
 * Supprime les colonnes dont les cases sélectionnées sont membres.
 */
void ChordTableWidget::deleteSelectedColumn() {

	QList<QTableWidgetItem*> listItems = selectedItems();
	//Suppression des doublons
	for(int i=0; i<listItems.size(); i++)
	{
		for(int j=i+1; j<listItems.size(); j++)
		{
			if(listItems.value(i)->column() == listItems.value(j)->column())
			{
				listItems.removeAt(j);
				j--;
			}
		}
	}

	if(listItems.count() == 1 && listItems.value(0)->column() != columnCount() - 1)
	{
		removeColumn(listItems.first()->column());
	}
	else if(listItems.count() > 1)
	{
		QString listColumn;
		listColumn.append(tr("Are you sure you want to delete columns "));

		for(QList<QTableWidgetItem*>::Iterator i = listItems.begin(); i != listItems.end() ; i++)
		{
			listColumn.append(QString::number((**i).column()+1));
			listColumn.append(", ");
		}
		listColumn.remove(listColumn.length()-2, 1);
		listColumn.append("?");

		int answer = QMessageBox::question(this, tr("Deleting columns"), listColumn, QMessageBox::Yes | QMessageBox::No);
		if(answer == QMessageBox::Yes)
		{
			for(QList<QTableWidgetItem*>::Iterator i = listItems.begin(); i != listItems.end() ; i++)
			{
				if(columnCount() > 1 && (**i).column() != columnCount() - 1)
				{
					removeColumn((**i).column());
				}
			}
		}
	}
	emit somethingChanged();
}
Beispiel #5
0
int QAbstractItemModel_removeColumn(lua_State* const state)
{
    auto self = lua::get<QAbstractItemModel*>(state, 1);

    // bool     removeColumn(int column, const QModelIndex & parent = QModelIndex())
    if (lua_gettop(state) == 2) {
        lua::push(state, self->removeColumn(
            lua::get<int>(state, 2)
        ));
    } else {
        lua::push(state, self->removeColumn(
            lua::get<int>(state, 2),
            lua::get<const QModelIndex&>(state, 3)
        ));
    }

    return 1;
}
void tableTemplateWidget::deleteTemplate(void)
{
  if (templateId == 0)
    return;

  QMessageBox delTmp(QMessageBox::Question,
                     tr("Deleting template!"),
                     tr("Do you want delete template ?"),
                     QMessageBox::Yes | QMessageBox::No);

  int code = delTmp.exec();

  if (code == QMessageBox::No)
    return;

  QSqlQuery query;
  QSqlError le;

  query.prepare("DELETE FROM crossword.private_data WHERE _template = ?;");
    query.addBindValue(QVariant(templateId));
  query.exec();

  le = query.lastError();
  if (le.type() != QSqlError::NoError)
    qDebug() << "1. deleteTemplate: " << le.text();

  query.prepare("DELETE FROM crossword.grids WHERE _template = ?;");
    query.addBindValue(QVariant(templateId));
  query.exec();

  le = query.lastError();
  if (le.type() != QSqlError::NoError)
    qDebug() << "2. deleteTemplate: " << le.text();

  query.prepare("DELETE FROM crossword.templates WHERE _id = ?;");
    query.addBindValue(QVariant(templateId));
  query.exec();

  le = query.lastError();
  if (le.type() != QSqlError::NoError)
    qDebug() << "3. deleteTemplate: " << le.text();

  for (int i = 0; i < numCol; i++)
    removeColumn(0);

  setRowCount(0);

  sb->showMessage(tr("Template deleted"), 2000);

  // need for templateListWidget
  emit deletedFromDB(templateId);

  numCol = numRow = 0;
  templateId = 0;
  countWords = 0;
  wi.clear();
}
Beispiel #7
0
//SLOT:setVar : changement de l'id de la variable et traçage du Tri à plat
void TaP::setVar(QIntList id)
{
    //On prend la première variable si plusieurs sont sélectionnées
    var_courante=this->population->pVar(id.at(0));
    this->setNom(var_courante->Nom());
    this->typeVar=var_courante->Type();

        while(columnCount()>3)
        {removeColumn(columnCount()-1);}

        if(rowCount()>0)
        {
            removeRows(0,rowCount());
        }
        setNomVar(0, "Modalités");
        setNomVar(1, "Effectifs");
        setNomVar(2, "Fréquences");

        TAP_DONNEES donnees;
        donnees.Charger(var_courante);

        switch(typeVar)
        {
            case TYPES::QUALITATIF_ORDINAL:
                addColumn();
                setNomVar(3, "Fréquences Cumulées");
                setTypeVar(3, TYPES::QUALITATIF_PURE);
                break;
            case TYPES::QUANTITATIF_DISCRET:
                addColumn();
                setNomVar(3, "Fréquences Cumulées");
                setTypeVar(3, TYPES::QUALITATIF_PURE);
                break;
            case TYPES::QUANTITATIF_CONTINU_PURE:
                addColumn();
                setNomVar(3, "Fréquences Cumulées");
                setTypeVar(3, TYPES::QUALITATIF_PURE);
                break;
        }
        for(int i=0; i<donnees.Modalites().size();i++)
        {
            if(i==rowCount())
            {
                addRows();
            }
            setData(0, i, donnees.Modalites().at(i));
            setData(1, i, donnees.Effectifs().at(i));
            setData(2, i, donnees.Frequences().at(i));
            if(donnees.FrequencesCumulees().size())
            {setData(3,i, donnees.FrequencesCumulees().at(i));}
        }
        addRows();
        setData(0,rowCount()-1,"TOTAL");
        setData(1,rowCount()-1,population->NbValideString(id.at(0)));
        setData(2,rowCount()-1,"1,00");
}
Beispiel #8
0
void WMSetBrowserMaxVisibleColumns(WMBrowser * bPtr, int columns)
{
	int curMaxVisibleColumns;
	int newFirstVisibleColumn = 0;

	assert(bPtr != NULL);

	columns = (columns < MIN_VISIBLE_COLUMNS) ? MIN_VISIBLE_COLUMNS : columns;
	columns = (columns > MAX_VISIBLE_COLUMNS) ? MAX_VISIBLE_COLUMNS : columns;
	if (columns == bPtr->maxVisibleColumns) {
		return;
	}
	curMaxVisibleColumns = bPtr->maxVisibleColumns;
	bPtr->maxVisibleColumns = columns;
	/* browser not loaded */
	if (!bPtr->flags.loaded) {
		if ((columns > curMaxVisibleColumns) && (columns > bPtr->columnCount)) {
			int i = columns - bPtr->columnCount;
			bPtr->usedColumnCount = bPtr->columnCount;
			while (i--) {
				WMAddBrowserColumn(bPtr);
			}
			bPtr->usedColumnCount = 0;
		}
		/* browser loaded and columns > curMaxVisibleColumns */
	} else if (columns > curMaxVisibleColumns) {
		if (bPtr->usedColumnCount > columns) {
			newFirstVisibleColumn = bPtr->usedColumnCount - columns;
		}
		if (newFirstVisibleColumn > bPtr->firstVisibleColumn) {
			newFirstVisibleColumn = bPtr->firstVisibleColumn;
		}
		if (columns > bPtr->columnCount) {
			int i = columns - bPtr->columnCount;
			int curUsedColumnCount = bPtr->usedColumnCount;
			bPtr->usedColumnCount = bPtr->columnCount;
			while (i--) {
				WMAddBrowserColumn(bPtr);
			}
			bPtr->usedColumnCount = curUsedColumnCount;
		}
		/* browser loaded and columns < curMaxVisibleColumns */
	} else {
		newFirstVisibleColumn = bPtr->firstVisibleColumn;
		if (newFirstVisibleColumn + columns >= bPtr->usedColumnCount) {
			removeColumn(bPtr, newFirstVisibleColumn + columns);
		}
	}
	WMResizeWidget(bPtr, bPtr->view->size.width, bPtr->view->size.height);
	if (bPtr->flags.loaded) {
		XClearArea(bPtr->view->screen->display, bPtr->view->window, 0, 0,
			   bPtr->view->size.width, bPtr->titleHeight, False);
		scrollToColumn(bPtr, newFirstVisibleColumn, True);
	}
}
Beispiel #9
0
void FormLayoutMatrix::simplifyMatrix()
{
    bool rowRemoved = false;

    //check for empty rows
    for (int i = 0; i < m_rows; i++) {
        bool markedRow = false; //current row removal flag
        QList<AbstractFormWidget*>& currentColumn = m_matrix[i];

        if (currentColumn.isEmpty()) {
            markedRow = true;
        } else {
            markedRow = true; //init value
            //check if all elements of the row are empty
            for (int c = 0; c < m_columns; c++) {
                AbstractFormWidget* p = currentColumn.at(c);
                //markedRow is only true if all previous and current cell is empty
                markedRow = markedRow && ((p == NULL) || (p == (void*)NO_FORM_WIDGET));
            }
        }

        if (markedRow) {
            removeRow(i);
            rowRemoved = true;
            simplifyMatrix(); //repeat for all rows but now with one row less
            break; //break cycle because after removal the indexes are not coherent anymore
        }
    }

    //if no row was deleted the indexes are still valid, so we can check columns
    if (!rowRemoved) {
        //check for empty columns
        for (int i = 0; i < m_columns; i++) {
            bool markedColumn = true; //current column removal flag
            int j = 0;
            while (j < m_rows) {
                AbstractFormWidget* p = m_matrix[j].at(i);
                if ((p == (void*)NO_FORM_WIDGET) || (p == NULL)) {
                    j++;
                } else {
                    markedColumn = false;
                    break; //there is an item that is valid so exit cycle
                }
            }

            if (markedColumn) {
                removeColumn(i);
                simplifyMatrix(); //repeat for all columns but now with one column less
                break; //break cycle because after removal the indexes are not coherent anymore
            }
        }
    }
}
int gui::TreeWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updateActions((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 1: updateActions(); break;
        case 2: clickedTree((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 3: { string _r = ObtType((*reinterpret_cast< const QModelIndex(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< string*>(_a[0]) = _r; }  break;
        case 4: insertChild(); break;
        case 5: { bool _r = insertColumn((*reinterpret_cast< const QModelIndex(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 6: { bool _r = insertColumn();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 7: insertRow(); break;
        case 8: { bool _r = removeColumn((*reinterpret_cast< const QModelIndex(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 9: { bool _r = removeColumn();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 10: removeRow(); break;
        case 11: editObject(); break;
        case 12: saveShow(); break;
        case 13: loadShow(); break;
        case 14: setOrbitmode(); break;
        case 15: setRollmode(); break;
        case 16: setDollymode(); break;
        case 17: setPanymode(); break;
        case 18: setCalibration(); break;
        case 19: quit(); break;
        default: ;
        }
        _id -= 20;
    }
    return _id;
}
void tableTemplateWidget::rmColumn(void)
{
  int lc, cc;

  selectionRange = selectedRanges();

  for (int i = 0; i < selectionRange.count(); i++)
    {
      lc = selectionRange[i].leftColumn();
      cc = selectionRange[i].columnCount();

      for (int j = 0; j < cc; j++)
        removeColumn(lc);
    }

  numCol = columnCount();
  isDirty = true;
}
Beispiel #12
0
static void listCallback(void *self, void *clientData)
{
	WMBrowser *bPtr = (WMBrowser *) clientData;
	WMList *lPtr = (WMList *) self;
	WMListItem *item;
	int i, selNo;
	static WMListItem *oldItem = NULL;
	static int oldSelNo = 0;

	item = WMGetListSelectedItem(lPtr);
	selNo = WMGetArrayItemCount(WMGetListSelectedItems(lPtr));

	if (oldItem == NULL || oldItem != item || oldSelNo != selNo) {
		for (i = 0; i < bPtr->columnCount; i++) {
			if (lPtr == bPtr->columns[i])
				break;
		}
		assert(i < bPtr->columnCount);

		bPtr->selectedColumn = i;

		/* columns at right must be cleared */
		removeColumn(bPtr, i + 1);
		/* open directory */
		if (item && item->isBranch && selNo == 1) {
			WMAddBrowserColumn(bPtr);
		}
		if (bPtr->usedColumnCount < bPtr->maxVisibleColumns)
			i = 0;
		else
			i = bPtr->usedColumnCount - bPtr->maxVisibleColumns;
		scrollToColumn(bPtr, i, True);
		if (item && item->isBranch && selNo == 1) {
			loadColumn(bPtr, bPtr->usedColumnCount - 1);
		}
	}

	/* call callback for click */
	if (bPtr->action)
		(*bPtr->action) (bPtr, bPtr->clientData);

	oldItem = item;
	oldSelNo = selNo;
}
void QCustomTableWidget::removeSkill(int index)
{
    removeColumn(index);
    // updating the she skill/character Lists
    if (pSkills != NULL)
    {
        pSkills->remove(index);
    }
    if (pCharacters != NULL)
    {
        for (CharacterList::iterator it=pCharacters->begin(); it != pCharacters->end(); it++)
        {
            if ((unsigned int)index < it->skillNumber())
            {
                it->removeSkill(index);
            }
        } 
    }
}
Beispiel #14
0
void WMRemoveBrowserItem(WMBrowser * bPtr, int column, int row)
{
	WMList *list;

	if (column < 0 || column >= bPtr->usedColumnCount)
		return;

	list = WMGetBrowserListInColumn(bPtr, column);

	if (row < 0 || row >= WMGetListNumberOfRows(list))
		return;

	removeColumn(bPtr, column + 1);
	if (bPtr->usedColumnCount < bPtr->maxVisibleColumns)
		scrollToColumn(bPtr, 0, True);
	else
		scrollToColumn(bPtr, bPtr->usedColumnCount - bPtr->maxVisibleColumns, True);

	WMRemoveListItem(list, row);
}
Beispiel #15
0
void ListProgress::applySettings()
{
    int iEnabledCols = 0;

    // Update listcolumns to show
    for(int i = 0; i < TB_MAX; i++)
    {
        if(!m_lpcc[i].enabled)
            continue;

        iEnabledCols++;

        // Add new or reuse existing column
        if(iEnabledCols > columns())
            m_lpcc[i].index = addColumn(m_lpcc[i].title, m_fixedColumnWidths ? m_lpcc[i].width : -1);
        else
        {
            m_lpcc[i].index = iEnabledCols - 1;
            setColumnText(m_lpcc[i].index, m_lpcc[i].title);
        }

        setColumnWidth(m_lpcc[i].index, m_lpcc[i].width); // yes, this is required here, alexxx
        if(m_fixedColumnWidths)
            setColumnWidthMode(m_lpcc[i].index, Manual);
    }

    // Remove unused columns. However we must keep one column left
    // Otherwise the listview will be emptied
    while(iEnabledCols < columns() && columns() > 1)
        removeColumn(columns() - 1);

    if(columns() == 0)
        addColumn("");

    if(!m_showHeader || iEnabledCols == 0)
        header()->hide();
    else
        header()->show();
}
Beispiel #16
0
void ColumnFileBrowserContents::selectedFileChanged (const File& file)
{
    // if last column clicked add new column
	if (columns[activeColumn] == columns.getLast())
	{
		addColumn (file);
	}
	else        // otherwise remove uneeded columns and change last
	{
		for (int i = 0; i < columns.size(); i++)
		{
			if (columns[activeColumn] == columns[i])
            {
                const int numColumnsToRemove = columns.size() - i - (file.isDirectory() ? 1 : 0);
				removeColumn (numColumnsToRemove);
				
				if (file.isDirectory())
					columns.getLast()->setRoot (file);
                
                break;
			}
		}
		
		resized();
	}
	
	// stick to edges of viewport
	if (getWidth() < viewport->getWidth())
    {
		viewport->setViewPosition (0, 0);
    }
	else if (file.exists() || (getRight() < viewport->getRight()))
	{
		const int ammountToSubtract = viewport->getRight() - getRight();
		viewport->setViewPosition (viewport->getViewPositionX() - ammountToSubtract, 0);
	}
}
Beispiel #17
0
void Mesh::resize(int nColumns_, int nRows_)
{
    // Brutal: if asked to reduce columns or rows, just delete and redo.
    if (nColumns_ < nColumns())
    {
        while (nColumns_ != nColumns())
            removeColumn(nColumns()-2);
    }
    if (nRows_ < nRows())
    {
        while (nRows_ != nRows())
            removeRow(nRows()-2);
    }
    if (nColumns_ > nColumns())
    {
        while (nColumns_ != nColumns())
            addColumn();
    }
    if (nRows_ > nRows())
    {
        while (nRows_ != nRows())
            addRow();
    }
}
void HierarchyList::setup()
{
    if ( !formWindow )
  return;
    clear();
    QWidget *w = formWindow->mainContainer();
#ifndef QT_NO_SQL
    if ( formWindow->isDatabaseAware() ) {
  if ( columns() == 2 ) {
      addColumn( i18n("Database" ) );
      header()->resizeSection( 0, 1 );
      header()->resizeSection( 1, 1 );
      header()->resizeSection( 2, 1 );
      header()->adjustHeaderSize();
  }
    } else {
  if ( columns() == 3 ) {
      removeColumn( 2 );
  }
    }
#endif
    if ( w )
  insertObject( w, 0 );
}
Beispiel #19
0
bool QTable::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: setNumRows((int)static_QUType_int.get(_o+1)); break;
    case 1: setNumCols((int)static_QUType_int.get(_o+1)); break;
    case 2: setShowGrid((bool)static_QUType_bool.get(_o+1)); break;
    case 3: hideRow((int)static_QUType_int.get(_o+1)); break;
    case 4: hideColumn((int)static_QUType_int.get(_o+1)); break;
    case 5: showRow((int)static_QUType_int.get(_o+1)); break;
    case 6: showColumn((int)static_QUType_int.get(_o+1)); break;
    case 7: static_QUType_bool.set(_o,isRowHidden((int)static_QUType_int.get(_o+1))); break;
    case 8: static_QUType_bool.set(_o,isColumnHidden((int)static_QUType_int.get(_o+1))); break;
    case 9: setColumnWidth((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 10: setRowHeight((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 11: adjustColumn((int)static_QUType_int.get(_o+1)); break;
    case 12: adjustRow((int)static_QUType_int.get(_o+1)); break;
    case 13: setColumnStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 14: setRowStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 15: static_QUType_bool.set(_o,isColumnStretchable((int)static_QUType_int.get(_o+1))); break;
    case 16: static_QUType_bool.set(_o,isRowStretchable((int)static_QUType_int.get(_o+1))); break;
    case 17: setSorting((bool)static_QUType_bool.get(_o+1)); break;
    case 18: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 19: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 20: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 21: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 22: swapCells((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break;
    case 23: setLeftMargin((int)static_QUType_int.get(_o+1)); break;
    case 24: setTopMargin((int)static_QUType_int.get(_o+1)); break;
    case 25: setCurrentCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 26: clearSelection(); break;
    case 27: clearSelection((bool)static_QUType_bool.get(_o+1)); break;
    case 28: setColumnMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 29: setRowMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 30: setReadOnly((bool)static_QUType_bool.get(_o+1)); break;
    case 31: setRowReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 32: setColumnReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 33: setDragEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 34: static_QUType_bool.set(_o,dragEnabled()); break;
    case 35: insertRows((int)static_QUType_int.get(_o+1)); break;
    case 36: insertRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 37: insertColumns((int)static_QUType_int.get(_o+1)); break;
    case 38: insertColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 39: removeRow((int)static_QUType_int.get(_o+1)); break;
    case 40: removeRows((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 41: removeColumn((int)static_QUType_int.get(_o+1)); break;
    case 42: removeColumns((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 43: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 44: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 45: setRowLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 46: setColumnLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 47: columnWidthChanged((int)static_QUType_int.get(_o+1)); break;
    case 48: rowHeightChanged((int)static_QUType_int.get(_o+1)); break;
    case 49: columnIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 50: rowIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 51: columnClicked((int)static_QUType_int.get(_o+1)); break;
    case 52: doAutoScroll(); break;
    case 53: doValueChanged(); break;
    case 54: updateGeometriesSlot(); break;
    default:
	return QScrollView::qt_invoke( _id, _o );
    }
    return TRUE;
}
//------------------------------------------------------------------------------
QWidget *FeedPropertiesDialog::createColumnsTab()
{
  QWidget *tab = new QWidget();

  columnsTree_ = new QTreeWidget(this);
  columnsTree_->setObjectName("columnsTree");
  columnsTree_->setIndentation(0);
  columnsTree_->setColumnCount(2);
  columnsTree_->setColumnHidden(1, true);
  columnsTree_->setSortingEnabled(false);
  columnsTree_->setHeaderHidden(true);
#ifdef HAVE_QT5
  columnsTree_->header()->setSectionResizeMode(0, QHeaderView::Stretch);
#else
  columnsTree_->header()->setResizeMode(0, QHeaderView::Stretch);
#endif

  QStringList treeItem;
  treeItem << "Name" << "Index";
  columnsTree_->setHeaderLabels(treeItem);

  sortByColumnBox_ = new QComboBox(this);

  sortOrderBox_ = new QComboBox(this);
  treeItem.clear();
  treeItem << tr("Ascending") << tr("Descending");
  sortOrderBox_->addItems(treeItem);

  QHBoxLayout *styleLayout = new QHBoxLayout();
  styleLayout->setMargin(0);
  styleLayout->addWidget(new QLabel(tr("Sort by:")));
  styleLayout->addWidget(sortByColumnBox_);
  styleLayout->addSpacing(10);
  styleLayout->addWidget(sortOrderBox_);
  styleLayout->addStretch();

  QWidget *styleWidget = new QWidget(this);
  styleWidget->setLayout(styleLayout);

  QVBoxLayout *mainVLayout = new QVBoxLayout();
  mainVLayout->addWidget(columnsTree_, 1);
  mainVLayout->addWidget(styleWidget);

  addButtonMenu_ = new QMenu(this);
  addButton_ = new QPushButton(tr("Add"));
  addButton_->setMenu(addButtonMenu_);
  connect(addButtonMenu_, SIGNAL(aboutToShow()),
          this, SLOT(showMenuAddButton()));
  connect(addButtonMenu_, SIGNAL(triggered(QAction*)),
          this, SLOT(addColumn(QAction*)));

  removeButton_ = new QPushButton(tr("Remove"));
  removeButton_->setEnabled(false);
  connect(removeButton_, SIGNAL(clicked()), this, SLOT(removeColumn()));

  moveUpButton_ = new QPushButton(tr("Move up"));
  moveUpButton_->setEnabled(false);
  connect(moveUpButton_, SIGNAL(clicked()), this, SLOT(moveUpColumn()));
  moveDownButton_ = new QPushButton(tr("Move down"));
  moveDownButton_->setEnabled(false);
  connect(moveDownButton_, SIGNAL(clicked()), this, SLOT(moveDownColumn()));

  QPushButton *defaultButton = new QPushButton(tr("Default"));
  connect(defaultButton, SIGNAL(clicked()), this, SLOT(defaultColumns()));

  QVBoxLayout *buttonsVLayout = new QVBoxLayout();
  buttonsVLayout->addWidget(addButton_);
  buttonsVLayout->addWidget(removeButton_);
  buttonsVLayout->addSpacing(10);
  buttonsVLayout->addWidget(moveUpButton_);
  buttonsVLayout->addWidget(moveDownButton_);
  buttonsVLayout->addSpacing(10);
  buttonsVLayout->addWidget(defaultButton);
  buttonsVLayout->addStretch();

  QHBoxLayout *tabLayout = new QHBoxLayout(tab);
  tabLayout->setMargin(10);
  tabLayout->setSpacing(5);
  tabLayout->addLayout(mainVLayout);
  tabLayout->addLayout(buttonsVLayout);

  connect(columnsTree_, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
          this, SLOT(slotCurrentColumnChanged(QTreeWidgetItem*,QTreeWidgetItem*)));

  return tab;
}
Beispiel #21
0
/*!
 * \~english
 *	Sets property `DefFields', `DefHeaders', `ColWidth', `DefIdList' to
 *	values from metadata.
 * \~russian
 *	Устанавливает свойства `DefFields', `DefHeaders', `ColWidth', `DefIdList'
 *	в значения, определенные в метаданных. Старые значения не сохраняются.
 *	Для документа используется idTable.
 *	\~
 *	\param idTable (in) - 	\~english table id
 *				\~russian id таблицы документа.  Не используется для каталогов и журналов.
 *	\~
 */
void
wDBTable::setFields(int idTable)
{
CHECK_POINT
	int field_count,j;
	int i; //,tableCount;
	//QSqlCursor *cur;
	const Q3SqlFieldInfo *field;
	QString str;
	QStringList Cwidth, list_fields,list_id;
	aCfgItem o, o_table, o_field;
	QString mdtag=QString(md_field);

	list_fields.clear();
	o = tables; // object tables
	QString objClass = md->objClass(o);
	//printf("table parent obj class '%s'\n", (const char*)objClass);
	if(objClass==md_tables)
	{
		o_table = md->find(idTable);
	}
	else
	if(objClass==md_columns)
	{
		o_table = o;
		mdtag=QString(md_column);
	}
	else
	if(objClass==md_element)
	{
		o_table = o;
	}
	colWidth.clear();
	i=0;
	while(i<numCols())
	{
		removeColumn(0);
	}
	cur->clear();
	if(!o_table.isNull())
	{
		field_count = md->countChild(o_table,mdtag);
		//printf("table name '%s'\n",(const char*)md->attr(o_table,mda_name));
		//printf("table id '%s'\n",(const char*)md->attr(o_table,mda_id));
		for (j=0; j<field_count; j++)
		{
			o_field = md->findChild(o_table,mdtag,j);
			//printf("field %i name '%s'\n",j,(const char*)md->attr(o_field,mda_name));
			//printf("field %i id '%s'\n",j,(const char*)md->attr ( o_field, mda_id ));
			list_fields << md->attr(o_field,mda_name);
			list_id << md->attr(o_field,mda_id);
			str.setNum(j);
			field = new Q3SqlFieldInfo(md->attr(o_field,"name"));
			cur->append(*field);
			setSqlCursor(cur);
			addColumn(field->name(),field->name(),property("DefaultColWidth").toInt());
			refresh(RefreshColumns);
			Cwidth << property("DefaultColWidth").toString();
		}
	}
	setProperty("DefFields",list_fields);
	setProperty("DefHeaders",list_fields);
	setProperty("ColWidth",Cwidth);
	setProperty("DefIdList",list_id);
}
Beispiel #22
0
/*!
 *\~english
 *	Initialisation the widget on form loaded in engine.
 *\~russian
 *	Инициализация виджета при загрузке в форму инжина.
 *\~
 */
void
wDBTable::init(aDatabase *adb, aEngine *e )
{

	aLog::print(aLog::Debug, tr("wDBTable init in engine "));
//	printf("begin init wdbtable\n");
	unsigned int countField,i;
	aCfgItem o, own;
	QString str, ctype;
	QStringList lst,lstHead,lstWidth;
	int tid;
	aWidget *container = NULL;

	t_doc = rcIcon( "t_doc.png" );
        t_doc_d = rcIcon( "t_doc_d.png" );
        t_doc_t = rcIcon( "t_doc_t.png" );
        t_doc_m = rcIcon( "t_doc_m.png" );
        t_doc_tm = rcIcon( "t_doc_tm.png" );
	t_cat_e = rcIcon( "t_cat_e.png" );
        t_cat_ed = rcIcon( "t_cat_ed.png" );
	t_cat_g = rcIcon( "t_cat_g.png" );
	t_cat_gd = rcIcon( "t_cat_gd.png" );

	engine = e;
	setConfirmDelete(true);
	db = adb;
	md = &adb->cfg;
	tid = property("TableInd").toInt();
	container = aWidget::parentContainer( this );
	if ( !container )
	{
		aLog::print(aLog::Error, tr("wDBTable not in Ananas object container "));
		return; //printf("!no wDBTable parent container\n");
	}
	else
	{
		o = md->objTable( container->getId(), tid );
		if ( o.isNull() )
		{
			//debug_message("Table not found\n");
			aLog::print(aLog::Error, tr("wDBTable init meta object not found "));
		}
		ctype = container->className();
		aLog::print(aLog::Info, tr("wDBTable container type is %1 ").arg(ctype));

		setContainerType(ctype);
	}

	//o  = md->find(property("TableInd").toInt());
	if ( o.isNull() )
	{
		aLog::print(aLog::Error, tr("wDBTable init meta object not found "));
		return;
	}
	countField = numCols();
	for(i=0; i<countField;i++)
	{
		removeColumn(0);
	}
	aSQLTable *tbl = NULL;
	//printf("ctype = %s\n",( const char *) ctype );
	if ( containerType() == "wDocument" )
	{
		QString flt;
		flt = QString("idd=%1").arg(container->uid());
		aLog::print(aLog::Info, tr("wDBTable filter is %1 ").arg(flt));
		setFilter(flt);
		//TODO: fix memory leak
		tbl = new aSQLTable( o, adb );
//		printf("new table ok\n");
	//	tbl->first();

	}
	if ( containerType() == "wCatalogue" ) {
                tbl = container->table(); //new aSQLTable( o, adb );
		setFilter(QString("idg=0"));
		newDataId(0);
		tbl->append( Q3SqlFieldInfo("system_icon") );
//		tbl->setGenerated( "system_icon", false );
		tbl->setCalculated("system_icon", true );
          }
	if ( containerType() == "wJournal" ) {
		tbl = container->table(); //new aSQLTable( o, adb );
		tbl->setMode( 0 );
		tbl->append( Q3SqlFieldInfo( "system_icon" ) );
//		tbl->setGenerated( "system_icon", false );
		tbl->setCalculated( "system_icon", true );
//		tbl->append( QSqlFieldInfo( "t1" ) );
//		tbl->setGenerated( "t1", false );
//		tbl->setCalculated("t1", true );
        }
	refresh();
	cur->clear();
	setSqlCursor(tbl,true);
	refresh(RefreshColumns);
	countField = numCols();
	lst = property("DefIdList").toStringList();
	lstHead = property("DefHeaders").toStringList();
	lstWidth = property("ColWidth").toStringList();
	for ( i = 0; i < countField; i++ )
	{
		//remove all columns in wDBTable, not in sql cursor
		removeColumn( 0 );
		QString s = sqlCursor()->fieldName(i);
//		printf(">>>>s = %s\n",s.ascii());
//		if(sqlCursor()->isCalculated(s))
//		{
//			if((s.left(7)=="text_uf" && lst.findIndex(s.mid(7))!=-1) || s == "system_icon")
//			{
//				continue;
//			}
			// not calculate field, if is not contents in wDBTable
//			sqlCursor()->setCalculated(sqlCursor()->fieldName(i),false);
//		}
	}
	if ( containerType() == "wJournal" ) {
		addColumn( "system_icon", "", 20 );
		setColumnReadOnly( 0, true );
		if (md->objClass(*(container->getMDObject()))==md_journal && !((aDocJournal*) container->dataObject())->type() ) {
			// we have common journal
			// Insert journal system columns.
			addColumn( "ddate", tr("Date"), 100 );
			addColumn( "pnum", tr("Prefix"), 200 );
			addColumn( "num", tr("Number"), 100 );
		}
	}
	if ( containerType() == "wCatalogue" ) {
		addColumn( "system_icon", "", 20 );
	//	printf("set column ro\n");
		setColumnReadOnly( 0, true );
	}

	if ( containerType() == "wDocument" || containerType() == "wCatalogue" ) {

	// Задаем сортировку по индентификатору в обратном порядке для
	// табличной части документа
	// чтобы при добавлении новых позиций в список строки не скакали
	    QSqlIndex pk = sqlCursor()->primaryIndex();
	    pk.setDescending( 0, false);
	    setSort( pk );
	    sqlCursor()->select();
	    sqlCursor()->first();
	    refresh();
	}


	//refresh(RefreshColumns);
	if (md->objClass(*(container->getMDObject()))!=md_journal || ((aDocJournal*) container->dataObject())->type() ) {
		// we have not common journal
		for(i=0; i<lst.count();i++)
		{
			// assemble sql table field names
			if ( containerType() == "wJournal" )
			{
//				str = journalFieldName(lst[i].toLong());

				str = "uf"+QString::number(journalFieldId(lst[i].toLong()));
				//printf(">>>>>>ss=%s\n",str.ascii());
			}
			else
			{
				str = "uf"+lst[i];
			}
			// add defined fields
			addColumn(str,lstHead[i],lstWidth[i].toInt());
		}
	}
	refresh(RefreshAll);
	setWFieldEditor();
	aLog::print(aLog::Debug, tr("wDBTable init in engine ok"));
}
void SheetAccessModel::slotSheetRemoved(Sheet *sheet)
{
    Q_ASSERT(d->cols.contains(sheet));
    removeColumn(d->cols[sheet]);
    d->cols.remove(sheet);
}
Beispiel #24
0
char *WMSetBrowserPath(WMBrowser * bPtr, char *path)
{
	int i;
	char *str;
	char *tmp, *retPtr = NULL;
	int item;
	WMListItem *listItem;

	/* WMLoadBrowserColumnZero must be call first */
	if (!bPtr->flags.loaded) {
		return False;
	}

	removeColumn(bPtr, 1);

	WMSelectListItem(bPtr->columns[0], -1);
	WMSetListPosition(bPtr->columns[0], 0);

	i = 0;
	str = wstrdup(path);
	tmp = strtok(str, bPtr->pathSeparator);
	while (tmp) {
		/* select it in the column */
		item = WMFindRowOfListItemWithTitle(bPtr->columns[i], tmp);
		if (item < 0) {
			retPtr = &path[(int)(tmp - str)];
			break;
		}
		WMSelectListItem(bPtr->columns[i], item);
		WMSetListPosition(bPtr->columns[i], item);

		listItem = WMGetListItem(bPtr->columns[i], item);
		if (!listItem || !listItem->isBranch) {
			break;
		}

		/* load next column */
		WMAddBrowserColumn(bPtr);

		loadColumn(bPtr, i + 1);

		tmp = strtok(NULL, bPtr->pathSeparator);

		i++;
	}

	wfree(str);

	for (i = bPtr->usedColumnCount - 1; (i > -1) && !WMGetListSelectedItem(bPtr->columns[i]); i--) ;

	bPtr->selectedColumn = i;

	if (bPtr->columnCount < bPtr->maxVisibleColumns) {
		int i = bPtr->maxVisibleColumns - bPtr->columnCount;
		int curUsedColumnCount = bPtr->usedColumnCount;
		bPtr->usedColumnCount = bPtr->columnCount;
		while (i--) {
			WMAddBrowserColumn(bPtr);
		}
		bPtr->usedColumnCount = curUsedColumnCount;
	}

	scrollToColumn(bPtr, bPtr->columnCount - bPtr->maxVisibleColumns, True);

	return retPtr;
}
LiveViewWindow::LiveViewWindow(DVRServerRepository *serverRepository, QWidget *parent, bool openfs, Qt::WindowFlags f)
    : QWidget(parent, f), m_liveView(0), m_serverRepository(serverRepository), m_savedLayouts(new QComboBox),
      m_lastLayoutIndex(-1), m_autoSized(false), m_isLayoutChanging(false),
	  m_wasOpenedFs(openfs)
{
    QBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    layout->setSpacing(0);

	m_toolBar = new QToolBar(tr("Live View"));
	m_toolBar->setIconSize(QSize(16, 16));
	m_toolBar->setMovable(false);

#ifndef Q_OS_MAC
    //toolBar->setStyleSheet(QLatin1String("QToolBar { border: none; }"));
#endif

    m_liveView = new LiveViewArea(m_serverRepository);
    LiveViewLayout *viewLayout = m_liveView->layout();

    /* Saved layouts box */
    m_savedLayouts->setModel(SavedLayoutsModel::instance());
    m_savedLayouts->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    m_savedLayouts->setInsertPolicy(QComboBox::NoInsert);
    m_savedLayouts->setMinimumWidth(100);
    m_savedLayouts->setContextMenuPolicy(Qt::CustomContextMenu);
    m_savedLayouts->setCurrentIndex(-1);
    m_savedLayouts->setMaxVisibleItems(22);
	m_toolBar->addWidget(m_savedLayouts);

    QWidget *spacer = new QWidget;
    spacer->setFixedWidth(20);
	m_toolBar->addWidget(spacer);

	aNewLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/plus.png")), tr("New Layout"), this, SLOT(createNewLayout()));
	aRenameLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/pencil.png")), tr("Rename Layout"), this, SLOT(renameLayout()));
	aDelLayout = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Delete Layout"), this, SLOT(deleteCurrentLayout()));

    aRenameLayout->setEnabled(false);
    aDelLayout->setEnabled(false);

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

    connect(m_savedLayouts, SIGNAL(currentIndexChanged(int)), SLOT(savedLayoutChanged(int)));
    connect(m_savedLayouts, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showLayoutMenu(QPoint)));

	m_addRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split-vertical.png")),
                     tr("Add Row"), viewLayout, SLOT(appendRow()));
	m_removeRowAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join-vertical.png")),
                        tr("Remove Row"), viewLayout, SLOT(removeRow()));

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

	m_addColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-split.png")),
                        tr("Add Column"), viewLayout, SLOT(appendColumn()));
	m_removeColumnAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-join.png")),
                           tr("Remove Column"), viewLayout, SLOT(removeColumn()));

    spacer = new QWidget;
    spacer->setFixedWidth(16);
	m_toolBar->addWidget(spacer);

    QSignalMapper *mapper = new QSignalMapper(this);
    connect(mapper, SIGNAL(mapped(int)), viewLayout, SLOT(setGridSize(int)));

	m_singleAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout.png")),
                                    tr("Single"), mapper, SLOT(map()));
	mapper->setMapping(m_singleAction, 1);
	QAction *a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-4.png")),
                           tr("2x2"), mapper, SLOT(map()));
    mapper->setMapping(a, 2);
	a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-9.png")),
                           tr("3x3"), mapper, SLOT(map()));
    mapper->setMapping(a, 3);
	a = m_toolBar->addAction(QIcon(QLatin1String(":/icons/layout-16.png")),
                           tr("4x4"), mapper, SLOT(map()));
    mapper->setMapping(a, 4);

    spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
	m_toolBar->addWidget(spacer);

	m_fullscreenAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/application-resize-full.png")),
                       tr("Fullscreen"), this, SLOT(toggleFullScreen()));
	m_fullscreenAction->setShortcut(Qt::Key_F11);

    if (m_wasOpenedFs)
    {
		m_closeAction = m_toolBar->addAction(QIcon(QLatin1String(":/icons/cross.png")), tr("Exit"),
                           this, SLOT(close()));
        new QShortcut(Qt::Key_Escape, this, SLOT(close()), 0, Qt::WindowShortcut);
    }
    else
        new QShortcut(Qt::Key_Escape, this, SLOT(exitFullScreen()), 0, Qt::WindowShortcut);

    connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(updateLayoutActionStates()));
    connect(m_liveView->layout(), SIGNAL(layoutChanged()), SLOT(saveLayout()));

    QMainWindow *wnd = qobject_cast<QMainWindow*>(window());
    if (wnd)
		wnd->addToolBar(Qt::TopToolBarArea, m_toolBar);
    else
		layout->addWidget(m_toolBar);
    layout->addWidget(m_liveView);

    updateLayoutActionStates();
}
Beispiel #26
0
void KeyValuesTable::updateThisFromNode(HaveKeyValueData *hv, bool isReadOnly)
{

    if (!isReadOnly)
    {
        if(numCols() == 2)
            insertColumns(2);
        horizontalHeader()->setLabel(2, TR("do"));
    }
    else
    {
        if(numCols() == 3)
            removeColumn(2);
    }

    int index;
    int sup = 0;
    if(hv)
        sup = hv->get_n_keys();
    int rowCount = numRows();
    for (index = rowCount - 1; index > sup; index -= 1)
        removeRow(index);

    if (isReadOnly)
    {
        for (index = 0; index < sup; index += 1)
        {
            TableItem * tiKey = nullptr;
            TableItem * tiValue = nullptr;
            QString s = toUnicode(hv->get_value(index));
            int n = s.count('\n');

            if(index == numRows() || numRows() == 0)
            {
                tiKey = new TableItem(this, Q3TableItem::Never,
                                      toUnicode(hv->get_key(index)));
                tiValue = new TableItem(this, Q3TableItem::Never, s);
                setItem(index, 0, tiKey);
                setItem(index, 1, tiValue);
            }
            else
            {
                tiKey = dynamic_cast<TableItem*>(item(index, 0));
                tiKey->setText(hv->get_key(index));
                tiValue = dynamic_cast<TableItem*>(item(index, 1));
                tiValue->setText(s);
            }
            tiKey->setReplaceable(FALSE);
            tiValue->setReplaceable(FALSE);


            if (n != 0)
            {
                // note : adjustRow(index) does nothing
                setRowHeight(index, rowHeight(index) * (n + 1));
            }
        }
    }
    else
    {
        props.setAutoDelete(TRUE);

        QStringList items;

        for (index = 0; index < sup; index += 1)
        {
            QString k = toUnicode(hv->get_key(index));
            QString v = toUnicode(hv->get_value(index));
            QStringList * psl = props[k];

            setText(index, 0, k);

            if (psl != 0)
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));

            if ((k.contains(':') == 2) &&
                    ProfiledStereotypes::enumerated(k, items)) {
                psl = new QStringList(items);
                props.insert(k, psl);
                setItem(index, 1, new ComboItem(this, v, *psl, FALSE));
            }
            else
                setItem(index, 1, new MLinesItem(this, v));

            setText(index, 2, QString());
            setRowStretchable(index, TRUE);
        }

        if(index == numRows())
            insertRows(numRows());
        setText(index, 0, QString());
        setItem(index, 1, new MLinesItem(this, QString()));
        setText(index, 2, QString());
        setRowStretchable(index, TRUE);
    }

    horizontalHeader()->setResizeEnabled(TRUE, 0);  //setColumnStretchable (0, TRUE);
    setColumnStretchable(1, TRUE);

    if (! isReadOnly) {
        adjustColumn(2);
        setColumnStretchable(2, FALSE);
    }



}
Beispiel #27
0
/*************************************************************************
	Remove a segment from the header
*************************************************************************/
void ListHeader::removeSegment(const ListHeaderSegment& segment)
{
	removeColumn(getColumnFromSegment(segment));
}
Beispiel #28
0
/**
  This is a generic class for importing line-oriented data from text files. It
  provides a dialog for file selection, preview, separator selection and column
  assignment as well as generic conversion routines. For conversion to special
  data objects, this class has to be inherited by a special class, which
  reimplements the convertRow() function.
*/
KImportDialog::KImportDialog(QWidget *parent)
    : KDialogBase(parent, "importdialog", true, i18n("Import Text File"), Ok | Cancel),
      mSeparator(","),
      mCurrentRow(0)
{
    mData.setAutoDelete(true);

    QVBox *topBox = new QVBox(this);
    setMainWidget(topBox);
    topBox->setSpacing(spacingHint());

    QHBox *fileBox = new QHBox(topBox);
    fileBox->setSpacing(spacingHint());
    new QLabel(i18n("File to import:"), fileBox);
    KURLRequester *urlRequester = new KURLRequester(fileBox);
    urlRequester->setFilter("*.csv");
    connect(urlRequester, SIGNAL(returnPressed(const QString &)),
            SLOT(setFile(const QString &)));
    connect(urlRequester, SIGNAL(urlSelected(const QString &)),
            SLOT(setFile(const QString &)));
    connect(urlRequester->lineEdit(), SIGNAL(textChanged(const QString &)),
            SLOT(slotUrlChanged(const QString &)));
    mTable = new QTable(5, 5, topBox);
    mTable->setMinimumHeight(150);
    connect(mTable, SIGNAL(selectionChanged()), SLOT(tableSelected()));

    QHBox *separatorBox = new QHBox(topBox);
    separatorBox->setSpacing(spacingHint());

    new QLabel(i18n("Separator:"), separatorBox);

    mSeparatorCombo = new KComboBox(separatorBox);
    mSeparatorCombo->insertItem(",");
    mSeparatorCombo->insertItem(i18n("Tab"));
    mSeparatorCombo->insertItem(i18n("Space"));
    mSeparatorCombo->insertItem("=");
    mSeparatorCombo->insertItem(";");
    connect(mSeparatorCombo, SIGNAL(activated(int)),
            this, SLOT(separatorClicked(int)));
    mSeparatorCombo->setCurrentItem(0);

    QHBox *rowsBox = new QHBox(topBox);
    rowsBox->setSpacing(spacingHint());

    new QLabel(i18n("Import starts at row:"), rowsBox);
    mStartRow = new QSpinBox(rowsBox);
    mStartRow->setMinValue(1);
    /*
      new QLabel( i18n( "And ends at row:" ), rowsBox );
      mEndRow = new QSpinBox( rowsBox );
      mEndRow->setMinValue( 1 );
    */
    QVBox *assignBox = new QVBox(topBox);
    assignBox->setSpacing(spacingHint());

    QHBox *listsBox = new QHBox(assignBox);
    listsBox->setSpacing(spacingHint());

    mHeaderList = new QListView(listsBox);
    mHeaderList->addColumn(i18n("Header"));
    connect(mHeaderList, SIGNAL(selectionChanged(QListViewItem *)),
            this, SLOT(headerSelected(QListViewItem *)));
    connect(mHeaderList, SIGNAL(doubleClicked(QListViewItem *)),
            SLOT(assignColumn(QListViewItem *)));

    mFormatCombo = new KComboBox(listsBox);
    mFormatCombo->setDuplicatesEnabled(false);

    QPushButton *assignButton = new QPushButton(i18n("Assign to Selected Column"),
            assignBox);
    connect(assignButton, SIGNAL(clicked()), SLOT(assignColumn()));

    QPushButton *removeButton = new QPushButton(i18n("Remove Assignment From Selected Column"),
            assignBox);
    connect(removeButton, SIGNAL(clicked()), SLOT(removeColumn()));

    QPushButton *assignTemplateButton = new QPushButton(i18n("Assign with Template..."),
            assignBox);
    connect(assignTemplateButton, SIGNAL(clicked()), SLOT(assignTemplate()));

    QPushButton *saveTemplateButton = new QPushButton(i18n("Save Current Template"),
            assignBox);
    connect(saveTemplateButton, SIGNAL(clicked()), SLOT(saveTemplate()));

    resize(500, 300);

    connect(this, SIGNAL(okClicked()), SLOT(applyConverter()));
    connect(this, SIGNAL(applyClicked()), SLOT(applyConverter()));
    enableButtonOK(!urlRequester->lineEdit()->text().isEmpty());
}