summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-04-27 16:19:30 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-04-27 16:19:30 (GMT)
commitd197c6b11748a7e98ca8ddacf5f43023f25e667a (patch)
treeb9100af44e19f8498f430ee8d48dd9a45f62f8b1 /Swift/QtUI
parent74df18dda93f154339af1137e8676337233b4a61 (diff)
downloadswift-d197c6b11748a7e98ca8ddacf5f43023f25e667a.zip
swift-d197c6b11748a7e98ca8ddacf5f43023f25e667a.tar.bz2
Clean up AdHoc to a usable state
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtAdHocCommandWindow.cpp11
-rw-r--r--Swift/QtUI/QtAdHocCommandWindow.h1
-rw-r--r--Swift/QtUI/QtFormWidget.cpp1
3 files changed, 4 insertions, 9 deletions
diff --git a/Swift/QtUI/QtAdHocCommandWindow.cpp b/Swift/QtUI/QtAdHocCommandWindow.cpp
index 88aa708..b0281d9 100644
--- a/Swift/QtUI/QtAdHocCommandWindow.cpp
+++ b/Swift/QtUI/QtAdHocCommandWindow.cpp
@@ -15,7 +15,6 @@ const int FormLayoutIndex = 1;
namespace Swift {
QtAdHocCommandWindow::QtAdHocCommandWindow(boost::shared_ptr<OutgoingAdHocCommandSession> command) : command_(command) {
- someActions_ = false;
formWidget_ = NULL;
setAttribute(Qt::WA_DeleteOnClose);
@@ -105,23 +104,23 @@ void QtAdHocCommandWindow::handleError(ErrorPayload::ref /*error*/) {
}
void QtAdHocCommandWindow::setForm(Form::ref form) {
+ form_ = form;
delete formWidget_;
formWidget_ = new QtFormWidget(form, this);
layout_->insertWidget(FormLayoutIndex, formWidget_);
show();
- formWidget_->setEditable(someActions_);
}
void QtAdHocCommandWindow::setNoForm() {
+ form_.reset();
delete formWidget_;
formWidget_ = NULL;
- show();
+ hide();
}
typedef std::pair<Command::Action, QPushButton*> ActionButton;
void QtAdHocCommandWindow::setAvailableActions(Command::ref /*commandResult*/) {
- someActions_ = false;
foreach (ActionButton pair, actions_) {
OutgoingAdHocCommandSession::ActionState state = command_->getActionState(pair.first);
if (state & OutgoingAdHocCommandSession::Present) {
@@ -132,15 +131,11 @@ void QtAdHocCommandWindow::setAvailableActions(Command::ref /*commandResult*/) {
}
if (state & OutgoingAdHocCommandSession::Enabled) {
pair.second->setEnabled(true);
- someActions_ = true;
}
else {
pair.second->setEnabled(false);
}
}
- if (formWidget_) {
- formWidget_->setEditable(someActions_);
- }
}
}
diff --git a/Swift/QtUI/QtAdHocCommandWindow.h b/Swift/QtUI/QtAdHocCommandWindow.h
index 7f824f8..42e3b1c 100644
--- a/Swift/QtUI/QtAdHocCommandWindow.h
+++ b/Swift/QtUI/QtAdHocCommandWindow.h
@@ -44,6 +44,5 @@ namespace Swift {
QPushButton* cancelButton_;
std::map<Command::Action, QPushButton*> actions_;
QBoxLayout* layout_;
- bool someActions_;
};
}
diff --git a/Swift/QtUI/QtFormWidget.cpp b/Swift/QtUI/QtFormWidget.cpp
index 158bc9d..1307735 100644
--- a/Swift/QtUI/QtFormWidget.cpp
+++ b/Swift/QtUI/QtFormWidget.cpp
@@ -44,6 +44,7 @@ QtFormWidget::QtFormWidget(Form::ref form, QWidget* parent) : QWidget(parent), f
}
scrollArea->setWidget(scroll);
scrollArea->setWidgetResizable(true);
+ setEditable(form->getType() != Form::CancelType && form->getType() != Form::ResultType);
}
QtFormWidget::~QtFormWidget() {