Ejemplo n.º 1
0
/******************************************************************************
*  Set which time columns are to be displayed.
*/
void AlarmListView::selectTimeColumns(bool time, bool timeTo)
{
    if(!time  &&  !timeTo)
        return;       // always show at least one time column
    bool changed = false;
    int w = columnWidth(mColumn[TIME_COLUMN]);
    if(time  &&  !w)
    {
        // Unhide the time column
        int colWidth = mTimeColumnHeaderWidth;
        QFontMetrics fm = fontMetrics();
        for(AlarmListViewItem *item = firstChild();  item;  item = item->nextSibling())
        {
            int w = item->width(fm, this, mColumn[TIME_COLUMN]);
            if(w > colWidth)
                colWidth = w;
        }
        setColumnWidth(mColumn[TIME_COLUMN], colWidth);
        setColumnWidthMode(mColumn[TIME_COLUMN], QListView::Maximum);
        changed = true;
    }
    else if(!time  &&  w)
    {
        // Hide the time column
        setColumnWidthMode(mColumn[TIME_COLUMN], QListView::Manual);
        setColumnWidth(mColumn[TIME_COLUMN], 0);
        changed = true;
    }
    w = columnWidth(mColumn[TIME_TO_COLUMN]);
    if(timeTo  &&  !w)
    {
        // Unhide the time-to-alarm column
        setColumnWidthMode(mColumn[TIME_TO_COLUMN], QListView::Maximum);
        updateTimeToAlarms(true);
        if(columnWidth(mColumn[TIME_TO_COLUMN]) < mTimeToColumnHeaderWidth)
            setColumnWidth(mColumn[TIME_TO_COLUMN], mTimeToColumnHeaderWidth);
        changed = true;
    }
    else if(!timeTo  &&  w)
    {
        // Hide the time-to-alarm column
        setColumnWidthMode(mColumn[TIME_TO_COLUMN], QListView::Manual);
        setColumnWidth(mColumn[TIME_TO_COLUMN], 0);
        changed = true;
    }
    if(changed)
    {
        resizeLastColumn();
        triggerUpdate();   // ensure scroll bar appears if needed
    }
}
Ejemplo n.º 2
0
void KItemListHeaderWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
    QGraphicsItem::mouseDoubleClickEvent(event);

    const int roleIndex = roleIndexAt(event->pos());
    if (roleIndex >= 0 && isAboveRoleGrip(event->pos(), roleIndex)) {
        const QByteArray role = m_columns.at(roleIndex);

        qreal previousWidth = columnWidth(role);
        setColumnWidth(role, preferredColumnWidth(role));
        qreal currentWidth = columnWidth(role);

        emit columnWidthChanged(role, currentWidth, previousWidth);
    }
}
Ejemplo n.º 3
0
KDCoordinate TableViewDataSource::cumulatedWidthFromIndex(int i) {
  int result = 0;
  for (int k = 0; k < i; k++) {
    result += columnWidth(k);
  }
  return result;
}
Ejemplo n.º 4
0
/**************************************************************************
  Displays menu on header by right clicking
**************************************************************************/
void plr_widget::display_header_menu(const QPoint &)
{
  struct player_dlg_column *pcol;
  QMenu hideshowColumn(this);
  hideshowColumn.setTitle(_("Column visibility"));
  QList<QAction *> actions;
  for (int i = 0; i < list_model->columnCount(); ++i) {
    QAction *myAct = hideshowColumn.addAction(
                       list_model->headerData(i, Qt::Horizontal, 
                                              Qt::DisplayRole).toString());
    myAct->setCheckable(true);
    myAct->setChecked(!isColumnHidden(i));
    actions.append(myAct);
  }
  QAction *act = hideshowColumn.exec(QCursor::pos());
  if (act) {
    int col = actions.indexOf(act);
    Q_ASSERT(col >= 0);
    pcol = &player_dlg_columns[col];
    pcol->show = !pcol->show;
    setColumnHidden(col, !isColumnHidden(col));
    if (!isColumnHidden(col) && columnWidth(col) <= 5)
      setColumnWidth(col, 100);
  }
}
Ejemplo n.º 5
0
KDCoordinate CalculationController::cumulatedWidthFromIndex(int j) {
  int result = 0;
  for (int k = 0; k < j; k++) {
    result += columnWidth(k);
  }
  return result;
}
Ejemplo n.º 6
0
void TransferListWidget::hidePriorityColumn(bool hide)
{
    qDebug("hidePriorityColumn(%d)", hide);
    setColumnHidden(TorrentModel::TR_PRIORITY, hide);
    if (!hide && !columnWidth(TorrentModel::TR_PRIORITY))
        resizeColumnToContents(TorrentModel::TR_PRIORITY);
}
Ejemplo n.º 7
0
void UIListView::setColumnVisible( int col, bool show )
{
        if ( columnVisible( col ) == show )
                return ;

        ColumnData * data = m_data.find( col );

        if ( show == false )
        {
                data->name = columnText( col );
                data->size = columnWidth( col );
                data->mode = columnWidthMode( col );

                setColumnText ( col, "" );
                setColumnWidth( col, 0 );
                setColumnWidthMode( col, QListView::Manual );
                header()->setResizeEnabled( false, col );
        }
        else
        {
                setColumnText ( col, data->name );
                setColumnWidth( col, data->size );
                setColumnWidthMode( col, data->mode );
                header()->setResizeEnabled( true, col );
        }
}
Ejemplo n.º 8
0
/******************************************************************************
*  Sets the last column in the list view to extend at least to the right hand
*  edge of the list view.
*/
void EventListViewBase::resizeLastColumn()
{
    int lastColumnWidth = mLastColumnHeaderWidth;
    for (EventListViewItemBase* item = firstChild();  item;  item = item->nextSibling())
    {
        int mw = item->lastColumnWidth();
        if (mw > lastColumnWidth)
            lastColumnWidth = mw;
    }
    QHeader* head = header();
    int x = head->sectionPos(mLastColumn);
    int availableWidth = visibleWidth() - x;
    int rightColWidth = 0;
    int index = head->mapToIndex(mLastColumn);
    if (index < mLastColumn)
    {
        // The last column has been dragged by the user to a different position.
        // Ensure that the columns now to the right of it are still shown.
        for (int i = index + 1;  i <= mLastColumn;  ++i)
            rightColWidth += columnWidth(head->mapToSection(i));
        availableWidth -= rightColWidth;
    }
    if (availableWidth < lastColumnWidth)
        availableWidth = lastColumnWidth;
    setColumnWidth(mLastColumn, availableWidth);
    if (contentsWidth() > x + availableWidth + rightColWidth)
        resizeContents(x + availableWidth + rightColWidth, contentsHeight());
}
Ejemplo n.º 9
0
void FreezeTableWidget::init() {
	frozenTableView->setFocusPolicy(Qt::NoFocus);
	frozenTableView->verticalHeader()->hide();
	frozenTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);

	viewport()->stackUnder(frozenTableView);

	frozenTableView->setSelectionModel(selectionModel());

	frozenTableView->setColumnWidth(0, columnWidth(0));

	frozenTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	frozenTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	frozenTableView->show();

	updateFrozenTableGeometry();
	for (int col = 1; col < model()->columnCount(); ++col)
		frozenTableView->setColumnHidden(col, true);	//should hide more when inserted

	setHorizontalScrollMode(ScrollPerPixel);
	setVerticalScrollMode(ScrollPerPixel);
	frozenTableView->setVerticalScrollMode(ScrollPerPixel);

