fieldnames.cpp 1.7 KB
Newer Older
1
/* This file is part of the Chakra project
2

3 4 5 6 7 8 9 10 11
   Copyright (C) 2011 Daniele Cocca <daniele.cocca@gmail.com>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#include <fieldnames.h>
12 13 14 15

FieldNames::FieldNames()
  : maxFieldLength( 0 )
{
16 17 18 19 20 21 22
  insert("Name:");
  insert("Available version:");
  insert("Homepage:");
  insert("Licenses:");
  insert("Groups:");
  insert("Provides:");
  insert("Depends on:");
23
  insert("Make dependencies:");
24 25 26 27 28 29 30 31 32 33 34 35 36 37
  insert("Optional dependencies:");
  insert("Required by:");
  insert("Replaces:");
  insert("Installation size:");
  insert("Packager:");
  insert("Architecture:");
  insert("Creation time:");
  insert("Installation time:");
  insert("Install reason:");
  insert("Installation script:");
  insert("Description:");
  insert("MD5 sum:");
  insert("Repository:");
  insert("Installed version:");
38 39 40 41 42
}

QHash< QString, QString >::iterator FieldNames::insert(QString const& key)
{
  // get translated string
43
  QString value(key);
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

  // compute the new maximum length
  maxFieldLength = qMax(static_cast<unsigned int>( value.length() ), maxFieldLength);

  // associate the string with its translation
  return QHash< QString, QString >::insert(key, value);
}

QString const FieldNames::value(QString const& key) const
{
  if (contains(key)) {
    return value(key);
  }

  // default to an untranslated string
  return key;
}

unsigned int FieldNames::getMaxFieldLength() const
{
  return maxFieldLength;
}

FieldNames const& FieldNames::instance()
{
  static FieldNames const __instance;
  return __instance;
}