Source Code (Use browser search to find items of interest.)
Class Index
killustrator'LayerView (./koffice/killustrator/share/LayerView.h:38)
class LayerView : public QTableView {
Q_OBJECT
public:
LayerView (QWidget *parent = 0L, const char *name = 0);
~LayerView ();
void setActiveDocument (GDocument* doc);
protected:
void showLayers (const std::vector<GLayer*>& lvec);
virtual int cellWidth (int col);
virtual int cellHeight (int row);
virtual void paintCell (QPainter *, int row, int col);
virtual void mousePressEvent (QMouseEvent *event);
virtual void mouseDoubleClickEvent (QMouseEvent *event);
private slots:
void lineEditorSlot ();
private:
GDocument* document;
std::vector<GLayer*> layers;
QPixmap pixmaps[3];
QLineEdit* lineEditor;
int editorRow;
};
killustrator'LayerView::LayerView() (./koffice/killustrator/share/LayerView.cc:42)
LayerView::LayerView (QWidget *parent, const char *name)
: QTableView (parent, name) {
setNumCols (4);
setBackgroundColor (white);
document = 0L;
#if NEWKDE
KIconLoader* loader = KGlobal::iconLoader ();
#else
KIconLoader* loader = kapp->getIconLoader ();
#endif
pixmaps[0] = UserIcon ("eye");
pixmaps[1] = UserIcon ("freehandtool");
pixmaps[2] = BarIcon ("fileprint");
setMinimumSize (3 * CELL1_WIDTH + CELL2_WIDTH, 4 * CELL_HEIGHT);
setTableFlags (Tbl_autoScrollBars | Tbl_smoothScrolling);
setFrameStyle (QFrame::Panel | QFrame::Sunken);
setLineWidth (2);
lineEditor = NULL;
editorRow = -1;
}
killustrator'LayerView::~LayerView() (./koffice/killustrator/share/LayerView.cc:65)
LayerView::~LayerView () {
}
killustrator'LayerView::setActiveDocument() (./koffice/killustrator/share/LayerView.cc:68)
void LayerView::setActiveDocument (GDocument* doc) {
document = doc;
showLayers (document->getLayers ());
}
killustrator'LayerView::showLayers() (./koffice/killustrator/share/LayerView.cc:73)
void LayerView::showLayers (const vector<GLayer*>& lvec) {
layers = lvec;
setNumRows (layers.size ());
updateTableSize ();
repaint ();
}
killustrator'LayerView::cellWidth() (./koffice/killustrator/share/LayerView.cc:80)
int LayerView::cellWidth (int col) {
return (col == 3 ? CELL2_WIDTH : CELL1_WIDTH);
}
killustrator'LayerView::cellHeight() (./koffice/killustrator/share/LayerView.cc:84)
int LayerView::cellHeight (int) {
return QMAX (CELL_HEIGHT, fontMetrics ().lineSpacing () + 1);
}
killustrator'LayerView::paintCell() (./koffice/killustrator/share/LayerView.cc:88)
void LayerView::paintCell (QPainter *p, int row, int col) {
GLayer* layer = layers[numRows () - 1 - row];
bool rowIsActive = (document->activeLayer () == layer);
p->save ();
p->setPen (rowIsActive ? white : black);
if (col < 3)
p->fillRect (0, 0, CELL1_WIDTH, cellHeight (row),
QBrush (rowIsActive ? darkBlue : white));
switch (col) {
case 0:
// visible
if (layer->isVisible ())
p->drawPixmap (2, 2, pixmaps[col]);
break;
case 1:
// editable
if (layer->isEditable ())
p->drawPixmap (2, 2, pixmaps[col]);
break;
case 2:
// printable
if (layer->isPrintable ())
p->drawPixmap (2, 2, pixmaps[col]);
break;
case 3:
{
QFontMetrics fm = p->fontMetrics ();
int yPos;
if (CELL_HEIGHT < fm.height ())
yPos = fm.ascent () + fm.leading () / 2;
else
yPos = (CELL_HEIGHT - fm.height ()) / 2 + fm.ascent ();
if (editorRow == row) {
if (lineEditor == NULL) {
lineEditor = new QLineEdit (this);
lineEditor->setMaxLength (20);
lineEditor->setFrame (false);
connect (lineEditor, SIGNAL(returnPressed ()),
this, SLOT(lineEditorSlot ()));
}
lineEditor->setGeometry (3 * CELL1_WIDTH + 3,
CELL_HEIGHT * editorRow + 1,
CELL2_WIDTH, CELL_HEIGHT);
lineEditor->setEnabled (true);
lineEditor->show ();
lineEditor->setFocus ();
lineEditor->setText (layer->name ());
}
else {
// name
p->fillRect (0, 0, width (), cellHeight (row),
QBrush (rowIsActive ? darkBlue : white));
p->drawText (5, yPos, layer->name ());
}
break;
}
default:
break;
}
p->restore ();
}
killustrator'LayerView::mouseDoubleClickEvent() (./koffice/killustrator/share/LayerView.cc:152)
void LayerView::mouseDoubleClickEvent (QMouseEvent *event) {
int row, col;
row = findRow (event->y ());
col = findCol (event->x ());
if (row != -1 && col == 3) {
editorRow = row;
repaint ();
}
}
killustrator'LayerView::mousePressEvent() (./koffice/killustrator/share/LayerView.cc:164)
void LayerView::mousePressEvent (QMouseEvent *event) {
int row, col;
row = findRow (event->y ());
col = findCol (event->x ());
if (row != -1 && col != -1) {
if (editorRow != -1) {
editorRow = -1;
lineEditor->setEnabled (false);
lineEditor->hide ();
}
else {
GLayer* layer = layers[numRows () - 1 - row];
switch (col) {
case 0:
layer->setVisible (! layer->isVisible ());
break;
case 1:
layer->setEditable (! layer->isEditable ());
break;
case 2:
layer->setPrintable (! layer->isPrintable ());
break;
case 3:
document->setActiveLayer (layer);
break;
default:
break;
}
}
repaint ();
}
}
killustrator'LayerView::lineEditorSlot() (./koffice/killustrator/share/LayerView.cc:200)
void LayerView::lineEditorSlot () {
GLayer* layer = layers[numRows () - 1 - editorRow];
layer->setName (lineEditor->text ());
lineEditor->setEnabled (false);
lineEditor->hide ();
repaint ();
}