72 |
72 |
void QgsPluginManager::setTable()
|
73 |
73 |
{
|
74 |
74 |
lstPlugins->setAlternatingRowColors(true);
|
75 |
|
modelPlugins= new QStandardItemModel(0,4);
|
76 |
|
modelPlugins->setHorizontalHeaderItem(0,new QStandardItem(tr("Name")));
|
77 |
|
modelPlugins->setHorizontalHeaderItem(1,new QStandardItem(tr("Version")));
|
78 |
|
modelPlugins->setHorizontalHeaderItem(2,new QStandardItem(tr("Description")));
|
79 |
|
modelPlugins->setHorizontalHeaderItem(3,new QStandardItem(tr("Library name")));
|
|
75 |
mModelPlugins= new QStandardItemModel(0,4);
|
|
76 |
mModelPlugins->setHorizontalHeaderItem(0,new QStandardItem(tr("Name")));
|
|
77 |
mModelPlugins->setHorizontalHeaderItem(1,new QStandardItem(tr("Version")));
|
|
78 |
mModelPlugins->setHorizontalHeaderItem(2,new QStandardItem(tr("Description")));
|
|
79 |
mModelPlugins->setHorizontalHeaderItem(3,new QStandardItem(tr("Library name")));
|
80 |
80 |
|
81 |
|
lstPlugins->setModel(modelPlugins);
|
|
81 |
lstPlugins->setModel(mModelPlugins);
|
82 |
82 |
// No vertical headers
|
83 |
83 |
lstPlugins->verticalHeader()->hide();
|
84 |
84 |
lstPlugins->setSelectionBehavior(QAbstractItemView::SelectRows);
|
... | ... | |
95 |
95 |
void QgsPluginManager::sortModel(int column)
|
96 |
96 |
{
|
97 |
97 |
// Sort column ascending.
|
98 |
|
modelPlugins->sort(column);
|
|
98 |
mModelPlugins->sort(column);
|
99 |
99 |
QgsDebugMsg("QgsPluginManager::sortModel\n");
|
100 |
100 |
}
|
101 |
101 |
|
... | ... | |
157 |
157 |
// Add items to model
|
158 |
158 |
QList<QStandardItem *> myItems;
|
159 |
159 |
myItems << myName << myVersion << myDesc << myDir;
|
160 |
|
modelPlugins->appendRow(myItems);
|
|
160 |
mModelPlugins->appendRow(myItems);
|
161 |
161 |
}
|
162 |
162 |
#endif
|
163 |
163 |
}
|
... | ... | |
299 |
299 |
// Add items to model
|
300 |
300 |
QList<QStandardItem *> myItems;
|
301 |
301 |
myItems << myName << myVersion << myDesc << myDir;
|
302 |
|
modelPlugins->appendRow(myItems);
|
|
302 |
mModelPlugins->appendRow(myItems);
|
303 |
303 |
|
304 |
304 |
delete myLib;
|
305 |
305 |
}
|
... | ... | |
317 |
317 |
#ifdef QGISDEBUG
|
318 |
318 |
std::cout << "Checking for plugins to unload" << std::endl;
|
319 |
319 |
#endif
|
320 |
|
for (int row=0;row < modelPlugins->rowCount();row++)
|
|
320 |
for (int row=0;row < mModelPlugins->rowCount();row++)
|
321 |
321 |
{
|
322 |
322 |
// FPV - I want to use index. You can do evrething with item.
|
323 |
|
QModelIndex myIndex=modelPlugins->index(row,0);
|
324 |
|
if (modelPlugins->data(myIndex,Qt::CheckStateRole).toInt() == 0)
|
|
323 |
QModelIndex myIndex=mModelPlugins->index(row,0);
|
|
324 |
if (mModelPlugins->data(myIndex,Qt::CheckStateRole).toInt() == 0)
|
325 |
325 |
{
|
326 |
326 |
// its off -- see if it is loaded and if so, unload it
|
327 |
327 |
QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance();
|
328 |
328 |
#ifdef QGISDEBUG
|
329 |
|
std::cout << "Checking to see if " << modelPlugins->data(myIndex).toString().toLocal8Bit().data() << " is loaded" << std::endl;
|
|
329 |
std::cout << "Checking to see if " << mModelPlugins->data(myIndex).toString().toLocal8Bit().data() << " is loaded" << std::endl;
|
330 |
330 |
#endif
|
331 |
|
QString pluginName = modelPlugins->data(myIndex).toString();
|
|
331 |
QString pluginName = mModelPlugins->data(myIndex).toString();
|
332 |
332 |
if (pRegistry->isPythonPlugin(pluginName))
|
333 |
333 |
{
|
334 |
334 |
#ifdef HAVE_PYTHON
|
... | ... | |
358 |
358 |
{
|
359 |
359 |
std::vector < QgsPluginItem > pis;
|
360 |
360 |
// FPV - I want to use item here. You can do everything with index if you want.
|
361 |
|
for (int row=0;row < modelPlugins->rowCount();row++)
|
|
361 |
for (int row=0;row < mModelPlugins->rowCount();row++)
|
362 |
362 |
{
|
363 |
|
QStandardItem *myItem=modelPlugins->item(row,0);
|
364 |
|
if (modelPlugins->item(row,0)->checkState() == Qt::Checked)
|
|
363 |
if (mModelPlugins->item(row,0)->checkState() == Qt::Checked)
|
365 |
364 |
{
|
366 |
|
QString pluginName = modelPlugins->item(row,0)->text();
|
|
365 |
QString pluginName = mModelPlugins->item(row,0)->text();
|
367 |
366 |
bool pythonic = false;
|
368 |
367 |
|
369 |
|
QString library = modelPlugins->item(row,3)->text();
|
|
368 |
QString library = mModelPlugins->item(row,3)->text();
|
370 |
369 |
if (library.left(7) == "python:")
|
371 |
370 |
{
|
372 |
371 |
library = library.mid(7);
|
... | ... | |
376 |
375 |
{
|
377 |
376 |
library = txtPluginDir->text() + "/" + library;
|
378 |
377 |
}
|
379 |
|
pis.push_back(QgsPluginItem(pluginName, modelPlugins->item(row,2)->text(), library, 0, pythonic));
|
|
378 |
pis.push_back(QgsPluginItem(pluginName, mModelPlugins->item(row,2)->text(), library, 0, pythonic));
|
380 |
379 |
}
|
381 |
380 |
|
382 |
381 |
}
|
... | ... | |
386 |
385 |
void QgsPluginManager::on_btnSelectAll_clicked()
|
387 |
386 |
{
|
388 |
387 |
// select all plugins
|
389 |
|
for (int row=0;row < modelPlugins->rowCount();row++)
|
|
388 |
for (int row=0;row < mModelPlugins->rowCount();row++)
|
390 |
389 |
{
|
391 |
|
QStandardItem *myItem=modelPlugins->item(row,0);
|
|
390 |
QStandardItem *myItem=mModelPlugins->item(row,0);
|
392 |
391 |
myItem->setCheckState(Qt::Checked);
|
393 |
392 |
}
|
394 |
393 |
}
|
... | ... | |
396 |
395 |
void QgsPluginManager::on_btnClearAll_clicked()
|
397 |
396 |
{
|
398 |
397 |
// clear all selection checkboxes
|
399 |
|
for (int row=0;row < modelPlugins->rowCount();row++)
|
|
398 |
for (int row=0;row < mModelPlugins->rowCount();row++)
|
400 |
399 |
{
|
401 |
|
QStandardItem *myItem=modelPlugins->item(row,0);
|
|
400 |
QStandardItem *myItem=mModelPlugins->item(row,0);
|
402 |
401 |
myItem->setCheckState(Qt::Unchecked);
|
403 |
402 |
}
|
404 |
403 |
}
|
... | ... | |
407 |
406 |
{
|
408 |
407 |
reject();
|
409 |
408 |
}
|
|
409 |
|
|
410 |
void QgsPluginManager::on_lstPlugins_clicked(const QModelIndex &theIndex )
|
|
411 |
{
|
|
412 |
if (theIndex.column() == 0)
|
|
413 |
{
|
|
414 |
int row = theIndex.row();
|
|
415 |
if ( mModelPlugins->item(row,0)->checkState() == Qt::Checked )
|
|
416 |
{
|
|
417 |
mModelPlugins->item(row,0)->setCheckState(Qt::Unchecked);
|
|
418 |
} else {
|
|
419 |
mModelPlugins->item(row,0)->setCheckState(Qt::Checked);
|
|
420 |
}
|
|
421 |
}
|
|
422 |
}
|