1 /***************************************************************************
2 *   Copyright (C) 2007 by BOP                                             *
3 *   polepolek@gmail.com                                                   *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 *                                                                         *
10 *   This program is distributed in the hope that it will be useful,       *
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13 *   GNU General Public License for more details.                          *
14 *                                                                         *
15 *   You should have received a copy of the GNU General Public License     *
16 *   along with this program; if not, write to the                         *
17 *   Free Software Foundation, Inc.,                                       *
18 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19 ***************************************************************************/
20 #ifndef GROUPWIDGET_H
21 #define GROUPWIDGET_H
22 
23 #include "book.h"
24 
25 #include <QListWidget>
26 
27 class QLineEdit;
28 class QPushButton;
29 class QDialogButtonBox;
30 class QLabel;
31 
32 class GroupWidget : public QWidget
33 {
34     Q_OBJECT
35 public:
36     GroupWidget(QList <Group*> *group, QWidget *parent);
currentRow()37     inline int currentRow() const
38     {
39         return groupListWidget->currentRow();
40     }
currentGroup()41     inline Group *currentGroup() const
42     {
43         return (*groupList)[currentRow()];
44     }
currentItem()45     inline QListWidgetItem* currentItem() const
46     {
47         return groupListWidget->currentItem();
48     }
49 
50 private slots:
51     void initGroup();
52     void changeAddGroup(const QString &str);
53     void createGroup();
54     void upItem();
55     void downItem();
56     void delItem();
changeRow(int)57     void changeRow(int)
58     {
59         resetButtons();
60     }
editItem(QListWidgetItem * item)61     void editItem(QListWidgetItem *item)
62     {
63         groupListWidget->openPersistentEditor(item);
64         groupListWidget->editItem(item);
65     }
editItem()66     void editItem()
67     {
68         editItem(currentItem());
69     }
70 
changeName(QListWidgetItem * item)71     void changeName(QListWidgetItem *item)
72     {
73         Group *group = (Group *)item;
74 
75         group->setName(item->text());
76     }
77 
changeSelect(QListWidgetItem *,QListWidgetItem * prev)78     void changeSelect(QListWidgetItem*, QListWidgetItem *prev)
79     {
80         groupListWidget->closePersistentEditor(prev);
81     }
82 
83 
84 signals:
85     void rowChanged(int row);
86 
87 private:
88     void resetButtons();
89 
90     QList <Group*> *groupList;
91     QListWidget *groupListWidget;
92     QLineEdit *addGroupEdit;
93     QPushButton *addButton;
94     QPushButton *upButton;
95     QPushButton *downButton;
96     QPushButton *delButton;
97     QPushButton *editButton;
98 };
99 
100 #endif
101 
102