Skip to content
Permalink
Browse files
Patch from Fernando for ticket #909
git-svn-id: http://svn.osgeo.org/qgis/trunk@7989 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jan 17, 2008
1 parent 16b1069 commit d9960cf05d05c9b33dae0103ff9392b60361088f
Showing with 81 additions and 33 deletions.
  1. +37 −24 src/app/qgspluginmanager.cpp
  2. +3 −1 src/app/qgspluginmanager.h
  3. +41 −8 src/ui/qgspluginmanagerbase.ui
@@ -72,13 +72,13 @@ QgsPluginManager::~QgsPluginManager()
void QgsPluginManager::setTable()
{
lstPlugins->setAlternatingRowColors(true);
modelPlugins= new QStandardItemModel(0,4);
modelPlugins->setHorizontalHeaderItem(0,new QStandardItem(tr("Name")));
modelPlugins->setHorizontalHeaderItem(1,new QStandardItem(tr("Version")));
modelPlugins->setHorizontalHeaderItem(2,new QStandardItem(tr("Description")));
modelPlugins->setHorizontalHeaderItem(3,new QStandardItem(tr("Library name")));
mModelPlugins= new QStandardItemModel(0,4);
mModelPlugins->setHorizontalHeaderItem(0,new QStandardItem(tr("Name")));
mModelPlugins->setHorizontalHeaderItem(1,new QStandardItem(tr("Version")));
mModelPlugins->setHorizontalHeaderItem(2,new QStandardItem(tr("Description")));
mModelPlugins->setHorizontalHeaderItem(3,new QStandardItem(tr("Library name")));

lstPlugins->setModel(modelPlugins);
lstPlugins->setModel(mModelPlugins);
// No vertical headers
lstPlugins->verticalHeader()->hide();
lstPlugins->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -95,7 +95,7 @@ void QgsPluginManager::resizeColumnsToContents()
void QgsPluginManager::sortModel(int column)
{
// Sort column ascending.
modelPlugins->sort(column);
mModelPlugins->sort(column);
QgsDebugMsg("QgsPluginManager::sortModel\n");
}

@@ -157,7 +157,7 @@ void QgsPluginManager::getPythonPluginDescriptions()
// Add items to model
QList<QStandardItem *> myItems;
myItems << myName << myVersion << myDesc << myDir;
modelPlugins->appendRow(myItems);
mModelPlugins->appendRow(myItems);
}
#endif
}
@@ -299,7 +299,7 @@ sharedLibExtension = "*.so*";
// Add items to model
QList<QStandardItem *> myItems;
myItems << myName << myVersion << myDesc << myDir;
modelPlugins->appendRow(myItems);
mModelPlugins->appendRow(myItems);

