5 #include "../../../../plugin/PluginInfo.h"
6 #include "../../../../plugin/PluginManager.h"
67 header = QObject::tr(
"Enabling");
71 header = QObject::tr(
"Plugin");
75 header = QObject::tr(
"Version");
79 header = QObject::tr(
"License");
83 header = QObject::tr(
"Category");
87 header = QObject::tr(
"Site");
91 header = QObject::tr(
"Provider");
95 header = QObject::tr(
"Provider site");
99 header = QObject::tr(
"Provider email");
103 header = QObject::tr(
"Name");
112 QAbstractTableModel(parent)
122 return (
int) m_plugins.size();
137 case Qt::TextAlignmentRole:
138 return int(Qt::AlignVCenter | Qt::AlignLeft);
141 case Qt::DisplayRole:
142 return (index.column() > 0) ?
143 QString(
GetData(index.column(), *(m_plugins[index.row()])).c_str()) :
150 PluginsStatus st = m_pluginsStatus[index.row()];
152 if(st.testFlag(To_add) || st.testFlag(To_enable) || st.testFlag(To_disable))
154 else if(st.testFlag(To_remove))
161 case Qt::CheckStateRole:
163 PluginsStatus st = m_pluginsStatus[index.row()];
165 if(!st.testFlag(Broked) && index.column() == 0)
166 return ((st.testFlag(Loaded) && !(st.testFlag(To_disable))) || st.testFlag(To_enable)) ? Qt::Checked : Qt::Unchecked;
182 case Qt::DisplayRole:
183 return (orientation == Qt::Horizontal) ?
185 QVariant::fromValue<int>(section+1);
189 return QAbstractTableModel::headerData(section, orientation, role);
195 if (!index.isValid())
198 Qt::ItemFlags flags(0);
200 if(!m_pluginsStatus[index.row()].testFlag(To_remove))
202 flags = flags | Qt::ItemIsEnabled;
204 if(index.column() == 0)
205 flags = flags | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
207 flags = flags | Qt::ItemIsSelectable;
218 if(role == Qt::CheckStateRole && !m_pluginsStatus[index.row()].testFlag(Broked))
220 if(value.toInt() == Qt::Checked)
222 m_pluginsStatus[index.row()] &= ~To_disable;
223 m_pluginsStatus[index.row()] |= To_enable;
227 m_pluginsStatus[index.row()] &= ~To_enable;
228 m_pluginsStatus[index.row()] |= To_disable;
233 emit dataChanged (idx, idx);
242 m_pluginsStatus.push_back(status);
249 QModelIndexList::ConstIterator it;
251 for(it=plgs.constBegin(); it!=plgs.constEnd(); ++it)
252 m_pluginsStatus[(*it).row()] = To_remove;
260 status = m_pluginsStatus;
265 std::vector<te::plugin::PluginInfo*>::iterator it;
267 for(it = m_plugins.begin(); it != m_plugins.end(); ++it)
271 m_pluginsStatus.clear();
The basic information about a plugin.
std::string m_site
The provider home page.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
void addPlugin(const te::plugin::PluginInfo *info, const PluginsStatus &status)
Adds information about plugin.
std::string m_name
Provider name: may be a person or a company.
void removePlugins(const QModelIndexList &plgs)
Remove the selected plugins.
QVariant headerData(int section, Qt::Orientation orientation, int role) const
Returns the data to be presented as header.
void getPluginsInfo(std::vector< te::plugin::PluginInfo * > &plgs, std::vector< PluginsStatus > &status)
Returns plugins informations.
std::string m_licenseDescription
A brief description about the plugin license.
QString GetHeader(const int §ion)
int rowCount(const QModelIndex &parent) const
Returns the number of plugins regitered in plugins manager.
PluginsModel(QObject *parent=0)
Constructor.
std::string m_site
An URL pointing to the plugin site.
std::string GetData(const int &column, const te::plugin::PluginInfo &info)
std::string m_version
The plugin version.
int columnCount(const QModelIndex &parent) const
Returns the number of columns.
virtual ~PluginsModel()
Destructor.
Provider m_provider
Information about the plugin provider.
void clear()
Clear the list of plugins and status.
std::string m_email
The provider contact e-mail.
std::string m_name
The plugin name: an internal value used to identify the plugin in the system. Must be a unique value...
std::string m_category
The plugin category.
QVariant data(const QModelIndex &index, int role) const
Returns data identified by index.
Qt::ItemFlags flags(const QModelIndex &index) const
Returns the flags associated with a given item.
std::string m_displayName
The plugin name to be displayed in a graphical interface.