Exemplo n.º 1
0
void KURLBar::slotSelected(int button, QListBoxItem *item)
{
    if(button != Qt::LeftButton)
        return;

    slotSelected(item);
}
Exemplo n.º 2
0
void KMConfigFonts::slotRemove()
{
	delete m_fontpath->selectedItem();
	if (m_fontpath->currentItem())
		m_fontpath->setSelected(m_fontpath->currentItem(), true);
	slotSelected();
}
CitySelectDlg::CitySelectDlg(QString str1,QString str2,QString str3):ZPopup()
{
    setTitle(str1);
    listBox = new ZListBox("%I%M",this);
    
    // insert menu items with images from SysRegistry
    ZConfig config ( getAppDir() + "cities.ini", false );
    QStringList grouplist;
    config.getGroupsKeyList ( grouplist );
    QString cityCode = "";
    
    for ( QStringList::Iterator it = grouplist.begin(); it != grouplist.end(); ++it ) 
    {
        cityCode = config.readEntry(*it, "Code", "");
        City *city = new City(listBox);
        qDebug(*it);
        qDebug(cityCode);
        city->setName(*it);
        city->setCode(cityCode);
        
        listBox->insertItem(city);
        city->appendSubItem(1,ctr(city->getName()));
        
    }
    
    insertChild(listBox);
    setSoftkeyText(str2,str3);
    connect(this,SIGNAL(leftSoftkeyClicked()),this,SLOT(slotSelected()));
    connect(listBox,SIGNAL(returnPressed(ZSettingItem *)),this,SLOT(slotItemClicked(ZSettingItem *)));
    
}
Exemplo n.º 4
0
void FormulaDialog::slotIndexSelected(const QModelIndex& index)
{
    // This slot is only called when single-click to activate is uesd in the listbox, when the mouse moves over a item; to prevent
    // the active selection to change after the user activated one, slotSelected is only called when the current tab is the Help tab,
    // and not when the parameters tab is active
    if (m_tabwidget->currentIndex() != 0) return;
    QString function = proxyModel->data(index).toString();
    slotSelected(function);
}
Exemplo n.º 5
0
void FormulaDialog::slotActivated(const QString& category)
{
    QStringList lst;
    if (category == i18n("All"))
        lst = KCFunctionRepository::self()->functionNames();
    else
        lst = KCFunctionRepository::self()->functionNames(category);

    kDebug(36001) << "category:" << category << " (" << lst.count() << "functions)";

    functionsModel->setStringList(lst);

    QStringList upperList;
    for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
        upperList.append((*it).toUpper());
    listFunct.setItems(upperList);

    // Go to the first function in the list.
    const QString text = proxyModel->data(proxyModel->index(0, 0)).toString();
    slotSelected(text);
}
Exemplo n.º 6
0
// from hyperlink in the "Related KCFunction"
void FormulaDialog::slotShowFunction(const QString& function)
{
    KCFunctionDescription* desc =
        KCFunctionRepository::self()->functionInfo(function);
    if (!desc) return;

    // select the category
    QString category = desc->group();
    typeFunction->setCurrentIndex(typeFunction->findText(category));
    slotActivated(category);

    // select the function
    //Q3ListBoxItem* item = functions->findItem( function, QKeySequence::ExactMatch | Qt::CaseSensitive );
    //if( item ) functions->setCurrentItem( item );
    int row = functionsModel->stringList().indexOf(function);
    const QModelIndex sourcemodelindex = functionsModel->index(row, 0);
    const QModelIndex proxymodelindex = proxyModel->mapFromSource(sourcemodelindex);
    if (proxymodelindex.isValid())
        functions->setCurrentIndex(proxymodelindex);

    slotSelected(function);
}
Exemplo n.º 7
0
KMConfigFonts::KMConfigFonts(TQWidget *parent, const char *name)
: KMConfigPage(parent, name)
{
	setPageName(i18n("Fonts"));
	setPageHeader(i18n("Font Settings"));
	setPagePixmap("fonts");

	TQGroupBox	*box = new TQGroupBox(0, Qt::Vertical, i18n("Fonts Embedding"), this);
	TQGroupBox	*box2 = new TQGroupBox(0, Qt::Vertical, i18n("Fonts Path"), this);

	m_embedfonts = new TQCheckBox(i18n("&Embed fonts in PostScript data when printing"), box);
	m_fontpath = new TDEListView(box2);
	m_fontpath->addColumn("");
	m_fontpath->header()->setStretchEnabled(true, 0);
	m_fontpath->header()->hide();
	m_fontpath->setSorting(-1);
	m_addpath = new KURLRequester(box2);
	m_addpath->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly);
	m_up = new KPushButton(KGuiItem(i18n("&Up"), "up"), box2);
	m_down = new KPushButton(KGuiItem(i18n("&Down"), "down"), box2);
	m_add = new KPushButton(KGuiItem(i18n("&Add"), "add"), box2);
	m_remove = new KPushButton(KGuiItem(i18n("&Remove"), "editdelete"), box2);
	TQLabel	*lab0 = new TQLabel(i18n("Additional director&y:"), box2);
	lab0->setBuddy(m_addpath);

	TQVBoxLayout	*l0 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), KDialog::spacingHint());
	l0->addWidget(m_embedfonts);
	TQVBoxLayout	*l1 = new TQVBoxLayout(TQT_TQLAYOUT(box2->layout()), KDialog::spacingHint());
	l1->addWidget(m_fontpath);
	TQHBoxLayout	*l2 = new TQHBoxLayout(0, 0, KDialog::spacingHint());
	l1->addLayout(l2);
	l2->addWidget(m_up);
	l2->addWidget(m_down);
	l2->addWidget(m_remove);
	l1->addSpacing(10);
	l1->addWidget(lab0);
	l1->addWidget(m_addpath);
	TQHBoxLayout	*l3 = new TQHBoxLayout(0, 0, KDialog::spacingHint());
	l1->addLayout(l3);
	l3->addStretch(1);
	l3->addWidget(m_add);
	TQVBoxLayout	*l4 = new TQVBoxLayout(this, 0, KDialog::spacingHint());
	l4->addWidget(box);
	l4->addWidget(box2);

	TQWhatsThis::add(m_embedfonts,
			i18n("These options will automatically put fonts in the PostScript file "
                             "which are not present on the printer. Font embedding usually produces better print results "
			     "(closer to what you see on the screen), but larger print data as well."));
	TQWhatsThis::add(m_fontpath, 
			i18n("When using font embedding you can select additional directories where "
			     "KDE should search for embeddable font files. By default, the X server "
			     "font path is used, so adding those directories is not needed. The default "
			     "search path should be sufficient in most cases."));

	connect(m_remove, TQT_SIGNAL(clicked()), TQT_SLOT(slotRemove()));
	connect(m_add, TQT_SIGNAL(clicked()), TQT_SLOT(slotAdd()));
	connect(m_up, TQT_SIGNAL(clicked()), TQT_SLOT(slotUp()));
	connect(m_down, TQT_SIGNAL(clicked()), TQT_SLOT(slotDown()));
	connect(m_fontpath, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelected()));
	connect(m_addpath, TQT_SIGNAL(textChanged(const TQString&)), TQT_SLOT(slotTextChanged(const TQString&)));
	m_add->setEnabled(false);
	m_remove->setEnabled(false);
	m_up->setEnabled(false);
	m_down->setEnabled(false);
}
Exemplo n.º 8
0
FormulaDialog::FormulaDialog(QWidget* parent, Selection* selection, CellEditorBase* editor, const QString& formulaName)
        : KDialog(parent)
{
    setCaption(i18n("Function"));
    setButtons(Ok | Cancel);
    //setWFlags( Qt::WDestructiveClose );

    m_selection = selection;
    m_editor = editor;
    m_focus = 0;
    m_desc = 0;

    KCCell cell(m_selection->activeSheet(), m_selection->marker());
    m_oldText = cell.userInput();
    // Make sure that there is a cell editor running.
    if (cell.userInput().isEmpty())
        m_editor->setText("=");
    else if (cell.userInput().at(0) != '=')
        m_editor->setText('=' + cell.userInput());
    else
        m_editor->setText(cell.userInput());

    QWidget *page = new QWidget(this);
    setMainWidget(page);

    QGridLayout *grid1 = new QGridLayout(page);
    grid1->setMargin(KDialog::marginHint());
    grid1->setSpacing(KDialog::spacingHint());

    searchFunct = new KLineEdit(page);
    searchFunct->setClearButtonShown(true);
    searchFunct->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));

    grid1->addWidget(searchFunct, 0, 0);

    typeFunction = new KComboBox(page);
    QStringList cats = KCFunctionRepository::self()->groups();
    cats.prepend(i18n("All"));
    typeFunction->setMaxVisibleItems(15);
    typeFunction->insertItems(0, cats);
    grid1->addWidget(typeFunction, 1, 0);

    functions = new QListView(page);
    functions->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
    functions->setSelectionMode(QAbstractItemView::SingleSelection);
    functions->setEditTriggers(QAbstractItemView::NoEditTriggers);
    grid1->addWidget(functions, 2, 0);

    functionsModel = new QStringListModel(this);
    proxyModel = new QSortFilterProxyModel(functions);
    proxyModel->setSourceModel(functionsModel);
    proxyModel->setFilterKeyColumn(0);
    proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    functions->setModel(proxyModel);

    QItemSelectionModel* selectionmodel = new QItemSelectionModel(proxyModel, this);
    functions->setSelectionModel(selectionmodel);
    connect(selectionmodel, SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
            this, SLOT(slotSelected()));
    // When items are activated on single click, also change the help page on mouse-over, otherwise there is no (easy) way to get
    // the help without inserting the function
    if (functions->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, 0, functions)) {
        connect(functions, SIGNAL(entered(QModelIndex)), this, SLOT(slotIndexSelected(QModelIndex)));
        functions->setMouseTracking(true);
    }
    //connect(proxyModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotDataChanged(QModelIndex,QModelIndex)));

    selectFunction = new QPushButton(page);
    selectFunction->setToolTip(i18n("Insert function"));
    selectFunction->setIcon(BarIcon("go-down", KIconLoader::SizeSmall));
    grid1->addWidget(selectFunction, 3, 0);

    result = new KLineEdit(page);
    grid1->addWidget(result, 4, 0, 1, -1);

    m_tabwidget = new KTabWidget(page);
    m_tabwidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
    grid1->addWidget(m_tabwidget, 0, 1, 4, 1);

    m_browser = new KTextBrowser(m_tabwidget, true);
    m_browser->document()->setDefaultStyleSheet("h1 { font-size:x-large; } h2 { font-size:large; } h3 { font-size:medium; }");
    m_browser->setMinimumWidth(300);

    m_tabwidget->addTab(m_browser, i18n("Help"));
    int index = m_tabwidget->currentIndex();

    m_input = new QWidget(m_tabwidget);
    QVBoxLayout *grid2 = new QVBoxLayout(m_input);
    grid2->setMargin(KDialog::marginHint());
    grid2->setSpacing(KDialog::spacingHint());

    // grid2->setResizeMode (QLayout::Minimum);

    label1 = new QLabel(m_input);
    grid2->addWidget(label1);

    firstElement = new KLineEdit(m_input);
    grid2->addWidget(firstElement);

    label2 = new QLabel(m_input);
    grid2->addWidget(label2);

    secondElement = new KLineEdit(m_input);
    grid2->addWidget(secondElement);

    label3 = new QLabel(m_input);
    grid2->addWidget(label3);

    thirdElement = new KLineEdit(m_input);
    grid2->addWidget(thirdElement);

    label4 = new QLabel(m_input);
    grid2->addWidget(label4);

    fourElement = new KLineEdit(m_input);
    grid2->addWidget(fourElement);

    label5 = new QLabel(m_input);
    grid2->addWidget(label5);

    fiveElement = new KLineEdit(m_input);
    grid2->addWidget(fiveElement);

    grid2->addStretch(10);

    m_tabwidget->addTab(m_input, i18n("Parameters"));
    m_tabwidget->setTabEnabled(m_tabwidget->indexOf(m_input), false);

    m_tabwidget->setCurrentIndex(index);

    refresh_result = true;

    connect(this, SIGNAL(cancelClicked()), this, SLOT(slotClose()));
    connect(this, SIGNAL(okClicked()), this, SLOT(slotOk()));
    connect(typeFunction, SIGNAL(activated(const QString &)),
            this, SLOT(slotActivated(const QString &)));
    /*
        connect( functions, SIGNAL( highlighted(const QString &) ),
                 this, SLOT( slotSelected(const QString &) ) );
        connect( functions, SIGNAL( selected(const QString &) ),
                 this, SLOT( slotSelected(const QString &) ) );
    */
    connect(functions, SIGNAL(activated(QModelIndex)),
            this , SLOT(slotDoubleClicked(QModelIndex)));

    slotActivated(i18n("All"));

    connect(selectFunction, SIGNAL(clicked()),
            this, SLOT(slotSelectButton()));

    connect(firstElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(secondElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(thirdElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(fourElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));
    connect(fiveElement, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotChangeText(const QString &)));

    connect(m_selection, SIGNAL(changed(const KCRegion&)),
            this, SLOT(slotSelectionChanged()));

    connect(m_browser, SIGNAL(urlClick(const QString&)),
            this, SLOT(slotShowFunction(const QString&)));

    // Save the name of the active sheet.
    m_sheetName = m_selection->activeSheet()->sheetName();
    // Save the cells current text.
    QString tmp_oldText = m_editor->toPlainText();
    // Position of the cell.
    m_column = m_selection->marker().x();
    m_row = m_selection->marker().y();

    if (tmp_oldText.isEmpty())
        result->setText("=");
    else {
        if (tmp_oldText.at(0) != '=')
            result->setText('=' + tmp_oldText);
        else
            result->setText(tmp_oldText);
    }

    // Allow the user to select cells on the spreadsheet.
    m_selection->startReferenceSelection();

    qApp->installEventFilter(this);

    // Was a function name passed along with the constructor ? Then activate it.
    if (!formulaName.isEmpty()) {
        kDebug() << "formulaName=" << formulaName;
#if 0
        QList<QListWidgetItem *> items = functions->findItems(formulaName, Qt::MatchFixedString);
        if (items.count() > 0) {
            functions->setCurrentItem(items[0]);
            slotDoubleClicked(items[0]);
        }
#else
        int row = functionsModel->stringList().indexOf(formulaName);
        const QModelIndex sourcemodelindex = functionsModel->index(row, 0);
        const QModelIndex proxymodelindex = proxyModel->mapFromSource(sourcemodelindex);
        if (proxymodelindex.isValid()) {
            functions->setCurrentIndex(proxymodelindex);
            slotDoubleClicked(proxymodelindex);
        }
#endif
    } else {
        // Set keyboard focus to allow selection of a formula.
        searchFunct->setFocus();
    }

    // Add auto completion.
    searchFunct->setCompletionMode(KGlobalSettings::CompletionAuto);
    searchFunct->setCompletionObject(&listFunct, true);

    if (functions->currentIndex().isValid())
        selectFunction->setEnabled(false);

    connect(searchFunct, SIGNAL(textChanged(const QString &)),
            this, SLOT(slotSearchText(const QString &)));
    connect(searchFunct, SIGNAL(returnPressed()),
            this, SLOT(slotPressReturn()));

    resize(QSize(660, 520).expandedTo(minimumSizeHint()));
}