mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
Ref T673, hide values marked as incognito column
This commit is contained in:
committed by
Mat Sutcliffe
parent
235508ec98
commit
538ea297e4
@@ -458,5 +458,12 @@ namespace BlackGui
|
||||
return empty;
|
||||
}
|
||||
|
||||
CVariant CIncognitoFormatter::displayRole(const CVariant &dataCVariant) const
|
||||
{
|
||||
Q_UNUSED(dataCVariant);
|
||||
static const CVariant masked("******");
|
||||
return masked;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -179,6 +179,17 @@ namespace BlackGui
|
||||
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
|
||||
class CDelegateFormatter : public CDefaultFormatter
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "blackgui/models/columns.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/compare.h"
|
||||
|
||||
#include <QByteArray>
|
||||
@@ -39,6 +40,14 @@ namespace BlackGui
|
||||
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) :
|
||||
m_columnToolTip(toolTip), m_formatter(new CPixmapFormatter()), m_propertyIndex(propertyIndex)
|
||||
{}
|
||||
@@ -80,6 +89,12 @@ namespace BlackGui
|
||||
return col;
|
||||
}
|
||||
|
||||
const CIncognitoFormatter *CColumn::incongitoFormatter()
|
||||
{
|
||||
static const CIncognitoFormatter incognito;
|
||||
return &incognito;
|
||||
}
|
||||
|
||||
// --------------- columns ----------------------------------------------
|
||||
|
||||
CColumns::CColumns(const QString &translationContext, QObject *parent) :
|
||||
@@ -88,16 +103,24 @@ namespace BlackGui
|
||||
// void
|
||||
}
|
||||
|
||||
void CColumns::addColumn(CColumn column)
|
||||
void CColumns::addColumn(const CColumn &column)
|
||||
{
|
||||
Q_ASSERT(!m_translationContext.isEmpty());
|
||||
column.setTranslationContext(m_translationContext);
|
||||
m_columns.push_back(column);
|
||||
CColumn copy(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
|
||||
{
|
||||
int column = this->propertyIndexToColumn(propertyIndex);
|
||||
const int column = this->propertyIndexToColumn(propertyIndex);
|
||||
Q_UNUSED(i18n); // not implemented
|
||||
return m_columns.at(column).getColumnName();
|
||||
}
|
||||
@@ -258,8 +281,9 @@ namespace BlackGui
|
||||
|
||||
const CDefaultFormatter *CColumns::getFormatter(const QModelIndex &index) const
|
||||
{
|
||||
if (!isValidColumn(index)) { return nullptr; }
|
||||
return m_columns.at(index.column()).getFormatter();
|
||||
if (!this->isValidColumn(index)) { return nullptr; }
|
||||
const CColumn c = m_columns.at(index.column());
|
||||
return c.getFormatter();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace BlackGui
|
||||
void setFormatter(CDefaultFormatter *formatter) { Q_ASSERT(formatter); m_formatter.reset(formatter); }
|
||||
|
||||
//! Formatter
|
||||
const CDefaultFormatter *getFormatter() const { return m_formatter.data(); }
|
||||
const CDefaultFormatter *getFormatter() const;
|
||||
|
||||
//! Aligment as CVariant
|
||||
BlackMisc::CVariant getAlignment() const;
|
||||
@@ -100,6 +100,12 @@ namespace BlackGui
|
||||
//! Width percentage
|
||||
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
|
||||
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_sortPropertyIndex; //!< Property index used when sorted (optional alternative)
|
||||
|
||||
bool m_editable = false;
|
||||
bool m_sortable = true;
|
||||
//! Incognito formatter
|
||||
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);
|
||||
|
||||
//! 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
|
||||
QString propertyIndexToColumnName(const BlackMisc::CPropertyIndex &propertyIndex, bool i18n = false) const;
|
||||
@@ -230,10 +243,10 @@ namespace BlackGui
|
||||
bool endsWithEmptyColumn() const;
|
||||
|
||||
private:
|
||||
QList<CColumn> m_columns;
|
||||
QList<CColumn> m_columns; //!< all columns
|
||||
QString m_translationContext; //!< for future usage
|
||||
};
|
||||
}
|
||||
} // namespace BlackGui
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user