Example #1
0
QObject *KPluginFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
{
    qDebug() << Q_FUNC_INFO << "iface=" << iface << "parentWidget=" << parentWidget << "parent=" << parent << "args=" << args << "keyword=" << keyword;
    if (keyword.isEmpty()) {
        const bool hasOne = m_registeredPlugins.count() == 1;
        QObject *p = m_registeredPlugins.count() > 1 ? new KPluginFactoryContainer(parent) : 0;
        for(QHash<QString, PluginIface*>::ConstIterator it = m_registeredPlugins.constBegin(); it != m_registeredPlugins.constEnd(); ++it) {
            QObject *obj = it.value()->create(iface, parentWidget, p ? p : parent, args, keyword);
            Q_ASSERT(obj);
            if (!obj)
                continue;
            emit objectCreated(obj);
            if (hasOne)
                p = obj;
        }
        return p;
    } else {
        QHash<QString, PluginIface*>::ConstIterator it =  m_registeredPlugins.constFind(keyword);
        if (it != m_registeredPlugins.constEnd()) {
            QObject *obj = it.value()->create(iface, parentWidget, parent, args, keyword);
            if (obj)
                emit objectCreated(obj);
            return obj;
        }
        return 0;
    }
}
Example #2
0
QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args )
{
    QObject* obj = createObject( parent, name, classname, args );
    if ( obj )
	emit objectCreated( obj );
    return obj;
}
Example #3
0
QObject* PluginFactory::create( const char* iface, QWidget* parentWidget, QObject* parent, const QString& keyword )
{
    QObject* obj = nullptr;

    const QList<PluginFactoryPrivate::Plugin> candidates( pd_ptr->createInstanceHash.values( keyword ) );
    // for !keyword.isEmpty() candidates.count() is 0 or 1

    for ( const PluginFactoryPrivate::Plugin& plugin : candidates )
    {
        for ( const QMetaObject* current = plugin.first; current; current = current->superClass() )
        {
            if ( 0 == qstrcmp( iface, current->className() ) )
            {
                if ( obj )
                    qWarning() << "ambiguous interface requested from a DSO containing more than one plugin";
                obj = plugin.second( parentWidget, parent );
                break;
            }
        }
    }

    if ( obj )
        emit objectCreated( obj );
    return obj;
}
QObject *NoteeditFactory::create(QObject *parent, const char *name, const char*,
				 const QStringList& )
#endif
{
  QObject *obj = new NoteeditPart((QWidget*)parent, name);
#if KDE_VERSION < 290
  emit objectCreated(obj);
#endif
  return obj;
}
Example #5
0
PaintWidget::PaintWidget( QWidget *parent, plugin::PluginsManager *manager):
	PaintWidgetInterface(parent), painter(manager, this)
{
    setMouseTracking(true);
    scaleVal = 1;
    isCreatedPWE = false;

	setWidget( &painter );
	setAlignment( Qt::AlignCenter );
    setViewportColor( QColor( 100, 100, 100 ) );

    manager->addPlugins(this, "PaintWidget");
	
    connect( &painter, SIGNAL( objectCreated() ), this, SIGNAL( objectCreated() ) );
    connect( &painter, SIGNAL( frameChanged( qreal ) ), this, SIGNAL( frameChanged( qreal ) ) );
    connect( &painter, SIGNAL( undoEvents() ), this, SIGNAL( undoEvents() ) );
    connect( &painter, SIGNAL( isFrame( bool) ), this, SIGNAL( isFrame(bool) ) );
    connect( &painter, SIGNAL( figureSelected( int, int ) ), this, SIGNAL( figureSelected( int, int ) ) );
    connect( &painter, SIGNAL( paintEvent(QPoint) ), this, SLOT( RPW_paintEvent(QPoint) ) );
}
QSharedPointer<QObject> QpDaoBase::createObject()
{
    QObject *object = createInstance();

    if(!d->sqlDataAccessObjectHelper->insertObject(d->metaObject, object)) {
        setLastError(d->sqlDataAccessObjectHelper->lastError());
        return QSharedPointer<QObject>();
    }
    QSharedPointer<QObject> obj = d->cache.insert(Qp::Private::primaryKey(object), object);
    Qp::Private::enableSharedFromThis(obj);

    emit objectCreated(obj);
    return obj;
}
Example #7
0
QObject *DbSeFactory::createObject( QObject *parent, const char *name,
				    const char *classname, const QStringList &)
{
	if(QCString(classname) != "SearchEngine")
	{
		kdError() << "not a SearchEngine requested" << endl;
		return 0;
	}
	
	KDBSearchEngine *se = new KDBSearchEngine(parent,name);

	emit objectCreated(se);
	return se;
}
Example #8
0
/*!
  This function will create a new object and add it to the object list. It will then return an instance of that object to the caller. The function returns NULL if the object was not created. Since the Object Manager is the only class that can create objects all other classes must call this particular function to request a new object.
  @param objType The type of object that is to be added as a QString
  @param objName The name of the object to be added. All objects have names.
  @return An instance of a new object of a particular type. NULL is returned if the object could not be created.
 */
rtRenderObject* rtObjectManager::addObjectOfType(QString objType, QString objName) {
#ifdef DEBUG_VERBOSE_MODE_ON
  rtApplication::instance().getMessageHandle()->debug( QString("rtObjectManager::addObjectOfType() start") );
#endif

  rtRenderObject* temp = NULL;
  rtDataObject* dataO = NULL;
  int nextID;

  // Lock this function
  QMutexLocker locker(&m_objectLock);

  // Find out which object will be used.

  if (objType == "OT_None")
  {
      temp=new rtNoneRenderObject();
      rtApplication::instance().getMessageHandle()->warning(__LINE__, __FILE__, QString("Warning: None Object Requested. "));
  } else if (objType == "OT_3DObject")
  {
      temp=new rt3DVolumeRenderObject();
  } else if (objType == "OT_2DObject")
  {
      temp=new rt2DSliceRenderObject();
  } else if (objType == "OT_Cath")
  {
      temp=new rtCathRenderObject();
  } else if (objType == "OT_vtkMatrix4x4")
  {
      temp=new rtMatrixRenderObject();
  } else if (objType == "OT_vtkPolyData")
  {
      temp=new rtPolyRenderObject();
  } else if (objType == "OT_vtkPiecewiseFunction")
  {
      temp=new rtPieceFuncRenderObject();
  } else if (objType == "OT_vtkColorTransferFunction")
  {
      temp=new rtColorFuncRenderObject();
  } else if (objType == "OT_ImageBuffer")
  {
      temp=new rtImageBufferRenderObject();
  } else if (objType == "OT_2DPointBuffer")
  {
      temp=new rt2DPointRenderObject();
  } else if (objType == "OT_3DPointBuffer")
  {
      temp=new rt3DPointBufferRenderObject();
  } else if (objType == "OT_2DPlot")
  {
      temp=new rt2DPlotRenderObject();
  }else if (objType == "OT_TextLabel")
  {
      temp=new rtLabelRenderObject();
  } else
  {
      bool ok = false;
      for (int ix1=0; ix1<m_extObjects.size(); ix1++)
      {
          if (m_extObjects[ix1].first == objType)
          {
              temp = m_extObjects[ix1].second->createObject();
              ok = true;
          }
      }
      if (!ok)
      {
          rtApplication::instance().getMessageHandle()->warning(__LINE__, __FILE__, QString("No object of type: ").append(objType));
          temp=NULL;
      }
  }



  // The object has been created.
  if (temp){
    dataO = temp->getDataObject();

    // Try to get the valid ID.
    nextID = dataO->getId();
    if (nextID == -1) {
      rtApplication::instance().getMessageHandle()->error(__LINE__, __FILE__, QString("Could not find a valid ID for a new object! "));
      delete temp;
      return NULL;
    }

    // Push the new object creation to the log.
    rtApplication::instance().getMessageHandle()->log(QString("Created Object with ID: ").append(QString::number(nextID)));

    dataO->setObjName(objName);
    dataO->update();
    m_objectHash.insert(nextID, temp);
    updateGuiObjectList();

    QList<QString> twoDViews = temp->get2DViewNameList();
    for (int ix1=0; ix1<twoDViews.size(); ix1++) {
      m_list2DHash.insertMulti(nextID, twoDViews[ix1]);
    }
    if (twoDViews.size()>0 && rtApplication::instance().getMainWinHandle()) {
      rtApplication::instance().getMainWinHandle()->update2DWindowLists(&m_list2DHash);
    }

    emit objectCreated(nextID);
  }

#ifdef DEBUG_VERBOSE_MODE_ON
  rtApplication::instance().getMessageHandle()->debug( QString("rtObjectManager::addObjectOfType() end") );
#endif
  return temp;
}
Example #9
0
void NotifyManager::createded(Db* db, const QString& database, const QString& object)
{
    emit objectCreated(db, database, object);
}
Example #10
0
void RealPaintWidget::mousePressEvent( QMouseEvent *event )
{
	QPoint pos = event->pos();
	int button = event->button();

	if(button == Qt::LeftButton || selection.isInAddPointMode())
	{
		if( fixedSize )
		{
			QSize sz = rect().size() - size;
			pos -= QPoint( sz.width() / 2, sz.height() / 2 );
		}

		if( currentTool != 0 )
		{
            isMousePress = true;
			GObjectInterface * o = GObject::create( currentTool, pos,
								currentTool->figureName(), currentFrame);

			layers[currentLayer]->add( GOBJECT(o), true );

			selection.setSelected( o );
			selection.setIsNewFigure(true);

			emit objectCreated();
			emit figureSelected( currentLayer, layers[currentLayer]->objectIndex( GOBJECT(o) ) );

			if( currentTool->createStyle() != FigureToolInterface::paint )
			{
				selection.mousePress( event->button(), pos, event->modifiers() );
				selection.setCreateFigureMode( true );
			}
			else
				selection.reset();

			QVector <int> frames = layers[currentLayer]->getFrames();
			for( int i = 0; i < frames.size(); i++ )
			{
				if( frames[i] != currentFrame )
					o->addFrame(frames[i], false);
			}
			return;
		}

		if( selection.mousePress( event->button(), pos, event->modifiers() ) )
			return;

		if(button == Qt::RightButton && !selection.isInAddPointMode())
		{
			paintConMenu->exec(QWidget::mapToGlobal(pos),0);
			return;
		}

		GContainer * cont = GCONTAINER(selection.getSelected());
		if(button != Qt::RightButton && cont != 0 && selection.isInAddPointMode() && cont->countObjects()==1)
		{
			cont->addPointToEnd(pos);
			emit StateChanged("Add point");
			return;
		}

		GObjectInterface* o = 0;
		for(int i=0;i<layers.size();i++)
		{
			o = layers[i]->contains( pos );
			if(o != 0)
			{
				currentLayer = i;
				break;
			}
		}

		if( o == 0 )
		{
			selection.reset();
			emit figureSelected( currentLayer, -1 );

			inSelectionMode = true;
			selectionRect = QRect( pos, QSize( 0, 0 ) );
			update();
			return;
		}



		if( ( ( event->modifiers() & Qt::ControlModifier ) == 0 ) ||
			( selection.countSelected() <= 0 ) )
		{
			selection.setSelected( o );
			emit figureSelected(currentLayer, layers[currentLayer]->objectIndex( GOBJECT(o) ) );
		}
		else
		{
			selection.addSelected( o );
			inKeyPressedHandler = true;
			emit figureSelected( currentLayer, -1 );
			inKeyPressedHandler = false;

		}


		selection.mousePress( event->button(), pos, event->modifiers() );
	}

	if(button == Qt::RightButton && !(selection.isInAddPointMode()))
	{
		if(selection.countSelected() != 1)
			propertiesAct->setEnabled(false);
		else
			propertiesAct->setEnabled(true);
		paintConMenu->exec(QWidget::mapToGlobal(pos),0);
	}


}