//	frozenTableView->setEditTriggers(QTableView::DoubleClicked|QTableView::AnyKeyPressed);
}
Ejemplo n.º 10
0
void ResultsTree::SaveSettings() const
{
    for (int i = 0; i < mModel.columnCount(); i++) {
        QString temp = QString(SETTINGS_RESULT_COLUMN_WIDTH).arg(i);
        mSettings->setValue(temp, columnWidth(i));
    }
}
void cCustomShotTable::mouseMoveEvent(QMouseEvent *event) {
    if (IsDragOn!=1) {
        setCursor(Qt::ArrowCursor);
        QTableWidget::mouseMoveEvent(event);
    } else {
        if ((columnCount()==0)||(DiaporamaObject==NULL)) return;

        int ThumbHeight=rowHeight(0);
        int ThumbWidth =columnWidth(0);
        int NbrX       =width()/ThumbWidth;
        int NbrY       =height()/ThumbHeight;  if (NbrY>rowCount()) NbrY=rowCount();
        int ToUse      =DragItemDest; if (DragItemDest==columnCount()) ToUse--;

        // Try to scroll left
        if ((event->pos().x()<0)&&(horizontalScrollBar()->value()>0)) horizontalScrollBar()->setValue(horizontalScrollBar()->value()-1);
        // Try to scroll right
        else if ((event->pos().x()>=NbrX*ThumbWidth)&&(horizontalScrollBar()->value()<horizontalScrollBar()->maximum())) horizontalScrollBar()->setValue(horizontalScrollBar()->value()+1);
        else {
            // Get item number under mouse
            int Selected=(event->pos().x()+horizontalOffset())/ThumbWidth;
            if ((Selected>NbrItem())||(Selected==DragItemSource)||((Selected==DragItemSource+1)&&(Selected!=NbrItem()))) {
                DragItemDest=-1;
                setCursor(Qt::ForbiddenCursor);
            } else {
                setCursor(Qt::ClosedHandCursor);
                DragItemDest=Selected;
            }
        }
        // Force a repaint
        setUpdatesEnabled(false);
        setUpdatesEnabled(true);
    }
}
Ejemplo n.º 12
0
void EventListViewBase::addLastColumn(const QString& title)
{
    addColumn(title);
    mLastColumn = columns() - 1;
    mLastColumnHeaderWidth = columnWidth(mLastColumn);
    setColumnWidthMode(mLastColumn, QListView::Maximum);
}
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);
			}
		}
	}
}
Ejemplo n.º 14
0
void SEQListView::setColumnVisible(int column, bool visible)
{
  QString columnName = columnPreferenceName(column);

  // default width is 0
  int width = 0;

  // if column is to become visible, get it's width
  if (visible)
  {
    // get the column width
    width = pSEQPrefs->getPrefInt(columnName + "Width", preferenceName(), 
				  columnWidth(column));

    // if it's zero, use default width of 40
    if (width == 0)
      width = 40;
  }

  // set the column width mode
  setColumnWidthMode(column, Q3ListView::Manual);

  // set the column width
  setColumnWidth(column, width);

  // set the the preferences as to if the column is shown
  pSEQPrefs->setPrefBool(QString("Show") + columnName, preferenceName(),
			 (width != 0));

  // trigger an update, otherwise things may look messy
  triggerUpdate();
}
Ejemplo n.º 15
0
void PacketList::writeRecent(FILE *rf) {
    gint col, width, col_fmt;
    gchar xalign;

    fprintf (rf, "%s:", RECENT_KEY_COL_WIDTH);
    for (col = 0; col < packet_list_model_->columnCount(); col++) {
        if (col > 0) {
            fprintf (rf, ",");
        }
        col_fmt = get_column_format(col);
        if (col_fmt == COL_CUSTOM) {
            fprintf (rf, " %%Cus:%s,", get_column_custom_field(col));
        } else {
            fprintf (rf, " %s,", col_format_to_string(col_fmt));
        }
        width = columnWidth(col);
        xalign = recent_get_column_xalign (col);
        if (width == 0) {
            /* We have not initialized the packet list yet, use old values */
            width = recent_get_column_width (col);
        }
        fprintf (rf, " %d", width);
        if (xalign != COLUMN_XALIGN_DEFAULT) {
            fprintf (rf, ":%c", xalign);
        }
    }
    fprintf (rf, "\n");

}
Ejemplo n.º 16
0
/**
 * @brief Toggles the visibility of the column on or off.
 * If a signal is sent, the column name is derived from QAction::text(). Because of this,
 * You can only connect signals from a QAction to this slot.
 * @param column The name of the column to toggle
 */
