Esempio n. 1
0
KviModuleExtension * KviModuleExtensionManager::allocateExtension(const KviCString &szType,const KviCString &szName,KviWindow * pWnd,KviPointerHashTable<QString,QVariant> * pParams,void * pSpecial,const QString &preloadModule)
{
	KviModuleExtensionDescriptorList * l = allocateExtensionGetDescriptorList(szType,preloadModule);
	if(!l)return 0;

	KviModuleExtensionDescriptor * d;

	for(d = l->first();d;d = l->next())
	{
		if(d->name().equalsCI(szName))return d->allocate(pWnd,pParams,pSpecial);
	}

	// uhm... not there ?
	g_pModuleManager->loadModulesByCaps(szType.ptr());
	// try again after loading the modules
	// l = m_pExtensionDict->find(szType.ptr()); <--- this shouldn't change!
	for(d = l->first();d;d = l->next())
	{
		if(d->name().equalsCI(szName))return d->allocate(pWnd,pParams,pSpecial);
	}

	// no way : no such extension

	return 0;
}
Esempio n. 2
0
void KviModuleExtensionManager::unregisterExtensionsByModule(KviModule * m)
{
	KviPointerHashTableIterator<const char *,KviModuleExtensionDescriptorList> it(*m_pExtensionDict);
	KviPointerList<KviCString> dying;
	dying.setAutoDelete(true);
	while(KviModuleExtensionDescriptorList * l = it.current())
	{
		KviPointerList<KviModuleExtensionDescriptor> dying2;
		dying2.setAutoDelete(true);

		for(KviModuleExtensionDescriptor * d = l->first();d;d = l->next())
		{
			if(d->module() == m)dying2.append(d);
		}

		for(KviModuleExtensionDescriptor * de = dying2.first();de;de = dying2.next())
		{
			l->removeRef(de);
		}

		if(l->isEmpty())dying.append(new KviCString(it.currentKey()));
		++it;
	}
	for(KviCString * li = dying.first();li;li = dying.next())
	{
		m_pExtensionDict->remove(li->ptr());
	}
}
Esempio n. 3
0
static bool mircimport_module_init(KviModule * m)
{
	QString szPath;
	QPixmap * pix = 0;
	if(g_pApp->findImage(szPath,"kvi_mircimport.png"))
	{
		pix = new QPixmap(szPath);
		if(pix->isNull())
		{
			delete pix;
			pix = 0;
		}
	}

	KviModuleExtensionDescriptor * d = m->registerExtension("serverimport",
							"mIRC servers.ini import filter",
							__tr("Import from servers.ini"),
							mircimport_local_filter_alloc);

	if(d && pix)d->setIcon(*pix);

	d = m->registerExtension("serverimport",
							"Remote mIRC servers.ini import filter",
							__tr("Import from http://www.mirc.co.uk/servers.ini"),
							mircimport_remote_filter_alloc);

	if(d && pix)d->setIcon(*pix);

	if(pix)delete pix;
	return true;
}
Esempio n. 4
0
KviModuleExtensionDescriptor * KviModuleExtensionManager::findExtensionDescriptor(const KviCString &szType,const KviCString &szName)
{
	KviModuleExtensionDescriptorList * l = m_pExtensionDict->find(szType.ptr());
	if(!l)return 0;

	for(KviModuleExtensionDescriptor * d = l->first();d;d = l->next())
	{
		if(d->name().equalsCI(szName))return d;
	}

	return 0;
}
Esempio n. 5
0
void KviMainWindow::fillToolBarsPopup(QMenu * p)
{
	p->clear();

	disconnect(p, SIGNAL(triggered(QAction *)), this, SLOT(toolbarsPopupSelected(QAction *))); // just to be sure
	connect(p, SIGNAL(triggered(QAction *)), this, SLOT(toolbarsPopupSelected(QAction *)));

	QAction * pAction = nullptr;
	int cnt = 0;

	KviModuleExtensionDescriptorList * l = g_pModuleExtensionManager->getExtensionList("toolbar");
	if(l)
	{
		for(KviModuleExtensionDescriptor * d = l->first(); d; d = l->next())
		{
			QString label = __tr2qs("Show %1").arg(d->visibleName());
			if(d->icon())
				pAction = p->addAction(*(d->icon()), label);
			else
				pAction = p->addAction(label);
			pAction->setCheckable(true);
			pAction->setChecked(moduleExtensionToolBar(d->id()));
			pAction->setData(d->id());
			cnt++;
		}
	}

	// FIXME: Should this display "Hide %1" when the toolbar is already visible ?
	KviPointerHashTableIterator<QString, KviCustomToolBarDescriptor> it2(*(KviCustomToolBarManager::instance()->descriptors()));
	if(it2.current())
	{
		if(cnt > 0)
			p->addSeparator();

		while(KviCustomToolBarDescriptor * d = it2.current())
		{
			QString label = __tr2qs("Show %1").arg(d->label());
			QString ico = d->iconId();
			if(!ico.isEmpty())
			{
				QPixmap * pix = g_pIconManager->getImage(d->iconId());
				if(pix)
				{
					pAction = p->addAction(*pix, label);
				}
				else
				{
					pAction = p->addAction(label);
				}
			}
			else
			{
				pAction = p->addAction(label);
			}
			pAction->setData(d->internalId());
			pAction->setCheckable(true);
			pAction->setChecked(d->toolBar());
			++it2;
			cnt++;
		}
	}

	if(cnt > 0)
		p->addSeparator();

	p->addAction(
	    *(g_pIconManager->getSmallIcon(KviIconManager::ToolBarEditor)),
	    __tr2qs("Customize..."),
	    this,
	    SLOT(customizeToolBars()));
}