Commit a21efd84 authored by Jan Möbius's avatar Jan Möbius

Changed addEmpty dialog to get available datatypes from registered types.

List only types supported by plugins

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7675 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b870ae14
......@@ -600,7 +600,10 @@ private:
/// Gets called by examiner widget when Wheel is moved in picking mode
void slotWheelEvent( QWheelEvent * _event, const std::string & _mode);
/// Slot adding empty object from Menu
/** \brief Open the add Empty dialog
*
* This slot shows the addEmpty dialog which is used to add empty objects of supported dataTypes
*/
void slotAddEmptyObjectMenu();
/// Slot adding empty object of a given type
......@@ -1003,9 +1006,6 @@ private:
/// File-Plugins
std::vector<fileTypes> supportedTypes_;
/// addEmpty Widget
// addEmptyWidget* addEmptyWidget_;
private :
///Pointer to the data rootNode;
BaseObject* objectRoot_;
......
......@@ -591,22 +591,53 @@ void Core::slotEmptyObjectAdded ( int _id ) {
/// Opens AddEmpty-Object widget
void Core::slotAddEmptyObjectMenu() {
if (supportedTypes_.size() != 0){
static addEmptyWidget* widget = 0;
if ( !widget ){
std::vector< DataType > types;
QStringList typeNames;
for (int i=0; i < (int)supportedTypes_.size(); i++) {
types.push_back(supportedTypes_[i].type);
typeNames.push_back(supportedTypes_[i].plugin->typeName());
std::vector< DataType > types;
QStringList typeNames;
DataType currentType = 2;
// Iterate over all Types known to the core
// Start at 2:
// 0 type is defined as DATA_UNKNOWN
// 1 type is defined as DATA_GROUP
// Therefore we have two types less then reported
//
for ( uint i = 0 ; i < typeCount() - 2 ; ++i) {
// iterate over all support types (created from plugins on load.
// Check if a plugin supports addEmpty for the current type.
// Only if the type is supported, add it to the addEmpty Dialog
for ( uint j = 0 ; j < supportedTypes_.size(); j++) {
// Check if a plugin supports the current Type
if ( supportedTypes_[j].type & currentType ) {
types.push_back(currentType);
typeNames.push_back( typeName( currentType ) );
// Stop here as we need only one plugin supporting addEmpty for a given type
break;
}
}
// Advance to next type ( Indices are bits so multiply by to to get next bit)
currentType *= 2;
}
static addEmptyWidget* widget = 0;
if (supportedTypes_.size() != 0) {
if ( !widget ){
widget = new addEmptyWidget(types,typeNames);
widget->setWindowIcon( OpenFlipper::Options::OpenFlipperIcon() );
connect(widget,SIGNAL(chosen(DataType, int&)),this,SLOT(slotAddEmptyObject(DataType, int&)));
}
widget->show();
}else
emit log(LOGERR,tr("Could not show 'add Empty' dialog. Missing file-plugins."));
} else
emit log(LOGERR,tr("Could not show 'add Empty' dialog. Missing file-plugins ?"));
}
//========================================================================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment