Browse Source

small changes

cl-refactor
yann300 10 years ago
parent
commit
d9be32d631
  1. 3
      mix/AppContext.cpp
  2. 25
      mix/SortFilterProxyModel.cpp
  3. 0
      mix/SortFilterProxyModel.h

3
mix/AppContext.cpp

@ -22,7 +22,6 @@
* - KeyEventManager
*/
#include <QSortFilterProxyModel>
#include <QMessageBox>
#include <QClipboard>
#include <QQmlComponent>
@ -38,7 +37,7 @@
#include "QVariableDefinition.h"
#include "HttpServer.h"
#include "AppContext.h"
#include "Sortfilterproxymodel.h"
#include "SortFilterProxyModel.h"
using namespace dev;
using namespace dev::eth;

25
mix/Sortfilterproxymodel.cpp → mix/SortFilterProxyModel.cpp

@ -21,7 +21,7 @@
*/
#include "Sortfilterproxymodel.h"
#include "SortFilterProxyModel.h"
#include <QtDebug>
#include <QtQml>
@ -29,8 +29,8 @@ using namespace dev::mix;
SortFilterProxyModel::SortFilterProxyModel(QObject* _parent) : QSortFilterProxyModel(_parent)
{
connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged()));
connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged()));
connect(this, &SortFilterProxyModel::rowsInserted, this, &SortFilterProxyModel::countChanged);
connect(this, &SortFilterProxyModel::rowsRemoved, this, &SortFilterProxyModel::countChanged);
}
int SortFilterProxyModel::count() const
@ -45,7 +45,7 @@ QObject* SortFilterProxyModel::source() const
void SortFilterProxyModel::setSource(QObject* _source)
{
setSourceModel(qobject_cast<QAbstractItemModel *>(_source));
setSourceModel(qobject_cast<QAbstractItemModel*>(_source));
}
QByteArray SortFilterProxyModel::sortRole() const
@ -87,10 +87,12 @@ QJSValue SortFilterProxyModel::get(int _idx) const
{
QJSEngine *engine = qmlEngine(this);
QJSValue value = engine->newObject();
if (_idx >= 0 && _idx < count()) {
if (_idx >= 0 && _idx < count())
{
QHash<int, QByteArray> roles = roleNames();
QHashIterator<int, QByteArray> it(roles);
while (it.hasNext()) {
while (it.hasNext())
{
it.next();
value.setProperty(QString::fromUtf8(it.value()), data(index(_idx, 0), it.key()).toString());
}
@ -102,7 +104,8 @@ int SortFilterProxyModel::roleKey(QByteArray const& _role) const
{
QHash<int, QByteArray> roles = roleNames();
QHashIterator<int, QByteArray> it(roles);
while (it.hasNext()) {
while (it.hasNext())
{
it.next();
if (it.value() == _role)
return it.key();
@ -119,12 +122,10 @@ QHash<int, QByteArray> SortFilterProxyModel::roleNames() const
bool SortFilterProxyModel::filterAcceptsRow(int _sourceRow, QModelIndex const& _sourceParent) const
{
QRegExp rx = filterRegExp();
QAbstractItemModel *model = sourceModel();
QAbstractItemModel* model = sourceModel();
QModelIndex sourceIndex = model->index(_sourceRow, 0, _sourceParent);
if (!sourceIndex.isValid())
return true;
if (!sourceIndex.isValid())
return true;
QString keyType = model->data(sourceIndex, roleKey(type.toUtf8())).toString();
QString keyContent = model->data(sourceIndex, roleKey(content.toUtf8())).toString();

0
mix/Sortfilterproxymodel.h → mix/SortFilterProxyModel.h

Loading…
Cancel
Save