1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +01:00

Merge commit '07a48573ea828685f0465786e16dd13db68a850f'

This commit is contained in:
James Cotton 2011-05-29 17:08:17 -05:00
commit df69bbb950
4 changed files with 86 additions and 39 deletions

View File

@ -3668,7 +3668,7 @@
id="g6963" /><g id="g6963" /><g
id="g6995" /><g id="g6995" /><g
id="g7027" /><g id="g7027" /><g
id="quad-x"><g id="quad-X"><g
transform="matrix(1,0,0,-1,0,2792.2535)" transform="matrix(1,0,0,-1,0,2792.2535)"
id="g5011"><path id="g5011"><path
d="m 1001.67,1438.583 2.695,0 0,-16.728 16.729,0 0,16.728 2.988,0 -11.205,11.205 -11.207,-11.205 z" d="m 1001.67,1438.583 2.695,0 0,-16.728 16.729,0 0,16.728 2.988,0 -11.205,11.205 -11.207,-11.205 z"
@ -6800,4 +6800,4 @@
d="m 234.6162,1496.2944 0,10.918 -2.771,-2.142 -1.828,2.499 4.892,3.59 3.234,0 0,-14.865 -3.527,0 z" d="m 234.6162,1496.2944 0,10.918 -2.771,-2.142 -1.828,2.499 4.892,3.59 3.234,0 0,-14.865 -3.527,0 z"
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
id="path10359" id="path10359"
inkscape:connector-curvature="0" /></g></g></svg> inkscape:connector-curvature="0" /></g></g></svg>

Before

Width:  |  Height:  |  Size: 438 KiB

After

Width:  |  Height:  |  Size: 438 KiB

View File

