Index: src/app/qgisapp.cpp =================================================================== --- src/app/qgisapp.cpp (revisión: 7854) +++ src/app/qgisapp.cpp (copia de trabajo) @@ -3662,6 +3662,7 @@ void QgisApp::showPluginManager() { QgsPluginManager *pm = new QgsPluginManager(this); + pm->resizeColumnsToContents(); if (pm->exec()) { // load selected plugins Index: src/app/qgspluginmanager.cpp =================================================================== --- src/app/qgspluginmanager.cpp (revisión: 7854) +++ src/app/qgspluginmanager.cpp (copia de trabajo) @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -60,6 +59,7 @@ QString libDir = baseDir + "/lib"; */ txtPluginDir->setText(pr->libraryDirectory().path()); + setTable(); getPluginDescriptions(); getPythonPluginDescriptions(); } @@ -69,7 +69,33 @@ { } +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"))); + lstPlugins->setModel(modelPlugins); + // No vertical headers + lstPlugins->verticalHeader()->hide(); +} +void QgsPluginManager::resizeColumnsToContents() +{ + // Resize columns to contents. + lstPlugins->resizeColumnsToContents(); + QgsDebugMsg("QgsPluginManager::resizeColumnsToContents\n"); +} + +void QgsPluginManager::sortModel(int column) +{ + // Sort column ascending. + modelPlugins->sort(column); + QgsDebugMsg("QgsPluginManager::sortModel\n"); +} + void QgsPluginManager::getPythonPluginDescriptions() { #ifdef HAVE_PYTHON @@ -94,16 +120,23 @@ if (pluginName == "???" || description == "???" || version == "???") continue; - - // add to the list box - Q3CheckListItem *pl = new Q3CheckListItem(lstPlugins, pluginName, Q3CheckListItem::CheckBox); - pl->setText(1, version); - pl->setText(2, description); - pl->setText(3, "python:" + packageName); - + + //create the items + QStandardItem *myName=new QStandardItem(pluginName); + QStandardItem *myVersion=new QStandardItem(version); + QStandardItem *myDesc=new QStandardItem(description); + QStandardItem *myDir=new QStandardItem("python:" + packageName); + // myName have a checkbox + myName->setCheckable(true); + //read only + myName->setEditable(false); + myVersion->setEditable(false); + myDesc->setEditable(false); + myDir->setEditable(false); + // check to see if the plugin is loaded and set the checkbox accordingly QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance(); - + QString libName = pRegistry->library(pluginName); if (libName.length() == 0 || !pRegistry->isPythonPlugin(pluginName)) { @@ -115,9 +148,13 @@ if (libName == packageName) { // set the checkbox - pl->setOn(true); + myName->setCheckState(Qt::Checked); } } + // Add items to model + QList myItems; + myItems << myName << myVersion << myDesc << myDir; + modelPlugins->appendRow(myItems); } #endif } @@ -223,10 +260,18 @@ continue; } - Q3CheckListItem *pl = new Q3CheckListItem(lstPlugins, pName(), Q3CheckListItem::CheckBox); //, pDesc(), pluginDir[i]) - pl->setText(1, pVersion()); - pl->setText(2, pDesc()); - pl->setText(3, pluginDir[i]); + //create the items + QStandardItem *myName=new QStandardItem(pName()); + QStandardItem *myVersion=new QStandardItem(pVersion()); + QStandardItem *myDesc=new QStandardItem(pDesc()); + QStandardItem *myDir=new QStandardItem(pluginDir[i]); + // myName have a checkbox + myName->setCheckable(true); + //read only + myName->setEditable(false); + myVersion->setEditable(false); + myDesc->setEditable(false); + myDir->setEditable(false); QgsDebugMsg("Getting an instance of the QgsPluginRegistry"); @@ -245,15 +290,18 @@ if (libName == myLib->library()) { // set the checkbox - pl->setOn(true); + myName->setCheckState(Qt::Checked); } } + // Add items to model + QList myItems; + myItems << myName << myVersion << myDesc << myDir; + modelPlugins->appendRow(myItems); delete myLib; } } - void QgsPluginManager::on_btnOk_clicked() { unload(); @@ -266,59 +314,56 @@ #ifdef QGISDEBUG std::cout << "Checking for plugins to unload" << std::endl; #endif - Q3CheckListItem *lvi = (Q3CheckListItem *) lstPlugins->firstChild(); - while (lvi != 0) + for (int row=0;row < modelPlugins->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) { - if (!lvi->isOn()) - { - // its off -- see if it is loaded and if so, unload it - QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance(); + // its off -- see if it is loaded and if so, unload it + QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance(); #ifdef QGISDEBUG - std::cout << "Checking to see if " << lvi->text(0).toLocal8Bit().data() << " is loaded" << std::endl; + std::cout << "Checking to see if " << modelPlugins->data(myIndex).toString().toLocal8Bit().data() << " is loaded" << std::endl; #endif - - QString pluginName = lvi->text(0); - - if (pRegistry->isPythonPlugin(pluginName)) - { + QString pluginName = modelPlugins->data(myIndex).toString(); + if (pRegistry->isPythonPlugin(pluginName)) + { #ifdef HAVE_PYTHON - QString packageName = pRegistry->library(pluginName); - QgsPythonUtils::unloadPlugin(packageName); - - //disable it to the qsettings file - settings.writeEntry("/PythonPlugins/" + packageName, false); + QString packageName = pRegistry->library(pluginName); + QgsPythonUtils::unloadPlugin(packageName); + //disable it to the qsettings file + settings.setValue("/PythonPlugins/" + packageName, false); #endif - } - else // C++ plugin - { - QgisPlugin *plugin = pRegistry->plugin(pluginName); - if (plugin) - { - plugin->unload(); - } - //disable it to the qsettings file [ts] - settings.writeEntry("/Plugins/" + pluginName, false); - } - - // remove the plugin from the registry - pRegistry->removePlugin(pluginName); + } + else // C++ plugin + { + QgisPlugin *plugin = pRegistry->plugin(pluginName); + if (plugin) + { + plugin->unload(); } - lvi = (Q3CheckListItem *) lvi->nextSibling(); + //disable it to the qsettings file [ts] + settings.setValue("/Plugins/" + pluginName, false); + } + // remove the plugin from the registry + pRegistry->removePlugin(pluginName); } + } } std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins() { std::vector < QgsPluginItem > pis; - Q3CheckListItem *lvi = (Q3CheckListItem *) lstPlugins->firstChild(); - while (lvi != 0) + // FPV - I want to use item here. You can do everything with index if you want. + for (int row=0;row < modelPlugins->rowCount();row++) { - if (lvi->isOn()) + QStandardItem *myItem=modelPlugins->item(row,0); + if (modelPlugins->item(row,0)->checkState() == Qt::Checked) { - QString pluginName = lvi->text(0); + QString pluginName = modelPlugins->item(row,0)->text(); bool pythonic = false; - - QString library = lvi->text(3); + + QString library = modelPlugins->item(row,3)->text(); if (library.left(7) == "python:") { library = library.mid(7); @@ -328,10 +373,9 @@ { library = txtPluginDir->text() + "/" + library; } - - pis.push_back(QgsPluginItem(pluginName, lvi->text(2), library, 0, pythonic)); + pis.push_back(QgsPluginItem(pluginName, modelPlugins->item(row,2)->text(), library, 0, pythonic)); } - lvi = (Q3CheckListItem *) lvi->nextSibling(); + } return pis; } @@ -339,23 +383,20 @@ void QgsPluginManager::on_btnSelectAll_clicked() { // select all plugins - Q3CheckListItem *child = dynamic_cast(lstPlugins->firstChild()); - while(child) + for (int row=0;row < modelPlugins->rowCount();row++) { - child->setOn(true); - child = dynamic_cast(child->nextSibling()); + QStandardItem *myItem=modelPlugins->item(row,0); + myItem->setCheckState(Qt::Checked); } - } void QgsPluginManager::on_btnClearAll_clicked() { - // clear all selection checkboxes - Q3CheckListItem *child = dynamic_cast(lstPlugins->firstChild()); - while(child) + // clear all selection checkboxes + for (int row=0;row < modelPlugins->rowCount();row++) { - child->setOn(false); - child = dynamic_cast(child->nextSibling()); + QStandardItem *myItem=modelPlugins->item(row,0); + myItem->setCheckState(Qt::Unchecked); } } Index: src/app/qgspluginmanager.h =================================================================== --- src/app/qgspluginmanager.h (revisión: 7854) +++ src/app/qgspluginmanager.h (copia de trabajo) @@ -19,10 +19,16 @@ #ifndef QGSPLUGINMANAGER_H #define QGSPLUGINMANAGER_H #include +#include +#include +#include +#include #include "ui_qgspluginmanagerbase.h" #include "qgisgui.h" class QgsPluginItem; +class QTableView; + /*! * \brief Plugin manager for loading/unloading plugins @author Gary Sherman @@ -43,7 +49,13 @@ void unload(); //! Gets the selected plugins std::vector getSelectedPlugins(); - public slots: + //! Set lstPlugins table GUI + void setTable(); + //! Resize columns to contents + void resizeColumnsToContents(); + //! Sort model by column ascending + void sortModel(int ); + public slots: //! Load selected plugins and close the dialog void on_btnOk_clicked(); //! Select all plugins by setting their checkbox on @@ -52,7 +64,8 @@ void on_btnClearAll_clicked(); //! Close the dialog void on_btnClose_clicked(); - + private: + QStandardItemModel *modelPlugins; }; #endif Index: src/ui/qgspluginmanagerbase.ui =================================================================== --- src/ui/qgspluginmanagerbase.ui (revisión: 7854) +++ src/ui/qgspluginmanagerbase.ui (copia de trabajo) @@ -16,20 +16,41 @@ true - + 11 - + + 11 + + + 11 + + + 11 + + 6 + + 6 + - - 11 - 6 + + 11 + + + 11 + + + 11 + + + 11 + @@ -52,41 +73,6 @@ - - - - - Arial - 10 - 50 - false - false - false - false - - - - - Name - - - - - Version - - - - - Description - - - - - Library Name - - - - @@ -94,14 +80,23 @@ - + - - 11 - 6 + + 11 + + + 11 + + + 11 + + + 11 + @@ -176,17 +171,20 @@ + + + + true + + + true + + + qPixmapFromMimeSource - - - Q3ListView - Q3Frame -
q3listview.h
-
-