Skip to content

Commit 356dc61

Browse files

File tree

3 files changed

+81
-33
lines changed

3 files changed

+81
-33
lines changed
 

‎src/app/qgspluginmanager.cpp

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ QgsPluginManager::~QgsPluginManager()
7272
void QgsPluginManager::setTable()
7373
{
7474
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")));
8080

81-
lstPlugins->setModel(modelPlugins);
81+
lstPlugins->setModel(mModelPlugins);
8282
// No vertical headers
8383
lstPlugins->verticalHeader()->hide();
8484
lstPlugins->setSelectionBehavior(QAbstractItemView::SelectRows);
@@ -95,7 +95,7 @@ void QgsPluginManager::resizeColumnsToContents()
9595
void QgsPluginManager::sortModel(int column)
9696
{
9797
// Sort column ascending.
98-
modelPlugins->sort(column);
98+
mModelPlugins->sort(column);
9999
QgsDebugMsg("QgsPluginManager::sortModel\n");
100100
}
101101

@@ -157,7 +157,7 @@ void QgsPluginManager::getPythonPluginDescriptions()
157157
// Add items to model
158158
QList<QStandardItem *> myItems;
159159
myItems << myName << myVersion << myDesc << myDir;
160-
modelPlugins->appendRow(myItems);
160+
mModelPlugins->appendRow(myItems);
161161
}
162162
#endif
163163
}
@@ -299,7 +299,7 @@ sharedLibExtension = "*.so*";
299299
// Add items to model
300300
QList<QStandardItem *> myItems;
301301
myItems << myName << myVersion << myDesc << myDir;
302-
modelPlugins->appendRow(myItems);
302+
mModelPlugins->appendRow(myItems);
303303

304304
delete myLib;
305305
}
@@ -317,18 +317,18 @@ void QgsPluginManager::unload()
317317
#ifdef QGISDEBUG
318318
std::cout << "Checking for plugins to unload" << std::endl;
319319
#endif
320-
for (int row=0;row < modelPlugins->rowCount();row++)
320+
for (int row=0;row < mModelPlugins->rowCount();row++)
321321
{
322322
// 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)
325325
{
326326
// its off -- see if it is loaded and if so, unload it
327327
QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance();
328328
#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;
330330
#endif
331-
QString pluginName = modelPlugins->data(myIndex).toString();
331+
QString pluginName = mModelPlugins->data(myIndex).toString();
332332
if (pRegistry->isPythonPlugin(pluginName))
333333
{
334334
#ifdef HAVE_PYTHON
@@ -358,15 +358,14 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
358358
{
359359
std::vector < QgsPluginItem > pis;
360360
// 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++)
362362
{
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)
365364
{
366-
QString pluginName = modelPlugins->item(row,0)->text();
365+
QString pluginName = mModelPlugins->item(row,0)->text();
367366
bool pythonic = false;
368367

369-
QString library = modelPlugins->item(row,3)->text();
368+
QString library = mModelPlugins->item(row,3)->text();
370369
if (library.left(7) == "python:")
371370
{
372371
library = library.mid(7);
@@ -376,7 +375,7 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
376375
{
377376
library = txtPluginDir->text() + "/" + library;
378377
}
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));
380379
}
381380

382381
}
@@ -386,19 +385,19 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
386385
void QgsPluginManager::on_btnSelectAll_clicked()
387386
{
388387
// select all plugins
389-
for (int row=0;row < modelPlugins->rowCount();row++)
388+
for (int row=0;row < mModelPlugins->rowCount();row++)
390389
{
391-
QStandardItem *myItem=modelPlugins->item(row,0);
390+
QStandardItem *myItem=mModelPlugins->item(row,0);
392391
myItem->setCheckState(Qt::Checked);
393392
}
394393
}
395394

396395
void QgsPluginManager::on_btnClearAll_clicked()
397396
{
398397
// clear all selection checkboxes
399-
for (int row=0;row < modelPlugins->rowCount();row++)
398+
for (int row=0;row < mModelPlugins->rowCount();row++)
400399
{
401-
QStandardItem *myItem=modelPlugins->item(row,0);
400+
QStandardItem *myItem=mModelPlugins->item(row,0);
402401
myItem->setCheckState(Qt::Unchecked);
403402
}
404403
}
@@ -407,3 +406,17 @@ void QgsPluginManager::on_btnClose_clicked()
407406
{
408407
reject();
409408
}
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+
}

‎src/app/qgspluginmanager.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class QgsPluginManager : public QDialog, private Ui::QgsPluginManagerBase
5656
//! Sort model by column ascending
5757
void sortModel(int );
5858
public slots:
59+
//! Enable disable checkbox
60+
void on_lstPlugins_clicked(const QModelIndex & );
5961
//! Load selected plugins and close the dialog
6062
void on_btnOk_clicked();
6163
//! Select all plugins by setting their checkbox on
@@ -65,7 +67,7 @@ class QgsPluginManager : public QDialog, private Ui::QgsPluginManagerBase
6567
//! Close the dialog
6668
void on_btnClose_clicked();
6769
private:
68-
QStandardItemModel *modelPlugins;
70+
QStandardItemModel *mModelPlugins;
6971
};
7072

