Changeset 112 for trunk/lib/Directory.cc


Ignore:
Timestamp:
Jun 29, 2006, 11:30:54 AM (15 years ago)
Author:
Peter Johansson
Message:

fixes #27 and added some beauty

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r101 r112  
    4343
    4444
    45   Directory::Directory(const std::string& path, const std::string& output)
    46     : Node(path,output)
     45  Directory::Directory(const u_int level, const std::string& path,
     46                       const std::string& output)
     47    : Node(level,path,output)
    4748  {
    4849    using namespace std;
     
    6970          lstat(fullpath.c_str(),&nodestat);   // C api from sys/stat.h
    7071          if (S_ISDIR(nodestat.st_mode))       // C api from sys/stat.h
    71             daughters_.push_back(new Directory(fullpath, output_name()+"/"));
     72            daughters_.push_back(new Directory(level_+1,fullpath,
     73                                               output_name()+"/"));
    7274          else
    73             daughters_.push_back(new File(fullpath,output_name()+"/"));
     75            daughters_.push_back(new File(level_,fullpath,output_name()+"/"));
    7476          break;
    7577        case SVN::unresolved:
     
    8890  }
    8991
     92  std::string Directory::author(void) const
     93  {
     94    std::string a;
     95    u_int max_rev=0;
     96    for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); i++)
     97      if ((*i)->last_changed_rev()>max_rev){
     98        max_rev = (*i)->last_changed_rev();
     99        a = (*i)->author();
     100      }
     101    return a;
     102  }
     103
    90104  bool Directory::dir(void) const
    91105  {
     
    96110  {
    97111    return "<a href=\"" + name() + "/index.html\">" + name() + "</a>";
     112  }
     113
     114  u_int Directory::last_changed_rev(void) const
     115  {
     116    u_int max_rev=0;
     117    for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); i++)
     118      if ((*i)->last_changed_rev()>max_rev)
     119        max_rev = (*i)->last_changed_rev();
     120    return max_rev;
    98121  }
    99122
     
    120143       << file_name(stats_.plot(output_name()+"/index.png", output_name()))
    121144       << "' alt='[plot]' border=0><br>\n";
    122     os << "<table>\n";
    123     os << "<tr>\n<td><strong>Node</strong></td>\n";
    124     os << "<td><strong>Count</strong></td>\n</tr>\n";
    125     os << "<tr>\n<td bgcolor=#dddddd>Total</td>\n";
    126     os << "<td align=right bgcolor=#dddddd>" << stats_.rows()
    127        << "</td>\n</tr>\n";
     145    os << "<table class=\"listings\">\n";
     146    os << "<thead>";
     147    os << "<tr>\n";
     148    os << "<th>Node</th>\n";
     149    os << "<th>Lines</th>\n";
     150    os << "<th>Code</th>\n";
     151    os << "<th>Comments</th>\n";
     152    os << "<th>Revision</th>\n";
     153    os << "<th>Author</th>\n";
     154    os << "</tr>\n</thead>\n";
     155    os << "<tbody>";
     156
     157    bool dark=false;
     158    if (level_){
     159      os << "<tr class=\"light\">\n";
     160      os << "<td colspan=\"6\"><a href=\"../index.html\">../</a></td>\n";
     161      os << "</tr>\n";
     162      dark=!dark;
     163    }
    128164
    129165    // print html links to daughter nodes
    130     bool dark=true;
    131166    for (NodeConstIterator d = daughters_.begin(); d!=daughters_.end(); d++){
    132167      if (dark)
    133         os << (*d)->html_tablerow("#eeeeee");
     168        os << (*d)->html_tablerow("dark");
    134169      else
    135         os << (*d)->html_tablerow("#dddddd");
     170        os << (*d)->html_tablerow("light");
    136171      dark = !dark;
    137172    }
     173    if (dark)
     174      os << "<tr class=\"dark\">\n";
     175    else
     176      os << "<tr class=\"light\">\n";
     177    os << "<td>Total</td>\n";
     178    os << "<td>" << stats_.rows() << "</td>\n";
     179    os << "<td>---</td>\n";
     180    os << "<td>---</td>\n";
     181    os << "<td>" << stats_.last_changed_rev() << "</td>\n";
     182    os << "<td>" << author() << "</td>\n";
     183    os << "</tr>\n";
    138184    os << "</table>\n";
    139185    os << "</p>\n";
Note: See TracChangeset for help on using the changeset viewer.