[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kolourpaint/lgpl/generic/widgets
From: Clarence Dang <dang () kde ! org>
Date: 2007-09-27 6:49:35
Message-ID: 1190875775.430387.32393.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 717558 by dang:
* +assert
* Add and fix APIDoc
* Style
M +19 -20 kpColorCellsBase.cpp
M +24 -10 kpColorCellsBase.h
--- trunk/KDE/kdegraphics/kolourpaint/lgpl/generic/widgets/kpColorCellsBase.cpp \
#717557:717558 @@ -1,12 +1,4 @@
-// SYNC: Periodically merge in changes from:
-//
-// trunk/KDE/kdelibs/kdeui/colors/kcolordialog.{h,cpp}
-//
-// which this is a fork of.
-//
-// Our changes can be merged back into KDE (grep for "Added for KolourPaint" \
and similar).
-
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones@kde.org)
Copyright (C) 2007 Roberto Raggi (roberto@kdevelop.org)
@@ -59,7 +51,7 @@
}
kpColorCellsBase *q;
-
+
// Note: This is a good thing and is _not_ data duplication with the
// colors of QTableWidget cells, for the following reasons:
//
@@ -73,7 +65,7 @@
//
// Therefore, do not remove this field without better reasons.
QColor *colors;
-
+
QPoint mousePos;
int selected;
bool shade;
@@ -262,21 +254,25 @@
if (event->type () != QEvent::EnabledChange)
return;
-
+
for (int r = 0; r < rowCount (); r++)
{
for (int c = 0; c < columnCount (); c++)
{
+ const int index = r * columnCount () + c;
+
QTableWidgetItem* tableItem = item(r, c);
+
+ // See API Doc for this invariant.
+ Q_ASSERT (!!tableItem == d->colors [index].isValid ());
+
if (!tableItem)
continue;
+
QColor color;
if (isEnabled ())
- {
- color = d->colors [r * columnCount () + c];
- Q_ASSERT (color.isValid ());
- }
+ color = d->colors [index];
else
color = palette ().color (backgroundRole ());
@@ -369,10 +365,10 @@
if (r == -1 || c == -1)
return -1;
-
+
if (!allowEmptyCell && !itemAt(pos))
return -1;
-
+
const int cell = r * columnCount() + c;
/*if (!ignoreBorders)
@@ -399,11 +395,14 @@
e->y() > d->mousePos.y()+delay || e->y() < d->mousePos.y()-delay){
// Drag color object
int cell = positionToCell(d->mousePos);
- if ((cell != -1) && d->colors[cell].isValid())
+ if (cell != -1)
{
#if DEBUG_KP_COLOR_CELLS_BASE
- kDebug () << "beginning drag from cell=" << cell;
+ kDebug () << "beginning drag from cell=" << cell
+ << "color: isValid=" << d->colors [cell].isValid ()
+ << " rgba=" << (int *) d->colors [cell].rgba();
#endif
+ Q_ASSERT (d->colors[cell].isValid());
KColorMimeData::createDrag(d->colors[cell], \
this)->start(Qt::CopyAction | Qt::MoveAction); #if DEBUG_KP_COLOR_CELLS_BASE
kDebug () << "finished drag";
@@ -427,7 +426,7 @@
static void SetDropAction (QWidget *self, QDropEvent *event)
{
// TODO: Would be nice to default to CopyAction if the destination cell
- // is null.
+ // is null.
if (event->source () == self && (event->keyboardModifiers () & \
Qt::ControlModifier) == 0) event->setDropAction(Qt::MoveAction);
else
--- trunk/KDE/kdegraphics/kolourpaint/lgpl/generic/widgets/kpColorCellsBase.h \
#717557:717558 @@ -1,3 +1,12 @@
+
+// SYNC: Periodically merge in changes from:
+//
+// trunk/KDE/kdelibs/kdeui/colors/kcolordialog.{h,cpp}
+//
+// which this is a fork of.
+//
+// Our changes can be merged back into KDE (grep for "Added for KolourPaint" \
and similar). +
/* This file is part of the KDE libraries
Copyright (C) 1997 Martin Jones (mjones@kde.org)
@@ -44,7 +53,8 @@
* does not exist. Note that:
*
* 1. You can double click on cells that don't contain a widget
-* 2. You can drop onto -- but not drag a -- cell that doesn't contain a widget
+* 2. You can drop onto -- but not drag from -- a cell that doesn't contain a
+* widget
*
* If a color is dragged and dropped to-and-from the same instance of this
* widget, then the colors in the source and destination cells are swapped
@@ -58,9 +68,9 @@
{
Q_OBJECT
public:
- /**
+ /**
* Constructs a new table of color cells, consisting of
- * @p rows * @p columns colors.
+ * @p rows * @p columns colors.
*
* @param parent The parent of the new widget
* @param rows The number of rows in the table
@@ -71,12 +81,14 @@
kpColorCellsBase( QWidget *parent, int rows = 0, int columns = 0 );
~kpColorCellsBase();
+private:
+ /** Added for KolourPaint. */
+ void invalidateAllColors ();
+
+public:
/** Added for KolourPaint.
WARNING: These are not virtual in QTableWidget.
*/
-private:
- void invalidateAllColors ();
-public:
void clear ();
void clearContents ();
@@ -108,10 +120,11 @@
void setAcceptDrags(bool acceptDrags);
/** Whether the alpha values (e.g. as passed to setColor() and received
- from a drop) will be ignored for colors
+ from a drop) will be ignored for colors
Default is false.
Call this in your constructor before you've set any colors.
+ If you ignore this instruction, undefined behavior will result.
Added for KolourPaint since none of the drawing routines support
alpha, other than pure transparency, which we don't currently
@@ -130,7 +143,7 @@
void setSelected(int index);
/** Returns the index of the cell which is currently selected */
int selectedIndex() const;
-
+
Q_SIGNALS:
/** Emitted when a color is selected in the table */
void colorSelected( int index , const QColor& color );
@@ -152,7 +165,7 @@
protected:
/** Grays out the cells, when the object is disabled.
- Added for KolourPaint.
+ Added for KolourPaint.
*/
virtual void changeEvent( QEvent* event );
@@ -170,6 +183,7 @@
virtual void dropEvent( QDropEvent *);
virtual void mouseDoubleClickEvent( QMouseEvent * );
+ /** <allowEmptyCell> was added for KolourPaint. */
int positionToCell(const QPoint &pos, bool ignoreBorders=false,
bool allowEmptyCell=false) const;
@@ -177,7 +191,7 @@
class kpColorCellsBasePrivate;
friend class kpColorCellsBasePrivate;
kpColorCellsBasePrivate *const d;
-
+
Q_DISABLE_COPY(kpColorCellsBase)
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic