15
15
* You should have received a copy of the GNU General Public License
16
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
#include <qlineedit.h>
25
#include <qcheckbox.h>
27
#include <qcombobox.h>
28
#include <qpushbutton.h>
31
#include <qapplication.h>
28
#include <QPushButton>
29
#include <QDomElement>
31
#include <QApplication>
33
32
#include <QHBoxLayout>
364
363
hb->addWidget(d->cb_proxy);
365
364
d->pb_edit = new QPushButton(tr("Edit..."), this);
366
365
connect(d->pb_edit, SIGNAL(clicked()), SLOT(doOpen()));
366
connect(d->cb_proxy, SIGNAL(activated(int)), SIGNAL(itemChanged()));
367
367
hb->addWidget(d->pb_edit);
424
424
d->m->openDialog(x);
428
//----------------------------------------------------------------------------
430
//----------------------------------------------------------------------------
431
const QString defaultItemName = "Default";
433
ProxyForObject::ProxyForObject(OptionsTree *o, QObject *parent)
437
loadItem(defaultItemName);
440
ProxyForObject::~ProxyForObject()
444
QString ProxyForObject::itemForObject(const QString& obj)
446
if(!items_.contains(obj))
449
return items_.value(obj);
452
void ProxyForObject::save()
455
QString base = "proxy.";
456
foreach(QString obj, items_.keys()) {
457
QString val = items_.value(obj);
458
ot_->setOption(base+obj, QVariant(val));
462
QComboBox* ProxyForObject::getComboBox(ProxyChooser* pc, QWidget* p)
466
cb_ = new QComboBox(p);
467
cb_->addItems(items_.keys());
468
cb_->setCurrentIndex(0);
469
currentItemChanged(0);
471
connect(cb_, SIGNAL(currentIndexChanged(int)), SLOT(currentItemChanged(int)));
472
connect(pc_, SIGNAL(itemChanged()), SLOT(updateCurrentItem()));
477
void ProxyForObject::currentItemChanged(int index)
479
const QString data = cb_->itemText(index);
480
pc_->setCurrentItem(tmp_.value(data));
483
void ProxyForObject::loadItem(const QString& obj)
485
QVariant v = ot_->getOption(("proxy." + obj));
487
v = ot_->getOption(("proxy." + defaultItemName));
488
items_[obj] = v.toString();
491
void ProxyForObject::updateCurrentItem()
493
tmp_[cb_->currentText()] = pc_->currentItem();
427
496
//----------------------------------------------------------------------------
429
498
//----------------------------------------------------------------------------
430
499
class ProxyManager::Private
435
504
QPointer<ProxyDlg> pd;
436
505
QList<int> prevMap;
437
506
QString lastEdited;
440
510
void itemToOptions(ProxyItem pi) {
441
511
QString base = "proxies." + pi.id;
448
ProxyManager::ProxyManager(OptionsTree *opt, QObject *parent)
518
ProxyManager::ProxyManager()
524
void ProxyManager::init(OptionsTree *o)
528
d->po = new ProxyForObject(o, this);
455
531
ProxyManager::~ProxyManager()
536
ProxyManager* ProxyManager::instance()
539
instance_ = new ProxyManager();
460
543
ProxyChooser *ProxyManager::createProxyChooser(QWidget *parent)
462
545
return new ProxyChooser(this, parent);
541
624
settingsChanged();
627
ProxyItem ProxyManager::getItemForObject(const QString& obj)
630
return getItem(d->po->itemForObject(str.replace(QRegExp("\\s+"), "_")));
633
ProxyForObject* ProxyManager::proxyForObject()
638
ProxyManager* ProxyManager::instance_ = NULL;
544
640
#include "proxy.moc"