Esempio n. 1
0
void ConditionalDialog::init(KCConditional const & tmp, int numCondition)
{
    kDebug() << "Adding" << numCondition;
    KComboBox * cb  = 0;
    KComboBox * sb  = 0;
    KLineEdit * kl1 = 0;
    KLineEdit * kl2 = 0;
    QString value;
    KCMap *const map = m_selection->activeSheet()->map();
    KCValueConverter *const converter = map->converter();

    switch (numCondition) {
    case 0:
        cb  = m_dlg->m_condition_1;
        sb  = m_dlg->m_style_1;
        kl1 = m_dlg->m_firstValue_1;
        kl2 = m_dlg->m_secondValue_1;
        break;
    case 1:
        cb  = m_dlg->m_condition_2;
        sb  = m_dlg->m_style_2;
        kl1 = m_dlg->m_firstValue_2;
        kl2 = m_dlg->m_secondValue_2;
        break;
    case 2:
        cb  = m_dlg->m_condition_3;
        sb  = m_dlg->m_style_3;
        kl1 = m_dlg->m_firstValue_3;
        kl2 = m_dlg->m_secondValue_3;
        break;
    default:
        return;
    }

    if (!tmp.styleName.isEmpty()) {
        sb->setCurrentIndex(sb->findText(tmp.styleName));
        sb->setEnabled(true);
    }

    switch (tmp.cond) {
    case KCConditional::None :
    case KCConditional::IsTrueFormula: // was unhandled
        break;

    case KCConditional::Equal :
        cb->setCurrentIndex(1);
        break;

    case KCConditional::Superior :
        cb->setCurrentIndex(2);
        break;

    case KCConditional::Inferior :
        cb->setCurrentIndex(3);
        break;

    case KCConditional::SuperiorEqual :
        cb->setCurrentIndex(4);
        break;

    case KCConditional::InferiorEqual :
        cb->setCurrentIndex(5);
        break;

    case KCConditional::Between :
        cb->setCurrentIndex(6);
        kl2->setText(converter->asString(tmp.value2).asString());
        break;

    case KCConditional::Different :
        cb->setCurrentIndex(7);
        kl2->setText(converter->asString(tmp.value2).asString());
        break;
    case KCConditional::DifferentTo :
        cb->setCurrentIndex(8);
        break;
    }

    if (tmp.cond != KCConditional::None) {
        kl1->setEnabled(true);
        kl1->setText(converter->asString(tmp.value1).asString());
    }
}
DialogCreateTag::DialogCreateTag(QWidget *parent, TagTreeNode* parentNode, const char *name)
    : KDialogBase(parent, name, true, "", KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, false )
    , m_parentNode(parentNode) {

    if (parentNode) {
        this->setCaption(i18n("Create tag"));
    } else {
        this->setCaption(i18n("Create toplevel tag"));
    }

    QWidget* mainPanel = new QWidget(this, "mainPanel");
    setMainWidget(mainPanel);
    QVBoxLayout* mainPanelLayout = new QVBoxLayout(mainPanel, 0, 5, "mainPanelLayout");
    mainPanelLayout->setAutoAdd(true);

    // parent
    if (parentNode) {
        // newTagGroup
        QGroupBox* parentTagGroup = new QGroupBox(i18n("Parent tag"), mainPanel, "parentTagGroup");
        QGridLayout* parentTagGroupLayout = new QGridLayout(parentTagGroup, 4, 4, 20, 5, "parentTagGroupLayout");

        parentTagGroupLayout->setRowSpacing(0, 10);

        // type
        QLabel* typeLabel = new QLabel(i18n("Type"), parentTagGroup, "typeLabel");
        parentTagGroupLayout->addWidget(typeLabel, 1, 0);

        KComboBox* typeComboBox = new KComboBox(false, parentTagGroup, "typeComboBox");
        typeComboBox->insertItem(parentNode->tagNode()->typeName());
        typeComboBox->setEnabled(false);
        parentTagGroupLayout->addMultiCellWidget(typeComboBox, 1, 1, 1, 2);

        // name
        QLabel* nameLabel = new QLabel(i18n("Name"), parentTagGroup, "nameLabel");
        parentTagGroupLayout->addWidget(nameLabel, 2, 0);

        KLineEdit* nameLineEdit = new KLineEdit(parentTagGroup, "nameLineEdit");
        nameLineEdit->setText(*parentNode->tagNode()->text());
        nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        nameLineEdit->setReadOnly(true);
        parentTagGroupLayout->addMultiCellWidget(nameLineEdit, 2, 2, 1, 2);

        // icon
        QLabel* iconLabel = new QLabel(i18n("Icon"), parentTagGroup, "iconLabel");
        parentTagGroupLayout->addWidget(iconLabel, 3, 0);

        KLineEdit* iconLineEdit = new KLineEdit(parentTagGroup, "iconLineEdit");
        iconLineEdit->setText(*parentNode->tagNode()->iconName());
        iconLineEdit->setMinimumWidth(300);
        iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
        iconLineEdit->setReadOnly(true);
        parentTagGroupLayout->addWidget(iconLineEdit, 3, 1);

        QPushButton* iconButton = new QPushButton(i18n("Icon"), parentTagGroup, "iconButton");
        QIconSet iconSet = KGlobal::iconLoader()->loadIconSet(iconLineEdit->text(), KIcon::Small, Configuration::getInstance()->tagtreeIconSize(), true);
        iconButton->setIconSet(iconSet);
        iconButton->setText(QString::null);
        iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        iconButton->setEnabled(true);
        parentTagGroupLayout->addWidget(iconButton, 3, 2);
    }

    // newTagGroup
    QGroupBox* newTagGroup = new QGroupBox(i18n("New tag"), mainPanel, "newTagGroup");
    QGridLayout* newTagGroupLayout = new QGridLayout(newTagGroup, 4, 4, 20, 5, "newTagGroupLayout");

    newTagGroupLayout->setRowSpacing(0, 10);

    // type
    QLabel* typeLabel = new QLabel(i18n("Type"), newTagGroup, "typeLabel");
    newTagGroupLayout->addWidget(typeLabel, 1, 0);

    m_typeComboBox = new KComboBox(false, newTagGroup, "typeComboBox");
    m_typeComboBoxEntries = new QValueList<int>;
    if (!parentNode) {
        m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_TITLE));
        m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_TITLE));
    }
    m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_BOOLEAN));
    m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_BOOLEAN));
    newTagGroupLayout->addMultiCellWidget(m_typeComboBox, 1, 1, 1, 2);

    // name
    QLabel* nameLabel = new QLabel(i18n("Name"), newTagGroup, "nameLabel");
    newTagGroupLayout->addWidget(nameLabel, 2, 0);

    m_nameLineEdit = new KLineEdit(newTagGroup, "nameLineEdit");
    m_nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QObject::connect(m_nameLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)));
    newTagGroupLayout->addMultiCellWidget(m_nameLineEdit, 2, 2, 1, 2);

    // icon
    QLabel* iconLabel = new QLabel(i18n("Icon"), newTagGroup, "iconLabel");
    newTagGroupLayout->addWidget(iconLabel, 3, 0);

    m_iconLineEdit = new KLineEdit(newTagGroup, "iconLineEdit");
    m_iconLineEdit->setMinimumWidth(300);
    m_iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QObject::connect(m_iconLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotIconTextChanged(const QString&)));
    newTagGroupLayout->addWidget(m_iconLineEdit, 3, 1);

    m_iconButton = new QPushButton(i18n("Icon"), newTagGroup, "iconButton");
    m_iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    newTagGroupLayout->addWidget(m_iconButton, 3, 2);

    QObject::connect(m_iconButton, SIGNAL(clicked()), this, SLOT(slotIconButtonClicked()));

    // spacer
    QWidget* spacer = new QWidget(mainPanel, "spacer");
    spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);

    // disable ok button
    validate();

    // set the focus
    m_nameLineEdit->setFocus();
}
Esempio n. 3
0
LinkDialog::LinkDialog(QWidget* parent, Selection* selection)
        : KPageDialog(parent)
        , d(new Private)
{
    setCaption(i18n("Insert Link"));
    setButtons(Ok | Cancel);
    setFaceType(List);

    // link for web or ftp
    d->internetPage = new QWidget();
    d->p1 = addPage(d->internetPage, i18n("Internet"));
    d->p1->setHeader(i18n("Link to Internet Address"));
    d->p1->setIcon(KIcon("internet-web-browser"));
    QVBoxLayout* iLayout = new QVBoxLayout(d->internetPage);
    iLayout->addWidget(new QLabel(i18n("Text to display:"), d->internetPage));
    d->internetText = new KLineEdit(d->internetPage);
    iLayout->addWidget(d->internetText);
    iLayout->addWidget(new QLabel(i18n("Internet address:"), d->internetPage));
    d->internetLink = new KLineEdit(d->internetPage);
    iLayout->addWidget(d->internetLink);
    iLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
    connect(d->internetText, SIGNAL(textChanged(const QString&)), this,
            SLOT(setText(const QString&)));

    // link for e-mail
    d->mailPage = new QWidget();
    d->p2 = addPage(d->mailPage, i18n("Mail"));
    d->p2->setHeader(i18n("Link to Mail Address"));
    d->p2->setIcon(KIcon("mail-message"));
    QVBoxLayout* mLayout = new QVBoxLayout(d->mailPage);
    mLayout->addWidget(new QLabel(i18n("Text to display:"), d->mailPage));
    d->mailText = new KLineEdit(d->mailPage);
    mLayout->addWidget(d->mailText);
    mLayout->addWidget(new QLabel(i18n("Email:"), d->mailPage));
    d->mailLink = new KLineEdit(d->mailPage);
    mLayout->addWidget(d->mailLink);
    connect(d->mailText, SIGNAL(textChanged(const QString&)), this,
            SLOT(setText(const QString&)));
    mLayout->addWidget(new QLabel(i18n("Subject:"), d->mailPage));
    d->mailSubject = new KLineEdit(d->mailPage);
    mLayout->addWidget(d->mailSubject);
    mLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));

    // link for external file
    d->filePage = new QWidget();
    d->p3 = addPage(d->filePage, i18n("File"));
    d->p3->setHeader(i18n("Link to File"));
    d->p3->setIcon(KIcon("system-file-manager"));
    QVBoxLayout* fLayout = new QVBoxLayout(d->filePage);
    fLayout->addWidget(new QLabel(i18n("Text to display:"), d->filePage));
    d->fileText = new KLineEdit(d->filePage);
    fLayout->addWidget(d->fileText);
    fLayout->addWidget(new QLabel(i18n("File location:"), d->filePage));
    d->fileLink = new KUrlRequester(d->filePage);
    d->fileLink->completionObject()->setReplaceHome(true);
    d->fileLink->completionObject()->setReplaceEnv(true);
    fLayout->addWidget(d->fileLink);
    fLayout->addWidget(new QLabel(i18n("Recent file:"), d->filePage));
    KComboBox* recentFile = new KComboBox(d->filePage);
    recentFile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    recentFile->setMinimumContentsLength(40);
    fLayout->addWidget(recentFile);
    fLayout->addItem(new QSpacerItem(0, 40, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding));
    connect(d->fileText, SIGNAL(textChanged(const QString&)), this,
            SLOT(setText(const QString&)));
    QObject::connect(recentFile, SIGNAL(highlighted(const QString &)),
                     d->fileLink->lineEdit(), SLOT(setText(const QString &)));

    // populate recent files
    int index = 0;
    const QStringList fileList = KRecentDocument::recentDocuments();
    for (QStringList::ConstIterator it = fileList.constBegin(); it != fileList.constEnd(); ++it) {
        KDesktopFile f(*it);
        if (!f.readUrl().isEmpty())
            recentFile->insertItem(index++, f.readUrl());
    }
    if (recentFile->count() == 0) {
        recentFile->insertItem(0, i18n("No Entries"));
        recentFile->setEnabled(false);
    }

    // link to another cell
    d->cellPage = new QWidget();
    d->p4 = addPage(d->cellPage, i18n("Cell"));
    d->p4->setHeader(i18n("Link to Cell"));
    d->p4->setIcon(KIcon("table"));
    QVBoxLayout* cLayout = new QVBoxLayout(d->cellPage);
    cLayout->addWidget(new QLabel(i18n("Text to display:"), d->cellPage));
    d->cellText = new KLineEdit(d->cellPage);
    cLayout->addWidget(d->cellText);
    cLayout->addWidget(new QLabel(i18n("Cell or Named Area:"), d->cellPage));
    d->cellLink = new KComboBox(d->cellPage);
    d->cellLink->setEditable(true);

    const Sheet *sheet = selection->activeSheet();
    if (sheet && selection) {
        Cell cell(sheet, selection->cursor());
        d->cellLink->addItem(cell.fullName());
    }

    const NamedAreaManager *manager = selection->activeSheet()->map()->namedAreaManager();
    d->cellLink->addItems(manager->areaNames());

    d->cellLink->setItemText(d->cellLink->currentIndex(), "");
    cLayout->addWidget(d->cellLink);
    cLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
    connect(d->cellText, SIGNAL(textChanged(const QString&)), this,
            SLOT(setText(const QString&)));

    showButtonSeparator(true);
    d->internetText->setFocus();
    resize(400, 300);
    connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
}
Esempio n. 4
0
    void setupGUI()
    {
        QBoxLayout *layout = new QVBoxLayout(p);
        tabWidget = new QTabWidget(p);
        layout->addWidget(tabWidget);

        QWidget *container = new QWidget(tabWidget);
        tabWidget->addTab(container, QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Library"));
        connect(tabWidget, &QTabWidget::currentChanged, p, &ZoteroBrowser::tabChanged);
        QBoxLayout *containerLayout = new QVBoxLayout(container);

        /// Personal or Group Library
        QGridLayout *gridLayout = new QGridLayout();
        containerLayout->addLayout(gridLayout);
        gridLayout->setMargin(0);
        gridLayout->setColumnMinimumWidth(0, 16); // TODO determine size of a radio button
        radioPersonalLibrary = new QRadioButton(i18n("Personal library"), container);
        gridLayout->addWidget(radioPersonalLibrary, 0, 0, 1, 2);
        radioGroupLibrary = new QRadioButton(i18n("Group library"), container);
        gridLayout->addWidget(radioGroupLibrary, 1, 0, 1, 2);
        comboBoxGroupList = new KComboBox(false, container);
        gridLayout->addWidget(comboBoxGroupList, 2, 1, 1, 1);
        QSizePolicy sizePolicy = comboBoxGroupList->sizePolicy();
        sizePolicy.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
        comboBoxGroupList->setSizePolicy(sizePolicy);
        radioPersonalLibrary->setChecked(true);
        comboBoxGroupList->setEnabled(false);
        comboBoxGroupList->addItem(i18n("No groups available"));
        connect(radioGroupLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled);
        connect(radioPersonalLibrary, &QRadioButton::toggled, p, &ZoteroBrowser::radioButtonsToggled);
        connect(comboBoxGroupList, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), p, &ZoteroBrowser::groupListChanged);

        containerLayout->addStretch(10);

        /// Credentials
        QFormLayout *containerForm = new QFormLayout();
        containerLayout->addLayout(containerForm, 1);
        containerForm->setMargin(0);
        lineEditNumericUserId = new KLineEdit(container);
        lineEditNumericUserId->setSizePolicy(sizePolicy);
        lineEditNumericUserId->setReadOnly(true);
        containerForm->addRow(i18n("Numeric user id:"), lineEditNumericUserId);
        connect(lineEditNumericUserId, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList);

        lineEditApiKey = new KLineEdit(container);
        lineEditApiKey->setSizePolicy(sizePolicy);
        lineEditApiKey->setReadOnly(true);
        containerForm->addRow(i18n("API key:"), lineEditApiKey);
        connect(lineEditApiKey, &KLineEdit::textChanged, p, &ZoteroBrowser::invalidateGroupList);

        QBoxLayout *containerButtonLayout = new QHBoxLayout();
        containerLayout->addLayout(containerButtonLayout, 0);
        containerButtonLayout->setMargin(0);
        QPushButton *buttonGetOAuthCredentials = new QPushButton(QIcon::fromTheme(QStringLiteral("preferences-web-browser-identification")), i18n("Get New Credentials"), container);
        containerButtonLayout->addWidget(buttonGetOAuthCredentials, 0);
        connect(buttonGetOAuthCredentials, &QPushButton::clicked, p, &ZoteroBrowser::getOAuthCredentials);
        containerButtonLayout->addStretch(1);

        /// Collection browser
        collectionBrowser = new QTreeView(tabWidget);
        tabWidget->addTab(collectionBrowser, QIcon::fromTheme(QStringLiteral("folder-yellow")), i18n("Collections"));
        collectionBrowser->setHeaderHidden(true);
        collectionBrowser->setExpandsOnDoubleClick(false);
        connect(collectionBrowser, &QTreeView::doubleClicked, p, &ZoteroBrowser::collectionDoubleClicked);

        /// Tag browser
        tagBrowser = new QListView(tabWidget);
        tabWidget->addTab(tagBrowser, QIcon::fromTheme(QStringLiteral("mail-tagged")), i18n("Tags"));
        connect(tagBrowser, &QListView::doubleClicked, p, &ZoteroBrowser::tagDoubleClicked);
    }