diff options
author | deva <deva> | 2006-03-09 11:03:35 +0000 |
---|---|---|
committer | deva <deva> | 2006-03-09 11:03:35 +0000 |
commit | 0eb1af1add19c8ffb8f5ab11f74810366f1beed1 (patch) | |
tree | 06191ba6af6cbb474f670c5ecd729e48989791af /client/historyframe.cc | |
parent | 4f84ffc811d93371f395f11a0e0f42000eaa99fc (diff) |
*** empty log message ***
Diffstat (limited to 'client/historyframe.cc')
-rw-r--r-- | client/historyframe.cc | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/client/historyframe.cc b/client/historyframe.cc index ad9154b..8c67c66 100644 --- a/client/historyframe.cc +++ b/client/historyframe.cc @@ -29,40 +29,50 @@ #include <QVBoxLayout> #include <QResizeEvent> +#include <QListWidgetItem> HistoryFrame::HistoryFrame() { - QVBoxLayout *layout = new QVBoxLayout(); - setLayout(layout); } HistoryFrame::~HistoryFrame() { } +void HistoryFrame::clearHistory() +{ + while(!widgets.empty()) delete widgets.takeLast(); +} + void HistoryFrame::addHistoryItem(HistoryWidget *item) { - widgets.append(item); + item->setParent(this); + + if(widgets.size() == MAX_HISTORY) delete widgets.takeLast(); + widgets.prepend(item); + + doLayoutHistoryWidgets(); } void HistoryFrame::resizeEvent(QResizeEvent *event) { - int w = event->size().width(); - int h = event->size().height(); - - int widget_height = h / 10; + doLayoutHistoryWidgets(); +} - int num_widgets = h / widget_height; - int top = num_widgets<widgets.size()?num_widgets:widgets.size(); +void HistoryFrame::doLayoutHistoryWidgets() +{ + int w = width(); + int h = (int)((double)w / (720.0 / 576.0)); - while(layout()->count()) { - layout()->removeItem(layout()->itemAt(0)); // Remove all widgets - } + int num_widgets = height() / h; + int hspace = widgets.size();// - clear_button->height(); + int top = num_widgets<hspace?num_widgets:hspace; - for(int i = 0; i < top; i++) { + for(int i = 0; i < widgets.size(); i++) { HistoryWidget *history = widgets.at(i); - history->resize(w, widget_height); - layout()->addWidget(history); + history->resize(w, h); + history->move(0, i * h); + if(i < top) history->show(); + else history->hide(); } - } |