void Ut_MSettingsLanguageTextFactory::testCreateWidget()
{
    // Create a settings text
    MSettingsLanguageText settingsText("TestKey", "Title");
    MSettingsLanguageWidget dds;
    MockDataStore dataStore;
    MWidget *widget = MSettingsLanguageTextFactory::createWidget(settingsText, dds, &dataStore);
    QVERIFY(widget != NULL);

    // Expecting the widget to have a layout and linear policy
    QGraphicsLinearLayout *layout = dynamic_cast<QGraphicsLinearLayout *>(widget->layout());
    QVERIFY(layout != NULL);

    // Expecting the layout to contain a MLabel and a MTextEdit
    QCOMPARE(layout->count(), 2);

    // The label's title should be the SettingsText's title
    MLabel *label = dynamic_cast<MLabel *>(layout->itemAt(0));
    QVERIFY(label != NULL);
    QCOMPARE(label->text(), settingsText.title());

    // The label's title should be the specified key's value
    MTextEdit *textEdit = dynamic_cast<MTextEdit *>(layout->itemAt(1));
    QVERIFY(textEdit != NULL);
    QCOMPARE(textEdit->text(), dataStore.value("TestKey").toString());

    delete widget;
}
    void DualButtonToolbarSnippet::setChildSpacing(int width) {
        QGraphicsLinearLayout* l = layout();

        // If all the buttons have been added, set the spacing for the last button
        if (l->count() == DUAL_TOOLBAR_NUM_BUTTONS ) {
            int spacing = width - l->itemAt(0)->geometry().width() -  l->itemAt(l->count()-1)->geometry().width();
            l->setItemSpacing(l->count()-1, spacing);
        }
        ToolbarSnippet::updateOwnerArea();
    }
