~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to src/ahcommanddlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2010-02-19 09:37:12 UTC
  • mfrom: (6.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100219093712-e225xvm1wjcf1cgi
Tags: 0.14-2
* comment out only function which uses va_list to work around build
  problems on armel
* Set Standards-Version to 3.8.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *
19
19
 */
20
20
 
 
21
#include "ahcommanddlg.h"
 
22
 
21
23
#include <QComboBox>
22
24
#include <QMessageBox>
23
25
#include <QPushButton>
25
27
#include <QLabel>
26
28
 
27
29
#include "ahcexecutetask.h" 
28
 
#include "ahcommanddlg.h"
29
30
#include "busywidget.h"
30
31
#include "psiaccount.h"
31
32
#include "xmpp_xmlcommon.h"
120
121
AHCommandDlg::AHCommandDlg(PsiAccount* pa, const Jid& receiver)
121
122
        : QDialog(0), pa_(pa), receiver_(receiver)
122
123
{
 
124
        ui_.setupUi(this);
123
125
        setAttribute(Qt::WA_DeleteOnClose);
124
 
        QVBoxLayout *vb = new QVBoxLayout(this, 11, 6);
125
 
 
126
 
        // Command list + Buttons
127
 
        QLabel* lb_commands = new QLabel(tr("Command:"),this);
128
 
        vb->addWidget(lb_commands);
129
 
        cb_commands = new QComboBox(this);
130
 
        vb->addWidget(cb_commands);
131
 
        /*pb_info = new QPushButton(tr("Info"), this);
132
 
        hb1->addWidget(pb_info);*/
133
 
 
134
 
        // Refresh button
135
 
        //pb_refresh = new QPushButton(tr("Refresh"), this);
136
 
        //hb2->addWidget(pb_refresh);
137
 
        //connect(pb_refresh, SIGNAL(clicked()), SLOT(refreshCommands()));
138
 
 
139
 
        vb->addStretch(1);
140
 
 
141
 
        // Bottom row
142
 
        QHBoxLayout *hb2 = new QHBoxLayout(vb);
143
 
        busy_ = new BusyWidget(this);
144
 
        hb2->addWidget(busy_);
145
 
        hb2->addItem(new QSpacerItem(20,0,QSizePolicy::Expanding));
146
 
        pb_execute = new QPushButton(tr("Execute"), this);
147
 
        hb2->addWidget(pb_execute);
 
126
 
 
127
        pb_close = ui_.buttonBox->button(QDialogButtonBox::Cancel);
 
128
        pb_execute = ui_.buttonBox->addButton(tr("Execute"), QDialogButtonBox::AcceptRole);
148
129
        connect(pb_execute, SIGNAL(clicked()), SLOT(executeCommand()));
149
 
        pb_close = new QPushButton(tr("Close"), this);
150
 
        hb2->addWidget(pb_close);
151
130
        connect(pb_close, SIGNAL(clicked()), SLOT(close()));
152
 
        pb_close->setDefault(true);
153
 
        pb_close->setFocus();
154
 
 
155
 
        setCaption(QString("Execute Command (%1)").arg(receiver.full()));
156
 
 
157
 
        // Load commands
 
131
        pb_execute->setDefault(true);
 
132
 
 
133
        setWindowTitle(QString("Execute Command (%1)").arg(receiver.full()));
 
134
 
158
135
        refreshCommands();
 
136
        adjustSize();
159
137
}
160
138
 
161
 
 
162
139
void AHCommandDlg::refreshCommands()
163
140
{
164
 
        cb_commands->clear();
 
141
        ui_.cb_commands->clear();
165
142
        pb_execute->setEnabled(false);
166
 
        //pb_info->setEnabled(false);
167
143
 
168
 
        busy_->start();
 
144
        ui_.busy->start();
169
145
        JT_AHCGetList* t= new JT_AHCGetList(pa_->client()->rootTask(),receiver_);
170
146
        connect(t,SIGNAL(finished()),SLOT(listReceived()));
171
147
        t->go(true);
175
151
{
176
152
        JT_AHCGetList* task_list = (JT_AHCGetList*) sender();
177
153
        foreach(AHCommandItem i, task_list->commands()) {
178
 
                cb_commands->insertItem(i.name);        
 
154
                ui_.cb_commands->addItem(i.name);
179
155
                commands_.append(i);
180
156
        }
181
 
        pb_execute->setEnabled(cb_commands->count()>0);
182
 
        busy_->stop();
 
157
        pb_execute->setEnabled(ui_.cb_commands->count()>0);
 
158
        ui_.busy->stop();
183
159
}
184
160
 
185
161
void AHCommandDlg::executeCommand()
186
162
{
187
 
        if (cb_commands->count() > 0) {
188
 
                busy_->start();
189
 
                Jid to(commands_[cb_commands->currentItem()].jid);
190
 
                QString node = commands_[cb_commands->currentItem()].node;
 
163
        if (ui_.cb_commands->count() > 0) {
 
164
                ui_.busy->start();
 
165
                Jid to(commands_[ui_.cb_commands->currentIndex()].jid);
 
166
                QString node = commands_[ui_.cb_commands->currentIndex()].node;
191
167
                AHCExecuteTask* t = new AHCExecuteTask(to,AHCommand(node),pa_->client()->rootTask());
192
168
                connect(t,SIGNAL(finished()),SLOT(commandExecuted()));
193
169
                t->go(true);
196
172
 
197
173
void AHCommandDlg::commandExecuted()
198
174
{
199
 
        busy_->stop();
 
175
        ui_.busy->stop();
200
176
        close();
201
177
}
202
178