mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #413 Moved iconByIndex method from CIconList to CIcon, to reduce coupling.
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "icon.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/iconlist.h"
|
||||
#include "blackmisc/pq/angle.h"
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -47,4 +48,17 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
const CIcon &CIcon::iconByIndex(CIcons::IconIndex index)
|
||||
{
|
||||
return iconByIndex(static_cast<int>(index));
|
||||
}
|
||||
|
||||
const CIcon &CIcon::iconByIndex(int index)
|
||||
{
|
||||
// changed to index / at based approach during #322 (after Sleepy profiling)
|
||||
// this seems to be faster as the findBy approach previously used, but required synced indexes
|
||||
Q_ASSERT_X(index >= 0 && index < CIconList::allIcons().size(), "iconForIndex", "wrong index");
|
||||
return CIconList::allIcons()[index];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -67,6 +67,12 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
//! Icon for given index
|
||||
static const CIcon &iconByIndex(CIcons::IconIndex index);
|
||||
|
||||
//! Icon for given index
|
||||
static const CIcon &iconByIndex(int index);
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CIcon)
|
||||
int m_index = static_cast<int>(CIcons::NotSet);
|
||||
|
||||
@@ -151,14 +151,11 @@ namespace BlackMisc
|
||||
|
||||
const CIcon &CIconList::iconByIndex(CIcons::IconIndex index)
|
||||
{
|
||||
return iconByIndex(static_cast<int>(index));
|
||||
return CIcon::iconByIndex(index);
|
||||
}
|
||||
|
||||
const CIcon &CIconList::iconByIndex(int index)
|
||||
{
|
||||
// changed to index / at based approach during #322 (after Sleepy profiling)
|
||||
// this seems to be faster as the findBy approach previously used, but required synced indexes
|
||||
Q_ASSERT_X(index >= 0 && index < allIcons().size(), "iconForIndex", "wrong index");
|
||||
return allIcons()[index];
|
||||
return CIcon::iconByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,11 +46,12 @@ namespace BlackMisc
|
||||
static const CIconList &allIcons();
|
||||
|
||||
//! Icon for given index
|
||||
//! \deprecated Use CIcon::iconByIndex instead.
|
||||
static const CIcon &iconByIndex(CIcons::IconIndex index);
|
||||
|
||||
//! Icon for given index
|
||||
//! \deprecated Use CIcon::iconByIndex instead.
|
||||
static const CIcon &iconByIndex(int index);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user