diff options
| author | Amaury Pouly <amaury.pouly@gmail.com> | 2014-04-07 11:28:04 +0200 |
|---|---|---|
| committer | Amaury Pouly <amaury.pouly@gmail.com> | 2014-05-01 19:34:18 +0200 |
| commit | 4356666101e0e7985e65a19f86bc4a74519e93f9 (patch) | |
| tree | bf8de8057d93d0fab0a30cae92a90f5a4edc79dc /utils/regtools/qeditor/backend.cpp | |
| parent | 3754624edc48539c5cc5acbf426ce909477e87d8 (diff) | |
| download | rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.zip rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.gz rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.bz2 rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.xz | |
regtools: completely rework qeditor, improve soc desc library and tools
The graphical editor can now display and editor description files.
The library has been improved to provide more useful function.
The XML format has been slightly changed: only one soc is allowed per file
(this is was already de facto the case since <soc> was the root tag).
Also introduce a DTD to validate the files.
Change-Id: If70ba35b6dc0242bdb87411cf4baee9597798aac
Diffstat (limited to 'utils/regtools/qeditor/backend.cpp')
| -rw-r--r-- | utils/regtools/qeditor/backend.cpp | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/utils/regtools/qeditor/backend.cpp b/utils/regtools/qeditor/backend.cpp index eebda31..204c160 100644 --- a/utils/regtools/qeditor/backend.cpp +++ b/utils/regtools/qeditor/backend.cpp @@ -5,6 +5,36 @@ #include "backend.h" /** + * SocFile + */ +SocFile::SocFile() + :m_valid(false) +{ +} + +SocFile::SocFile(const QString& filename) + :m_filename(filename) +{ + m_valid = soc_desc_parse_xml(filename.toStdString(), m_soc); + soc_desc_normalize(m_soc); +} + +bool SocFile::IsValid() +{ + return m_valid; +} + +SocRef SocFile::GetSocRef() +{ + return SocRef(this); +} + +QString SocFile::GetFilename() +{ + return m_filename; +} + +/** * Backend */ @@ -12,33 +42,31 @@ Backend::Backend() { } -QStringList Backend::GetSocNameList() + +QList< SocFileRef > Backend::GetSocFileList() { - QStringList sl; - foreach(const soc_t& soc, m_socs) - sl.append(QString(soc.name.c_str())); - return sl; + QList< SocFileRef > list; + for(std::list< SocFile >::iterator it = m_socs.begin(); it != m_socs.end(); ++it) + list.append(SocFileRef(&(*it))); + return list; } -bool Backend::GetSocByName(const QString& name, SocRef& s) +QList< SocRef > Backend::GetSocList() { - for(std::list< soc_t >::iterator it = m_socs.begin(); it != m_socs.end(); ++it) - if(it->name == name.toStdString()) - { - s = SocRef(&(*it)); - return true; - } - return false; + QList< SocRef > list; + for(std::list< SocFile >::iterator it = m_socs.begin(); it != m_socs.end(); ++it) + list.append(it->GetSocRef()); + return list; } bool Backend::LoadSocDesc(const QString& filename) { - std::vector< soc_t > new_socs; - bool ret = soc_desc_parse_xml(filename.toStdString(), new_socs); - for(size_t i = 0; i < new_socs.size(); i++) - m_socs.push_back(new_socs[i]); + SocFile f(filename); + if(!f.IsValid()) + return false; + m_socs.push_back(f); emit OnSocListChanged(); - return ret; + return true; } IoBackend *Backend::CreateFileIoBackend(const QString& filename) @@ -321,7 +349,7 @@ HWStubBackendHelper::HWStubBackendHelper() if(m_hotplug) { m_hotplug = LIBUSB_SUCCESS == libusb_hotplug_register_callback( - NULL, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, + NULL, (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), LIBUSB_HOTPLUG_ENUMERATE, HWSTUB_USB_VID, HWSTUB_USB_PID, HWSTUB_CLASS, &HWStubBackendHelper::HotPlugCallback, reinterpret_cast< void* >(this), &m_hotplug_handle); } @@ -364,6 +392,7 @@ void HWStubBackendHelper::OnHotPlug(bool arrived, struct libusb_device *dev) int HWStubBackendHelper::HotPlugCallback(struct libusb_context *ctx, struct libusb_device *dev, libusb_hotplug_event event, void *user_data) { + Q_UNUSED(ctx); HWStubBackendHelper *helper = reinterpret_cast< HWStubBackendHelper* >(user_data); switch(event) { |