mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Ref T673, hide values marked as incognito column
This commit is contained in:
@@ -458,5 +458,12 @@ namespace BlackGui
|
|||||||
return empty;
|
return empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CVariant CIncognitoFormatter::displayRole(const CVariant &dataCVariant) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(dataCVariant);
|
||||||
|
static const CVariant masked("******");
|
||||||
|
return masked;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -179,6 +179,17 @@ namespace BlackGui
|
|||||||
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &dataCVariant) const override;
|
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &dataCVariant) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Just returns a empty "" value
|
||||||
|
class CIncognitoFormatter : public CDefaultFormatter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
CIncognitoFormatter(int alignment = alignDefault()) : CDefaultFormatter(alignment, false, roleDisplay()) {}
|
||||||
|
|
||||||
|
//! \copydoc CDefaultFormatter::displayRole
|
||||||
|
virtual BlackMisc::CVariant displayRole(const BlackMisc::CVariant &dataCVariant) const override;
|
||||||
|
};
|
||||||
|
|
||||||
//! Layout will be defined by a delegate
|
//! Layout will be defined by a delegate
|
||||||
class CDelegateFormatter : public CDefaultFormatter
|
class CDelegateFormatter : public CDefaultFormatter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackgui/models/columns.h"
|
#include "blackgui/models/columns.h"
|
||||||
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackmisc/compare.h"
|
#include "blackmisc/compare.h"
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
@@ -39,6 +40,14 @@ namespace BlackGui
|
|||||||
m_sortPropertyIndex = propertyIndex;
|
m_sortPropertyIndex = propertyIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CDefaultFormatter *CColumn::getFormatter() const
|
||||||
|
{
|
||||||
|
const bool incogntio = this->isIncognito() && sGui && sGui->isIncognito();
|
||||||
|
return incogntio ?
|
||||||
|
CColumn::incongitoFormatter() :
|
||||||
|
m_formatter.data();
|
||||||
|
}
|
||||||
|
|
||||||
CColumn::CColumn(const QString &toolTip, const CPropertyIndex &propertyIndex) :
|
CColumn::CColumn(const QString &toolTip, const CPropertyIndex &propertyIndex) :
|
||||||
m_columnToolTip(toolTip), m_formatter(new CPixmapFormatter()), m_propertyIndex(propertyIndex)
|
m_columnToolTip(toolTip), m_formatter(new CPixmapFormatter()), m_propertyIndex(propertyIndex)
|
||||||
{}
|
{}
|
||||||
@@ -80,6 +89,12 @@ namespace BlackGui
|
|||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CIncognitoFormatter *CColumn::incongitoFormatter()
|
||||||
|
{
|
||||||
|
static const CIncognitoFormatter incognito;
|
||||||
|
return &incognito;
|
||||||
|
}
|
||||||
|
|
||||||
// --------------- columns ----------------------------------------------
|
// --------------- columns ----------------------------------------------
|
||||||
|
|
||||||
CColumns::CColumns(const QString &translationContext, QObject *parent) :
|
CColumns::CColumns(const QString &translationContext, QObject *parent) :
|
||||||
@@ -88,16 +103,24 @@ namespace BlackGui
|
|||||||
// void
|
// void
|
||||||
}
|
}
|
||||||
|
|
||||||
void CColumns::addColumn(CColumn column)
|
void CColumns::addColumn(const CColumn &column)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_translationContext.isEmpty());
|
Q_ASSERT(!m_translationContext.isEmpty());
|
||||||
column.setTranslationContext(m_translationContext);
|
CColumn copy(column);
|
||||||
m_columns.push_back(column);
|
copy.setTranslationContext(m_translationContext);
|
||||||
|
m_columns.push_back(copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CColumns::addColumnIncognito(const CColumn &column)
|
||||||
|
{
|
||||||
|
CColumn copy(column);
|
||||||
|
copy.setIncognito(true);
|
||||||
|
this->addColumn(copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CColumns::propertyIndexToColumnName(const CPropertyIndex &propertyIndex, bool i18n) const
|
QString CColumns::propertyIndexToColumnName(const CPropertyIndex &propertyIndex, bool i18n) const
|
||||||
{
|
{
|
||||||
int column = this->propertyIndexToColumn(propertyIndex);
|
const int column = this->propertyIndexToColumn(propertyIndex);
|
||||||
Q_UNUSED(i18n); // not implemented
|
Q_UNUSED(i18n); // not implemented
|
||||||
return m_columns.at(column).getColumnName();
|
return m_columns.at(column).getColumnName();
|
||||||
}
|
}
|
||||||
@@ -258,8 +281,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
const CDefaultFormatter *CColumns::getFormatter(const QModelIndex &index) const
|
const CDefaultFormatter *CColumns::getFormatter(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
if (!isValidColumn(index)) { return nullptr; }
|
if (!this->isValidColumn(index)) { return nullptr; }
|
||||||
return m_columns.at(index.column()).getFormatter();
|
const CColumn c = m_columns.at(index.column());
|
||||||
|
return c.getFormatter();
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace BlackGui
|
|||||||
void setFormatter(CDefaultFormatter *formatter) { Q_ASSERT(formatter); m_formatter.reset(formatter); }
|
void setFormatter(CDefaultFormatter *formatter) { Q_ASSERT(formatter); m_formatter.reset(formatter); }
|
||||||
|
|
||||||
//! Formatter
|
//! Formatter
|
||||||
const CDefaultFormatter *getFormatter() const { return m_formatter.data(); }
|
const CDefaultFormatter *getFormatter() const;
|
||||||
|
|
||||||
//! Aligment as CVariant
|
//! Aligment as CVariant
|
||||||
BlackMisc::CVariant getAlignment() const;
|
BlackMisc::CVariant getAlignment() const;
|
||||||
@@ -100,6 +100,12 @@ namespace BlackGui
|
|||||||
//! Width percentage
|
//! Width percentage
|
||||||
void setWidthPercentage(int width) { m_widthPercentage = width; }
|
void setWidthPercentage(int width) { m_widthPercentage = width; }
|
||||||
|
|
||||||
|
//! If incognito mode, do NOT display daza
|
||||||
|
bool isIncognito() const { return m_incognito; }
|
||||||
|
|
||||||
|
//! Mark as incognito enabled
|
||||||
|
void setIncognito(bool incognito) { m_incognito = incognito; }
|
||||||
|
|
||||||
//! Get a standard value object formatted column
|
//! Get a standard value object formatted column
|
||||||
static CColumn standardValueObject(const QString &headerName, const BlackMisc::CPropertyIndex &propertyIndex, int alignment = CDefaultFormatter::alignDefault());
|
static CColumn standardValueObject(const QString &headerName, const BlackMisc::CPropertyIndex &propertyIndex, int alignment = CDefaultFormatter::alignDefault());
|
||||||
|
|
||||||
@@ -130,8 +136,12 @@ namespace BlackGui
|
|||||||
BlackMisc::CPropertyIndex m_propertyIndex; //!< Property index for column
|
BlackMisc::CPropertyIndex m_propertyIndex; //!< Property index for column
|
||||||
BlackMisc::CPropertyIndex m_sortPropertyIndex; //!< Property index used when sorted (optional alternative)
|
BlackMisc::CPropertyIndex m_sortPropertyIndex; //!< Property index used when sorted (optional alternative)
|
||||||
|
|
||||||
bool m_editable = false;
|
//! Incognito formatter
|
||||||
bool m_sortable = true;
|
static const CIncognitoFormatter *incongitoFormatter();
|
||||||
|
|
||||||
|
bool m_editable = false;
|
||||||
|
bool m_sortable = true;
|
||||||
|
bool m_incognito = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -150,7 +160,10 @@ namespace BlackGui
|
|||||||
CColumns(const QString &translationContext, QObject *parent = nullptr);
|
CColumns(const QString &translationContext, QObject *parent = nullptr);
|
||||||
|
|
||||||
//! Add a column
|
//! Add a column
|
||||||
void addColumn(CColumn column);
|
void addColumn(const CColumn &column);
|
||||||
|
|
||||||
|
//! Add a column as incognito enabled
|
||||||
|
void addColumnIncognito(const CColumn &column);
|
||||||
|
|
||||||
//! Property index to name
|
//! Property index to name
|
||||||
QString propertyIndexToColumnName(const BlackMisc::CPropertyIndex &propertyIndex, bool i18n = false) const;
|
QString propertyIndexToColumnName(const BlackMisc::CPropertyIndex &propertyIndex, bool i18n = false) const;
|
||||||
@@ -230,10 +243,10 @@ namespace BlackGui
|
|||||||
bool endsWithEmptyColumn() const;
|
bool endsWithEmptyColumn() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<CColumn> m_columns;
|
QList<CColumn> m_columns; //!< all columns
|
||||||
QString m_translationContext; //!< for future usage
|
QString m_translationContext; //!< for future usage
|
||||||
};
|
};
|
||||||
}
|
} // ns
|
||||||
} // namespace BlackGui
|
} // ns
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user