ticket909patch.diff

Fernando Pacheco -, 2008-01-16 03:46 PM

Download (8.4 KB)

View differences:

src/app/qgspluginmanager.cpp (copia de trabajo)
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
}
src/app/qgspluginmanager.h (copia de trabajo)
56 56
    //! Sort model by column ascending
57 57
    void sortModel(int );
58 58
  public slots:
59
    //! Enable disable checkbox
60
    void on_lstPlugins_clicked(const QModelIndex & );
59 61
    //! Load selected plugins and close the dialog
60 62
    void on_btnOk_clicked();
61 63
    //! Select all plugins by setting their checkbox on
......
65 67
    //! Close the dialog
66 68
    void on_btnClose_clicked();
67 69
  private:
68
    QStandardItemModel *modelPlugins;
70
    QStandardItemModel *mModelPlugins;
69 71
};
70 72

  
71 73
#endif
src/ui/qgspluginmanagerbase.ui (copia de trabajo)
19 19
   <bool>true</bool>
20 20
  </property>
21 21
  <layout class="QGridLayout" >
22
   <property name="margin" >
22
   <property name="leftMargin" >
23 23
    <number>11</number>
24 24
   </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" >
26 35
    <number>6</number>
27 36
   </property>
37
   <property name="verticalSpacing" >
38
    <number>6</number>
39
   </property>
28 40
   <item row="0" column="0" >
29 41
    <layout class="QHBoxLayout" >
30
     <property name="margin" >
31
      <number>11</number>
32
     </property>
33 42
     <property name="spacing" >
34 43
      <number>6</number>
35 44
     </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>
36 57
     <item>
37 58
      <widget class="QLabel" name="textLabel1" >
38 59
       <property name="text" >
......
64 85
   </item>
65 86
   <item row="4" column="0" >
66 87
    <layout class="QHBoxLayout" >
67
     <property name="margin" >
68
      <number>11</number>
69
     </property>
70 88
     <property name="spacing" >
71 89
      <number>6</number>
72 90
     </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>
73 103
     <item>
74 104
      <spacer>
75 105
       <property name="orientation" >
......
149 179
     <property name="alternatingRowColors" >
150 180
      <bool>true</bool>
151 181
     </property>
182
     <property name="selectionMode" >
183
      <enum>QAbstractItemView::NoSelection</enum>
184
     </property>
152 185
     <property name="sortingEnabled" >
153 186
      <bool>true</bool>
154 187
     </property>