Ticket #3957: 3957_diff.patch

File 3957_diff.patch, 2.1 KB (added by Joe Ripley <vitaminjoe@…>, 17 years ago)

Patch mythbackend to properly add commas to numbers > 1000 for mythweb status page

  • mythtv/programs/mythbackend/httpstatus.h

     
    6363        int     PrintScheduled    ( QTextStream &os, QDomElement scheduled );
    6464        int     PrintJobQueue     ( QTextStream &os, QDomElement jobs );
    6565        int     PrintMachineInfo  ( QTextStream &os, QDomElement info );
     66        QString addCommas         ( int num );
    6667
    6768    public:
    6869                 HttpStatus( QMap<int, EncoderLink *> *tvList, Scheduler *sched, AutoExpire *expirer, bool bIsMaster );
  • mythtv/programs/mythbackend/httpstatus.cpp

     
    11331133                }
    11341134
    11351135                os << "            <li>Total Space: ";
    1136                 sRep.sprintf( "%d,%03d MB ", (nTotal) / 1000, (nTotal) % 1000);
    1137                 os << sRep << "</li>\r\n";
     1136                sRep = addCommas(nTotal);
     1137                os << sRep << " MB </li>\r\n";
    11381138
    11391139                os << "            <li>Space Used: ";
    1140                 sRep.sprintf( "%d,%03d MB ", (nUsed) / 1000, (nUsed) % 1000);
    1141                 os << sRep << "</li>\r\n";
     1140                sRep = addCommas(nUsed);
     1141                os << sRep << " MB</li>\r\n";
    11421142
    11431143                os << "            <li>Space Free: ";
    1144                 sRep.sprintf( "%d,%03d MB ", (nFree) / 1000, (nFree) % 1000);
    1145                 os << sRep << "</li>\r\n";
     1144                sRep = addCommas(nFree);
     1145                os << sRep << " MB</li>\r\n";
    11461146
    11471147                os << "          </ul>\r\n"
    11481148                   << "        </li>\r\n";
     
    12371237    return( 1 );
    12381238}
    12391239
     1240QString HttpStatus::addCommas ( int num ) {
     1241    QString x = QString::number( num );
     1242    int count = x.length();
     1243    int i;
     1244
     1245    for (i=3;i<count;i+=4) {
     1246        x.insert(i, ",");
     1247    }
     1248
     1249    return x;
     1250}
     1251
    12401252// vim:set shiftwidth=4 tabstop=4 expandtab: