#include <PluginSelector.h>
Public Slots | |
| void | on_pluginList_itemChanged (QListWidgetItem *selItem) |
| void | on_searchPaths_clicked () |
Public Member Functions | |
| QString | file () const |
| PluginSelector (QWidget *parent=0, bool debug=false) | |
| ~PluginSelector () | |
Protected Member Functions | |
| bool | setLibList (QStringList libs) |
Protected Attributes | |
| bool | _debug |
| QStringList | _pluginFileList |
| bool | _wrongBuildKey |
Static Protected Attributes | |
| static const char * | _noticeContents |
| PluginSelector::PluginSelector | ( | QWidget * | parent = 0, |
| bool | debug = false |
||
| ) |
References _noticeContents, setLibList(), and TRACE.
: Dialog(parent), _debug(debug) { TRACE; setupUi(this); dinverNotice->setHtml(QApplication::translate( "PluginSelector", _noticeContents) ); QSettings reg; reg.beginGroup( "Plugins" ); reg.beginGroup(DINVER_VERSION_TYPE); if( !reg.contains( "pluginList" )) { setLibList(File::getLibList(DinverCoreObject::defaultPluginPaths()) ); } else { if( !setLibList(reg.value( "pluginList" ).toStringList()) ) { printf("Detected wrong dinvercore interface version reset to default\n"); setLibList(File::getLibList(DinverCoreObject::defaultPluginPaths()) ); } } QListWidgetItem * defItem=pluginList->item(reg.value( "defaultPlugin", 0).toInt()); if(defItem) defItem->setCheckState(Qt::Checked); }
References _pluginFileList, and TRACE.
{
TRACE;
QSettings reg;
reg.beginGroup( "Plugins" );
reg.beginGroup(DINVER_VERSION_TYPE);
reg.setValue( "pluginList", _pluginFileList);
}
| QString PluginSelector::file | ( | ) | const |
References _pluginFileList, and TRACE.
Referenced by DinverGui::pluginSelector().
{
TRACE;
int n=pluginList->count();
for(int i=0;i < n;i++ ) {
if(pluginList->item(i) ->checkState()==Qt::Checked) {
QSettings reg;
reg.beginGroup( "Plugins" );
reg.beginGroup(DINVER_VERSION_TYPE);
reg.setValue( "defaultPlugin", i);
return _pluginFileList.at(i);
}
}
return QString();
}
| void PluginSelector::on_pluginList_itemChanged | ( | QListWidgetItem * | selItem | ) | [slot] |
| void PluginSelector::on_searchPaths_clicked | ( | ) | [slot] |
References PluginPaths::getPaths(), setLibList(), and TRACE.
{
TRACE;
PluginPaths * d=new PluginPaths(this);
Settings::getWidget(d);
if(d->exec()==QDialog::Accepted) {
Settings::setWidget(d);
QStringList paths=d->getPaths();
delete d;
QApplication::processEvents();
pluginList->clear();
setLibList(File::getLibList(paths));
} else delete d;
}
| bool PluginSelector::setLibList | ( | QStringList | libs | ) | [protected] |
Return false if one plugin has not the correct interface version. This is use to detect upgrades. In case of upgrade, the stored list of plugins must be redefined.
References _debug, _pluginFileList, DinverCore::DinverInterface::description(), QGpCoreTools::endl(), DinverCore::DinverInterface::isValid(), DinverCore::DinverInterface::title(), QGpCoreTools::tr(), TRACE, and DinverCore::DinverInterface::version().
Referenced by on_searchPaths_clicked(), and PluginSelector().
{
TRACE;
_pluginFileList.clear();
pluginList->clear();
int n=libs.count();
searchProgress->setMaximum(n);
bool correctBuildKey=true;
for(int i=0;i < n;i++ ) {
QString libFile=libs.at(i);
DinverInterface * dinverInstance=DinverCoreObject::loadPlugin(libFile, _debug);
searchProgress->setValue(i + 1);
if(dinverInstance) {
if(dinverInstance->isValid()) {
QListWidgetItem * item=new QListWidgetItem(dinverInstance->title() + " - " + dinverInstance->version());
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setCheckState(Qt::Unchecked);
item->setToolTip(dinverInstance->description());
pluginList->addItem(item);
_pluginFileList.append(libFile);
} else {
App::stream() << tr("%1 has not a compatible plugin interface version.").arg(libFile) << endl;
correctBuildKey=false;
}
CoreApplication::instance()->deletePlugin(dinverInstance);
}
}
return correctBuildKey;
}
bool PluginSelector::_debug [protected] |
Referenced by setLibList().
const char * PluginSelector::_noticeContents [static, protected] |
QT_TRANSLATE_NOOP(
"PluginSelector", "<p>Dinver is a framework for inversion problems. The core engine is a "
"Neighbourhood Algorithm originally proposed by Sambridge (1999), implemented in C++ "
"and improved by <a href=\"http://www.geopsy.org/#References\">Wathelet(2008)</a>.</p>"
"<p>Each specific inversion problem can be coded with a simple API and packaged in a "
"dynamic library (plugin).</p>"
"<p>Using, Copying and Modifying this program is granted to everyone under the terms "
"of the GNU Public License version 2. <b>However, we would appreciate that you properly "
"reference this work, released for free, in all your publications or reports achieved "
"with this software.</b></p>" )
Referenced by PluginSelector().
QStringList PluginSelector::_pluginFileList [protected] |
Referenced by file(), setLibList(), and ~PluginSelector().
bool PluginSelector::_wrongBuildKey [protected] |