delete myLib;
}
@@ -317,18 +317,18 @@ void QgsPluginManager::unload()
#ifdef QGISDEBUG
std::cout << "Checking for plugins to unload" << std::endl;
#endif
for (int row=0;row < modelPlugins->rowCount();row++)
for (int row=0;row < mModelPlugins->rowCount();row++)
{
// FPV - I want to use index. You can do evrething with item.
QModelIndex myIndex=modelPlugins->index(row,0);
if (modelPlugins->data(myIndex,Qt::CheckStateRole).toInt() == 0)
QModelIndex myIndex=mModelPlugins->index(row,0);
if (mModelPlugins->data(myIndex,Qt::CheckStateRole).toInt() == 0)
{
// its off -- see if it is loaded and if so, unload it
QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance();
#ifdef QGISDEBUG
std::cout << "Checking to see if " << modelPlugins->data(myIndex).toString().toLocal8Bit().data() << " is loaded" << std::endl;
std::cout << "Checking to see if " << mModelPlugins->data(myIndex).toString().toLocal8Bit().data() << " is loaded" << std::endl;
#endif
QString pluginName = modelPlugins->data(myIndex).toString();
QString pluginName = mModelPlugins->data(myIndex).toString();
if (pRegistry->isPythonPlugin(pluginName))
{
#ifdef HAVE_PYTHON
@@ -358,15 +358,14 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
{
std::vector < QgsPluginItem > pis;
// FPV - I want to use item here. You can do everything with index if you want.
for (int row=0;row < modelPlugins->rowCount();row++)
for (int row=0;row < mModelPlugins->rowCount();row++)
{
QStandardItem *myItem=modelPlugins->item(row,0);
if (modelPlugins->item(row,0)->checkState() == Qt::Checked)
if (mModelPlugins->item(row,0)->checkState() == Qt::Checked)
{
QString pluginName = modelPlugins->item(row,0)->text();
QString pluginName = mModelPlugins->item(row,0)->text();
bool pythonic = false;

QString library = modelPlugins->item(row,3)->text();
QString library = mModelPlugins->item(row,3)->text();
if (library.left(7) == "python:")
{
library = library.mid(7);
@@ -376,7 +375,7 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
{
library = txtPluginDir->text() + "/" + library;
}
pis.push_back(QgsPluginItem(pluginName, modelPlugins->item(row,2)->text(), library, 0, pythonic));
pis.push_back(QgsPluginItem(pluginName, mModelPlugins->item(row,2)->text(), library, 0, pythonic));
}

}
@@ -386,19 +385,19 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
void QgsPluginManager::on_btnSelectAll_clicked()
{
// select all plugins
for (int row=0;row < modelPlugins->rowCount();row++)
for (int row=0;row < mModelPlugins->rowCount();row++)
{
QStandardItem *myItem=modelPlugins->item(row,0);
QStandardItem *myItem=mModelPlugins->item(row,0);
myItem->setCheckState(Qt::Checked);
}
}

void QgsPluginManager::on_btnClearAll_clicked()
{
// clear all selection checkboxes
for (int row=0;row < modelPlugins->rowCount();row++)
for (int row=0;row < mModelPlugins->rowCount();row++)
{
QStandardItem *myItem=modelPlugins->item(row,0);
QStandardItem *myItem=mModelPlugins->item(row,0);
myItem->setCheckState(Qt::Unchecked);
}
}
@@ -407,3 +406,17 @@ void QgsPluginManager::on_btnClose_clicked()
{
reject();
}

void QgsPluginManager::on_lstPlugins_clicked(const QModelIndex &theIndex )
{
if (theIndex.column() == 0)
{
int row = theIndex.row();
if ( mModelPlugins->item(row,0)->checkState() == Qt::Checked )
{
mModelPlugins->item(row,0)->setCheckState(Qt::Unchecked);
} else {
mModelPlugins->item(row,0)->setCheckState(Qt::Checked);
}
}
}
@@ -56,6 +56,8 @@ class QgsPluginManager : public QDialog, private Ui::QgsPluginManagerBase
//! Sort model by column ascending
void sortModel(int );
public slots:
//! Enable disable checkbox
void on_lstPlugins_clicked(const QModelIndex & );
//! Load selected plugins and close the dialog
void on_btnOk_clicked();
//! Select all plugins by setting their checkbox on
@@ -65,7 +67,7 @@ class QgsPluginManager : public QDialog, private Ui::QgsPluginManagerBase
//! Close the dialog
void on_btnClose_clicked();
private:
QStandardItemModel *modelPlugins;
QStandardItemModel *mModelPlugins;
};

#endif
@@ -19,20 +19,41 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<property name="leftMargin" >
<number>11</number>
</property>
<property name="spacing" >
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<number>11</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<number>11</number>
</property>
<item>
<widget class="QLabel" name="textLabel1" >
<property name="text" >
@@ -64,12 +85,21 @@
</item>
<item row="4" column="0" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>11</number>
</property>
<property name="topMargin" >
<number>11</number>
</property>
<property name="rightMargin" >
<number>11</number>
</property>
<property name="bottomMargin" >
<number>11</number>
</property>
<item>
<spacer>
<property name="orientation" >
@@ -149,6 +179,9 @@
<property name="alternatingRowColors" >
<bool>true</bool>
</property>
<property name="selectionMode" >
<enum>QAbstractItemView::NoSelection</enum>
</property>
<property name="sortingEnabled" >
<bool>true</bool>
</property>

0 comments on commit d9960cf

Please sign in to comment.