7173
#endif

‎src/ui/qgspluginmanagerbase.ui

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,41 @@
1919
<bool>true</bool>
2020
</property>
2121
<layout class="QGridLayout" >
22-
<property name="margin" >
22+
<property name="leftMargin" >
2323
<number>11</number>
2424
</property>
25-
<property name="spacing" >
25+
<property name="topMargin" >
26+
<number>11</number>
27+
</property>
28+
<property name="rightMargin" >
29+
<number>11</number>
30+
</property>
31+
<property name="bottomMargin" >
32+
<number>11</number>
33+
</property>
34+
<property name="horizontalSpacing" >
35+
<number>6</number>
36+
</property>
37+
<property name="verticalSpacing" >
2638
<number>6</number>
2739
</property>
2840
<item row="0" column="0" >
2941
<layout class="QHBoxLayout" >
30-
<property name="margin" >
31-
<number>11</number>
32-
</property>
3342
<property name="spacing" >
3443
<number>6</number>
3544
</property>
45+
<property name="leftMargin" >
46+
<number>11</number>
47+
</property>
48+
<property name="topMargin" >
49+
<number>11</number>
50+
</property>
51+
<property name="rightMargin" >
52+
<number>11</number>
53+
</property>
54+
<property name="bottomMargin" >
55+
<number>11</number>
56+
</property>
3657
<item>
3758
<widget class="QLabel" name="textLabel1" >
3859
<property name="text" >
@@ -64,12 +85,21 @@
6485
</item>
6586
<item row="4" column="0" >
6687
<layout class="QHBoxLayout" >
67-
<property name="margin" >
68-
<number>11</number>
69-
</property>
7088
<property name="spacing" >
7189
<number>6</number>
7290
</property>
91+
<property name="leftMargin" >
92+
<number>11</number>
93+
</property>
94+
<property name="topMargin" >
95+
<number>11</number>
96+
</property>
97+
<property name="rightMargin" >
98+
<number>11</number>
99+
</property>
100+
<property name="bottomMargin" >
101+
<number>11</number>
102+
</property>
73103
<item>
74104
<spacer>
75105
<property name="orientation" >
@@ -149,6 +179,9 @@
149179
<property name="alternatingRowColors" >
150180
<bool>true</bool>
151181
</property>
182+
<property name="selectionMode" >
183+
<enum>QAbstractItemView::NoSelection</enum>
184+
</property>
152185
<property name="sortingEnabled" >
153186
<bool>true</bool>
154187
</property>

0 commit comments

Comments
 (0)
Please sign in to comment.