diff options
| -rw-r--r-- | client/macrowindow.cc | 5 | ||||
| -rw-r--r-- | client/macrowindow.h | 3 | ||||
| -rw-r--r-- | client/mainwindow.cc | 4 | ||||
| -rw-r--r-- | client/resumewidget.cc | 36 | 
4 files changed, 34 insertions, 14 deletions
| diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 18ed218..ac44b06 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -43,13 +43,14 @@ extern QString user;  extern QString host;  extern quint16 port; -MacroWindow::MacroWindow(NetCom *netcom, QDomNode &xml_doc, QString course, bool collapsed) +MacroWindow::MacroWindow(NetCom *netcom, QDomNode &xml_doc, QString course, +                         bool collapsed, bool compact)    : Collapser()  {    this->course = course;    this->netcom = netcom; -  setCollapsedWidget(new ResumeWidget()); +  setCollapsedWidget(new ResumeWidget(compact));    this->lua = new LUA(this); diff --git a/client/macrowindow.h b/client/macrowindow.h index f42a5a1..76d068c 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -47,7 +47,8 @@ class MacroWindow : public Collapser  {  Q_OBJECT  public: -  MacroWindow(NetCom *netcom, QDomNode &xml_doc, QString course, bool collapsed = true); +  MacroWindow(NetCom *netcom, QDomNode &xml_doc, QString course, +              bool collapsed = true, bool compact = false);    ~MacroWindow();    bool isClosed(); diff --git a/client/mainwindow.cc b/client/mainwindow.cc index bcb1b4e..0997c53 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -81,8 +81,10 @@ void MainWindow::update()        if(macros.find(macroname) == macros.end()) {          bool isstatic = false; +        bool iscompact = false;          if(xml_elem.attribute("static", "false") == "true") isstatic = true; -        macros[macroname] = new MacroWindow(&netcom, macronode, course, !isstatic); +        if(xml_elem.attribute("compact", "false") == "true") iscompact = true; +        macros[macroname] = new MacroWindow(&netcom, macronode, course, !isstatic, iscompact);          QGroupBox *g = new QGroupBox();          g->setTitle("      " + xml_elem.attribute("caption", macroname)); diff --git a/client/resumewidget.cc b/client/resumewidget.cc index d5b1825..6581797 100644 --- a/client/resumewidget.cc +++ b/client/resumewidget.cc @@ -29,30 +29,31 @@  #include <QHBoxLayout>  #include <QBoxLayout> -//#define RICH -ResumeWidget::ResumeWidget() +#define MAX_COMPACT_SIZE 100 + +//#define RICH // Experimental syntax highlighter (numbers turn blue) + +ResumeWidget::ResumeWidget(bool compact)  { +  this->compact = compact;    setLayout(new QHBoxLayout());    layout()->setContentsMargins(10,2,2,2); -  resume = new QLabel("Endnu ikke udfyldt"); +  resume = new QLabel("<font style='color: #ccc;'>Endnu ikke udfyldt</font>");  #ifdef RICH    resume->setTextFormat(Qt::RichText);  #endif    resume->setWordWrap(true); -  resume->setEnabled(false);    layout()->addWidget(resume);  }  void ResumeWidget::setText(QString text)  { -  resume->setEnabled(true); - -#ifdef RICH    QString f; +#ifdef RICH    for(int i = 0; i < text.length(); i++) {      if(text[i] >= '0' && text[i] <= '9') f += "<font style='color: #55F;'>" + text[i] + "</font>";      else if(text[i] == '\n') f += "<br/>"; @@ -60,10 +61,25 @@ void ResumeWidget::setText(QString text)      else f += text[i];    } -  resume->setText(f);    resume->setWordWrap(true);  #else -  resume->setText(text); +  f = text;  #endif -} +  if(compact) { +    QString origtext = f; + +    if(f.count('\n') > 0) f = f.left(f.indexOf('\n')); // Limit to one line. +     +    if(f.length() > MAX_COMPACT_SIZE) { +      f = f.left(MAX_COMPACT_SIZE); // limit to first MAX_COMPACT_SIZE characters. +    } +     +    if(text != f) { +      f += " <font style='color: #0b0;'>...</font>"; +      resume->setToolTip(origtext); // Only set tooltip if resume has actually been cut off. +    } +  } + +  resume->setText(f); +} | 
