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.º 2
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);
}
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;
}
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
void ActivityManager::sortActivities() {
  QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *>(static_cast<QGraphicsWidget *>(extender()->item("Activities")->widget())->layout());
  // remove all activities from the layout
  while (layout->count())
    layout->removeAt(0);
  // insert all activities to a map
  QMap<QString, ActivityWidget *> activities;
  foreach (ActivityWidget *activity, m_activities.values())
    activities.insertMulti(activity->name(), activity);
  // add activities into the layout at ascending order of their names
  foreach (ActivityWidget *activity, activities.values())
    layout->addItem(activity);
}
Ejemplo n.º 6
0
SessionWidget::SessionWidget( QGraphicsItem * parent, Qt::WindowFlags wFlags)
  : QGraphicsWidget ( parent, wFlags)
{
  this->setFocusPolicy(Qt::ClickFocus);

   m_signalMapper = new QSignalMapper(this);

  QGraphicsLinearLayout* mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
  mainLayout->setSpacing(0);
  mainLayout->addStretch();
  this->setLayout(mainLayout);

  connect( m_signalMapper, SIGNAL(mapped(int)),
           this, SLOT(slotSwitchSession(int)));

  Q_ASSERT(mainLayout->count() == 0);

  //Cache the icon pixmaps
  QSize iconSize = QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium);

  SessList sessions;
  KDisplayManager manager;
  manager.localSessions(sessions);

  QList<QGraphicsWidget*> entries;

  foreach(SessEnt session, sessions) {
    QPixmap pixmap;
    KUser user (session.user);
    if (!user.isValid())
      continue;

    if (session.tty)
      continue;

    Plasma::IconWidget* entry = createButton(this);
    pixmap = getUserIcon(user);

    entry->setIcon(pixmap);

    QString username = getUsername(false, user);
    entry->setText(username);

    connect(entry, SIGNAL(clicked()), m_signalMapper, SLOT(map()));
    m_signalMapper->setMapping(entry, session.vt);

    if (session.self)
      entry->setEnabled(false);

    entries << entry;
  }
Ejemplo n.º 7
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.º 8
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);
}