diff options
author | deva <deva> | 2008-12-01 15:28:44 +0000 |
---|---|---|
committer | deva <deva> | 2008-12-01 15:28:44 +0000 |
commit | 3ab207d95e47f81cf75effee3822cd787979cae7 (patch) | |
tree | 2b80cd75e0deeee1a5a3a20ba8f9716470dd99f9 /client/resumewidget.cc | |
parent | 40bad69cd77f32730f6939553d7f9667338c646f (diff) |
Added 'compact' attribute in templates.
Diffstat (limited to 'client/resumewidget.cc')
-rw-r--r-- | client/resumewidget.cc | 36 |
1 files changed, 26 insertions, 10 deletions
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); +} |