in my profile combo box: sort instruments alphabetical and show category by background color
This commit is contained in:
parent
a95038bf13
commit
78b61cf01b
1 changed files with 23 additions and 5 deletions
24
src/util.cpp
24
src/util.cpp
|
@ -592,13 +592,31 @@ CMusProfDlg::CMusProfDlg ( CClient* pNCliP,
|
||||||
// add an entry for all known instruments
|
// add an entry for all known instruments
|
||||||
for ( int iCurInst = 0; iCurInst < CInstPictures::GetNumAvailableInst(); iCurInst++ )
|
for ( int iCurInst = 0; iCurInst < CInstPictures::GetNumAvailableInst(); iCurInst++ )
|
||||||
{
|
{
|
||||||
// create a combo box item with text and image
|
// create a combo box item with text, image and background color
|
||||||
pcbxInstrument->addItem (
|
QColor InstrColor;
|
||||||
QIcon ( CInstPictures::GetResourceReference ( iCurInst ) ),
|
|
||||||
|
pcbxInstrument->addItem ( QIcon ( CInstPictures::GetResourceReference ( iCurInst ) ),
|
||||||
CInstPictures::GetName ( iCurInst ),
|
CInstPictures::GetName ( iCurInst ),
|
||||||
iCurInst );
|
iCurInst );
|
||||||
|
|
||||||
|
switch ( CInstPictures::GetCategory ( iCurInst ) )
|
||||||
|
{
|
||||||
|
case CInstPictures::IC_OTHER_INSTRUMENT: InstrColor = QColor ( Qt::blue ); break;
|
||||||
|
case CInstPictures::IC_WIND_INSTRUMENT: InstrColor = QColor ( Qt::green ); break;
|
||||||
|
case CInstPictures::IC_STRING_INSTRUMENT: InstrColor = QColor ( Qt::red ); break;
|
||||||
|
case CInstPictures::IC_PLUCKING_INSTRUMENT: InstrColor = QColor ( Qt::cyan ); break;
|
||||||
|
case CInstPictures::IC_PERCUSSION_INSTRUMENT: InstrColor = QColor ( Qt::white ); break;
|
||||||
|
case CInstPictures::IC_KEYBOARD_INSTRUMENT: InstrColor = QColor ( Qt::yellow ); break;
|
||||||
|
case CInstPictures::IC_MULTIPLE_INSTRUMENT: InstrColor = QColor ( Qt::black ); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InstrColor.setAlpha ( 10 );
|
||||||
|
pcbxInstrument->setItemData ( iCurInst, InstrColor, Qt::BackgroundRole );
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort the items in alphabetical order
|
||||||
|
pcbxInstrument->model()->sort ( 0 );
|
||||||
|
|
||||||
|
|
||||||
// Country flag icons combo box --------------------------------------------
|
// Country flag icons combo box --------------------------------------------
|
||||||
// add an entry for all known country flags
|
// add an entry for all known country flags
|
||||||
|
|
Loading…
Reference in a new issue