[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kexi
From: Jaroslaw Staniek <js () iidea ! pl>
Date: 2009-03-01 0:48:24
Message-ID: 1235868504.587396.10164.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 933480 by staniek:
Forms
- context menu appears at proper position also when executed for child widgets
- resize handles are properly displayed again
- widgets inserted with single click have size aligned to grid if necessary
- fixed inserting widgets by specifying the geometry using mouse
- fix drawing rectangle while inserting widgets by specifying the geometry
- selection rectangle is now painted over widgets too
- only minimal needed region is repainted when selection/insertion rectangle changes
= code simplified:
added utility function alignValueToGrid() for use instead of copy/pasted code
M +20 -2 doc/dev/CHANGELOG-Kexi-js
M +18 -9 formeditor/commands.cpp
M +26 -14 formeditor/container.cpp
M +1 -1 formeditor/form.cpp
M +4 -5 formeditor/resizehandle.cpp
M +7 -0 formeditor/utils.cpp
M +3 -1 formeditor/utils.h
--- trunk/koffice/kexi/doc/dev/CHANGELOG-Kexi-js #933479:933480
@@ -20,8 +20,7 @@
===================== Kexi 2.0 Alpha =====================
-TODO
- Form editor:
+TODO Form editor:
- FormManager::FormManager: register factory (port to koproperty2)
- port KFDPixmapEdit, PropertyFactory
@@ -31,11 +30,30 @@
- (the same?) Create a database -> enter the table schema editor -> add a field -> \
try to change the field type -> crash http://rafb.net/p/R4QIBR13.html
+2009-03-01
+Forms
+- context menu appears at proper position also when executed for child widgets
+- resize handles are properly displayed again
+- widgets inserted with single click have size aligned to grid if necessary
+- fixed inserting widgets by specifying the geometry using mouse
+- fix drawing rectangle while inserting widgets by specifying the geometry
+TODO: perhaps draw the rectangle differently
+- selection rectangle is now painted over widgets too
+- only minimal needed region is repainted when selection/insertion rectangle changes
+TODO: it is possible to optimize this even more by painting only areas near borders
+= code simplified:
+ added utility function alignValueToGrid() for use instead of copy/pasted code
+
+2009-02-28
+Forms
+- do not align selection rectangle to grid
+
2009-02-27
Forms
= make the actions from widget-action-group accessible for the Form object
- the above allows to switch back to the edit_pointer toggle action after
inserting a new widget
+TODO: remove usage of KFormDesigner::ActionGroup when the two libraries are merged
2009-02-26
Forms
--- trunk/koffice/kexi/formeditor/commands.cpp #933479:933480
@@ -315,9 +315,8 @@
switch (d->alignment) {
case Form::AlignToGrid: {
foreach (QWidget *w, list) {
- const int tmpx = int((float)w->x() / ((float)gridX) + 0.5) * gridX;
- const int tmpy = int((float)w->y() / ((float)gridY) + 0.5) * gridY;
-
+ const int tmpx = alignValueToGrid(w->x(), gridX);
+ const int tmpy = alignValueToGrid(w->y(), gridY);
if ((tmpx != w->x()) || (tmpy != w->y()))
w->move(tmpx, tmpy);
}
@@ -479,11 +478,10 @@
int tmpx = 0, tmpy = 0;
// same as in 'Align to Grid' + for the size
foreach (QWidget *w, list) {
- tmpx = int((float)w->x() / ((float)gridX) + 0.5) * gridX;
- tmpy = int((float)w->y() / ((float)gridY) + 0.5) * gridY;
- tmpw = int((float)w->width() / ((float)gridX) + 0.5) * gridX;
- tmph = int((float)w->height() / ((float)gridY) + 0.5) * gridY;
-
+ tmpx = alignValueToGrid(w->x(), gridX);
+ tmpy = alignValueToGrid(w->y(), gridY);
+ tmpw = alignValueToGrid(w->width(), gridX);
+ tmph = alignValueToGrid(w->height(), gridY);
if ((tmpx != w->x()) || (tmpy != w->y()))
w->move(tmpx, tmpy);
if ((tmpw != w->width()) || (tmph != w->height()))
@@ -827,6 +825,8 @@
KAcceleratorManager::setNoAccel(w);
}
+// w->installEventFilter(container);
+
// if the insertRect is invalid (ie only one point), we use widget' size hint
if (((d->insertRect.width() < 21) && (d->insertRect.height() < 21))) {
QSize s = w->sizeHint();
@@ -844,8 +844,17 @@
d->insertRect = QRect(x, y, s.width() + 16/* add some space so more text can \
be entered*/, s.height());
}
+
+ // fix widget size is align-to-grid is enabled
+ if (d->form->isSnapWidgetsToGridEnabled()) {
+ const int grid = d->form->gridSize();
+ d->insertRect.setWidth( alignValueToGrid(d->insertRect.width(), grid) );
+ d->insertRect.setHeight( alignValueToGrid(d->insertRect.height(), grid) );
+ }
+
w->move(d->insertRect.x(), d->insertRect.y());
- w->resize(d->insertRect.width() - 1, d->insertRect.height() - 1); // -1 is not \
to hide dots +// w->resize(d->insertRect.width() - 1, d->insertRect.height() - 1); \
// -1 is not to hide dots + w->resize(d->insertRect.size());
w->setStyle(container->widget()->style());
//2.0 not needed w->setBackgroundOrigin(QWidget::ParentOrigin);
w->show();
--- trunk/koffice/kexi/formeditor/container.cpp #933479:933480
@@ -33,7 +33,6 @@
#include <kdebug.h>
#include <KLocale>
-#include <KMenu>
#include <KGlobalSettings>
#include <cstdlib> // for abs()
@@ -137,13 +136,19 @@
stopSelectionRectangleOrInserting();
return;
}
+ QRect oldInsertRect( insertRect );
insertRect.setTopLeft( QPoint(
qMin(insertBegin.x(), end.x()),
qMin(insertBegin.y(), end.y()) ) );
insertRect.setBottomRight( QPoint(
qMax(insertBegin.x(), end.x()),
qMax(insertBegin.y(), end.y()) ) );
- m_widget->update();
+ QRegion region(oldInsertRect);
+ region.unite(insertRect);
+ QRect toUpdate( oldInsertRect.united(insertRect) );
+ toUpdate.setWidth(toUpdate.width()+1);
+ toUpdate.setHeight(toUpdate.height()+1);
+ m_widget->update(toUpdate);
}
bool selectionOrInsertingStarted() const
{
@@ -341,12 +346,9 @@
tmpy = mev->y();
}
else {
- int gridX = d->form->gridSize();
- int gridY = d->form->gridSize();
- tmpx = int((float)mev->x() / ((float)gridX) + 0.5); // snap to \
grid
- tmpx *= gridX;
- tmpy = int((float)mev->y() / ((float)gridY) + 0.5);
- tmpy *= gridX;
+ int grid = d->form->gridSize();
+ tmpx = alignValueToGrid(mev->x(), grid);
+ tmpy = alignValueToGrid(mev->y(), grid);
}
d->startSelectionOrInsertingRectangle( \
(static_cast<QWidget*>(s))->mapTo(widget(), QPoint(tmpx, tmpy)) ); @@ -392,6 +394,18 \
@@ )
)
{
+ QPoint realPos;
+ if (d->form->isSnapWidgetsToGridEnabled()) {
+ const int gridX = d->form->gridSize();
+ const int gridY = d->form->gridSize();
+ realPos = QPoint(
+ alignValueToGrid(mev->pos().x(), gridX),
+ alignValueToGrid(mev->pos().y(), gridY));
+ }
+ else {
+ realPos = mev->pos();
+ }
+ d->updateSelectionOrInsertingRectangle(realPos); //2.0
// draw the insert rect
//reimpl. drawInsertRect(mev, s);
return true;
@@ -1257,10 +1271,8 @@
tmpy = pos.y();
}
else {
- tmpx = int((float) pos.x() / ((float)gridX) + 0.5);
- tmpx *= gridX;
- tmpy = int((float)pos.y() / ((float)gridY) + 0.5);
- tmpy *= gridX;
+ tmpx = alignValueToGrid(pos.x(), gridX);
+ tmpy = alignValueToGrid(pos.y(), gridY);
}
int topx = (m_insertBegin.x() < tmpx) ? m_insertBegin.x() : tmpx;
@@ -1375,8 +1387,8 @@
tmpy = w->y() + dy;
}
else {
- tmpx = int(float(w->x() + dx) / float(gridX) + 0.5) * gridX;
- tmpy = int(float(w->y() + dy) / float(gridY) + 0.5) * gridY;
+ tmpx = alignValueToGrid(w->x() + dx, gridX);
+ tmpy = alignValueToGrid(w->y() + dy, gridY);
}
if ((tmpx != w->x()) || (tmpy != w->y())) {
--- trunk/koffice/kexi/formeditor/form.cpp #933479:933480
@@ -2130,7 +2130,7 @@
// QPoint realMenuPos = sel_w ? sel_w->mapToGlobal(QPoint(sel_w->width() / 2, \
sel_w->height() / 2)) : QCursor::pos();
d->insertionPoint = menuPos; //container->widget()->mapToGlobal(menuPos);
- QAction *result = menu.exec( container->widget()->mapToGlobal(menuPos) );
+ QAction *result = menu.exec( container->widget()->mapToGlobal(w->pos() + \
menuPos) );
if (!result) {
// nothing to do
--- trunk/koffice/kexi/formeditor/resizehandle.cpp #933479:933480
@@ -40,18 +40,17 @@
using namespace KFormDesigner;
ResizeHandle::ResizeHandle(ResizeHandleSet *set, HandlePos pos, bool editing)
- : QWidget(set->m_widget->parentWidget()), m_set(set)
+ : QWidget(set->m_widget->parentWidget()), m_set(set), m_pos(pos)
{
// setBackgroundMode(Qt::NoBackground);
m_dragging = false;
//m_editing = editing;
setEditingMode(editing);
- setFixedWidth(6);
- setFixedHeight(6);
- m_pos = pos;
+ setFixedSize(6, 6);
//m_buddy = buddy;
//buddy->installEventFilter(this);
m_set->m_widget->installEventFilter(this);
+ setAutoFillBackground(true);
//js installEventFilter(this);
updatePos();
@@ -65,7 +64,7 @@
void ResizeHandle::setEditingMode(bool editing)
{
QPalette pal(palette());
- pal.setColor(backgroundRole(), editing ? Qt::blue : Qt::black);
+ pal.setBrush(backgroundRole(), editing ? QBrush(Qt::blue) : pal.text());
setPalette(pal);
}
--- trunk/koffice/kexi/formeditor/utils.cpp #933479:933480
@@ -299,4 +299,11 @@
return d->actions.value(name);
}
+//-----------------------------
+
+int KFormDesigner::alignValueToGrid(int value, int gridSize)
+{
+ return int((float)value / ((float)gridSize) + 0.5) * gridSize;
+}
+
#include "utils.moc"
--- trunk/koffice/kexi/formeditor/utils.h #933479:933480
@@ -153,7 +153,9 @@
Private * const d;
};
+//! @return @a value aligned to the nearest multiple of gridSize
+KFORMEDITOR_EXPORT int alignValueToGrid(int value, int gridSize);
+
}
#endif
-
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic