コード例 #1
0
ファイル: vectorselector.cpp プロジェクト: mattryoung/kst
VectorSelector::VectorSelector(QWidget *parent, ObjectStore *store)
  : QWidget(parent), _allowEmptySelection(false), _isX(false), _store(store)  {

  setupUi(this);

  int size = style()->pixelMetric(QStyle::PM_SmallIconSize);

  _newVector->setIcon(KstGetIcon("kst_vectornew"));
  _editVector->setIcon(KstGetIcon("kst_vectoredit"));

  _newVector->setFixedSize(iconWidth(), iconWidth());
  _editVector->setFixedSize(iconWidth(), iconWidth());

  fillVectors();
  connect(_newVector, SIGNAL(pressed()), this, SLOT(newVector()));
  connect(_editVector, SIGNAL(pressed()), this, SLOT(editVector()));
  connect(_vector, SIGNAL(activated(int)), this, SLOT(emitSelectionChanged()));
  connect(_vector, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDescriptionTip()));
  connect(UpdateServer::self(), SIGNAL(objectListsChanged()), this, SLOT(fillVectors()));
}
コード例 #2
0
ファイル: htmldelegate.cpp プロジェクト: Pandahisham/outliner
void HtmlDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    QStyleOptionViewItem opt = option;
    initStyleOption(&opt, index);

    QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
    QAbstractItemView* parent = this->parent();

    const int top = opt.rect.top();
    const int height = opt.rect.height();
    int left = opt.rect.left();
    int width = opt.rect.width(); // the width of the item excluding the arrows but including the checkbox and icons
    if (opt.features & QStyleOptionViewItem::HasCheckIndicator) {
        const int padding = checkboxWidth(style, parent, opt);
        left += padding;
        width -= padding;
    }
    if (opt.features & QStyleOptionViewItem::HasDecoration) {
        const int padding = iconWidth(style, parent, opt);
        left += padding;
        width -= padding;
    }

    QTextDocument doc;
    // doc.setDefaultFont(QFont("Roboto", 9));
    doc.setDefaultStyleSheet("ul { margin-left: -36px; } ol { margin-left: -28px; }");

    doc.setTextWidth(width);
    doc.setHtml(opt.text);

    painter->save();
    opt.text = ""; // draw the item but with empty text
    style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget); // the 4th argument is required for QStyle to determine the style used to paint the control

    painter->translate(left, top);
    QRect clip(0, 0, width, height);
    painter->setClipRect(clip);

    QAbstractTextDocumentLayout::PaintContext context;
    context.clip = clip;
    const QColor textColor = this->textColor(index);
    context.palette.setColor(QPalette::AlternateBase, Qt::yellow);
    if (textColor != QColor(Qt::black)) {
        context.palette.setColor(QPalette::Text, textColor);
    }

    doc.documentLayout()->draw(painter, context);
    painter->restore();
}
コード例 #3
0
EventListViewItemBase::EventListViewItemBase(EventListViewBase* parent, const KAEvent& event)
    : QListViewItem(parent),
      mEvent(event)
{
    iconWidth();    // load the icons
}
コード例 #4
0
ファイル: vectorselector.cpp プロジェクト: mattryoung/kst
QSize VectorSelector::minimumSizeHint() const {
  return QSize(15*fontMetrics().width("m")+ 2 * iconWidth(), iconWidth());
}
コード例 #5
0
ファイル: alarmlistview.cpp プロジェクト: serghei/kde3-kdepim
/******************************************************************************
*  Return the width needed for the icons in the alarm type column.
*/
int AlarmListViewItem::typeIconWidth(AlarmListView *v)
{
    return iconWidth() +  2 * v->style().pixelMetric(QStyle::PM_DefaultFrameWidth);
}