1 /***************************************************************************
5 query groups dialog page
7 -----------------------------------------------------------------------
9 begin : Mon Nov 1 13:10:21 1999
11 copyright : (C) 1999-2001 Ewald Arnold
12 (C) 2001 The KDE-EDU team
14 email : kvoctrain@ewald-arnold.de
16 -----------------------------------------------------------------------
18 ***************************************************************************/
20 /***************************************************************************
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 ***************************************************************************/
29 #include "GroupOptPage.h"
31 #include <qcombobox.h>
33 #include <qpushbutton.h>
36 #include <kinputdialog.h>
38 GroupOptPage::GroupOptPage
40 vector
<PreSetting
> preset
,
45 GroupOptPageForm( parent
, name
)
47 connect( ps_del
, SIGNAL(clicked()), SLOT(slotDeleteGroup()) );
48 connect( ps_new
, SIGNAL(clicked()), SLOT(slotNewGroup()) );
49 connect( ps_recall
, SIGNAL(clicked()), SLOT(slotRecallGroup()) );
50 connect( ps_store
, SIGNAL(clicked()), SLOT(slotStoreGroup()) );
51 connect( ps_name
, SIGNAL(activated(int)), SLOT(slotGroupSelected(int)) );
53 setCaption(i18n("Groups"));
54 l_name
->setBuddy(ps_name
);
55 for (int i
= 0; i
< (int) preset
.size(); i
++)
56 ps_name
->insertItem (preset
[i
].name
);
61 void GroupOptPage::initFocus() const
67 void GroupOptPage::slotGroupSelected(int )
72 void GroupOptPage::slotDeleteGroup()
74 if (ps_name
->count() != 0) {
75 emit
deleteGroup (ps_name
->currentItem());
76 int curr
= ps_name
->currentItem();
77 ps_name
->removeItem(curr
);
78 if (curr
>= ps_name
->count()-1)
79 ps_name
->setCurrentItem(ps_name
->count()-1);
86 void GroupOptPage::slotNewGroup()
89 QString getGroup
= KInputDialog::getText(
90 i18n( "Group Description" ), i18n( "Enter group description:" ), QString::null
, &ok
);
93 ps_name
->insertItem(getGroup
.stripWhiteSpace());
94 emit
newGroup(getGroup
.stripWhiteSpace());
95 ps_name
->setCurrentItem(ps_name
->count()-1);
96 emit
selectGroup(ps_name
->currentItem());
101 void GroupOptPage::slotRecallGroup()
103 if (ps_name
->count() != 0)
104 emit
selectGroup(ps_name
->currentItem());
108 void GroupOptPage::slotStoreGroup()
110 if (ps_name
->count() != 0)
111 emit
modifyGroup(ps_name
->currentItem());
115 void GroupOptPage::updateButtons()
117 ps_del
->setEnabled (ps_name
->count() > 0);
118 ps_store
->setEnabled (ps_name
->count() > 0);
119 ps_recall
->setEnabled (ps_name
->count() > 0);
120 ps_name
->setEnabled (ps_name
->count() > 0);
124 void GroupOptPage::keyPressEvent( QKeyEvent
*e
)
126 if (e
->state() & AltButton
& ControlButton
& ShiftButton
== 0) {
127 if ( e
->key() == Key_Escape
)
129 else if ( e
->key() == Key_Enter
130 ||e
->key() == Key_Return
)
139 #include "GroupOptPage.moc"