~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to src/toworkingwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-04-07 13:16:05 UTC
  • mfrom: (1.2.7 upstream) (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090407131605-u422yigfv7jgg0l0
Tags: 2.0.0-3
* Cleaned up packaging a little bit.
* Added homepage information to control file.
* Bumped Standards-Version to 3.8.1.
* Released to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* BEGIN_COMMON_COPYRIGHT_HEADER
 
3
 *
 
4
 * TOra - An Oracle Toolkit for DBA's and developers
 
5
 * 
 
6
 * Shared/mixed copyright is held throughout files in this product
 
7
 * 
 
8
 * Portions Copyright (C) 2000-2001 Underscore AB
 
9
 * Portions Copyright (C) 2003-2005 Quest Software, Inc.
 
10
 * Portions Copyright (C) 2004-2008 Numerous Other Contributors
 
11
 * 
 
12
 * This program is free software; you can redistribute it and/or
 
13
 * modify it under the terms of the GNU General Public License
 
14
 * as published by the Free Software Foundation;  only version 2 of
 
15
 * the License is valid for this program.
 
16
 * 
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 * 
 
22
 * You should have received a copy of the GNU General Public License
 
23
 * along with this program; if not, write to the Free Software
 
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
25
 * 
 
26
 *      As a special exception, you have permission to link this program
 
27
 *      with the Oracle Client libraries and distribute executables, as long
 
28
 *      as you follow the requirements of the GNU GPL in regard to all of the
 
29
 *      software in the executable aside from Oracle client libraries.
 
30
 * 
 
31
 *      Specifically you are not permitted to link this program with the
 
32
 *      Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
 
33
 *      And you are not permitted to distribute binaries compiled against
 
34
 *      these libraries. 
 
35
 * 
 
36
 *      You may link this product with any GPL'd Qt library.
 
37
 * 
 
38
 * All trademarks belong to their respective owners.
 
39
 *
 
40
 * END_COMMON_COPYRIGHT_HEADER */
 
41
 
 
42
#include <QPushButton>
 
43
#include <QLabel>
 
44
#include <QHBoxLayout>
 
45
 
 
46
#include "toworkingwidget.h"
 
47
#include "icons/stop.xpm"
 
48
 
 
49
 
 
50
toWorkingWidget::toWorkingWidget(QWidget * parent)
 
51
    : QWidget(parent)
 
52
{
 
53
    CurrentType = toWorkingWidget::Interactive;
 
54
 
 
55
    setAutoFillBackground(true);
 
56
    setPalette(QPalette(Qt::white));
 
57
 
 
58
    HWorking = new QWidget(this);
 
59
    HWorking->setAutoFillBackground(true);
 
60
    HWorking->setPalette(QPalette(QColor(241, 241, 169)));
 
61
 
 
62
    QVBoxLayout *vbox = new QVBoxLayout;
 
63
    vbox->setSpacing(0);
 
64
    vbox->setContentsMargins(0, 0, 0, 0);
 
65
 
 
66
    QHBoxLayout *hbox = new QHBoxLayout;
 
67
 
 
68
    WorkingLabel = new QLabel(tr("Waiting..."), HWorking);
 
69
    WorkingLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
 
70
    hbox->addWidget(WorkingLabel);
 
71
 
 
72
    WorkingStop = new QPushButton(QIcon(stop_xpm), tr("Stop"), HWorking);
 
73
    WorkingStop->setAutoFillBackground(true);
 
74
    WorkingStop->setBackgroundRole(QPalette::Window);
 
75
    WorkingStop->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
 
76
    WorkingStop->setEnabled(false);
 
77
 
 
78
    connect(WorkingStop, SIGNAL(clicked()), this, SLOT(stopWorking()));
 
79
 
 
80
    hbox->addWidget(WorkingStop);
 
81
 
 
82
    HWorking->setLayout(hbox);
 
83
 
 
84
    vbox->addWidget(HWorking);
 
85
    vbox->addStretch(0);
 
86
 
 
87
    setLayout(vbox);
 
88
}
 
89
 
 
90
void toWorkingWidget::show()
 
91
{
 
92
    if (CurrentType == toWorkingWidget::Interactive)
 
93
        HWorking->hide();
 
94
    QWidget::show();
 
95
}
 
96
 
 
97
void toWorkingWidget::forceShow()
 
98
{
 
99
    HWorking->show();
 
100
}
 
101
 
 
102
void toWorkingWidget::stopWorking()
 
103
{
 
104
    emit stop();
 
105
}
 
106
 
 
107
void toWorkingWidget::setText(const QString & text)
 
108
{
 
109
    WorkingLabel->setText(text);
 
110
    WorkingStop->setEnabled(true);
 
111
}
 
112
 
 
113
void toWorkingWidget::setType(WorkingWidgetType type)
 
114
{
 
115
    CurrentType = type;
 
116
    bool e = (type == toWorkingWidget::Interactive);
 
117
    WorkingStop->setEnabled(e);
 
118
    WorkingStop->setVisible(e);
 
119
    WorkingStop->blockSignals(!e);
 
120
}