Skip to content

Commit

Permalink
Patch from Fernando for ticket #909
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7989 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Jan 17, 2008
1 parent e1056e7 commit 356dc61
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 33 deletions.
61 changes: 37 additions & 24 deletions src/app/qgspluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
}

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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));
}

}
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
}
4 changes: 3 additions & 1 deletion src/app/qgspluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -65,7 +67,7 @@ class QgsPluginManager : public QDialog, private Ui::QgsPluginManagerBase
//! Close the dialog
void on_btnClose_clicked();
private:
QStandardItemModel *modelPlugins;
QStandardItemModel *mModelPlugins;
};

#endif
49 changes: 41 additions & 8 deletions src/ui/qgspluginmanagerbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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" >
Expand Down Expand Up @@ -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" >
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 356dc61

Please sign in to comment.