diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-30 00:15:53 +0000 |
commit | 0aaa8e3fc8f8a1481333b564f0922277c8d8ad59 (patch) | |
tree | b95c0ca86c4876dd139af376b9f4afd8917cf0cd /src/libgui/device_gui.cpp | |
parent | b79a2c28534cf09987eeeba3077fff9236df182a (diff) | |
download | piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.tar.gz piklab-0aaa8e3fc8f8a1481333b564f0922277c8d8ad59.zip |
TQt4 port piklab
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1238822 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/libgui/device_gui.cpp')
-rw-r--r-- | src/libgui/device_gui.cpp | 202 |
1 files changed, 101 insertions, 101 deletions
diff --git a/src/libgui/device_gui.cpp b/src/libgui/device_gui.cpp index 8183725..dc781a9 100644 --- a/src/libgui/device_gui.cpp +++ b/src/libgui/device_gui.cpp @@ -8,12 +8,12 @@ ***************************************************************************/ #include "device_gui.h" -#include <qlayout.h> -#include <qpainter.h> -#include <qcombobox.h> -#include <qlabel.h> -#include <qcheckbox.h> -#include <qsplitter.h> +#include <tqlayout.h> +#include <tqpainter.h> +#include <tqcombobox.h> +#include <tqlabel.h> +#include <tqcheckbox.h> +#include <tqsplitter.h> #include <kiconloader.h> #include <kpushbutton.h> #include <klistview.h> @@ -31,21 +31,21 @@ namespace DeviceChooser //----------------------------------------------------------------------------- void DeviceChooser::Config::writeProgrammerGroup(const Programmer::Group *group) { - writeEntry("programmer", group ? group->name() : QString::null); + writeEntry("programmer", group ? group->name() : TQString()); } const Programmer::Group *DeviceChooser::Config::programmerGroup() { - QString name = readEntry("programmer", QString::null); + TQString name = readEntry("programmer", TQString()); return Programmer::lister().group(name); } void DeviceChooser::Config::writeToolGroup(const Tool::Group *group) { - writeEntry("tool", group ? group->name() : QString::null); + writeEntry("tool", group ? group->name() : TQString()); } const Tool::Group *DeviceChooser::Config::toolGroup() { - QString name = readEntry("tool", QString::null); + TQString name = readEntry("tool", TQString()); return Tool::lister().group(name); } @@ -53,20 +53,20 @@ const Tool::Group *DeviceChooser::Config::toolGroup() class ListItem : public KListViewItem { public: - ListItem(KListView *list, const QString &name, bool selectable, bool isDevice) + ListItem(KListView *list, const TQString &name, bool selectable, bool isDevice) : KListViewItem(list, name), _device(isDevice) { setSelectable(selectable); } - ListItem(KListViewItem *item, const QString &name) + ListItem(KListViewItem *item, const TQString &name) : KListViewItem(item, name), _device(true) {} bool isDevice() const { return _device; } - virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align) { - QColorGroup ncg = cg; + virtual void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align) { + TQColorGroup ncg = cg; if (_device) { const Device::Data *device = Device::lister().data(text(0)); Q_ASSERT(device); - ncg.setColor(QColorGroup::Text, Device::statusColor(device->status())); + ncg.setColor(TQColorGroup::Text, Device::statusColor(device->status())); } KListViewItem::paintCell(p, ncg, column, width, align); } @@ -83,38 +83,38 @@ const DeviceChooser::ListType::Data DeviceChooser::ListType::DATA[Nb_Types] = { { "flat", I18N_NOOP("Flat List") } }; -DeviceChooser::Dialog::Dialog(const QString &device, Type type, QWidget *parent) - : ::Dialog(parent, "device_chooser_dialog", true, i18n("Select a device"), - Ok|Close, Close, false, QSize(400, 300)), _withAuto(type==ChooseWithAuto) +DeviceChooser::Dialog::Dialog(const TQString &device, Type type, TQWidget *tqparent) + : ::Dialog(tqparent, "device_chooser_dialog", true, i18n("Select a device"), + Ok|Close, Close, false, TQSize(400, 300)), _withAuto(type==ChooseWithAuto) { setButtonOK(KGuiItem(i18n( "&Select"), "button_ok")); - QVBoxLayout *top = new QVBoxLayout(mainWidget(), 0, 10); + TQVBoxLayout *top = new TQVBoxLayout(mainWidget(), 0, 10); // view - QHBoxLayout *hbox = new QHBoxLayout(top, 10); - QVBoxLayout *vbox = new QVBoxLayout(hbox); + TQHBoxLayout *hbox = new TQHBoxLayout(top, 10); + TQVBoxLayout *vbox = new TQVBoxLayout(hbox); _listTypeCombo = new EnumComboBox<ListType>("list_type", mainWidget()); - connect(_listTypeCombo->combo(), SIGNAL(activated(int)), SLOT(updateList())); + connect(_listTypeCombo->combo(), TQT_SIGNAL(activated(int)), TQT_SLOT(updateList())); vbox->addWidget(_listTypeCombo->combo()); - QPushButton *button = new KPushButton(KGuiItem(i18n("Reset Filters"), "reload"), mainWidget()); - connect(button, SIGNAL(clicked()), SLOT(resetFilters())); + TQPushButton *button = new KPushButton(KGuiItem(i18n("Reset Filters"), "reload"), mainWidget()); + connect(button, TQT_SIGNAL(clicked()), TQT_SLOT(resetFilters())); vbox->addWidget(button); vbox->addStretch(1); // filters - QFrame *frame = new QFrame(mainWidget()); - frame->setFrameStyle(QFrame::Panel | QFrame::Raised); + TQFrame *frame = new TQFrame(mainWidget()); + frame->setFrameStyle(TQFrame::Panel | TQFrame::Raised); frame->setMargin(5); hbox->addWidget(frame); - hbox = new QHBoxLayout(frame, 10, 10); - QLabel *label = new QLabel(i18n("Filters:"), frame); + hbox = new TQHBoxLayout(frame, 10, 10); + TQLabel *label = new TQLabel(i18n("Filters:"), frame); hbox->addWidget(label); - vbox = new QVBoxLayout(hbox); + vbox = new TQVBoxLayout(hbox); - QHBoxLayout *shbox = new QHBoxLayout(vbox); + TQHBoxLayout *shbox = new TQHBoxLayout(vbox); // programmer filter - _programmerCombo = new KeyComboBox<QString>(frame); + _programmerCombo = new KeyComboBox<TQString>(frame); _programmerCombo->appendItem("<all>", i18n("<Programmer>")); Programmer::Lister::ConstIterator pit; for (pit=Programmer::lister().begin(); pit!=Programmer::lister().end(); ++pit) @@ -122,11 +122,11 @@ DeviceChooser::Dialog::Dialog(const QString &device, Type type, QWidget *parent) Config config; const Programmer::Group *pgroup = config.programmerGroup(); if (pgroup) _programmerCombo->setCurrentItem(pgroup->name()); - connect(_programmerCombo->widget(), SIGNAL(activated(int)), SLOT(updateList())); + connect(_programmerCombo->widget(), TQT_SIGNAL(activated(int)), TQT_SLOT(updateList())); shbox->addWidget(_programmerCombo->widget()); // tool filter - _toolCombo = new KeyComboBox<QString>(frame); + _toolCombo = new KeyComboBox<TQString>(frame); _toolCombo->appendItem("<all>", i18n("<Toolchain>")); Tool::Lister::ConstIterator tit; for (tit=Tool::lister().begin(); tit!=Tool::lister().end(); ++tit) { @@ -135,50 +135,50 @@ DeviceChooser::Dialog::Dialog(const QString &device, Type type, QWidget *parent) } const Tool::Group *tgroup = config.toolGroup(); if (tgroup) _toolCombo->setCurrentItem(tgroup->name()); - connect(_toolCombo->widget(), SIGNAL(activated(int)), SLOT(updateList())); + connect(_toolCombo->widget(), TQT_SIGNAL(activated(int)), TQT_SLOT(updateList())); shbox->addWidget(_toolCombo->widget()); // memory filter _memoryCombo = new EnumComboBox<Device::MemoryTechnology>(i18n("<Memory Type>"), "memory_technology", frame); - connect(_memoryCombo->combo(), SIGNAL(activated(int)), SLOT(updateList())); + connect(_memoryCombo->combo(), TQT_SIGNAL(activated(int)), TQT_SLOT(updateList())); shbox->addWidget(_memoryCombo->combo()); shbox->addStretch(1); - shbox = new QHBoxLayout(vbox); + shbox = new TQHBoxLayout(vbox); // status filter - _statusCombo = new EnumComboBox<Device::Status>(i18n("<Status>"), "status", frame); - connect(_statusCombo->combo(), SIGNAL(activated(int)), SLOT(updateList())); + _statusCombo = new EnumComboBox<Device::tqStatus>(i18n("<tqStatus>"), "status", frame); + connect(_statusCombo->combo(), TQT_SIGNAL(activated(int)), TQT_SLOT(updateList())); shbox->addWidget(_statusCombo->combo()); // features filter _featureCombo = new EnumComboBox<Pic::Feature>(i18n("<Feature>"), "feature", frame); - connect(_featureCombo->combo(), SIGNAL(activated(int)), SLOT(updateList())); + connect(_featureCombo->combo(), TQT_SIGNAL(activated(int)), TQT_SLOT(updateList())); shbox->addWidget(_featureCombo->combo()); shbox->addStretch(1); // list view - QValueList<int> widths; + TQValueList<int> widths; widths += 80; widths += 500; - Splitter *splitter = new Splitter(widths, Horizontal, mainWidget(), "device_shooser_splitter"); + Splitter *splitter = new Splitter(widths,Qt::Horizontal, mainWidget(), "device_shooser_splitter"); top->addWidget(splitter, 1); _listView = new KListView(splitter); - connect(_listView, SIGNAL(currentChanged(QListViewItem *)), - SLOT(currentChanged(QListViewItem *))); - connect(_listView, SIGNAL(doubleClicked(QListViewItem *, const QPoint &, int)), - SLOT(listDoubleClicked(QListViewItem *))); + connect(_listView, TQT_SIGNAL(currentChanged(TQListViewItem *)), + TQT_SLOT(currentChanged(TQListViewItem *))); + connect(_listView, TQT_SIGNAL(doubleClicked(TQListViewItem *, const TQPoint &, int)), + TQT_SLOT(listDoubleClicked(TQListViewItem *))); _listView->setAllColumnsShowFocus(true); _listView->setRootIsDecorated(true); _listView->setSorting(-1); _listView->addColumn(i18n("Device")); - _listView->setResizeMode(QListView::LastColumn); + _listView->setResizeMode(TQListView::LastColumn); // device view _deviceView = new View(splitter); - connect(_deviceView, SIGNAL(deviceChanged(const QString &)), - SLOT(deviceChange(const QString &))); + connect(_deviceView, TQT_SIGNAL(deviceChanged(const TQString &)), + TQT_SLOT(deviceChange(const TQString &))); updateList(device); } @@ -194,29 +194,29 @@ DeviceChooser::Dialog::~Dialog() _featureCombo->writeConfig(); } -QString DeviceChooser::Dialog::device() const +TQString DeviceChooser::Dialog::device() const { - QListViewItem *item = _listView->selectedItem(); + TQListViewItem *item = _listView->selectedItem(); if ( item==0 || !static_cast<ListItem *>(item)->isDevice() ) return Device::AUTO_DATA.name; return item->text(0); } -void DeviceChooser::Dialog::listDoubleClicked(QListViewItem *item) +void DeviceChooser::Dialog::listDoubleClicked(TQListViewItem *item) { if ( item==0 ) return; if ( !static_cast<ListItem *>(item)->isDevice() ) item->setOpen(!item->isOpen()); else accept(); } -void DeviceChooser::Dialog::currentChanged(QListViewItem *item) +void DeviceChooser::Dialog::currentChanged(TQListViewItem *item) { if ( item==0 || !static_cast<ListItem *>(item)->isDevice() ) _deviceView->clear(); else _deviceView->setDevice(item->text(0), false); } -void DeviceChooser::Dialog::deviceChange(const QString &name) +void DeviceChooser::Dialog::deviceChange(const TQString &name) { - QListViewItemIterator it(_listView); + TQListViewItemIterator it(_listView); for (; it.current(); ++it) if ( it.current()->text(0)==name ) { _listView->setSelected(it.current(), true); @@ -237,8 +237,8 @@ void DeviceChooser::Dialog::resetFilters() void DeviceChooser::Dialog::updateList() { - QListViewItem *item = _listView->selectedItem(); - QString device = (item ? item->text(0) : QString::null); + TQListViewItem *item = _listView->selectedItem(); + TQString device = (item ? item->text(0) : TQString()); _listView->clear(); updateList(device); } @@ -253,19 +253,19 @@ const Tool::Group *DeviceChooser::Dialog::toolGroup() const return Tool::lister().group(_toolCombo->currentItem()); } -void DeviceChooser::Dialog::updateList(const QString &device) +void DeviceChooser::Dialog::updateList(const TQString &device) { - QValueVector<QString> list = Device::lister().supportedDevices(); - QMap<QString, KListViewItem *> groups; - QListViewItem *selected = 0; + TQValueVector<TQString> list = Device::lister().supportedDevices(); + TQMap<TQString, KListViewItem *> groups; + TQListViewItem *selected = 0; const Programmer::Group *pgroup = programmerGroup(); if ( pgroup && pgroup->supportedDevices().isEmpty() && pgroup->isSoftware() ) { - _deviceView->setText(i18n("Could not detect supported devices for \"%1\". Please check installation.").arg(pgroup->label())); + _deviceView->setText(i18n("Could not detect supported devices for \"%1\". Please check installation.").tqarg(pgroup->label())); return; } const Tool::Group *tgroup = toolGroup(); if ( tgroup && tgroup->supportedDevices().isEmpty() ) { - _deviceView->setText(i18n("Could not detect supported devices for toolchain \"%1\". Please check installation.").arg(tgroup->label())); + _deviceView->setText(i18n("Could not detect supported devices for toolchain \"%1\". Please check installation.").tqarg(tgroup->label())); return; } for (int i=list.count()-1; i>=0; i--) { @@ -274,7 +274,7 @@ void DeviceChooser::Dialog::updateList(const QString &device) const Device::Data *data = Device::lister().data(list[i]); Q_ASSERT(data); if ( _memoryCombo->value()!=Device::MemoryTechnology::Nb_Types && data->memoryTechnology()!=_memoryCombo->value() ) continue; - if ( _statusCombo->value()!=Device::Status::Nb_Types && data->status()!=_statusCombo->value() ) continue; + if ( _statusCombo->value()!=Device::tqStatus::Nb_Types && data->status()!=_statusCombo->value() ) continue; if ( _featureCombo->value()!=Pic::Feature::Nb_Types ) { if ( data->group().name()!="pic" ) continue; if ( !static_cast<const Pic::Data *>(data)->hasFeature(_featureCombo->value()) ) continue; @@ -282,8 +282,8 @@ void DeviceChooser::Dialog::updateList(const QString &device) KListViewItem *item = 0; switch (_listTypeCombo->value().type()) { case ListType::FamilyTree: { - QString gname = data->listViewGroup(); - if ( !groups.contains(gname) ) + TQString gname = data->listViewGroup(); + if ( !groups.tqcontains(gname) ) groups[gname] = new ListItem(_listView, gname, false, false); item = new ListItem(groups[gname], list[i]); break; @@ -305,23 +305,23 @@ void DeviceChooser::Dialog::updateList(const QString &device) } //----------------------------------------------------------------------------- -DeviceChooser::ComboBox::ComboBox(bool withAuto, QWidget *parent) - : QComboBox(parent, "device_chooser_combo"), _withAuto(withAuto) +DeviceChooser::ComboBox::ComboBox(bool withAuto, TQWidget *tqparent) + : TQComboBox(tqparent, "device_chooser_combo"), _withAuto(withAuto) { if (withAuto) insertItem(i18n(Device::AUTO_DATA.label)); Device::Lister::ConstIterator it; for (it=Device::lister().begin(); it!=Device::lister().end(); ++it) { - QValueVector<QString> devices = it.data()->supportedDevices(); + TQValueVector<TQString> devices = it.data()->supportedDevices(); qHeapSort(devices); for (uint k=0; k<devices.count(); k++) insertItem(devices[k]); } } -void DeviceChooser::ComboBox::setDevice(const QString &device, const Device::Data *data) +void DeviceChooser::ComboBox::setDevice(const TQString &device, const Device::Data *data) { - QString text = device; + TQString text = device; if ( device.isEmpty() || device==Device::AUTO_DATA.name ) { - if (_withAuto) text = QString::null; + if (_withAuto) text = TQString(); else text = Device::lister().supportedDevices()[0]; } if ( text.isEmpty() ) { @@ -331,24 +331,24 @@ void DeviceChooser::ComboBox::setDevice(const QString &device, const Device::Dat } else setCurrentText(text); } -QString DeviceChooser::ComboBox::device() const +TQString DeviceChooser::ComboBox::device() const { if ( _withAuto && currentItem()==0 ) return Device::AUTO_DATA.name; return currentText(); } //----------------------------------------------------------------------------- -DeviceChooser::Button::Button(bool withAuto, QWidget *parent) - : QWidget(parent, "device_chooser_button") +DeviceChooser::Button::Button(bool withAuto, TQWidget *tqparent) + : TQWidget(tqparent, "device_chooser_button") { - QHBoxLayout *hbox = new QHBoxLayout(this, 0, 10); + TQHBoxLayout *hbox = new TQHBoxLayout(this, 0, 10); _combo = new ComboBox(withAuto, this); - connect(_combo, SIGNAL(activated(int)), SIGNAL(changed())); + connect(_combo, TQT_SIGNAL(activated(int)), TQT_SIGNAL(changed())); hbox->addWidget(_combo); KIconLoader loader; - QIconSet iconset = loader.loadIcon("fileopen", KIcon::Toolbar); - KPushButton *button = new KPushButton(iconset, QString::null, this); - connect(button, SIGNAL(clicked()), SLOT(chooseDevice())); + TQIconSet iconset = loader.loadIcon("fileopen", KIcon::Toolbar); + KPushButton *button = new KPushButton(iconset, TQString(), this); + connect(button, TQT_SIGNAL(clicked()), TQT_SLOT(chooseDevice())); hbox->addWidget(button); } @@ -361,16 +361,16 @@ void DeviceChooser::Button::chooseDevice() } //----------------------------------------------------------------------------- -DeviceChooser::Browser::Browser(QWidget *parent) - : KTextBrowser(parent, "device_browser") +DeviceChooser::Browser::Browser(TQWidget *tqparent) + : KTextBrowser(tqparent, "device_browser") {} -PURL::Url findDocumentUrl(const QString &prefix, const QString &baseName) +PURL::Url findDocumentUrl(const TQString &prefix, const TQString &baseName) { PURL::Url previous = KURL::fromPathOrURL(prefix + baseName + ".pdf"); bool previousExists = previous.exists(); for (uint i=0; i<26; i++) { - PURL::Url url = KURL::fromPathOrURL(prefix + baseName + QChar('a' + i) + ".pdf"); + PURL::Url url = KURL::fromPathOrURL(prefix + baseName + TQChar('a' + i) + ".pdf"); bool exists = url.exists(); if ( !exists && previousExists ) return previous; previous = url; @@ -379,12 +379,12 @@ PURL::Url findDocumentUrl(const QString &prefix, const QString &baseName) return previous; } -void DeviceChooser::Browser::setSource(const QString &name) +void DeviceChooser::Browser::setSource(const TQString &name) { - ::BusyCursor bc; + ::PBusyCursor bc; if ( name.startsWith("device://") ) emit deviceChanged(name.mid(9)); else if ( name.startsWith("document://") ) { - QString prefix = "http://ww1.microchip.com/downloads/en/DeviceDoc/"; + TQString prefix = "http://ww1.microchip.com/downloads/en/DeviceDoc/"; PURL::Url url = findDocumentUrl(prefix, name.mid(11, name.length()-11-1)); KTextBrowser::setSource(url.kurl().htmlURL()); } @@ -392,15 +392,15 @@ void DeviceChooser::Browser::setSource(const QString &name) } //----------------------------------------------------------------------------- -DeviceChooser::View::View(QWidget *parent) - : TabWidget(parent, "device_view") +DeviceChooser::View::View(TQWidget *tqparent) + : TabWidget(tqparent, "device_view") { // Information _info = new Browser(this); _info->setMimeSourceFactory(&_msf); insertTab(_info, i18n("Information")); - connect(_info, SIGNAL(deviceChanged(const QString &)), - SIGNAL(deviceChanged(const QString &))); + connect(_info, TQT_SIGNAL(deviceChanged(const TQString &)), + TQT_SIGNAL(deviceChanged(const TQString &))); // Memory Map _memory = new Browser(this); @@ -418,24 +418,24 @@ DeviceChooser::View::View(QWidget *parent) insertTab(_pins, i18n("Pin Diagrams")); } -void DeviceChooser::View::setDevice(const QString &name, bool cannotChangeDevice) +void DeviceChooser::View::setDevice(const TQString &name, bool cannotChangeDevice) { const Device::Data *data = Device::lister().data(name); if ( data==0 ) return; - QString doc = htmlInfo(*data, (cannotChangeDevice ? QString::null : "device:%1"), Device::documentHtml(*data)); + TQString doc = htmlInfo(*data, (cannotChangeDevice ? TQString() : "device:%1"), Device::documentHtml(*data)); doc += Device::supportedHtmlInfo(*data); _info->setText("<html><body>" + doc + "</body></html>"); - doc = htmlVoltageFrequencyGraphs(*data, QString::null, &_msf); - QPixmap pix = data->group().memoryGraph(*data); - QString label = data->name() + "_memory_map.png"; + doc = htmlVoltageFrequencyGraphs(*data, TQString(), &_msf); + TQPixmap pix = data->group().memoryGraph(*data); + TQString label = data->name() + "_memory_map.png"; _msf.setPixmap(label, pix); _memory->setText("<html><body><img src=\"" + label + "\" /></body></html>"); _vfg->setText("<html><body>" + doc + "</body></html>"); - doc = htmlPinDiagrams(*data, QString::null, &_msf); + doc = htmlPinDiagrams(*data, TQString(), &_msf); _pins->setText("<html><body>" + doc + "</body></html>"); } -void DeviceChooser::View::setText(const QString &text) +void DeviceChooser::View::setText(const TQString &text) { _info->setText(text); _vfg->setText(text); @@ -450,14 +450,14 @@ void DeviceChooser::View::clear() } //----------------------------------------------------------------------------- -DeviceChooser::Editor::Editor(const QString &title, const QString &tag, QWidget *widget) +DeviceChooser::Editor::Editor(const TQString &title, const TQString &tag, TQWidget *widget) : DeviceEditor(title, tag, widget, "device_view_editor") {} -QWidget *DeviceChooser::Editor::createView(const Device::Data *, QWidget *parent) +TQWidget *DeviceChooser::Editor::createView(const Device::Data *, TQWidget *tqparent) { - DeviceChooser::View *view = new DeviceChooser::View(parent); - connect(view, SIGNAL(deviceChanged(const QString &)), SIGNAL(deviceChanged(const QString &))); + DeviceChooser::View *view = new DeviceChooser::View(tqparent); + connect(view, TQT_SIGNAL(deviceChanged(const TQString &)), TQT_SIGNAL(deviceChanged(const TQString &))); view->setDevice(_device, true); return view; } |