ActionConfig::ActionConfig(QWidget *parent, SIM::PropertyHubPtr data, ActionPlugin *plugin)
  : QWidget(parent)
  , m_menu(NULL)
  , m_data(data)
  , m_plugin(plugin)
{
    setupUi(this);
    setButtonsPict(this);

    connect(btnHelp, SIGNAL(clicked()), this, SLOT(help()));

    int row = 0;
    addRow(lstEvent, row, Icon("SIM"), i18n("Contact online"), CONTACT_ONLINE, data->value("OnLine").toString() );

    row++;
    addRow(lstEvent, row, Icon("SIM"), i18n("Status changed"), CONTACT_STATUS, data->value("Status").toString() );

    CommandDef *cmd;
    CorePlugin *core = GET_CorePlugin();
    CommandsMapIterator it(core->messageTypes);
    while ((cmd = ++it) != NULL){
        MessageDef *def = (MessageDef*)(cmd->param);
        if ((def == NULL) || (cmd->icon.isEmpty()) ||
                (def->flags & (MESSAGE_HIDDEN | MESSAGE_SENDONLY | MESSAGE_CHILD)))
            continue;
        if ((def->singular == NULL) || (def->plural == NULL) ||
                (*def->singular == 0) || (*def->plural == 0))
            continue;
        QString type = i18n(def->singular, def->plural, 1);
        int pos = type.indexOf("1 ");
        if (pos == 0){
            type = type.mid(2);
        }else if (pos > 0){
            type = type.left(pos);
        }
        type = type.left(1).toUpper() + type.mid(1);

        row++;
        addRow(lstEvent, row, Icon(cmd->icon), type, cmd->id, data->stringMapValue("Message", cmd->id));
    }
    EventTmplHelpList e;
    e.process();
    LineEditDelegate *dg = new LineEditDelegate(1, lstEvent);
    dg->setHelpList(e.helpList());
    lstEvent->setItemDelegate(dg);
    lstEvent->resizeColumnToContents(0);
    lstEvent->sortByColumn(0, Qt::AscendingOrder);

    for (QObject *p = parent; p != NULL; p = p->parent()){
        QTabWidget *tab = qobject_cast<QTabWidget*>(p);
        if (!tab)
            continue;
        m_menu = new MenuConfig(tab, data);
        tab->addTab(m_menu, i18n("Menu"));
        tab->adjustSize();
        break;
    }
}
Exemple #2
0
AddItem::AddItem(QWidget *parent)
  : QDialog(parent)
{
    setupUi(this);
    setModal(true);
    setWindowIcon(Icon("run"));
    setButtonsPict(this);
    QTimer::singleShot(0, this, SLOT(changed()));
    connect(edtItem, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
    connect(edtPrg, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
    connect(buttonHelp, SIGNAL(clicked()), this, SLOT(help()));
    EventTmplHelpList e;
    e.process();
    edtPrg->setHelpList(e.helpList());
}