@ -59,10 +59,13 @@ bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2)
const UAVGadgetOptionsPageDecorator *gp2 = qobject_cast<const UAVGadgetOptionsPageDecorator*>(p2); const UAVGadgetOptionsPageDecorator *gp2 = qobject_cast<const UAVGadgetOptionsPageDecorator*>(p2);
if (gp1 && (gp2 == NULL)) if (gp1 && (gp2 == NULL))
return false; return false;
if (gp2 && (gp1 == NULL)) if (gp2 && (gp1 == NULL))
return true; return true;
if (const int cc = QString::localeAwareCompare(p1->trCategory(), p2->trCategory())) if (const int cc = QString::localeAwareCompare(p1->trCategory(), p2->trCategory()))
return cc < 0; return cc < 0;
return QString::localeAwareCompare(p1->trName(), p2->trName()) < 0; return QString::localeAwareCompare(p1->trName(), p2->trName()) < 0;
} }
@ -97,6 +100,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
} }
if (m_windowWidth > 0 && m_windowHeight > 0) if (m_windowWidth > 0 && m_windowHeight > 0)
resize(m_windowWidth, m_windowHeight); resize(m_windowWidth, m_windowHeight);
buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
@ -105,6 +109,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
connect(this, SIGNAL(settingsDialogShown(Core::Internal::SettingsDialog*)), m_instanceManager, SLOT(settingsDialogShown(Core::Internal::SettingsDialog*))); connect(this, SIGNAL(settingsDialogShown(Core::Internal::SettingsDialog*)), m_instanceManager, SLOT(settingsDialogShown(Core::Internal::SettingsDialog*)));
connect(this, SIGNAL(settingsDialogRemoved()), m_instanceManager, SLOT(settingsDialogRemoved())); connect(this, SIGNAL(settingsDialogRemoved()), m_instanceManager, SLOT(settingsDialogRemoved()));
connect(this, SIGNAL(categoryItemSelected()), this, SLOT(categoryItemSelectedShowChildInstead()), Qt::QueuedConnection);
splitter->setCollapsible(0, false); splitter->setCollapsible(0, false);
splitter->setCollapsible(1, false); splitter->setCollapsible(1, false);
@ -129,44 +134,33 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
item->setText(0, page->trName()); item->setText(0, page->trName());
item->setData(0, Qt::UserRole, qVariantFromValue(pageData)); item->setData(0, Qt::UserRole, qVariantFromValue(pageData));
QStringList categoriesId = page->category().split(QLatin1Char('|')); QString trCategories = page->trCategory();
QStringList trCategories = page->trCategory().split(QLatin1Char('|')); QString currentCategory = page->category();
QString currentCategory = categoriesId.at(0);
QTreeWidgetItem *treeitem; QTreeWidgetItem *categoryItem;
if (!categories.contains(currentCategory)) { if (!categories.contains(currentCategory)) {
if (!firstUavGadgetOptionsPageFound) // Above the first gadget option we insert a separator
{ if (!firstUavGadgetOptionsPageFound) {
UAVGadgetOptionsPageDecorator *pd = qobject_cast<UAVGadgetOptionsPageDecorator*>(page); UAVGadgetOptionsPageDecorator *pd = qobject_cast<UAVGadgetOptionsPageDecorator*>(page);
if (pd) if (pd) {
{
firstUavGadgetOptionsPageFound = true; firstUavGadgetOptionsPageFound = true;
QTreeWidgetItem *separator = new QTreeWidgetItem(pageTree); QTreeWidgetItem *separator = new QTreeWidgetItem(pageTree);
separator->setFlags(item->flags() & ~Qt::ItemIsSelectable & ~Qt::ItemIsEnabled); separator->setFlags(separator->flags() & ~Qt::ItemIsSelectable & ~Qt::ItemIsEnabled);
separator->setText(0, QString(30, 0xB7)); separator->setText(0, QString(30, 0xB7));
} }
} }
treeitem = new QTreeWidgetItem(pageTree); categoryItem = new QTreeWidgetItem(pageTree);
treeitem->setText(0, trCategories.at(0)); categoryItem->setText(0, trCategories);
treeitem->setData(0, Qt::UserRole, qVariantFromValue(pageData)); categoryItem->setData(0, Qt::UserRole, qVariantFromValue(pageData));
categories.insert(currentCategory, treeitem); categories.insert(currentCategory, categoryItem);
} }
int catCount = 1; QList<QTreeWidgetItem *> *categoryItemList = m_categoryItemsMap.value(currentCategory);
while (catCount < categoriesId.count()) { if (!categoryItemList) {
if (!categories.contains(currentCategory + QLatin1Char('|') + categoriesId.at(catCount))) { categoryItemList = new QList<QTreeWidgetItem *>();
treeitem = new QTreeWidgetItem(categories.value(currentCategory)); m_categoryItemsMap.insert(currentCategory, categoryItemList);
currentCategory += QLatin1Char('|') + categoriesId.at(catCount);
treeitem->setText(0, trCategories.at(catCount));
treeitem->setData(0, Qt::UserRole, qVariantFromValue(pageData));
categories.insert(currentCategory, treeitem);
} else {
currentCategory += QLatin1Char('|') + categoriesId.at(catCount);
}
++catCount;
} }
categoryItemList->append(item);
categories.value(currentCategory)->addChild(item);
m_pages.append(page); m_pages.append(page);
stackedPages->addWidget(page->createPage(stackedPages)); stackedPages->addWidget(page->createPage(stackedPages));
@ -179,6 +173,16 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
index++; index++;
} }
foreach(QString category, m_categoryItemsMap.keys()) {
QList<QTreeWidgetItem *> *categoryItemList = m_categoryItemsMap.value(category);
if (categoryItemList->size() > 1) {
foreach (QTreeWidgetItem *item, *categoryItemList) {
QTreeWidgetItem *categoryItem = categories.value(category);
categoryItem->addChild(item);
}
}
}
QList<int> sizes; QList<int> sizes;
sizes << 150 << 300; sizes << 150 << 300;
splitter->setSizes(sizes); splitter->setSizes(sizes);
@ -189,22 +193,49 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
SettingsDialog::~SettingsDialog() SettingsDialog::~SettingsDialog()
{ {
foreach(QString category, m_categoryItemsMap.keys()) {
QList<QTreeWidgetItem *> *categoryItemList = m_categoryItemsMap.value(category);
delete categoryItemList;
}
} }
void SettingsDialog::pageSelected() void SettingsDialog::pageSelected()
{ {
QTreeWidgetItem *item = pageTree->currentItem(); QTreeWidgetItem *item = pageTree->currentItem();
if (!item)
return;
PageData data = item->data(0, Qt::UserRole).value<PageData>(); PageData data = item->data(0, Qt::UserRole).value<PageData>();
int index = data.index; int index = data.index;
m_currentCategory = data.category; m_currentCategory = data.category;
m_currentPage = data.id; m_currentPage = data.id;
stackedPages->setCurrentIndex(index); stackedPages->setCurrentIndex(index);
// If user selects a toplevel item, select the first child for them
// I.e. Top level items are not really selectable
if ((pageTree->indexOfTopLevelItem(item) >= 0) && (item->childCount() > 0)) {
emit categoryItemSelected();
}
}
void SettingsDialog::categoryItemSelectedShowChildInstead()
{
QTreeWidgetItem *item = pageTree->currentItem();
item->setExpanded(true);
pageTree->setCurrentItem(item->child(0), 0, QItemSelectionModel::SelectCurrent);
} }
void SettingsDialog::deletePage() void SettingsDialog::deletePage()
{ {
QTreeWidgetItem *item = pageTree->currentItem(); QTreeWidgetItem *item = pageTree->currentItem();
item->parent()->removeChild(item); PageData data = item->data(0, Qt::UserRole).value<PageData>();
QString category = data.category;
QList<QTreeWidgetItem *> *categoryItemList = m_categoryItemsMap.value(category);
QTreeWidgetItem *parentItem = item->parent();
parentItem->removeChild(item);
categoryItemList->removeOne(item);
if (parentItem->childCount() == 1) {
parentItem->removeChild(parentItem->child(0));
}
pageSelected(); pageSelected();
} }
@ -227,11 +258,20 @@ void SettingsDialog::insertPage(IOptionsPage* page)
if (!categoryItem) if (!categoryItem)
return; return;
// If this category has no child right now
// we need to add the "default child"
QList<QTreeWidgetItem *> *categoryItemList = m_categoryItemsMap.value(page->category());
if (categoryItem->childCount() == 0) {
QTreeWidgetItem *defaultItem = categoryItemList->at(0);
categoryItem->addChild(defaultItem);
}
QTreeWidgetItem *item = new QTreeWidgetItem; QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, page->trName()); item->setText(0, page->trName());
item->setData(0, Qt::UserRole, qVariantFromValue(pageData)); item->setData(0, Qt::UserRole, qVariantFromValue(pageData));
categoryItem->addChild(item); categoryItem->addChild(item);
categoryItemList->append(item);
m_pages.append(page); m_pages.append(page);
stackedPages->addWidget(page->createPage(stackedPages)); stackedPages->addWidget(page->createPage(stackedPages));
@ -256,7 +296,7 @@ void SettingsDialog::accept()
{ {
m_applied = true; m_applied = true;
foreach (IOptionsPage *page, m_pages) { foreach (IOptionsPage *page, m_pages) {
page->apply(); page->apply();
page->finish(); page->finish();
} }
done(QDialog::Accepted); done(QDialog::Accepted);
@ -266,14 +306,15 @@ void SettingsDialog::reject()
{ {
foreach (IOptionsPage *page, m_pages) foreach (IOptionsPage *page, m_pages)
page->finish(); page->finish();
done(QDialog::Rejected); done(QDialog::Rejected);
} }
void SettingsDialog::apply() void SettingsDialog::apply()
{ {
foreach (IOptionsPage *page, m_pages) { foreach (IOptionsPage *page, m_pages)
page->apply(); page->apply();
}
m_applied = true; m_applied = true;
} }

View File

@ -62,6 +62,7 @@ public:
signals: signals:
void settingsDialogShown(Core::Internal::SettingsDialog*); void settingsDialogShown(Core::Internal::SettingsDialog*);
void settingsDialogRemoved(); void settingsDialogRemoved();
void categoryItemSelected();
public slots: public slots:
void done(int); void done(int);
@ -71,9 +72,13 @@ private slots:
void accept(); void accept();
void reject(); void reject();
void apply(); void apply();
void categoryItemSelectedShowChildInstead();
private: private:
QList<Core::IOptionsPage*> m_pages; QList<Core::IOptionsPage*> m_pages;
QMap<QString, QList<QTreeWidgetItem *> *> m_categoryItemsMap;
UAVGadgetInstanceManager *m_instanceManager; UAVGadgetInstanceManager *m_instanceManager;
bool m_applied; bool m_applied;
QString m_currentCategory; QString m_currentCategory;

View File

@ -168,17 +168,18 @@ bool deviceWidget::populateStructuredDescription(QByteArray desc)
# 20 bytes: SHA1 sum of the firmware. # 20 bytes: SHA1 sum of the firmware.
# 40 bytes: free for now. # 40 bytes: free for now.
*/ */
// I don't want to use structs, ok ?
quint32 gitCommitTag = desc.at(4)&0xFF; // Note: the ARM binary is big-endian:
quint32 gitCommitTag = desc.at(7)&0xFF;
for (int i=1;i<4;i++) { for (int i=1;i<4;i++) {
gitCommitTag = gitCommitTag<<8; gitCommitTag = gitCommitTag<<8;
gitCommitTag += desc.at(4+i) & 0xFF; gitCommitTag += desc.at(7-i) & 0xFF;
} }
myDevice->commitTag->setText("GIT tag 0x" + QString::number(gitCommitTag,16)); myDevice->commitTag->setText("GIT tag 0x" + QString::number(gitCommitTag,16));
quint32 buildDate = desc.at(8)&0xFF; quint32 buildDate = desc.at(11)&0xFF;
for (int i=1;i<4;i++) { for (int i=1;i<4;i++) {
buildDate = buildDate<<8; buildDate = buildDate<<8;
buildDate += desc.at(8+i) & 0xFF; buildDate += desc.at(11-i) & 0xFF;
} }
myDevice->buildDate->setText(QString("Build time: ") + QDateTime::fromTime_t(buildDate).toString()); myDevice->buildDate->setText(QString("Build time: ") + QDateTime::fromTime_t(buildDate).toString());