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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/***************************************************************************
* Copyright (C) 2005 Nicolas Hadacek <hadacek@kde.org> *
* *
* 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 DEVICE_GUI_H
#define DEVICE_GUI_H
#include <tqpushbutton.h>
#include <tqlayout.h>
#include <tqcombobox.h>
class TQListViewItem;
class TQCheckBox;
#include <ktextbrowser.h>
class KListView;
#include "common/gui/key_gui.h"
#include "common/gui/dialog.h"
#include "device_editor.h"
#include "devices/pic/base/pic.h"
namespace Programmer { class Group; }
namespace Tool { class Group; }
namespace DeviceChooser
{
enum Type { Choose, ChooseWithAuto };
class View;
BEGIN_DECLARE_ENUM(ListType)
FamilyTree = 0, Flat
END_DECLARE_ENUM_STD(ListType)
//-----------------------------------------------------------------------------
class Config : public GenericConfig
{
public:
Config() : GenericConfig("device_chooser") {}
const Programmer::Group *programmerGroup();
void writeProgrammerGroup(const Programmer::Group *group);
const Tool::Group *toolGroup();
void writeToolGroup(const Tool::Group *group);
};
//-----------------------------------------------------------------------------
template <typename Enum>
class EnumComboBox
{
public:
EnumComboBox(const TQString &key, TQWidget *tqparent) : _key(key) {
_combo = new TQComboBox(tqparent);
for (Enum type; type<Enum::Nb_Types; ++type) _combo->insertItem(type.label());
Config config;
Enum type = config.readEnumEntry(key, Enum(Enum::Nb_Types));
if ( type!=Enum::Nb_Types ) _combo->setCurrentItem(type.type());
}
EnumComboBox(const TQString &emptyLabel, const TQString &key, TQWidget *tqparent) : _key(key) {
_combo = new TQComboBox(tqparent);
_combo->insertItem(emptyLabel);
for (Enum type; type<Enum::Nb_Types; ++type) _combo->insertItem(type.label());
Config config;
Enum type = config.readEnumEntry(key, Enum(Enum::Nb_Types));
if ( type!=Enum::Nb_Types ) _combo->setCurrentItem(type.type()+1);
}
TQComboBox *combo() { return _combo; }
Enum value() const {
if ( _combo->count()==Enum::Nb_Types ) return typename Enum::Type(_combo->currentItem());
if ( _combo->currentItem()==0 ) return Enum::Nb_Types;
return typename Enum::Type(_combo->currentItem()-1);
}
void reset() { _combo->setCurrentItem(0); }
void writeConfig() {
Config config;
config.writeEnumEntry(_key, value());
}
private:
TQString _key;
TQComboBox *_combo;
};
//-----------------------------------------------------------------------------
class Dialog : public ::Dialog
{
Q_OBJECT
TQ_OBJECT
public:
Dialog(const TQString &device, Type type, TQWidget *tqparent);
virtual ~Dialog();
TQString device() const;
private slots:
void listDoubleClicked(TQListViewItem *item);
void currentChanged(TQListViewItem *item);
void deviceChange(const TQString &device);
void updateList();
void resetFilters();
private:
bool _withAuto;
KeyComboBox<TQString> *_programmerCombo, *_toolCombo;
EnumComboBox<ListType> *_listTypeCombo;
EnumComboBox<Device::MemoryTechnology> *_memoryCombo;
EnumComboBox<Device::tqStatus> *_statusCombo;
EnumComboBox<Pic::Feature> *_featureCombo;
KListView *_listView;
View *_deviceView;
void updateList(const TQString &device);
const Programmer::Group *programmerGroup() const;
const Tool::Group *toolGroup() const;
};
//-----------------------------------------------------------------------------
class ComboBox : public TQComboBox
{
Q_OBJECT
TQ_OBJECT
public:
ComboBox(bool withAuto, TQWidget *tqparent);
void setDevice(const TQString &device, const Device::Data *data = 0);
TQString device() const;
bool withAuto() const { return _withAuto; }
private:
bool _withAuto;
};
//-----------------------------------------------------------------------------
class Button : public TQWidget
{
Q_OBJECT
TQ_OBJECT
public:
Button(bool withAuto, TQWidget *tqparent);
void setDevice(const TQString &device) { _combo->setDevice(device); }
TQString device() const { return _combo->device(); }
signals:
void changed();
private slots:
void chooseDevice();
private:
ComboBox *_combo;
};
//-----------------------------------------------------------------------------
class Browser : public KTextBrowser
{
Q_OBJECT
TQ_OBJECT
public:
Browser(TQWidget *tqparent);
signals:
void deviceChanged(const TQString &device);
public slots:
virtual void setSource(const TQString &name);
};
//-----------------------------------------------------------------------------
class View : public TabWidget
{
Q_OBJECT
TQ_OBJECT
public:
View(TQWidget *tqparent);
void clear();
void setText(const TQString &text);
void setDevice(const TQString &name, bool cannotChangeDevice);
signals:
void deviceChanged(const TQString &device);
private:
TQMimeSourceFactory _msf;
Browser *_info, *_memory, *_vfg, *_pins;
};
//-----------------------------------------------------------------------------
class Editor : public DeviceEditor
{
Q_OBJECT
TQ_OBJECT
public:
Editor(const TQString &title, const TQString &tag, TQWidget *tqparent);
virtual bool isModified() const { return false; }
virtual bool isReadOnly() const { return true; }
virtual void addGui() {}
virtual void removeGui() {}
virtual void setFocus() {}
signals:
void deviceChanged(const TQString &device);
private:
virtual TQWidget *createView(const Device::Data *data, TQWidget *tqparent);
virtual void setModifiedInternal(bool) {}
virtual void setReadOnlyInternal(bool) {}
};
} // namespace
#endif
|