Browse Source

small changes

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

3
mix/AppContext.cpp

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

17
mix/Sortfilterproxymodel.cpp → mix/SortFilterProxyModel.cpp

@ -21,7 +21,7 @@
*/ */
#include "Sortfilterproxymodel.h" #include "SortFilterProxyModel.h"
#include <QtDebug> #include <QtDebug>
#include <QtQml> #include <QtQml>
@ -29,8 +29,8 @@ using namespace dev::mix;
SortFilterProxyModel::SortFilterProxyModel(QObject* _parent) : QSortFilterProxyModel(_parent) SortFilterProxyModel::SortFilterProxyModel(QObject* _parent) : QSortFilterProxyModel(_parent)
{ {
connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); connect(this, &SortFilterProxyModel::rowsInserted, this, &SortFilterProxyModel::countChanged);
connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); connect(this, &SortFilterProxyModel::rowsRemoved, this, &SortFilterProxyModel::countChanged);
} }
int SortFilterProxyModel::count() const int SortFilterProxyModel::count() const
@ -87,10 +87,12 @@ QJSValue SortFilterProxyModel::get(int _idx) const
{ {
QJSEngine *engine = qmlEngine(this); QJSEngine *engine = qmlEngine(this);
QJSValue value = engine->newObject(); QJSValue value = engine->newObject();
if (_idx >= 0 && _idx < count()) { if (_idx >= 0 && _idx < count())
{
QHash<int, QByteArray> roles = roleNames(); QHash<int, QByteArray> roles = roleNames();
QHashIterator<int, QByteArray> it(roles); QHashIterator<int, QByteArray> it(roles);
while (it.hasNext()) { while (it.hasNext())
{
it.next(); it.next();
value.setProperty(QString::fromUtf8(it.value()), data(index(_idx, 0), it.key()).toString()); 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(); QHash<int, QByteArray> roles = roleNames();
QHashIterator<int, QByteArray> it(roles); QHashIterator<int, QByteArray> it(roles);
while (it.hasNext()) { while (it.hasNext())
{
it.next(); it.next();
if (it.value() == _role) if (it.value() == _role)
return it.key(); return it.key();
@ -119,8 +122,6 @@ QHash<int, QByteArray> SortFilterProxyModel::roleNames() const
bool SortFilterProxyModel::filterAcceptsRow(int _sourceRow, QModelIndex const& _sourceParent) 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); QModelIndex sourceIndex = model->index(_sourceRow, 0, _sourceParent);
if (!sourceIndex.isValid()) if (!sourceIndex.isValid())

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

Loading…
Cancel
Save