35106695af2f011f00e7e738189f32a45666fb9d
[situare] / src / ui / panelbase.cpp
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Pekka Nissinen - pekka.nissinen@ixonos.com
6         Sami Rämö - sami.ramo@ixonos.com
7
8     Situare is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License
10     version 2 as published by the Free Software Foundation.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21 */
22
23 #include <QDebug>
24 #include <QListWidget>
25 #include <QResizeEvent>
26 #include <QVBoxLayout>
27
28 #include "panelbase.h"
29
30 PanelBase::PanelBase(QWidget *parent)
31     : QWidget(parent)
32 {
33     qDebug() << __PRETTY_FUNCTION__;
34
35     const int CONTEXT_BUTTON_MARGIN_LEFT = 2;
36     const int CONTEXT_BUTTON_MARGIN_TOP = 10;
37     const int CONTEXT_BUTTON_MARGIN_RIGHT = 0;
38     const int CONTEXT_BUTTON_MARGIN_BOTTOM = 0;
39     const int CONTEXT_BUTTON_SPACING = 0;
40
41     // --- GENERIC BUTTONS ---
42     m_genericButtons = new QWidget;
43
44     m_genericButtonsLayout = new QVBoxLayout;
45     m_genericButtonsLayout->setContentsMargins(CONTEXT_BUTTON_MARGIN_LEFT,
46                                               CONTEXT_BUTTON_MARGIN_TOP,
47                                               CONTEXT_BUTTON_MARGIN_RIGHT,
48                                               CONTEXT_BUTTON_MARGIN_BOTTOM);
49     m_genericButtonsLayout->setSpacing(CONTEXT_BUTTON_SPACING);
50
51     m_genericButtons->setLayout(m_genericButtonsLayout);
52
53     // --- ITEM RELATED BUTTONS ---
54     m_itemButtons = new QWidget(this);
55     m_itemButtonsLayout = new QHBoxLayout;
56     /// @todo set margins
57     m_itemButtons->setLayout(m_itemButtonsLayout);
58 }
59
60 QWidget* PanelBase::genericPanelButtons() const
61 {
62     qDebug() << __PRETTY_FUNCTION__;
63
64     return m_genericButtons;
65 }
66
67 QWidget* PanelBase::itemButtons() const
68 {
69     qDebug() << __PRETTY_FUNCTION__;
70
71     return m_itemButtons;
72 }
73
74 void PanelBase::onListItemSelectionChanged()
75 {
76     qDebug() << __PRETTY_FUNCTION__;
77
78     QListWidget *listWidget = dynamic_cast<QListWidget *>(sender());
79     if (listWidget && (listWidget->selectedItems().count() > 0))
80         emit listItemSelectionChanged(true);
81     else
82         emit listItemSelectionChanged(false);
83 }