void DatabaseList::toggleColumn(const QString column)
{
	QSettings settings;
	QAction* actionUsed = (QAction*)sender();
	QString columnName = column;

	// If we recieved a signal, find the column name from the sender
	if(actionUsed != 0)
		columnName = actionUsed->text();

	// Loop through the columns looking for the one we want
	for(int i = 0; i < mDatabaseModel->columnCount(); i++)
	{
		if(mDatabaseModel->headerData(i, Qt::Horizontal).toString() == columnName)
		{
			// Toggle the visibility of the column
			if(isColumnHidden(i))
			{
				setColumnWidth(i, settings.value("SongView/ColumnSize" + QString::number(i)).toInt());
				showColumn(i);
			}
			else
			{
				settings.setValue("SongView/ColumnSize" + QString::number(i), columnWidth(i));
				hideColumn(i);
			}
		}
	}
};
Ejemplo n.º 17
0
void TableItemDoc::buildLinePos() {
  int C = table()->columns();
  int R = table()->rows();
  QVector<double> columnWidth(C, 9.0);  // minimum column width = 9 pt
  QVector<double> const &cw = d->charWidths();
  double right = 0;
  for (int r=0; r<R; r++) {
    for (int c=0; c<C; c++) {
      int pos = table()->cellStart(r, c);
      int len = table()->cellLength(r, c);
      double w = 0;
      for (int k=0; k<len; k++)
	w += cw[pos+k];
      if (w>columnWidth[c])
	columnWidth[c] = w;
    }
  }
  d->linepos.resize(C*R);
  double x0 = 12;
  double y0 = 6;
  double ascent = d->fonts().metrics(MarkupStyles())->ascent();
  for (int r=0; r<R; r++) {
    double x = 4.5 + x0;
    double y = y0 + 4.0 + r*d->lineheight + ascent;
    for (int c=0; c<C; c++)  {
      d->linepos[c+C*r] = QPointF(x, y);
      x += columnWidth[c] + 9.0; // margin
      right = x;
    }
  }
  d->br = QRectF(QPointF(x0 - 4, 0),
		 QPointF(right - 1, R*d->lineheight + 4 + 2*y0));
}
Ejemplo n.º 18
0
int TracksView::frozenColWidth()
      {
      int width = 0;
      for (int col = 0; col != _frozenColCount; ++col)
            width += columnWidth(col);
      return width;
      }
