void Playlist::resizeColumns()
{
	int visibleRatio = 0;
	int resizableArea = size().width() - 4;
	if (verticalScrollBar()->isVisible()) {
		resizableArea -= verticalScrollBar()->size().width();
	}
	// Resize fixed columns first, and then compute the remaining width
	for (int c = 0; c < columnCount(); c++) {
		if (!isColumnHidden(c)) {
			int ratio = horizontalHeaderItem(c)->data(Qt::UserRole+2).toInt();
			// Fixed column
			if (ratio == 0) {
				this->resizeColumnToContents(c);
				resizableArea -= columnWidth(c) - 1;
			}
			visibleRatio += ratio;
		}
	}
	for (int c = 0; c < columnCount(); c++) {
		int ratio = horizontalHeaderItem(c)->data(Qt::UserRole+2).toInt();
		// Resizable column
		if (ratio != 0) {
			int s = resizableArea * ratio / visibleRatio ;
			if (!isColumnHidden(c)) {
				this->setColumnWidth(c, s);
			}
		}
	}
}
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 #3
0
// wrapper class to extract info from QTableWidget regarding sorting and
// position of each label in the header
MailListView::MailListView(QWidget *parent, const char *name)
    : QTableWidget( parent)
{
    setObjectName( name );
    setFrameStyle( NoFrame );
    connect(horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(sizeChange(int,int,int)) );
    horizontalHeader()->setSortIndicatorShown(false);

    sortColumn = -1;
    ascending = false;
    emailsOnly = false;

    connect( &menuTimer, SIGNAL(timeout()), SLOT(itemMenuRequested()) );
    connect( this, SIGNAL(itemSelectionChanged()), SLOT(cancelMenuTimer()) );
    connect( horizontalScrollBar(), SIGNAL(valueChanged(int)),
             this, SLOT(scrollToLeft(int)) );

    arrival = false;

    hVisible = true;    //part of sizeChangefix (avoid unnecessary flickering)
    maxColumnWidth = 0;
    mSingleColumnMode = true;
    QSoftMenuBar::setLabel(this, Qt::Key_Select, QSoftMenuBar::NoLabel);
    columns << "";
    if(!mSingleColumnMode)
    {
        columns << tr( "From" );
        columns <<  tr( "Subject" );
        columns <<  tr( "Date" );
    }
    setColumnCount( columns.count() );
    setHorizontalHeaderLabels( columns );
    verticalHeader()->hide();

    // Row height should be the size of the text - the second line being 3/4ths of the first
    int textHeight = QFontMetrics(font()).height() * 7 / 4;

    // Also, the icon could be larger than the text
    int iconHeight = style()->pixelMetric(QStyle::PM_ListViewIconSize);
    verticalHeader()->setDefaultSectionSize( qMax(textHeight, iconHeight) );

    setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    setAlternatingRowColors( true );

    horizontalHeaderItem(0)->setIcon(QPixmap(":image/flag"));

    QAction *hhWhatsThis = QWhatsThis::createAction( horizontalHeader() );
    hhWhatsThis->setText( tr("Select the sort order by tapping any of the columns in this header.  Tapping the same column twice will switch between ascending and descending order.") );

    QAction *tWhatsThis = QWhatsThis::createAction( this );
    tWhatsThis->setText( tr("A list of the messages in your current folder.  Tap a message to examine it.") );

//    setRootIsDecorated( true );

    setSelectionMode( QAbstractItemView::ExtendedSelection );
    EmailListItemDelegate *delegate = new EmailListItemDelegate( this );
    setItemDelegate( delegate );
    scrollToLeft( 0 );
    horizontalHeader()->setResizeMode(QHeaderView::Stretch);
}
Beispiel #4
0
void MailListView::setByArrival(bool on)
{
    arrival = on;

    if ( arrival && !mSingleColumnMode )
        horizontalHeaderItem(3)->setText( tr("Arrival") );
}
void StandardTreeModel::initialize()
{
    setHorizontalHeaderLabels(QStringList() << tr("Task/Subtask/...")
            << tr("Time (Today)") << tr("Time (Total)"));
    for (int column = 1; column < columnCount(); ++column)
        horizontalHeaderItem(column)->setTextAlignment(
                Qt::AlignVCenter|Qt::AlignRight);
}
Beispiel #6
0
void LibraryItemModel::reset()
{
	this->deleteCache();
	switch (SettingsPrivate::instance()->insertPolicy()) {
	case SettingsPrivate::IP_Artists:
		horizontalHeaderItem(0)->setText(tr("  Artists / Albums"));
		break;
	case SettingsPrivate::IP_Albums:
		horizontalHeaderItem(0)->setText(tr("  Albums"));
		break;
	case SettingsPrivate::IP_ArtistsAlbums:
		horizontalHeaderItem(0)->setText(tr("  Artists – Albums"));
		break;
	case SettingsPrivate::IP_Years:
		horizontalHeaderItem(0)->setText(tr("  Years"));
		break;
	}
}
/** Retranslate header columns. */
void Playlist::retranslateUi()
{
	for (int i=0; i < columnCount(); i++) {
		QTableWidgetItem *headerItem = horizontalHeaderItem(i);
		const QString text = tr(headerItem->data(Qt::UserRole+1).toString().toStdString().data());
		headerItem->setText(text);
		columns->actions().at(i)->setText(text);
	}
}
Beispiel #8
0
void QCustomTableWidget::editProperty(int index)
{
    if (index != -1)
    {
        scrollTo(-1, index);
        int logIndex = logicalColumn(index);
        QTableWidgetItem *columnHeaderItem = horizontalHeaderItem(logIndex);
        if(pChangePropertyDial->exec(columnHeaderItem->text())==QDialog::Accepted)
        {
            // updating the PropertyList
            if (pProperties)
            {
                std::string newProperty = pChangePropertyDial->text().toStdString();
                emit modificationDone(new CharacterModification(pProperties, (*pProperties)[index], newProperty, index));
                (*pProperties)[index] = newProperty;
            }
            QTableWidgetItem *columnHeaderItem = horizontalHeaderItem(logIndex);
            columnHeaderItem->setText(pChangePropertyDial->text());
            scrollTo(-1, index);
        }
    }
}
Beispiel #9
0
void QCustomTableWidget::addProperty(int index)
{
    if (index < 0)
    {
        // if no column is selected, we insert it at the end
        index += columnCount();
    }
    if(pChangePropertyDial->exec()==QDialog::Accepted)
    {
        // modifying the property/character Lists
        if (pProperties)
        {
            std::string property = pChangePropertyDial->text().toStdString();
            pProperties->add(property, index+1);
            emit modificationDone(new CharacterModification(pProperties, property, pCharacters, index+1));
        }
        if (pCharacters)
        {
            for (CharacterList::iterator it=pCharacters->begin(); it != pCharacters->end(); it++)
            {
                if ((unsigned int)index+1 < it->propertyNumber())
                {
                    // adding a property
                    it->addProperty("0",index+1);
                }
            } 
        }

        // updating the display
        int row_nb = rowCount();
        // created cells
        iCreatedCells = row_nb;
        insertColumn(index+1);
        for (int i = 0; i < row_nb; i++)
        {
            QTableWidgetItem *col1 = new QTableWidgetItem("0");
            setItem(i,index+1,col1);
        }
        QTableWidgetItem *columnHeaderItem = horizontalHeaderItem(index+1);
        if (columnHeaderItem)
        {
            columnHeaderItem->setText(pChangePropertyDial->text());
        }
        else
        {
            columnHeaderItem = new QTableWidgetItem(pChangePropertyDial->text());
            setHorizontalHeaderItem(index+1, columnHeaderItem);
        }
        scrollTo(-1, index+1);
    }
}
Beispiel #10
0
openvolume::openvolume( QWidget * parent ) : QDialog( parent ),m_ui( new Ui::openvolume() )
{
	m_ui->setupUi( this ) ;

	this->setFixedSize( this->size() ) ;
	this->setFont( parent->font() ) ;

	connect( m_ui->tableWidget,SIGNAL( itemDoubleClicked( QTableWidgetItem * ) ),
		 this,SLOT( tableEntryDoubleClicked( QTableWidgetItem * ) ) ) ;
	connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ),
		 this,SLOT( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ;
	connect( m_ui->pbHelp,SIGNAL( clicked() ),this,SLOT( pbHelp() ) ) ;
	connect( m_ui->pbUUID,SIGNAL( clicked() ),this,SLOT( pbUUID() ) ) ;
	connect( m_ui->pbCancel,SIGNAL( clicked() ),this,SLOT( pbCancel() ) ) ;
	connect( m_ui->pbOpen,SIGNAL( clicked() ),this,SLOT( pbOpen() ) ) ;

	this->addAction( [ this ](){

		auto ac = new QAction( this ) ;

		ac->setShortcuts( { Qt::Key_Enter,Qt::Key_Return } ) ;

		connect( ac,SIGNAL( triggered() ),this,SLOT( EnterKeyPressed() ) ) ;

		return ac ;
	}() ) ;

	auto tw = m_ui->tableWidget ;

	tw->setColumnWidth( 0,183 ) ;
	tw->setColumnWidth( 1,90 ) ;
	//tw->setColumnWidth( 2,110 ) ;
	tw->hideColumn( 2 ) ;
	tw->setColumnWidth( 3,90 ) ;
	tw->setColumnWidth( 4,309 ) ;

	for( int i = 0 ; i < 5 ; i++ ){

		tw->horizontalHeaderItem( i )->setFont( this->font() ) ;
	}

	tw->horizontalHeader()->setVisible( true ) ;

	m_ui->checkBoxUUID->setVisible( false ) ;

	m_ui->pbHelp->setVisible( false ) ;

	this->installEventFilter( this ) ;

	this->disableAll() ;
}
void
AttachmentModel::retranslateUi() {
  Util::setDisplayableAndSymbolicColumnNames(*this, {
    { QY("Name"),             Q("name")           },
    { QY("MIME type"),        Q("mimeType")       },
    { QY("Attach to"),        Q("attachTo")       },
    { QY("Description"),      Q("description")    },
    { QY("Source file name"), Q("sourceFileName") },
    { QY("Directory"),        Q("directory")      },
    { QY("Size"),             Q("size")           },
  });

  horizontalHeaderItem(SizeColumn)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);

  for (auto row = 0, numRows = rowCount(); row < numRows; ++row)
    setRowData(itemsForRow(row), *attachmentForRow(row));
}
Beispiel #12
0
void ViewTable::setHHeaderText(const QStringList &list )
{
	if( list.count() < columnCount() )
		return;

	QTableWidgetItem *cell;
	for(int i = 0; i < columnCount(); i++)
	{
		cell = horizontalHeaderItem(i);
		if( cell )
		{
			QFont font = cell->font();
			font.setBold( true );
			cell->setFont( font );

			cell->setText( list[i] );
		}
	}
}
void QCustomTableWidget::addSkill(int index)
{
    if(pChangeSkillDial->exec()==QDialog::Accepted)
    {
        // modifying the skill/character Lists
        if (pSkills != NULL)
        {
            pSkills->add(pChangeSkillDial->text().toStdString(),index+1);
        }
        if (pCharacters != NULL)
        {
            for (CharacterList::iterator it=pCharacters->begin(); it != pCharacters->end(); it++)
            {
                if ((unsigned int)index+1 < it->skillNumber())
                {
                    // adding a skill
                    it->addSkill("0",index+1);
                }
            } 
        }

        // updating the display
        insertColumn(index+1);
        int row_nb;
        row_nb = rowCount();
        for (int i = 0; i < row_nb; i++)
        {
            QTableWidgetItem *col1 = new QTableWidgetItem("0");
            setItem(i,index+1,col1);
        }
        QTableWidgetItem *columnHeaderItem = horizontalHeaderItem(index+1);
        if (columnHeaderItem != NULL)
        {
            columnHeaderItem->setText(pChangeSkillDial->text());
        }
        else
        {
            columnHeaderItem = new QTableWidgetItem(pChangeSkillDial->text());
            setHorizontalHeaderItem(index+1, columnHeaderItem);
        }
    }
    resizeColumnsToContents();
}
void OperationTable::resizeColumns()
{
	double width = this->width() - verticalHeader()->width();;

	if( resizeList.count() < columnCount() )
	{
		int c = 0;
		for(int i = 0; i < columnCount(); i++)
		{
			if( isColumnHidden(i) )
				continue;

			c++;
		}

		int w = ceil( width/c * 0.976 );
		for(int i = 0; i < columnCount(); i++)
		{
			if( isColumnHidden(i) )
				continue;

			setColumnWidth( i, w );
		}

		return;
	}

	
	for(int i = 0; i < columnCount(); i++)
	{
		if( isColumnHidden(i) )
			continue;

		int w1 = fontMetrics().width( horizontalHeaderItem(i)->text() ) * 1.5;
		int w2 = ceil( width*resizeList.at(i)/100 );

		if( w2 >= w1 )
			setColumnWidth( i, w2 );
		else
			setColumnWidth( i, w1 );
	}
}
void QCustomTableWidget::editSkill(int index)
{
    if(pChangeSkillDial->exec()==QDialog::Accepted)
    {
        QTableWidgetItem *columnHeaderItem = horizontalHeaderItem(index);
        if (columnHeaderItem != NULL)
        {
            columnHeaderItem->setText(pChangeSkillDial->text());
        }
        else
        {
            columnHeaderItem = new QTableWidgetItem(pChangeSkillDial->text());
            setHorizontalHeaderItem(index, columnHeaderItem);
        }
        // updating the SkillList
        if (pSkills != NULL)
        {
            (*pSkills)[index] = pChangeSkillDial->text().toStdString();
        }
    }
    resizeColumnToContents(index);
}