Ejemplo n.º 3
0
SxEditor::SxEditor( const QString& file, const QString& name, QObject *parent /*= NULL*/ )
: QObject(parent)
, m_szFile(file)
, m_pTextEdit(NULL)
{
	m_pWindow = KXmlUI::windowFromFile("res:/Resources/layout/sxeditor.xml");
	KXmlUI::setPropertyEx(m_pWindow, "titlebar.title", name);

	KWidget *rootWidget = m_pWindow->rootWidget();
	KToolBar *toolbar = rootWidget->findChild<KToolBar*>("edittoolbar");
	QGraphicsLinearLayout *linear = dynamic_cast<QGraphicsLinearLayout*>(toolbar->layout());
	for(int i = 0; i < linear->count(); i++)
	{
		QGraphicsLayoutItem * item = linear->itemAt(i);
		KPushButton *button = dynamic_cast<KPushButton*>(item);
		if(button)
		{
			bool bok = QObject::connect(button, SIGNAL(clicked()), this, SLOT(on_common_command_clicked()));
		}
	}

	m_pTextEdit = rootWidget->findChild<SxRichEdit*>("richtexteditor");
	QObject::connect(m_pTextEdit, SIGNAL(contextMenu(QMenu*,bool*)), this, SLOT(on_editor_contextMenu(QMenu*,bool*)));

	QFont font("SimSun", 9);
	m_pTextEdit->setFont(font);

	QPoint pt = KUtility::nextCascadesWindowPosition();
	m_pWindow->move(pt);
	m_pWindow->show();

	QObject::connect(m_pWindow, SIGNAL(aboutToClose()), this, SLOT(on_aboutToClose_triggered()));
	
	QMetaObject::invokeMethod(this, "asynOpen", Qt::QueuedConnection);
}
Ejemplo n.º 4
0
void
TabsView::updateScrollBarVisibility()
{
    QGraphicsLinearLayout *lo = static_cast<QGraphicsLinearLayout*>( layout() );
    if( m_scrollBar->maximum() == 0 )
    {
        if( lo->count() > 2 && lo->itemAt( 1 ) == m_scrollBar )
        {
            lo->removeAt( 1 );
            m_scrollBar->hide();
        }
    }
    else if( lo->count() == 2 )
    {
        lo->insertItem( 1, m_scrollBar );
        m_scrollBar->show();
    }
}
Ejemplo n.º 5
0
int KWidget::itemSpacing()
{
    QGraphicsLayout *layout = parentLayout();
    if(d_func()->layoutType == VBox || d_func()->layoutType == HBox)
    {
        QGraphicsLinearLayout *boxLayout = dynamic_cast<QGraphicsLinearLayout*>(layout);
        if(boxLayout)
        {
            QGraphicsLayoutItem *item = dynamic_cast<QGraphicsLayoutItem*>(this);
            for(int i = 0; i < boxLayout->count(); i++)
            {
                if(boxLayout->itemAt(i) == item)
                {
                    return boxLayout->itemSpacing(i);
                }
            }
        }
    }
    return 0;
}
Ejemplo n.º 6
0
void KWidget::setItemSpacing( int space )
{
    QGraphicsLayout *layout = parentLayout();
    LayoutType type = parentLayoutType();
    if(type == VBox || type == HBox)
    {
        QGraphicsLinearLayout *boxLayout = dynamic_cast<QGraphicsLinearLayout*>(layout);
        if(boxLayout)
        {
            QGraphicsLayoutItem *item = dynamic_cast<QGraphicsLayoutItem*>(this);
            for(int i = 0; i < boxLayout->count(); i++)
            {
                if(boxLayout->itemAt(i) == item)
                {
                    boxLayout->setItemSpacing(i, space);
                    return ;
                }
            }
        }
    }
}
void PeopleGroupedView::insertCard(const QModelIndex& index) {
    // requires: model is sorted in alphabetical order
    QGraphicsLinearLayout *linear;

    SEASIDE_SHORTCUTS
    SEASIDE_SET_MODEL_AND_ROW(m_itemModel, index.row());
    QString name = SEASIDE_FIELD(FirstName, String);
    bool isSelf = SEASIDE_FIELD(isSelf, Bool);

    int section;

    //if MeCard section 0, else shift other sections down one
    if(isSelf)
        section = 0;
    else
        section = findSection(name, m_headings)+1;

    // if this is the first item in the section, add the heading
    if (m_sectionCounts[section] == 0) {
        // items from before the first heading go in an "Other" section at the beginning
        QString heading;
        if (section > 1)
            heading = m_displayHeadings[section-2];
        else if(section == 1)
            heading = "Other";  // TODO: i18n
        else
            heading = "Me";
        linear = new QGraphicsLinearLayout(Qt::Vertical);
        linear->setContentsMargins(0, 0, 0, 0);
        linear->setSpacing(0);

        m_mainLayout->addItem(linear, section, 0);
        linear->addItem(createHeader(heading));
    }

    m_sectionCounts[section]++;

    qDebug() << "section " << section << " sectionCount " << m_sectionCounts[section];

    linear = static_cast<QGraphicsLinearLayout *>(m_mainLayout->itemAt(section, 0));
    SeasidePersonCard *card = new SeasidePersonCard(index);

    int i;
    int count = linear->count();
    for (i=1; i<count; i++) {
        SeasidePersonCard *existing = static_cast<SeasidePersonCard *>(linear->itemAt(i));
        if (existing->name().localeAwareCompare(name) > 0)
            break;
    }
     qDebug() << "item at " << i;
    linear->insertItem(i, card);

    QObject::connect(card, SIGNAL(requestDetails(QModelIndex)),
                     m_controller, SIGNAL(itemClicked(QModelIndex)),
                     Qt::UniqueConnection);

    /*QObject::connect(card, SIGNAL(requestEdit(QModelIndex)),
                     m_controller, SIGNAL(editRequest(QModelIndex)),
                     Qt::UniqueConnection);*/

    QObject::connect(card, SIGNAL(requestSetFavorite(const QUuid&,bool)),
                     m_controller, SLOT(setFavorite(const QUuid&,bool)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(requestDelete(const QUuid&)),
                     m_controller, SLOT(deletePerson(const QUuid&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(callNumber(const QString&)),
                     m_controller, SIGNAL(callNumber(const QString&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(composeSMS(const QString&)),
                     m_controller, SIGNAL(composeSMS(const QString&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(composeIM(const QString&)),
                     m_controller, SIGNAL(composeIM(const QString&)),
                     Qt::UniqueConnection);

    QObject::connect(card, SIGNAL(composeEmail(const QString&)),
                     m_controller, SIGNAL(composeEmail(const QString&)),
                     Qt::UniqueConnection);
}