mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 09:45:21 +03:00
Corrected list items width (long items were wrapping)
Refactored inputs tab, same system as mixes tab (grouping of lines) Fixed incorrect spacing for first list item
This commit is contained in:
parent
0e7b420b71
commit
a8c828f105
5 changed files with 72 additions and 38 deletions
|
@ -55,6 +55,7 @@ void InputsPanel::update()
|
||||||
// i -> mixer number
|
// i -> mixer number
|
||||||
QByteArray qba;
|
QByteArray qba;
|
||||||
ExposlistWidget->clear();
|
ExposlistWidget->clear();
|
||||||
|
firstLine = true;
|
||||||
int curDest = -1;
|
int curDest = -1;
|
||||||
|
|
||||||
for (int i=0; i<C9X_MAX_EXPOS; i++) {
|
for (int i=0; i<C9X_MAX_EXPOS; i++) {
|
||||||
|
@ -66,20 +67,61 @@ void InputsPanel::update()
|
||||||
|
|
||||||
while (curDest<(int)md->chn-1) {
|
while (curDest<(int)md->chn-1) {
|
||||||
curDest++;
|
curDest++;
|
||||||
str = getInputStr(model, curDest);
|
AddInputLine(-curDest-1);
|
||||||
qba.clear();
|
}
|
||||||
qba.append((quint8)-curDest-1);
|
if (AddInputLine(i, md)) {
|
||||||
QListWidgetItem *itm = new QListWidgetItem(str);
|
curDest++;
|
||||||
itm->setData(Qt::UserRole,qba);
|
|
||||||
ExposlistWidget->addItem(itm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curDest!=(int)md->chn) {
|
}
|
||||||
|
|
||||||
|
while (curDest<inputsCount-1) {
|
||||||
|
curDest++;
|
||||||
|
AddInputLine(-curDest-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
lock = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool InputsPanel::AddInputLine(int dest, const ExpoData * md)
|
||||||
|
{
|
||||||
|
bool new_ch;
|
||||||
|
QString str = getInputText(dest, &new_ch);
|
||||||
|
QListWidgetItem *itm = new QListWidgetItem(str);
|
||||||
|
QByteArray qba(1, (quint8)dest);
|
||||||
|
if (md) qba.append((const char*)md, sizeof(ExpoData));
|
||||||
|
itm->setData(Qt::UserRole, qba);
|
||||||
|
#if MIX_ROW_HEIGHT_INCREASE > 0
|
||||||
|
if (new_ch && !firstLine) {
|
||||||
|
//increase size of this row
|
||||||
|
itm->setData(GroupHeaderRole, 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ExposlistWidget->addItem(itm);
|
||||||
|
firstLine = false;
|
||||||
|
//qDebug() << "InputsPanel::AddInputLine(): dest" << dest << "text" << str;
|
||||||
|
return new_ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString InputsPanel::getInputText(int dest, bool * new_ch)
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
if (new_ch) *new_ch = 0;
|
||||||
|
if (dest < 0) {
|
||||||
|
str = getInputStr(model, -dest-1);
|
||||||
|
if (new_ch) *new_ch = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ExpoData *md = &model.expoData[dest];
|
||||||
|
|
||||||
|
if ((dest == 0) || (model.expoData[dest-1].chn != md->chn)) {
|
||||||
|
if (new_ch) *new_ch = 1;
|
||||||
if (firmware->getCapability(VirtualInputs))
|
if (firmware->getCapability(VirtualInputs))
|
||||||
str = QString("%1").arg(getInputStr(model, md->chn), -8, ' ');
|
str = QString("%1").arg(getInputStr(model, md->chn), -8, ' ');
|
||||||
else
|
else
|
||||||
str = getInputStr(model, md->chn);
|
str = getInputStr(model, md->chn);
|
||||||
curDest = md->chn;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (firmware->getCapability(VirtualInputs))
|
if (firmware->getCapability(VirtualInputs))
|
||||||
|
@ -117,29 +159,10 @@ void InputsPanel::update()
|
||||||
QString expoName = md->name;
|
QString expoName = md->name;
|
||||||
if (!expoName.isEmpty()) str += QString(" [%1]").arg(expoName);
|
if (!expoName.isEmpty()) str += QString(" [%1]").arg(expoName);
|
||||||
}
|
}
|
||||||
|
|
||||||
qba.clear();
|
|
||||||
qba.append((quint8)i);
|
|
||||||
qba.append((const char*)md, sizeof(ExpoData));
|
|
||||||
QListWidgetItem *itm = new QListWidgetItem(str);
|
|
||||||
itm->setData(Qt::UserRole,qba); // expo number
|
|
||||||
ExposlistWidget->addItem(itm); //(str);
|
|
||||||
}
|
}
|
||||||
|
return Qt::escape(str).replace(" ", " ");
|
||||||
while (curDest<inputsCount-1) {
|
|
||||||
curDest++;
|
|
||||||
QString str = getInputStr(model, curDest);
|
|
||||||
qba.clear();
|
|
||||||
qba.append((quint8)-curDest-1);
|
|
||||||
QListWidgetItem *itm = new QListWidgetItem(str);
|
|
||||||
itm->setData(Qt::UserRole,qba); // add new expo
|
|
||||||
ExposlistWidget->addItem(itm);
|
|
||||||
}
|
|
||||||
|
|
||||||
lock = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InputsPanel::gm_insertExpo(int idx)
|
bool InputsPanel::gm_insertExpo(int idx)
|
||||||
{
|
{
|
||||||
if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) {
|
if (idx<0 || idx>=C9X_MAX_EXPOS || model.expoData[C9X_MAX_EXPOS-1].mode > 0) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ class InputsPanel : public ModelPanel
|
||||||
private:
|
private:
|
||||||
bool expoInserted;
|
bool expoInserted;
|
||||||
MixersList *ExposlistWidget;
|
MixersList *ExposlistWidget;
|
||||||
|
bool firstLine;
|
||||||
|
|
||||||
int getExpoIndex(unsigned int dch);
|
int getExpoIndex(unsigned int dch);
|
||||||
bool gm_insertExpo(int idx);
|
bool gm_insertExpo(int idx);
|
||||||
|
@ -43,6 +44,8 @@ class InputsPanel : public ModelPanel
|
||||||
QList<int> createExpoListFromSelected();
|
QList<int> createExpoListFromSelected();
|
||||||
void setSelectedByExpoList(QList<int> list);
|
void setSelectedByExpoList(QList<int> list);
|
||||||
void pasteExpoMimeData(const QMimeData * mimeData, int destIdx);
|
void pasteExpoMimeData(const QMimeData * mimeData, int destIdx);
|
||||||
|
bool AddInputLine(int dest, const ExpoData * md = 0);
|
||||||
|
QString getInputText(int dest, bool * new_ch);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ QSize MixersDelegate::sizeHint ( const QStyleOptionViewItem & option, const QMod
|
||||||
height = doc.size().height() + MIX_ROW_HEIGHT_INCREASE;
|
height = doc.size().height() + MIX_ROW_HEIGHT_INCREASE;
|
||||||
}
|
}
|
||||||
//qDebug() << "MixersDelegate::sizeHint() options.rect " << options.rect;
|
//qDebug() << "MixersDelegate::sizeHint() options.rect " << options.rect;
|
||||||
//qDebug() << "MixersDelegate::sizeHint() result " << QSize(doc.idealWidth(), height);
|
//qDebug() << "MixersDelegate::sizeHint() result " << QSize(doc.idealWidth(), height) << options.rect.width();
|
||||||
return QSize(doc.idealWidth(), height);
|
return QSize(doc.idealWidth(), height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,6 @@ void MixersDelegate::SetupDocument(QTextDocument & doc, const QStyleOptionViewIt
|
||||||
//setup html document
|
//setup html document
|
||||||
doc.setHtml(options.text);
|
doc.setHtml(options.text);
|
||||||
doc.setDefaultFont(options.font);
|
doc.setDefaultFont(options.font);
|
||||||
doc.setTextWidth(options.rect.width());
|
|
||||||
|
|
||||||
//minimize margins (default margins look ugly)
|
//minimize margins (default margins look ugly)
|
||||||
QTextFrame *tf = doc.rootFrame();
|
QTextFrame *tf = doc.rootFrame();
|
||||||
|
|
|
@ -57,7 +57,7 @@ QString MixesPanel::getChannelLabel(int curDest)
|
||||||
name.append(" ");
|
name.append(" ");
|
||||||
str += name.left(8);
|
str += name.left(8);
|
||||||
}
|
}
|
||||||
return str;
|
return Qt::escape(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixesPanel::update()
|
void MixesPanel::update()
|
||||||
|
@ -66,6 +66,7 @@ void MixesPanel::update()
|
||||||
// i -> mixer number
|
// i -> mixer number
|
||||||
QByteArray qba;
|
QByteArray qba;
|
||||||
MixerlistWidget->clear();
|
MixerlistWidget->clear();
|
||||||
|
firstLine = true;
|
||||||
unsigned int curDest = 0;
|
unsigned int curDest = 0;
|
||||||
int i;
|
int i;
|
||||||
unsigned int outputs = firmware->getCapability(Outputs);
|
unsigned int outputs = firmware->getCapability(Outputs);
|
||||||
|
@ -73,7 +74,10 @@ void MixesPanel::update()
|
||||||
for (i=0; i<firmware->getCapability(Mixes); i++) {
|
for (i=0; i<firmware->getCapability(Mixes); i++) {
|
||||||
MixData *md = &model.mixData[i];
|
MixData *md = &model.mixData[i];
|
||||||
// qDebug() << "md->destCh: " << md->destCh;
|
// qDebug() << "md->destCh: " << md->destCh;
|
||||||
if (md->destCh==0 || md->destCh>outputs) continue;
|
if (md->destCh==0 || md->destCh>outputs) {
|
||||||
|
qDebug() << "WARNING: possible mixer corrupiton at i" << i << "destCh" << md->destCh;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
QString str = "";
|
QString str = "";
|
||||||
while (curDest < md->destCh-1) {
|
while (curDest < md->destCh-1) {
|
||||||
curDest++;
|
curDest++;
|
||||||
|
@ -94,19 +98,20 @@ bool MixesPanel::AddMixerLine(int dest, const MixData * md)
|
||||||
{
|
{
|
||||||
bool new_ch;
|
bool new_ch;
|
||||||
QString str = getMixerText(dest, &new_ch);
|
QString str = getMixerText(dest, &new_ch);
|
||||||
QListWidgetItem *itm = new QListWidgetItem();
|
QListWidgetItem *itm = new QListWidgetItem(str);
|
||||||
QByteArray qba(1, (quint8)dest);
|
QByteArray qba(1, (quint8)dest);
|
||||||
if (md) qba.append((const char*)md, sizeof(MixData));
|
if (md) qba.append((const char*)md, sizeof(MixData));
|
||||||
itm->setData(Qt::UserRole, qba);
|
itm->setData(Qt::UserRole, qba);
|
||||||
#if MIX_ROW_HEIGHT_INCREASE > 0
|
#if MIX_ROW_HEIGHT_INCREASE > 0
|
||||||
if ((new_ch && (dest > 0)) || (dest < 0)) {
|
//if ((new_ch && (dest > 0)) || (dest < -1)) {
|
||||||
|
if (new_ch && ! firstLine ) {
|
||||||
//increase size of this row
|
//increase size of this row
|
||||||
itm->setData(GroupHeaderRole, 1);
|
itm->setData(GroupHeaderRole, 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
MixerlistWidget->addItem(itm);
|
MixerlistWidget->addItem(itm);
|
||||||
itm->setText(str);
|
firstLine = false;
|
||||||
//qDebug() << "MixesPanel::AddMixerLine(): " << str;
|
// qDebug() << "MixesPanel::AddMixerLine(): dest" << dest << "text" << str;
|
||||||
return new_ch;
|
return new_ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +125,7 @@ QString MixesPanel::getMixerText(int dest, bool * new_ch)
|
||||||
if (-dest == (int)highlightedSource) {
|
if (-dest == (int)highlightedSource) {
|
||||||
str = "<b>" + str + "</b>";
|
str = "<b>" + str + "</b>";
|
||||||
}
|
}
|
||||||
|
if (new_ch) *new_ch = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MixData *md = &model.mixData[dest];
|
MixData *md = &model.mixData[dest];
|
||||||
|
@ -333,7 +339,7 @@ void MixesPanel::mixersCopy()
|
||||||
|
|
||||||
void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
||||||
{
|
{
|
||||||
//qDebug() << "void MixesPanel::pasteMixerMimeData" << mimeData->formats();
|
qDebug() << "void MixesPanel::pasteMixerMimeData" << destIdx;
|
||||||
if(mimeData->hasFormat("application/x-companion-mix")) {
|
if(mimeData->hasFormat("application/x-companion-mix")) {
|
||||||
int idx; // mixer index
|
int idx; // mixer index
|
||||||
int dch;
|
int dch;
|
||||||
|
@ -346,6 +352,7 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
||||||
dch = model.mixData[idx].destCh;
|
dch = model.mixData[idx].destCh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "void MixesPanel::pasteMixerMimeData() dch" << dch;
|
||||||
QByteArray mxData = mimeData->data("application/x-companion-mix");
|
QByteArray mxData = mimeData->data("application/x-companion-mix");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -358,6 +365,7 @@ void MixesPanel::pasteMixerMimeData(const QMimeData * mimeData, int destIdx)
|
||||||
MixData *md = &model.mixData[idx];
|
MixData *md = &model.mixData[idx];
|
||||||
memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData));
|
memcpy(md,mxData.mid(i,sizeof(MixData)).constData(),sizeof(MixData));
|
||||||
md->destCh = dch;
|
md->destCh = dch;
|
||||||
|
qDebug() << "void MixesPanel::pasteMixerMimeData() dch1" << dch;
|
||||||
i += sizeof(MixData);
|
i += sizeof(MixData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +476,7 @@ void MixesPanel::mixerlistWidget_customContextMenuRequested(QPoint pos)
|
||||||
void MixesPanel::mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction /*action*/)
|
void MixesPanel::mimeMixerDropped(int index, const QMimeData *data, Qt::DropAction /*action*/)
|
||||||
{
|
{
|
||||||
int idx= MixerlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0);
|
int idx= MixerlistWidget->item(index > 0 ? index-1 : 0)->data(Qt::UserRole).toByteArray().at(0);
|
||||||
//qDebug() << "MixesPanel::mimeMixerDropped()" << index << data;
|
qDebug() << "MixesPanel::mimeMixerDropped()" << index << data;
|
||||||
pasteMixerMimeData(data, idx);
|
pasteMixerMimeData(data, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ class MixesPanel : public ModelPanel
|
||||||
MixersList *MixerlistWidget;
|
MixersList *MixerlistWidget;
|
||||||
bool mixInserted;
|
bool mixInserted;
|
||||||
unsigned int highlightedSource;
|
unsigned int highlightedSource;
|
||||||
|
bool firstLine;
|
||||||
|
|
||||||
int getMixerIndex(unsigned int dch);
|
int getMixerIndex(unsigned int dch);
|
||||||
bool gm_insertMix(int idx);
|
bool gm_insertMix(int idx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue