summaryrefslogtreecommitdiff
path: root/client/historyframe.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/historyframe.cc')
-rw-r--r--client/historyframe.cc42
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();
}
-
}