Menu

[39a9d1]: / MyDesigner.cc  Maximize  Restore  History

Download this file

157 lines (114 with data), 4.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "MyDesigner.h"
DesignerObjects placeObject;
//int MyDesignerPushButton::count = 0;
//int MyDesignerEntryField::count = 0;
/*
void MyDesignerPushButton::paintEvent(QPaintEvent *event)
{
/*
QPushButton::paintEvent(event);
QPainter p(this);
p.drawRect(0,0,3,3);
p.drawRect(0,height()-3,3,3);
p.drawRect(width()-3,0,3,3);
p.drawRect(width()-3,height()-3,3,3);
p.drawRect(((width())/2)-3,0,3,3);
p.drawRect(((width())/2)-3,height()-3,3,3);
}
*/
void MyDesignerEntryField::mouseMoveEvent(QMouseEvent *event)
{
}
void MyDesignerEntryField::mouseReleaseEvent(QMouseEvent *event)
{
}
void MyDesignerEntryField::paintEvent(QPaintEvent *event)
{
}
void MyDesignerEntryField::mousePressEvent(QMouseEvent *event)
{
}
void MyDesignerEntryField::focusInEvent (QFocusEvent *event) { hasFocus = true; }
void MyDesignerEntryField::focusOutEvent(QFocusEvent *event) { hasFocus = false; }
QWidget* NoEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return 0;
}
void NoEditDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
//QStyledItemDelegate::paint(painter, option, index);
QStyleOptionViewItemV4 newOption(option);
initStyleOption(&newOption, index);
painter->save();
newOption.state &= ~QStyle::State_Selected;
newOption.state &= ~QStyle::State_HasFocus;
newOption.state &= ~QStyle::State_MouseOver;
newOption.widget->style()->drawControl(QStyle::CE_ItemViewItem, &newOption, painter);
painter->translate(newOption.rect.left()-50, newOption.rect.top());
QRect clip(0, 1, newOption.widget->width(), newOption.rect.height());
QString txt = newOption.text;
MyDesignerEntryField* edt = tree->findChild<MyDesignerEntryField*>("EditPageNoEdior");
if (txt == "pageno" && edt->hasFocus)
{
painter->fillRect(clip, QColor(120,200,200));
painter->drawText(42,15, txt);
}
else
{
painter->fillRect(clip, QColor(255,255,255));
painter->drawText(52,13, txt);
if (txt != "pageno")
{
painter->setFont(QFont("Arial",8));
painter->drawText(35,12,"[+]");
}
}
painter->restore();
}
void MyTreeWidget::set_items(QWidget *p)
{
QTreeWidgetItem *__qtreeitem = new QTreeWidgetItem(this);
QTreeWidgetItem *__qtreeitem1 = new QTreeWidgetItem((__qtreeitem));
__qtreeitem1->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEditable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setRootIsDecorated(true);
setAllColumnsShowFocus(false);
setFont(QFont("Arial",10));
header()->setDefaultSectionSize(100);
QTreeWidgetItem *___qtreeitem = headerItem();
___qtreeitem->setText(1, "Wert");
___qtreeitem->setText(0, "Eigenschaft");
NoEditDelegate *ne = new NoEditDelegate(this);
setSortingEnabled(false);
setItemDelegateForColumn(0, ne);
QTreeWidgetItem *___qtreeitem1 = (topLevelItem(0));
___qtreeitem1->setText(0, "Anzeige");
QTreeWidgetItem *___qtreeitem2 = (___qtreeitem1->child(0));
___qtreeitem2->setText(1, "1");
___qtreeitem2->setText(0, "pageno");
___qtreeitem2->setSelected(false);
MyDesignerEntryField *pe = new MyDesignerEntryField(this);
pe->setObjectName("EditPageNoEdior");
setItemWidget(___qtreeitem2,1,pe);
QTreeWidgetItem *___qtreeitem3 = new QTreeWidgetItem(this);
insertTopLevelItem(0,___qtreeitem3);
QTreeWidgetItem *___qtreeitem4 = topLevelItem(1);
___qtreeitem4->setText(0, "Bearbeiten");
}
void MyTreeWidget::paintEvent(QPaintEvent *event)
{
QTreeWidget::paintEvent(event);
int pHeight = font().pointSize();
int pWidth = columnWidth(0);
QPainter p;
p.begin(viewport());
int rc = 10;
int py = 0;
for(int i = 0; i < rc; i++)
{
p.drawRect(1,py,pWidth-2,py+pHeight+7);
p.drawRect(pWidth-1,py,columnWidth(1),py+pHeight+7);
py += pHeight+7;
}
p.end();
}