Ejemplo n.º 19
0
void FreezeTableWidget::init()
{
    frozenTableView->setModel(model());
    frozenTableView->setFocusPolicy(Qt::NoFocus);
    frozenTableView->verticalHeader()->hide();
    frozenTableView->horizontalHeader()->setResizeMode(QHeaderView::Fixed);

    viewport()->stackUnder(frozenTableView);

    frozenTableView->setStyleSheet("QTableView { border: none;"
                                   "background-color: #E0E0E0;"
                                   "selection-background-color: #999}"); //for demo purposes
    frozenTableView->setSelectionModel(selectionModel());
    for(int col=1; col<model()->columnCount(); col++)
        frozenTableView->setColumnHidden(col, true);

    frozenTableView->setColumnWidth(0, columnWidth(0) );

    frozenTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    frozenTableView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    frozenTableView->show();

    updateFrozenTableGeometry();

    //setHorizontalScrollMode(ScrollPerPixel);
    //setVerticalScrollMode(ScrollPerPixel);
    //frozenTableView->setVerticalScrollMode(ScrollPerPixel);
}
void KStandardItemListWidget::updateTextsCache()
{
    QTextOption textOption;
    switch (m_layout) {
    case IconsLayout:
        textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
        textOption.setAlignment(Qt::AlignHCenter);
        break;
    case CompactLayout:
    case DetailsLayout:
        textOption.setAlignment(Qt::AlignLeft);
        textOption.setWrapMode(QTextOption::NoWrap);
        break;
    default:
        Q_ASSERT(false);
        break;
    }

    qDeleteAll(m_textInfo);
    m_textInfo.clear();
    for (int i = 0; i < m_sortedVisibleRoles.count(); ++i) {
        TextInfo* textInfo = new TextInfo();
        textInfo->staticText.setTextFormat(Qt::PlainText);
        textInfo->staticText.setPerformanceHint(QStaticText::AggressiveCaching);
        textInfo->staticText.setTextOption(textOption);
        m_textInfo.insert(m_sortedVisibleRoles[i], textInfo);
    }

    switch (m_layout) {
    case IconsLayout:   updateIconsLayoutTextCache(); break;
    case CompactLayout: updateCompactLayoutTextCache(); break;
    case DetailsLayout: updateDetailsLayoutTextCache(); break;
    default: Q_ASSERT(false); break;
    }

    const TextInfo* ratingTextInfo = m_textInfo.value("rating");
    if (ratingTextInfo) {
        // The text of the rating-role has been set to empty to get
        // replaced by a rating-image showing the rating as stars.
        const KItemListStyleOption& option = styleOption();
        QSizeF ratingSize = preferredRatingSize(option);

        const qreal availableWidth = (m_layout == DetailsLayout)
                                     ? columnWidth("rating") - columnPadding(option)
                                     : size().width();
        if (ratingSize.width() > availableWidth) {
            ratingSize.rwidth() = availableWidth;
        }
        m_rating = QPixmap(ratingSize.toSize());
        m_rating.fill(Qt::transparent);

        QPainter painter(&m_rating);
        const QRect rect(0, 0, m_rating.width(), m_rating.height());
        const int rating = data().value("rating").toInt();
        KRatingPainter::paintRating(&painter, rect, Qt::AlignJustify | Qt::AlignVCenter, rating);
    } else if (!m_rating.isNull()) {
        m_rating = QPixmap();
    }
}
Ejemplo n.º 21
0
void CTableView::adjustSizeToContents()
{
    resizeColumnsToContents();
    resizeRowsToContents();
    int32_t h = rowHeight(1) * model()->rowCount() + 2;
    int32_t w = columnWidth(1) * model()->columnCount() + 2;
    setFixedSize(w, h);
}
Ejemplo n.º 22
0
int TableViewDataSource::indexFromCumulatedWidth(KDCoordinate offsetX) {
  int result = 0;
  int i = 0;
  while (result < offsetX && i < numberOfColumns()) {
    result += columnWidth(i++);
  }
  return (result < offsetX || offsetX == 0) ? i : i - 1;
}
Ejemplo n.º 23
0
int CalculationController::indexFromCumulatedWidth(KDCoordinate offsetX) {
  int result = 0;
  int i = 0;
  while (result < offsetX && i < numberOfColumns()) {
    result += columnWidth(i++);
  }
  return (result < offsetX || offsetX == 0) ? i : i - 1;
}
Ejemplo n.º 24
0
/******************************************************************************
*  Update all the values in the time-to-alarm column.
*/
void AlarmListView::updateTimeToAlarms(bool forceDisplay)
{
    if(forceDisplay  ||  columnWidth(mColumn[TIME_TO_COLUMN]))
    {
        QDateTime now = QDateTime::currentDateTime();
        for(AlarmListViewItem *item = firstChild();  item;  item = item->nextSibling())
            item->updateTimeToAlarm(now, forceDisplay);
    }
}
void PreviewTable::setHeader()
{
	Q3Header *head = horizontalHeader();
	for (int i=0; i<numCols(); i++){
		QString s = col_label[i];
        int lines = columnWidth(i)/head->fontMetrics().boundingRect("_").width();
        head->setLabel(i, s.remove("\n") + "\n" + QString(lines, '_') + "\n" + comments[i]);
	}
}
Ejemplo n.º 26
0
void TodoView::updateItem(int row, int col)
{
  QString tmpStr;
  int x=0, y=0;
  int id;

  updatingRow = row;

  ASSERT(row >= 0);
  editingFlag = TRUE;

  tmpStr = text(row, 0);
  id = atol(tmpStr.data());
  aTodo = calendar->getTodo(id);

  editor->hide();
  editor->setText(aTodo->getSummary());

  colXPos(col, &x);
  rowYPos(row, &y);
  y += 17; // correct for header size.

  // first, see if they clicked on the "done/not done column";
  if (col == 1) {
    tmpStr = text(row, 1);
    if (tmpStr == "CHECKED" || tmpStr == "CHECKEDMASK") {      
      aTodo->setStatus(QString("NEEDS ACTION"));
      changeItemPart("EMPTY", row, 1);
    } else {
      aTodo->setDtEnd(QDateTime::currentDateTime());
      aTodo->setStatus(QString("COMPLETED"));
      changeItemPart("CHECKED", row, 1);
    }
  }

  // see if they clicked on the "priority" column
  if (col == 2) {
    priList->move(x, y+2);
    priList->setCurrentItem(aTodo->getPriority()-1);
    priList->setFocus();
    priList->show();
  }

  // they clicked on the "description" column
  if (col == 3) {
    editor->move(x, y+2);
    editor->setFixedWidth(columnWidth(3));
    editor->setFixedHeight(cellHeight(row));
    editor->setFocus();
    editor->show();
  }
  if (col == 4) {
    // handle due date stuff
  }
  adjustColumns();
}
Ejemplo n.º 27
0
void TableView::resizeEvent(QResizeEvent *event)
{
    QTableView::resizeEvent(event);

    int w = 0;
    for(int i = 1; i < model()->columnCount(); ++i)
         w += columnWidth(i);

    setColumnWidth(0, width() - w - 20);
}
Ejemplo n.º 28
0
int MSTableColumn::columnPixelWidth(void)
{
  if (table()!=0)
   {
     unsigned len=columnWidth();
     int cw=(clipMode()==MSNoClipping)?charWidth('W'):charWidth('0');
     return (len*cw+2*table()->columnSpacing());
   }
  else return 0;
}
Ejemplo n.º 29
0
void TodoOutputTreeView::resizeEvent(QResizeEvent *event)
{
    int widthText = m_textColumnDefaultWidth;
    int widthFile = m_fileColumnDefaultWidth;

    if ((event->oldSize().width() == 0) || (event->oldSize().width() == -1)) {
        if (widthText == 0)
            widthText = 0.55 * event->size().width();
        if (widthFile == 0)
            widthFile = 0.35 * event->size().width();
    } else {
        const qreal scale = static_cast<qreal>(event->size().width())
                / static_cast<qreal>(event->oldSize().width());
        widthText = scale * columnWidth(Constants::OUTPUT_COLUMN_TEXT);
        widthFile = scale * columnWidth(Constants::OUTPUT_COLUMN_FILE);
    }

    setColumnWidth(Constants::OUTPUT_COLUMN_TEXT, widthText);
    setColumnWidth(Constants::OUTPUT_COLUMN_FILE, widthFile);
}
Ejemplo n.º 30
0
void DatabaseList::saveSettings()
{
	QSettings settings;

	// Loop through all the columns
	for(int i = 0; i < mDatabaseModel->columnCount(); i++)
	{
		// Save the value to the setting files for each column size
		settings.setValue(objectName() + "/ColumnSize" + QString::number(i), columnWidth(i));
	}
};