summaryrefslogtreecommitdiffstats
path: root/src/progs/gui/hardware_config_widget.h
blob: d6a943fd1144a6864f84a3eb3de98c3fb5319b93 (plain)
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
101
102
103
104
105
/***************************************************************************
 *   Copyright (C) 2005-2007 Nicolas Hadacek <hadacek@kde.org>             *
 *   Copyright (C) 2003-2004 Alain Gibaud <alain.gibaud@free.fr>           *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
#ifndef HARDWARE_CONFIG_WIDGET
#define HARDWARE_CONFIG_WIDGET

#include <tqlineedit.h>
#include <tqcombobox.h>
#include <kdialogbase.h>
#include <ktextbrowser.h>

#include "progs/base/hardware_config.h"
#include "progs/gui/prog_config_widget.h"
#include "progs/base/generic_prog.h"
#include "progs/base/prog_specific.h"

namespace Hardware
{

//-----------------------------------------------------------------------------
class HConfigWidget : public TQFrame
{
Q_OBJECT
  TQ_OBJECT
public:
  HConfigWidget(::Programmer::Base &base, TQWidget *parent, bool edit);
  virtual ~HConfigWidget() { delete _hardware; }
  virtual bool set(const Port::Description &pd, const Data &data) = 0;
  virtual Data *data() const = 0;
  Port::Description portDescription() const { return _hardware->portDescription(); }

protected:
  ::Programmer::Hardware *_hardware;
  TQVBoxLayout *_mainVBox, *_editVBox;
  bool _edit, _connected;
  ::Programmer::Base &_base;
};

//-----------------------------------------------------------------------------
class ConfigWidget;

class EditDialog : public KDialogBase
{
Q_OBJECT
  TQ_OBJECT
public:
  EditDialog(ConfigWidget *parent, const TQString &name, const Port::Description &pd, Data *data);
  TQString savedName() const { return _savedName; }

private slots:
  virtual void slotOk();
  virtual void slotCancel();

private:
  ConfigWidget  *_cwidget;
  TQString        _savedName;
  Data          *_oldData;
  HConfigWidget *_hc;
  TQLineEdit     *_name;
};

//-----------------------------------------------------------------------------
class ConfigWidget : public ::Programmer::ConfigWidget
{
Q_OBJECT
  TQ_OBJECT
public:
  ConfigWidget(::Programmer::Base *base, Config *config, TQWidget *parent);
  virtual ~ConfigWidget() { delete _base; }
  virtual void saveConfig();
  virtual bool setPort(const ::Programmer::HardwareDescription &hd);
  virtual HConfigWidget *createHardwareConfigWidget(TQWidget *parent, bool edit) const = 0;

private slots:
  void editClicked();
  void deleteClicked();
  void configChanged(int i);

protected:
  ::Programmer::Base *_base;

private:
  Config        *_config;
  TQStringList    _names;
  HConfigWidget *_hc;
  TQPushButton   *_editButton, *_deleteButton;
  TQComboBox     *_configCombo;
  KTextBrowser  *_comment;
  TQHBoxLayout   *_hbox;

  void updateList(PortType type);
  bool set(const Port::Description &pd, uint i);

  friend class EditDialog;
};

} // namespace

#endif