1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
/*
* Class to manage register models.
* Copyright (C) 2013 Vlas Puhov <vlas.puhov@mail.ru>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef MODELSMANAGER_H
#define MODELSMANAGER_H
#include <QObject>
#include <QString>
#include <QVector>
#include <QScopedPointer>
#include <KConfigGroup>
#include "registercontroller.h"
class QAbstractItemView;
class QStandardItem;
class QModelIndex;
namespace KDevMI {
class Models;
class IRegisterController;
struct Register;
struct RegistersGroup;
class GroupsName;
class ModelsManager : public QObject
{
Q_OBJECT
public:
explicit ModelsManager(QObject* parent = nullptr);
~ModelsManager() override;
///Adds new @p view with @p name, if not yet registered.
///All views removed after debug session ended.
///@return: Name of the new view.
QString addView(QAbstractItemView* view);
void setController(IRegisterController* rc);
///Sets @p format for the @p group, if format is valid. Does nothing otherwise.
void setFormat(const QString& group, Format format);
///Returns all supported formats for @p group. The first one is current.
QVector<Format> formats(const QString& group) const;
///Sets @p mode for the @p group, if mode is valid. Does nothing otherwise.
void setMode(const QString& group, Mode mode);
///Returns all supported modes for @p group. The first one is current.
QVector<Mode> modes(const QString& group) const;
Q_SIGNALS:
///Emitted when a register in a model changed. Updated value should be send to the debugger.
void registerChanged(const Register&);
public Q_SLOTS:
void updateModelForGroup(const RegistersGroup& group);
///Forcedly updates registers in @p group.
void updateRegisters(const QString& group = QString());
private:
void save(const GroupsName&);
void load(const GroupsName&);
private Q_SLOTS:
void flagChanged(const QModelIndex&);
void itemChanged(QStandardItem*);
private:
QScopedPointer<Models> m_models;
IRegisterController* m_controller = nullptr;
KConfigGroup m_config;
};
} // end of namespace KDevMI
#endif // MODELSMANAGER_H
|