[rkward-cvs] rkward/rkward/plugin rkcomponent.cpp,1.5,1.6 rkcomponent.h,1.5,1.6 rkcomponentproperties.cpp,1.10,1.11 rkcomponentproperties.h,1.12,1.13 rkstandardcomponent.cpp,1.6,1.7 rkstandardcomponent.h,1.5,1.6 rkvarselector.cpp,1.15,1.16 rkvarslot.cpp,1.16,1.17 rkvarslot.h,1.9,1.10
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Wed Mar 15 20:31:31 UTC 2006
Update of /cvsroot/rkward/rkward/rkward/plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4363
Modified Files:
rkcomponent.cpp rkcomponent.h rkcomponentproperties.cpp
rkcomponentproperties.h rkstandardcomponent.cpp
rkstandardcomponent.h rkvarselector.cpp rkvarslot.cpp
rkvarslot.h
Log Message:
First little victory in getting the new code to work: Basic varselector/varslot interaction functioning
Index: rkcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rkcomponent.h 15 Mar 2006 18:09:22 -0000 1.5
--- rkcomponent.h 15 Mar 2006 20:31:28 -0000 1.6
***************
*** 46,50 ****
};
/** for RTTI. see RKComponentBase::RKComponentTypes */
! int type () { return ComponentBase; };
/** tries to locate a component (or property) described by identifier as a child (of any generation) of this RKComponentBase. If found, a pointer to this is returned. Also, the modifier parameter is set to hold any remaining modifier contained in the identifier.
@param identifier The identifier string to look for (including a potential modifier suffix).
--- 46,50 ----
};
/** for RTTI. see RKComponentBase::RKComponentTypes */
! virtual int type () { return ComponentBase; };
/** tries to locate a component (or property) described by identifier as a child (of any generation) of this RKComponentBase. If found, a pointer to this is returned. Also, the modifier parameter is set to hold any remaining modifier contained in the identifier.
@param identifier The identifier string to look for (including a potential modifier suffix).
Index: rkvarselector.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarselector.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** rkvarselector.cpp 15 Mar 2006 18:09:22 -0000 1.15
--- rkvarselector.cpp 15 Mar 2006 20:31:28 -0000 1.16
***************
*** 67,70 ****
--- 67,71 ----
selected->setFromListView (list_view, true);
+ RK_DO (qDebug ("selected in varselector: %s", selected->value ().latin1 ()), PLUGIN, DL_DEBUG);
}
Index: rkvarslot.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarslot.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** rkvarslot.cpp 15 Mar 2006 18:09:22 -0000 1.16
--- rkvarslot.cpp 15 Mar 2006 20:31:28 -0000 1.17
***************
*** 63,67 ****
g_layout->addWidget (list, 1, 2);
! g_layout->setRowStretch (3, 1);
// initialize properties
--- 63,67 ----
g_layout->addWidget (list, 1, 2);
! g_layout->setRowStretch (3, 1); // so the label does not get separated from the view
// initialize properties
***************
*** 71,90 ****
// find out about options
! if (xml->getBoolAttribute (element, "multi", false, DL_INFO)) {
! available->setListLength (xml->getIntAttribute (element, "min_vars", 1, DL_INFO), xml->getIntAttribute (element, "min_vars_fi_any", 0, DL_INFO), xml->getIntAttribute (element, "max_vars", 0, DL_INFO));
connect (list, SIGNAL (selectionChanged ()), this, SLOT (listSelectionChanged ()));
} else {
list->header ()->hide ();
! //list->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
! list->setFixedHeight (20);
list->setColumnWidth (0, 0);
}
// initialize filters
! available->setClassFilter (xml->getStringAttribute (element, "classes", QString::null, DL_INFO));
available->setRequired (xml->getBoolAttribute (element, "required", true, DL_INFO));
! available->setTypeFilter (xml->getStringAttribute (element, "types", QString::null, DL_INFO));
connect (available, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (availablePropertyChanged (RKComponentPropertyBase *)));
}
--- 71,96 ----
// find out about options
! if (multi = xml->getBoolAttribute (element, "multi", false, DL_INFO)) {
! available->setListLength (xml->getIntAttribute (element, "min_vars", 1, DL_INFO), xml->getIntAttribute (element, "min_vars_if_any", 0, DL_INFO), xml->getIntAttribute (element, "max_vars", 0, DL_INFO));
connect (list, SIGNAL (selectionChanged ()), this, SLOT (listSelectionChanged ()));
} else {
+ available->setListLength (1, 1, 1);
+
+ // make it look like a line-edit
list->header ()->hide ();
! list->setFixedHeight (20); // TODO: use true height of one line instead of constant!
! list->setColumnWidthMode (0, QListView::Manual);
list->setColumnWidth (0, 0);
+ list->setHScrollBarMode (QScrollView::AlwaysOff);
+ list->setVScrollBarMode (QScrollView::AlwaysOff);
}
// initialize filters
! available->setClassFilter (QStringList::split (";", xml->getStringAttribute (element, "classes", QString::null, DL_INFO)));
available->setRequired (xml->getBoolAttribute (element, "required", true, DL_INFO));
! available->setTypeFilter (QStringList::split (";", xml->getStringAttribute (element, "types", QString::null, DL_INFO)));
connect (available, SIGNAL (valueChanged (RKComponentPropertyBase *)), this, SLOT (availablePropertyChanged (RKComponentPropertyBase *)));
+ availablePropertyChanged (available); // initialize
}
***************
*** 95,103 ****
void RKVarSlot::setSelectButton (bool add) {
if (add) {
- select->setPixmap (SmallIcon ("1leftarrow"));
- add_mode = false;
- } else {
select->setPixmap (SmallIcon ("1rightarrow"));
add_mode = true;
}
}
--- 101,109 ----
void RKVarSlot::setSelectButton (bool add) {
if (add) {
select->setPixmap (SmallIcon ("1rightarrow"));
add_mode = true;
+ } else {
+ select->setPixmap (SmallIcon ("1leftarrow"));
+ add_mode = false;
}
}
***************
*** 121,125 ****
selected->setObjectList (sellist);
! setSelectButton (!selection);
}
--- 127,131 ----
selected->setObjectList (sellist);
! setSelectButton ((!selection) && (!available->atMaxLength ()));
}
***************
*** 130,133 ****
--- 136,141 ----
item_map.clear ();
+ RK_DO (qDebug ("contained in varslot: %s", available->value ().latin1 ()), PLUGIN, DL_DEBUG);
+
ObjectList objlist = available->objectList ();
ObjectList::const_iterator it = objlist.begin ();
***************
*** 136,141 ****
--- 144,152 ----
QListViewItem *new_item = new QListViewItem (list, QString::number (i++), (*it)->getShortName ());
list->insertItem (new_item);
+ ++it;
}
+ listSelectionChanged (); // takes care of updating the select button
+
if (!isSatisfied ()) {
list->setPaletteBackgroundColor (QColor (255, 0, 0));
***************
*** 148,151 ****
--- 159,164 ----
RK_TRACE (PLUGIN);
+ RK_DO (qDebug ("select press in varslot: mode %d, source %s, selected %s", add_mode, source->value ().latin1 (), selected->value ().latin1 ()), PLUGIN, DL_DEBUG);
+
// first update the properties
if (add_mode) {
***************
*** 171,176 ****
}
}
-
- setSelectButton (false);
}
--- 184,187 ----
Index: rkstandardcomponent.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rkstandardcomponent.h 15 Mar 2006 18:09:22 -0000 1.5
--- rkstandardcomponent.h 15 Mar 2006 20:31:28 -0000 1.6
***************
*** 126,129 ****
--- 126,131 ----
RKComponent *component () const { return parent; };
private:
+ /** internal convenience function to schedule a property connection */
+ void addConnection (const QString &client_id, const QString &client_property, const QString &governor_id, const QString &governor_property, bool reconcile, const QDomElement &origin);
RKComponent *parent;
struct RKComponentPropertyConnection {
***************
*** 131,136 ****
QString client_property;
bool reconcile;
};
! QValueList <RKComponentPropertyConnection *> connection_list;
};
--- 133,140 ----
QString client_property;
bool reconcile;
+ QDomElement origin;
};
! typedef QValueList <RKComponentPropertyConnection> ConnectionList;
! ConnectionList connection_list;
};
Index: rkcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponent.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rkcomponent.cpp 15 Mar 2006 18:09:22 -0000 1.5
--- rkcomponent.cpp 15 Mar 2006 20:31:28 -0000 1.6
***************
*** 26,29 ****
--- 26,30 ----
if (identifier.isEmpty ()) return this;
+ RK_DO (qDebug ("looking up '%s'", identifier.latin1 ()), PLUGIN, DL_DEBUG);
RKComponentBase *child = child_map.find (identifier.section ("::", 0, 0));
Index: rkstandardcomponent.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkstandardcomponent.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** rkstandardcomponent.cpp 15 Mar 2006 18:09:22 -0000 1.6
--- rkstandardcomponent.cpp 15 Mar 2006 20:31:28 -0000 1.7
***************
*** 168,172 ****
RKComponent *widget = 0;
QDomElement e = *it; // shorthand
!
if (e.tagName () == "row") {
QHBox *box = new QHBox (parent_widget);
--- 168,173 ----
RKComponent *widget = 0;
QDomElement e = *it; // shorthand
! QString id = xml->getStringAttribute (e, "id", "#noid#", DL_INFO);
!
if (e.tagName () == "row") {
QHBox *box = new QHBox (parent_widget);
***************
*** 197,200 ****
--- 198,202 ----
} else if (e.tagName () == "varslot") {
widget = new RKVarSlot (e, component (), parent_widget);
+ addConnection (id, "source", xml->getStringAttribute (e, "source", "#noid#", DL_INFO), "selected", false, e);
/* } else if (e.tagName () == "radio") {
widget = new RKRadio (e, parent_component, parent_widget);
***************
*** 214,222 ****
widget = new RKText (e, parent_component, parent_widget); */
} else {
! xml->displayError (&e, QString ("Invalid tagname '%'").arg (e.tagName ()), DL_ERROR);
}
if (widget) {
! parent->addChild (xml->getStringAttribute (e, "id", "#noid#", DL_WARNING), widget);
// TODO: deal with (multi-page) wizards
// TODO: parse connections
--- 216,224 ----
widget = new RKText (e, parent_component, parent_widget); */
} else {
! xml->displayError (&e, QString ("Invalid tagname '%1'").arg (e.tagName ()), DL_ERROR);
}
if (widget) {
! parent->addChild (id, widget);
// TODO: deal with (multi-page) wizards
// TODO: parse connections
***************
*** 225,233 ****
--- 227,267 ----
}
+ void RKComponentBuilder::addConnection (const QString &client_id, const QString &client_property, const QString &governor_id, const QString &governor_property, bool reconcile, const QDomElement &origin) {
+ RK_TRACE (PLUGIN);
+
+ RKComponentPropertyConnection conn;
+ conn.client_property = client_id + "::" + client_property;
+ conn.governor_property = governor_id + "::" + governor_property;
+ conn.reconcile = reconcile;
+ conn.origin = origin;
+ connection_list.append (conn);
+ }
+
void RKComponentBuilder::makeConnections () {
RK_TRACE (PLUGIN);
+ XMLHelper *xml = XMLHelper::getStaticHelper ();
+
+ for (ConnectionList::const_iterator it = connection_list.begin (); it != connection_list.end (); ++it) {
+ RK_DO (qDebug ("Connecting '%s' to '%s'", (*it).client_property.latin1 (), (*it).governor_property.latin1 ()), PLUGIN, DL_DEBUG);
+
+ QString dummy;
+ RKComponentBase *client = parent->lookupComponent ((*it).client_property, &dummy);
+ if ((!client) || (!dummy.isEmpty ()) || (!client->isProperty ())) {
+ xml->displayError (&((*it).origin), QString ("Invalid client identifier '%1'").arg ((*it).client_property), DL_ERROR);
+ continue;
+ }
+ RKComponentBase *governor = parent->lookupComponent ((*it).governor_property, &dummy);
+ if ((!governor) || (!governor->isProperty ())) {
+ xml->displayError (&((*it).origin), QString ("Invalid governor identifier '%1'").arg ((*it).governor_property), DL_ERROR);
+ continue;
+ }
+
+ static_cast<RKComponentPropertyBase *> (client)->connectToGovernor (static_cast<RKComponentPropertyBase *> (governor), dummy, (*it).reconcile);
+ }
}
+
+
/////////////////////////////////////// RKStandardComponentGUI ////////////////////////////////////////////////
Index: rkcomponentproperties.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** rkcomponentproperties.cpp 15 Mar 2006 18:09:22 -0000 1.10
--- rkcomponentproperties.cpp 15 Mar 2006 20:31:28 -0000 1.11
***************
*** 646,650 ****
bool changes = false;
! // now remove items from the old list that are not in the new list
ObjectList::Iterator it = object_list.begin ();
while (it != object_list.end ()) {
--- 646,651 ----
bool changes = false;
!
! // remove items from the old list that are not in the new list
ObjectList::Iterator it = object_list.begin ();
while (it != object_list.end ()) {
***************
*** 661,664 ****
--- 662,666 ----
while (cit != newlist.end ()) {
if (!object_list.contains (*cit)) {
+ if (isObjectValid (*cit));
object_list.append (*cit);
changes = true;
***************
*** 874,880 ****
if ((property->type () == PropertyRObjects) && governor_modifier.isEmpty ()) {
! object_list = static_cast <RKComponentPropertyRObjects *> (property)->objectList ();
! validizeAll (true);
! emit (valueChanged (this));
} else {
setValue (property->value (governor_modifier));
--- 876,880 ----
if ((property->type () == PropertyRObjects) && governor_modifier.isEmpty ()) {
! setObjectList (static_cast <RKComponentPropertyRObjects *> (property)->objectList ());
} else {
setValue (property->value (governor_modifier));
***************
*** 894,903 ****
RObject *obj = list_view->findItemObject (current);
RK_ASSERT (obj);
! if (isObjectValid (obj)) {
! newlist.append (static_cast<RKVariable*> (obj));
! }
}
}
setObjectList (newlist);
}
--- 894,902 ----
RObject *obj = list_view->findItemObject (current);
RK_ASSERT (obj);
! newlist.append (static_cast<RKVariable*> (obj));
}
}
+ // invalid objects will be ignored in setObjectList
setObjectList (newlist);
}
***************
*** 950,953 ****
--- 949,960 ----
}
+ bool RKComponentPropertyRObjects::atMaxLength () {
+ RK_TRACE (PLUGIN);
+
+ if (max_num_objects && (object_list.count () >= max_num_objects)) return true;
+ return false;
+ }
+
+
/////////////////////////////////////////// Code ////////////////////////////////////////////////
Index: rkvarslot.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkvarslot.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** rkvarslot.h 15 Mar 2006 18:09:22 -0000 1.9
--- rkvarslot.h 15 Mar 2006 20:31:28 -0000 1.10
***************
*** 52,55 ****
--- 52,56 ----
void setSelectButton (bool add);
bool add_mode;
+ bool multi;
/** the available objects (typically a copy of the property of the varselector) */
***************
*** 62,66 ****
QListView *list;
QPushButton *select;
- bool multi;
typedef QMap<QListViewItem*, RObject*> ItemMap;
ItemMap item_map;
--- 63,66 ----
Index: rkcomponentproperties.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/plugin/rkcomponentproperties.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** rkcomponentproperties.h 15 Mar 2006 18:09:22 -0000 1.12
--- rkcomponentproperties.h 15 Mar 2006 20:31:28 -0000 1.13
***************
*** 270,273 ****
--- 270,275 ----
@param selected_only if true, only the currently selected objects are filled into this property */
void setFromListView (RKObjectListView *list_view, bool selected_only=false);
+ /** @returns true, if the property holds the maximum number of items (or more) */
+ bool atMaxLength ();
public slots:
/** remove an object value. to be connected to RKModificationTracker::objectRemoved (). This is so we get notified if the object currently selected is removed TODO: is this effectively a duplication of setFromList? */
***************
*** 323,326 ****
--- 325,331 ----
bool isValid () { return (have_preprocess && have_calculate && have_printout && have_cleanup); };
+
+ /** RTTI */
+ int type () { return PropertyCode; };
private:
QString preprocess_code;
More information about the rkward-tracker
mailing list