forked from qt-creator/qt-creator
Centralize handling of file-kind variables.
Change-Id: I400e28ae7d1d4f0250519dcd3c85746da1ea1e93 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
|
||||
static const char kFilePathPostfix[] = ":FilePath";
|
||||
static const char kPathPostfix[] = ":Path";
|
||||
|
||||
namespace Core {
|
||||
|
||||
class VMMapExpander : public Utils::AbstractQtcMacroExpander
|
||||
@@ -117,6 +120,34 @@ void VariableManager::registerVariable(const QByteArray &variable, const QString
|
||||
d->m_descriptions.insert(variable, description);
|
||||
}
|
||||
|
||||
void VariableManager::registerFileVariables(const QByteArray &prefix, const QString &heading)
|
||||
{
|
||||
registerVariable(prefix + kFilePathPostfix, tr("%1: Full path including file name.").arg(heading));
|
||||
registerVariable(prefix + kPathPostfix, tr("%1: Full path excluding file name.").arg(heading));
|
||||
}
|
||||
|
||||
bool VariableManager::isFileVariable(const QByteArray &variable, const QByteArray &prefix)
|
||||
{
|
||||
return variable == prefix + kFilePathPostfix
|
||||
|| variable == prefix + kPathPostfix;
|
||||
}
|
||||
|
||||
QString VariableManager::fileVariableValue(const QByteArray &variable, const QByteArray &prefix,
|
||||
const QString &fileName)
|
||||
{
|
||||
return fileVariableValue(variable, prefix, QFileInfo(fileName));
|
||||
}
|
||||
|
||||
QString VariableManager::fileVariableValue(const QByteArray &variable, const QByteArray &prefix,
|
||||
const QFileInfo &fileInfo)
|
||||
{
|
||||
if (variable == prefix + kFilePathPostfix)
|
||||
return fileInfo.filePath();
|
||||
else if (variable == prefix + kPathPostfix)
|
||||
return fileInfo.path();
|
||||
return QString();
|
||||
}
|
||||
|
||||
QList<QByteArray> VariableManager::variables() const
|
||||
{
|
||||
return d->m_descriptions.keys();
|
||||
|
||||
Reference in New Issue
Block a user