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))); }
void Ut_MListView::initTestCase() { static char *app_name[1] = { (char *) "./ut_mlistview" }; static int argc = 1; app = new MApplication(argc, app_name); MPannableViewport *viewport = new MPannableViewport(); viewport->resize(50, 100); MList *controller = new MList(viewport); m_subject = new MListView(controller); MListModel *model = new MListModel(); model->setShowGroups(true); QStandardItemModel *itemModel = new QStandardItemModel(4, 2); for (int row = 0; row < itemModel->rowCount(); ++row) { for (int column = 0; column < itemModel->columnCount(); ++column) { QStandardItem *item = new QStandardItem( QString("row %0, column %1").arg(row).arg(column)); itemModel->setItem(row, column, item); } } QItemSelectionModel *selectionModel = new QItemSelectionModel(itemModel); controller->setSelectionModel(selectionModel); controller->setItemModel(itemModel); model->setSelectionModel(selectionModel); m_dummyWidget = new MDummyTestWidget(); connect(m_dummyWidget, SIGNAL(itemClickSignal()), m_subject, SLOT(itemClick())); model->setItemModel(itemModel); m_subject->setModel(model); m_subject->init(); }
PanelPage::PanelPage(QGraphicsItem *parent): MApplicationPage(parent) { m_panelmgr = new McaPanelManager(this); m_panelmgr->setCategories(QStringList() << "email" << "social" << "im"); m_panelmgr->initialize("sample"); m_frozen = false; m_hiding = false; QGraphicsLinearLayout *linear = new QGraphicsLinearLayout(Qt::Vertical, centralWidget()); QGraphicsLinearLayout *toolbar = new QGraphicsLinearLayout(Qt::Horizontal); linear->addItem(toolbar); MButton *button = new MButton("Search"); connect(button, SIGNAL(clicked()), this, SLOT(openSearch())); toolbar->addItem(button); button = new MButton("Settings"); connect(button, SIGNAL(clicked()), this, SLOT(openSettings())); toolbar->addItem(button); m_freezeButton = new MButton("Freeze"); connect(m_freezeButton, SIGNAL(clicked()), this, SLOT(toggleFreeze())); toolbar->addItem(m_freezeButton); m_hideButton = new MButton("Mode: Default"); connect(m_hideButton, SIGNAL(clicked()), this, SLOT(toggleHide())); toolbar->addItem(m_hideButton); MList *list = new MList; linear->addItem(list); list->setPreferredWidth(800); list->setItemModel(m_panelmgr->feedModel()); PanelCellCreator *cellCreator = new PanelCellCreator; cellCreator->m_page = this; list->setCellCreator(cellCreator); }
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); }