mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +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.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "icon.h"
|
#include "blackmisc/icon.h"
|
||||||
|
#include "blackmisc/iconlist.h"
|
||||||
#include "blackmisc/pq/angle.h"
|
#include "blackmisc/pq/angle.h"
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
@@ -47,4 +48,17 @@ namespace BlackMisc
|
|||||||
return s;
|
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
|
} // namespace
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ namespace BlackMisc
|
|||||||
//! \copydoc CValueObject::convertToQString
|
//! \copydoc CValueObject::convertToQString
|
||||||
virtual QString convertToQString(bool i18n = false) const override;
|
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:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CIcon)
|
BLACK_ENABLE_TUPLE_CONVERSION(CIcon)
|
||||||
int m_index = static_cast<int>(CIcons::NotSet);
|
int m_index = static_cast<int>(CIcons::NotSet);
|
||||||
|
|||||||
@@ -151,14 +151,11 @@ namespace BlackMisc
|
|||||||
|
|
||||||
const CIcon &CIconList::iconByIndex(CIcons::IconIndex index)
|
const CIcon &CIconList::iconByIndex(CIcons::IconIndex index)
|
||||||
{
|
{
|
||||||
return iconByIndex(static_cast<int>(index));
|
return CIcon::iconByIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CIcon &CIconList::iconByIndex(int index)
|
const CIcon &CIconList::iconByIndex(int index)
|
||||||
{
|
{
|
||||||
// changed to index / at based approach during #322 (after Sleepy profiling)
|
return CIcon::iconByIndex(index);
|
||||||
// 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];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,11 +46,12 @@ namespace BlackMisc
|
|||||||
static const CIconList &allIcons();
|
static const CIconList &allIcons();
|
||||||
|
|
||||||
//! Icon for given index
|
//! Icon for given index
|
||||||
|
//! \deprecated Use CIcon::iconByIndex instead.
|
||||||
static const CIcon &iconByIndex(CIcons::IconIndex index);
|
static const CIcon &iconByIndex(CIcons::IconIndex index);
|
||||||
|
|
||||||
//! Icon for given index
|
//! Icon for given index
|
||||||
|
//! \deprecated Use CIcon::iconByIndex instead.
|
||||||
static const CIcon &iconByIndex(int index);
|
static const CIcon &iconByIndex(int index);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user