コード例 #1
0
ImageLabel::ImageLabel(MWidget *parent): MStylableWidget(parent)
{
    MLayout *layout = new MLayout();
    layout->setAnimation(NULL);
    m_policy = new MLinearLayoutPolicy(layout, Qt::Horizontal);
    setLayout(layout);

    m_image = NULL;
    m_label = new MLabel;
    m_label->setTextElide(true);
    m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    m_policy->addItem(m_label);
}
コード例 #2
0
void MMashupCanvasViewPrivate::init()
{
    MLayout *dl = new MLayout;
    dl->setAnimation(NULL);
    layout = dl;
    mainLayout->addItem(layout);
    layoutPolicy = new MFlowLayoutPolicy(dl);
    appletInventoryButton = new MButton;
    appletInventory = new MAppletInventory;
    appletInventoryWindow = new MModalSceneWindow;
    appletInventoryViewport = new MPannableViewport(appletInventoryWindow);

    // Put the applet inventory inside a viewport
    appletInventoryViewport->setWidget(appletInventory);

    // TODO: FIXME - this needs to have the scene specified,
    // temporarily uses currently active MWindow's scene.
    QSize sceneSize = MApplication::activeWindow()->visibleSceneSize();

    appletInventoryViewport->setMinimumSize(sceneSize);
    appletInventoryViewport->setMaximumSize(sceneSize);

    // Create a dialog layout
    QGraphicsLinearLayout *dialogLayout = new QGraphicsLinearLayout();
    dialogLayout->setContentsMargins(0, 0, 0, 0);
    dialogLayout->addItem(appletInventoryViewport);
    appletInventoryWindow->setLayout(dialogLayout);
    appletInventoryWindow->setObjectName("MAppletInventoryWindow");

    // Create an applet inventory button
    appletInventoryButton->setObjectName("MAppletInventoryButton");
    //~ uispec-document ??? FIXME
    //% "Applet Library"
    appletInventoryButton->setText(qtTrId("qtn_appl_inventory"));

    // Add the applet inventory button to a horizontal layout for centering
    QGraphicsLinearLayout *l = new QGraphicsLinearLayout(Qt::Horizontal);
    l->setContentsMargins(0, 0, 0, 0);
    l->addStretch();
    l->addItem(appletInventoryButton);
    l->addStretch();

    // Add the horizontal layout to the main layout
    mainLayout->addItem(l);
}
コード例 #3
0
ファイル: countrypage.cpp プロジェクト: flavio/rockmarble
void CountryPage::createContent()
{
  if (m_pageMode == CountryModel::BY_ARTIST)
    m_countryModel = new CountryModel(m_dbStorage, m_artistID);
  else
    m_countryModel = new CountryModel(m_dbStorage);

  QGraphicsWidget *panel = centralWidget();
  MLayout *layout = new MLayout(panel);
  layout->setAnimation(NULL);
  panel->setLayout(layout);
  m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);

  // No country label
  m_noCountryLabel = new MLabel(tr("No events to show.<br/>"
                                   "Possible reasons:<br/>"
                                   "<ul>"
                                   "<li>None of your artist is on tour.</li>"
                                   "<li>You don't have added an artist yet.</li>"
                                   "</ul>"));
  m_noCountryLabel->setAlignment(Qt::AlignJustify);
  if (m_countryModel->rowCount() == 0) {
    m_policy->addItem(m_noCountryLabel);
    m_noCountryLabelVisible = true;
  } else
    m_noCountryLabelVisible = false;

  MList *countryList = new MList();
  countryList->setSelectionMode(MList::SingleSelection);

  CountryItemCreator *cellCreator = new CountryItemCreator();
  countryList->setCellCreator(cellCreator);
  countryList->setItemModel(m_countryModel);
  m_policy->addItem(countryList);

  connect (countryList, SIGNAL(itemClicked(QModelIndex)),
           this, SLOT(slotCountryClicked(QModelIndex)));
  connect (DBManager::instance(m_dbStorage), SIGNAL(locationCreated(int)),
           this, SLOT(slotLocationCreated(int)));
}
コード例 #4
0
void ConversationPage::createContent()
{
    MApplicationPage::createContent();
    setContentsMargins(0, 0, 0, 0);
    setPannable(true);

    createActions();
    //% "Mail"
    setTitle(qtTrId("xx_page_title"));

    MLayout *layout = new MLayout(centralWidget());
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setAnimation(0);

    m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
    m_policy->setObjectName("VerticalPolicy");
    m_policy->setContentsMargins(0, 0, 0, 0);
    m_policy->setSpacing(0);

    QMailMessage message(m_id);
    //% "From"
    QString body = qtTrId("xx_from") + ": " + message.from().address() + "\n";
    QStringList addresses = QMailAddress::toStringList(message.to());
    //% "To"
    body.append(qtTrId("xx_to") + ": "  + addresses.join("; ") + "\n");
    addresses = QMailAddress::toStringList(message.cc());
    if (addresses.size() > 0)
        //% "Cc"
        body.append(qtTrId("xx_cc" ) + ": " + addresses.join("; ") + "\n");
    addresses = QMailAddress::toStringList(message.bcc());
    if (addresses.size() > 0)
        //% "Bcc"
        body.append(qtTrId("xx_bcc" ) + ": " + addresses.join("; ") + "\n");

    QMailAddress replyTo = message.replyTo();
    if (!replyTo.isNull())
        //% "Reply-To"
        body.append(qtTrId("xx_reply_to") + ": " + replyTo.toString() + "\n");

    //% "Subject"
    body.append(qtTrId("xx_subject") + ": " + message.subject() + "\n");
    //% "Date: %1"
    body.append(qtTrId("xx_date").arg(message.date().toLocalTime().toString(Qt::SystemLocaleShortDate)));
    MLabel *messageBody = new MLabel(body);
    messageBody->setWordWrap(true);
    messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    messageBody->setObjectName("BodyText");
    m_policy->addItem(messageBody);

    MSeparator *separator = new MSeparator();
    separator->setObjectName("Separator");
    m_policy->addItem(separator);

    messageBody = new MLabel("\n" + Utils::bodyPlainText(&message));
    messageBody->setWordWrap(true);
    messageBody->setObjectName("BodyText");
    messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

    m_policy->addItem (messageBody);
    processAttachments(message);

    centralWidget()->setLayout(layout);
}
コード例 #5
0
ファイル: artistpage.cpp プロジェクト: flavio/rockmarble
void ArtistPage::createContent()
{
  MApplicationPage::createContent();

  QGraphicsWidget *panel = centralWidget();
  MLayout* layout = new MLayout(panel);
  m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical);
  layout->setAnimation(NULL);
  panel->setLayout(layout);
  layout->setLandscapePolicy(m_policy);
  layout->setPortraitPolicy(m_policy);

  if (m_pageMode == ALL_ARTISTS) {
    // Menu Actions
    MAction* actionImportLastfm = new MAction(panel);
    actionImportLastfm->setText(tr("Import from Last.fm"));
    actionImportLastfm->setLocation(MAction::ApplicationMenuLocation);
    addAction(actionImportLastfm);
    connect(actionImportLastfm, SIGNAL(triggered()), this, SLOT(slotImportLastfm()));

    MAction* actionAddArtist = new MAction(panel);
    actionAddArtist->setText(tr("Add artist"));
    actionAddArtist->setLocation(MAction::ApplicationMenuLocation);
    addAction(actionAddArtist);
    connect(actionAddArtist, SIGNAL(triggered()), this, SLOT(slotAddArtist()));

    // Toolbar Actions
    MAction* actionFilter = new MAction("icon-m-toolbar-filter", "", this);
    actionFilter->setLocation(MAction::ToolBarLocation);
    addAction(actionFilter);
    connect(actionFilter, SIGNAL(triggered()), this, SLOT(slotShowFilter()));
  }

  MAction* actionRefresh = new MAction("icon-m-toolbar-refresh", "", this);
  actionRefresh->setLocation(MAction::ToolBarLocation);
  addAction(actionRefresh);
  connect(actionRefresh, SIGNAL(triggered()), this, SLOT(slotRefreshEvents()));

  MAction* actionSearch = new MAction("icon-m-toolbar-search", "", this);
  actionSearch->setLocation(MAction::ToolBarLocation);
  addAction(actionSearch);
  connect(actionSearch, SIGNAL(triggered()), this, SLOT(slotShowSearch()));

  // setup model
  m_artistsModel = new ArtistModel(m_dbStorage, artistsModelQuery());

  // filtering text box
  QGraphicsLinearLayout *containerLayout = new QGraphicsLinearLayout(Qt::Horizontal);

  MLabel* filterLabel = new MLabel(tr("Filter artist:"));
  containerLayout->addItem(filterLabel);

  m_filter = new MTextEdit(MTextEditModel::SingleLine, QString());
  containerLayout->addItem(m_filter);
  m_filter->setObjectName("CommonSingleInputField");
  connect(m_filter, SIGNAL(textChanged()), this, SLOT(slotFilterChanged()));

  m_filterWidget = new MWidget();
  m_filterWidget->setLayout(containerLayout);

  // No artist found label
  m_noArtistLabel = new MLabel(tr("No artist available, add them using one of "
                                  "menu options."));
  m_noArtistLabel->setAlignment(Qt::AlignCenter);
  if (m_artistsModel->rowCount() == 0)
    m_policy->addItem(m_noArtistLabel);

  // MList with fast view
  MList* artistsList = new MList();
  artistsList->setSelectionMode(MList::SingleSelection);

  // Content item creator and item model for the list
  artistsList->setCellCreator(new ArtistItemCreator(m_pageMode, m_dbStorage,
                                                    m_country));
  artistsList->setItemModel(m_artistsModel);
  m_policy->addItem(artistsList);

  connect(artistsList, SIGNAL(itemClicked(QModelIndex)),
           this, SLOT(slotArtistClicked(QModelIndex)));
  connect(DBManager::instance(m_dbStorage), SIGNAL(artistAdded(int,bool)),
           this, SLOT(slotArtistAdded(int,bool)));

  if (m_pageMode == ARTIST_NEAR_LOCATION_SEARCH) {
    //overwrite history
    MApplicationWindow* appWindow = applicationWindow();
    MScene* scene = appWindow->scene();
    MSceneManager* sceneManager = scene->sceneManager();
    QList<MSceneWindow*> history = sceneManager->pageHistory();
    if (history.last()->metaObject()->className() == NearLocationSearchPage::staticMetaObject.className()) {
      // overwrite history only if the last page is NearLocationSearchPage
      history.removeAt(history.size()-1);
      if (history.last()->metaObject()->className() != NearLocationMainPage::staticMetaObject.className()) {
        MApplicationPage* prevPage = new NearLocationMainPage();
        history << prevPage;
      }
      sceneManager->setPageHistory(history);
    }

    //search events
    m_lastfm->getEventsNearLocation(m_latitude, m_longitude, m_distance);
  }

  if (m_dbStorage == DBManager::DISK) {
    DBManager* db = DBManager::instance(m_dbStorage);
    QStringList incompleteArtists = db->incompleteArtists();
    foreach(QString artist, incompleteArtists) {
      m_lastfm->getEventsForArtist(artist);
    }