QDocumentServerCategoryStore::QDocumentServerCategoryStore( QObject *parent )
    : QCategoryStore( parent )
{
    d = new QDocumentServerCategoryStorePrivate( this );

    connect( d, SIGNAL(categoriesChanged()), this, SIGNAL(categoriesChanged()) );

    for( int i = 0; i < 5 && !d->connect(); i++ )
        qWarning() << "Could not connect to category store server";
}
Beispiel #2
0
void CategoryWidget::saveRecord()
{
    QString inputName = m_nameLineEdit->text();
    if (inputName.isEmpty()) {
        QMessageBox::critical(this, tr("Error"), tr("Name is empty"));
        return;
    }

    int row = m_treeView->currentIndex().row();

    for (int i = 0; i < m_model->rowCount(); ++i) {
        if (row != i && inputName == m_model->item(i, 1)->text()) {
            QMessageBox::critical(this, tr("Error"), tr("Name is duplicate"));
            return;
        }
    }

    m_addAct->setEnabled(true);
    m_deleteAct->setEnabled(true);
    m_modifyAct->setEnabled(true);
    m_saveAct->setDisabled(true);
    m_cancelAct->setDisabled(true);

    m_nameLineEdit->setDisabled(true);
    m_noteLineEdit->setDisabled(true);

    if (tr("Automatically assign") == m_idLabel->text()) {

        data::Category category = m_resourceManager->addCategory(
                    inputName, m_noteLineEdit->text());
        Q_ASSERT(-1 != category.id);

        m_categories.append(category);
        addOneCategoryToModel(category, m_model);
        m_treeView->setCurrentIndex(m_model->index(m_model->rowCount() -1, 0));

        emit categoriesChanged();

    } else {

        data::Category & category = m_categories[row];
        category.name = m_nameLineEdit->text();
        category.note = m_noteLineEdit->text();

        m_resourceManager->updateCategory(category);

        m_model->item(row, 1)->setText(category.name);
        m_model->item(row, 2)->setText(category.note);

        emit categoriesChanged();

    }
}
Beispiel #3
0
void Menu::addCategory(MenuCategory *category) {
    m_categories.append(category);
    if(category->property("id").toUInt() > m_currentCategoryId)
        m_currentCategoryId = category->property("id").toUInt();
    Pos::instance()->appendToMenuHistory("AddMenuCategory:" + category->serialize());
    categoriesChanged(categories());
}
void MaterialCategoryModel::removeCategory(const QString& name)
{
    QString uuid;

    std::map<QString,MaterialCategory*>::iterator it = categoriesMap_.find(name);
    if (it!=categoriesMap_.end()) {
        MaterialCategory* category = it->second;
        if (category->isReadOnly()) return;

        categoriesMap_.erase(it);

        uuid = category->getUUID();
        std::map<QString,MaterialCategory*>::iterator ituuid = categoriesUUIDMap_.find(uuid);
        if (it!=categoriesMap_.end()) {
            categoriesUUIDMap_.erase(ituuid);
        }

        for (std::vector<MaterialCategory*>::iterator itv = categories_.begin();
             itv!= categories_.end();
             ++itv) {
            if ((*itv)==category) {
                categories_.erase(itv);
                break;
            }
        }

        delete category;
    }

    modified_ = true;

    emit dataChanged(QModelIndex(), QModelIndex());
    emit categoriesChanged();
}
/*!
    Constructs a new SQL category store.
*/
QSqlCategoryStore::QSqlCategoryStore()
{
#ifndef QTOPIA_CONTENT_INSTALLER
    if (qApp)
        connect(qApp, SIGNAL(categoriesChanged()), this, SLOT(reloadCategories()));
#endif
}
CategoriesPage::CategoriesPage(Nepomuk::WebExtractorConfig* cfg, QWidget * parent):
    QWidget(parent),
    m_config(cfg),
    m_categoryEdited(false)
{
    this->setupUi(this);
    this->query_edit_widget->hide();
    this->query_prefix_edit->hide();
    this->plugins_selector = new PluginSelector(this);
    this->verticalLayout->insertWidget(0, this->plugins_selector);
    m_oldDelegate = this->plugins_selector->selectedView()->itemDelegate();
    m_newDelegate = new CategoryPluginItemDelegate(this->plugins_selector->selectedView(), this);
    this->plugins_selector->selectedView()->setItemDelegate(m_newDelegate);
    //this->plugins_selector->selectedListWidget()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    connect(this->query_edit, SIGNAL(textChanged()), this, SLOT(setCategoryChanged()));
    connect(this->query_prefix_edit, SIGNAL(textChanged()), this, SLOT(setCategoryChanged()));
    connect(this->interval_spinbox, SIGNAL(valueChanged(int)), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(added()), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(removed()), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(movedUp()), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(movedDown()), this, SLOT(setCategoryChanged()));
    connect(enabled_categories_listwidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
            SLOT(switchCategory(QListWidgetItem*, QListWidgetItem*)));

    connect(Nepomuk::CategoriesPool::self(), SIGNAL(categoriesChanged()),
            this, SLOT(reloadAvailableCategoriesList()));

    // Initialize machine
    m_machine = new QStateMachine();
    s1 = new QState();
    s2 = new QState();
    s3 = new QState();

    s1->addTransition(manageButton, SIGNAL(clicked()), s2);
    s2->addTransition(returnButton, SIGNAL(clicked()), s1);

    m_machine->addState(s1);
    m_machine->addState(s2);
    m_machine->setInitialState(s1);

    connect(s1, SIGNAL(entered()), this, SLOT(reloadEnabledCategoriesList()));
    connect(s2, SIGNAL(exited()), this, SLOT(syncEnabledCategoriesList()));
    s1->assignProperty(stackedWidget, "currentIndex", 0);
    s2->assignProperty(stackedWidget, "currentIndex", 1);

    // Initialize validator
    m_catvalidator = new CategoryNameValidator(this);

    // Inilialize buttons
    this->add_button->setGuiItem(KStandardGuiItem::add());
    this->add_button->setText(QString());
    this->remove_button->setGuiItem(KStandardGuiItem::remove());
    this->remove_button->setText(QString());
    connect(this->add_button, SIGNAL(clicked()), this, SLOT(addButton()));

    // no need to query endless numbers of results when we only want to create a query
    Nepomuk::Query::Query baseQuery;
    baseQuery.setLimit(10);
    queryBuilder->setBaseQuery(baseQuery);
}
Beispiel #7
0
QT_CHARTS_BEGIN_NAMESPACE

ChartCategoryAxisX::ChartCategoryAxisX(QCategoryAxis *axis, QGraphicsItem* item)
    : HorizontalAxis(axis, item, true),
      m_axis(axis)
{
    QObject::connect(axis, SIGNAL(categoriesChanged()), this, SLOT(handleCategoriesChanged()));
}
void Box2DFixture::setCategories(CategoryFlags layers)
{
    if (mFixtureDef.filter.categoryBits == layers)
        return;

    mFixtureDef.filter.categoryBits = layers;
    emit categoriesChanged();
}
CategoryFilterListModel::CategoryFilterListModel(QObject *parent)
    : AbstractContentFilterPropertyListModel( parent ) 
{
    categoryManager = new QCategoryManager(QLatin1String("Documents"), this);
    
    // reload the model each time cats change
    connect(categoryManager, SIGNAL(categoriesChanged()), SLOT(reload()));
}
Beispiel #10
0
void QDeclarativeLandmarkAbstractModel::connectManager()
{
    if (!m_manager)
        return;
    connect(m_manager, SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)),
            this, SLOT(categoriesChanged(QList<QLandmarkCategoryId>)));
    connect(m_manager, SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)),
            this, SLOT(categoriesChanged(QList<QLandmarkCategoryId>)));
    connect(m_manager, SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)),
            this, SLOT(categoriesChanged(QList<QLandmarkCategoryId>)));
    connect(m_manager, SIGNAL(landmarksAdded(QList<QLandmarkId>)),
            this, SLOT(landmarksChanged(QList<QLandmarkId>)));
    connect(m_manager, SIGNAL(landmarksChanged(QList<QLandmarkId>)),
            this, SLOT(landmarksChanged(QList<QLandmarkId>)));
    connect(m_manager, SIGNAL(landmarksRemoved(QList<QLandmarkId>)),
            this, SLOT(landmarksChanged(QList<QLandmarkId>)));
    connect(m_manager, SIGNAL(dataChanged()),
            this, SLOT(dataChanged()));
}
Beispiel #11
0
void QLandmarkManagerEngineSqlite::disconnectNotify(const char *signal)
{
    if (QLatin1String(signal) == SIGNAL(landmarksAdded(QList<QLandmarkId>))
        || QLatin1String(signal) == SIGNAL(landmarksChanged(QList<QLandmarkId>))
        || QLatin1String(signal) == SIGNAL(landmarksRemoved(QList<QLandmarkId>))
        || QLatin1String(signal) == SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>))
        || QLatin1String(signal) == SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>))
        || QLatin1String(signal) == SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>))) {
        if (receivers(SIGNAL(landmarksAdded(QList<QLandmarkId>))) == 0
            && receivers(SIGNAL(landmarksChanged(QList<QLandmarkId>))) == 0
            && receivers(SIGNAL(landmarksRemoved(QList<QLandmarkId>))) == 0
            && receivers(SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>))) == 0
            && receivers(SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>))) == 0
            && receivers(SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>))) == 0
            )
            setChangeNotificationsEnabled(false);
    }
    QObject::disconnectNotify(signal);
}
void McaPanelManager::initialize(const QString& managerData)
{
    m_panelName = managerData;

    // proxy model should be empty, but seem to need to call rowCount to wake it up
    rowsInserted(QModelIndex(), 0, m_serviceProxy->rowCount() - 1);
    feedRowsChanged();

    connect(m_serviceProxy, SIGNAL(rowsInserted(QModelIndex,int,int)),
            this, SLOT(rowsInserted(QModelIndex,int,int)));
    connect(m_serviceProxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
            this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int)));
    connect(m_serviceProxy, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
            this, SLOT(dataChanged(QModelIndex,QModelIndex)));
    connect(m_serviceProxy, SIGNAL(categoriesChanged(QStringList)),
            this, SIGNAL(categoriesChanged(QStringList)));
    connect(m_feedProxy, SIGNAL(rowsInserted(QModelIndex,int,int)),
            this, SLOT(feedRowsChanged()));
    connect(m_feedProxy, SIGNAL(rowsRemoved(QModelIndex,int,int)),
            this, SLOT(feedRowsChanged()));
}
Beispiel #13
0
KODialogManager::KODialogManager(CalendarView *mainView) :
    QObject(), mMainView(mainView)
{
    mOptionsDialog = 0;
    mSearchDialog = 0;
    mArchiveDialog = 0;
    mFilterEditDialog = 0;

    mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(), mMainView);
    // don't set any specific parent for the dialog, as its kept around and reused
    // in different cases where it should have different parents
    KWin::setMainWindow(mCategoryEditDialog, 0);
    connect(mainView, SIGNAL(categoriesChanged()),
            mCategoryEditDialog, SLOT(reload()));
    KOGlobals::fitDialogToScreen(mCategoryEditDialog);
}
Beispiel #14
0
void QLandmarkManagerEngineSymbian::handleLandmarkEvent(LandmarkEventObserver::lmEvent event,
    QList<QLandmarkId> landmarkIds, QList<QLandmarkCategoryId> categoryIds)
{
    switch (event) {
    case LandmarkEventObserver::landmarkAdded:
    {
        emit landmarksAdded(landmarkIds);
        break;
    }
    case LandmarkEventObserver::landmarkUpdated:
    {
        emit landmarksChanged(landmarkIds);
        break;
    }
    case LandmarkEventObserver::landmarkRemoved:
    {
        emit landmarksRemoved(landmarkIds);
        break;
    }
    case LandmarkEventObserver::categoryAdded:
    {
        emit categoriesAdded(categoryIds);
        break;
    }
    case LandmarkEventObserver::categoryUpdated:
    {
        emit categoriesChanged(categoryIds);
        break;
    }
    case LandmarkEventObserver::categoryRemoved:
    {
        emit categoriesRemoved(categoryIds);
        break;
    }
    case LandmarkEventObserver::unknownChanges:
    {
        emit dataChanged();
        break;
    }
    } // switch closure
}
void MaterialCategoryModel::renameCategory(MaterialCategory* category, const QString& name)
{
    std::map<QString,MaterialCategory*>::iterator it = categoriesMap_.find(category->getName());
    if (it != categoriesMap_.end()) {
        categoriesMap_.erase(it);
    }
    std::map<QString,MaterialCategory*>::iterator itd = categoriesDisplayMap_.find(category->getDisplayName());
    if (itd != categoriesDisplayMap_.end()) {
        categoriesDisplayMap_.erase(itd);
    }

    modified_ = true;

    category->setName(name);
    category->setDisplayName(name);
    categoriesMap_[name] = category;
    categoriesDisplayMap_[name] = category;

    emit dataChanged(QModelIndex(), QModelIndex());
    emit categoriesChanged();
}
Beispiel #16
0
void CategoryWidget::deleteRecord()
{
    int row = m_treeView->currentIndex().row();
    if (0 <= row && row < m_model->rowCount()) {
        const data::Category & category = m_categories.at(row);
        if (category.isBuildIn) {
            QMessageBox::critical(this, tr("Error"), tr("Cannot delete build-in category") + "!");
            return;
        }

        if (0 != m_resourceManager->productCntOfCategory(category)) {
            QMessageBox::critical(this, tr("Error"), tr("Cannot delete category with products") + "!");
            return;
        }

        m_resourceManager->deleteCategory(category);
        m_categories.remove(row);
        m_model->removeRow(row);

        emit categoriesChanged();
    }
}
void MaterialCategoryModel::addCategory(const QString& uuid,
                                        const QString& name,
                                        const QString& displayName,
                                        const QColor& bgColor,
                                        bool readonly)
{
    MaterialCategory * mc = new MaterialCategory(name, displayName, bgColor, readonly);
    mc->setUUID(uuid);
    if (uuid.length()==0) mc->setUUID(QUuid::createUuid().toString());

    // NQLog("MaterialCategoryModel", NQLog::Spam) << "Cat: " << mc;
    // NQLog("MaterialCategoryModel", NQLog::Spam) << "     " << mc->getUUID();

    categoriesMap_[name] = mc;
    categoriesDisplayMap_[displayName] = mc;
    categoriesUUIDMap_[uuid] = mc;
    categories_.push_back(mc);

    modified_ = true;

    emit dataChanged(QModelIndex(), QModelIndex());
    emit categoriesChanged();
}
Beispiel #18
0
TransfersWindow::TransfersWindow(StackedWindow *parent) :
    StackedWindow(parent),
    m_model(new TransferModel(this)),
    m_view(new QTreeView(this)),
    m_startAction(new QAction(tr("Start all transfers"), this)),
    m_pauseAction(new QAction(tr("Pause all transfers"), this)),
    m_contextMenu(new QMenu(this)),
    m_transferCommandAction(m_contextMenu->addAction(tr("Set custom command"),
                                                             this, SLOT(setCurrentTransferCustomCommand()))),
    m_transferStartAction(m_contextMenu->addAction(tr("Start"), this, SLOT(startCurrentTransfer()))),
    m_transferPauseAction(m_contextMenu->addAction(tr("Pause"), this, SLOT(pauseCurrentTransfer()))),
    m_transferCategoryMenu(m_contextMenu->addMenu(tr("Category"))),
    m_transferCategoryGroup(new QActionGroup(this)),
    m_transferPriorityMenu(m_contextMenu->addMenu(tr("Priority"))),
    m_transferPriorityGroup(new QActionGroup(this)),
    m_transferHighPriorityAction(m_transferPriorityMenu->addAction(tr("High"), this, SLOT(setCurrentTransferPriority()))),
    m_transferNormalPriorityAction(m_transferPriorityMenu->addAction(tr("Normal"), this, SLOT(setCurrentTransferPriority()))),
    m_transferLowPriorityAction(m_transferPriorityMenu->addAction(tr("Low"), this, SLOT(setCurrentTransferPriority()))),
    m_transferRemoveAction(m_contextMenu->addAction(tr("Remove"), this, SLOT(removeCurrentTransfer()))),
    m_label(new QLabel(QString("<p align='center'; style='font-size: 40px; color: %1'>%2</p>")
                              .arg(palette().color(QPalette::Mid).name()).arg(tr("No transfers queued")), this))
{
    setWindowTitle(tr("Transfers"));
    setCentralWidget(new QWidget);
        
    m_view->setModel(m_model);
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setItemsExpandable(false);
    m_view->setIndentation(0);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);
    m_view->setColumnHidden(1, true);
    
    QHeaderView *header = m_view->header();

    if (!header->restoreState(Settings::transfersHeaderViewState())) {
        const QFontMetrics fm = header->fontMetrics();
        header->resizeSection(0, fm.width("A long transfer name") + 10);
        header->resizeSection(2, fm.width(m_model->headerData(2).toString()) + 10);
        header->resizeSection(3, fm.width("999.99MB of 999.99MB (99.99%)") + 10);
        header->setSectionHidden(1, true);
    }
    
    m_transferCategoryGroup->setExclusive(true);
    m_transferPriorityGroup->setExclusive(true);
    m_transferHighPriorityAction->setCheckable(true);
    m_transferHighPriorityAction->setActionGroup(m_transferPriorityGroup);
    m_transferNormalPriorityAction->setCheckable(true);
    m_transferNormalPriorityAction->setActionGroup(m_transferPriorityGroup);
    m_transferLowPriorityAction->setCheckable(true);
    m_transferLowPriorityAction->setActionGroup(m_transferPriorityGroup);
    
    m_label->hide();
    
    m_layout = new QVBoxLayout(centralWidget());
    m_layout->addWidget(m_view);
    m_layout->addWidget(m_label);
    m_layout->setContentsMargins(0, 0, 0, 0);
    
    menuBar()->addAction(m_startAction);
    menuBar()->addAction(m_pauseAction);
    
    connect(m_model, SIGNAL(countChanged(int)), this, SLOT(onCountChanged(int)));
    connect(m_startAction, SIGNAL(triggered()), Transfers::instance(), SLOT(start()));
    connect(m_pauseAction, SIGNAL(triggered()), Transfers::instance(), SLOT(pause()));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_contextMenu, SIGNAL(aboutToShow()), this, SLOT(setTransferMenuActions()));
    connect(Settings::instance(), SIGNAL(categoriesChanged()), this, SLOT(setCategoryMenuActions()));
    
    onCountChanged(m_model->rowCount());
    setCategoryMenuActions();
}
Beispiel #19
0
StreamsBrowsePage::StreamsBrowsePage(QWidget *p)
    : SinglePageWidget(p)
    , settings(0)
{
    importAction = new Action(Icon("document-import"), i18n("Import Streams Into Favorites"), this);
    exportAction = new Action(Icon("document-export"), i18n("Export Favorite Streams"), this);
    addAction = ActionCollection::get()->createAction("addstream", i18n("Add New Stream To Favorites"), Icons::self()->addRadioStreamIcon);
    editAction = new Action(Icons::self()->editIcon, i18n("Edit"), this);
    searchAction = new Action(Icons::self()->searchIcon, i18n("Seatch For Streams"), this);
    connect(searchAction, SIGNAL(triggered()), this, SIGNAL(searchForStreams()));
//     connect(view, SIGNAL(itemsSelected(bool)), addToPlaylist, SLOT(setEnabled(bool)));
    connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(itemDoubleClicked(const QModelIndex &)));
    connect(view, SIGNAL(itemsSelected(bool)), SLOT(controlActions()));
    connect(addAction, SIGNAL(triggered()), this, SLOT(addStream()));
    connect(StreamsModel::self()->addBookmarkAct(), SIGNAL(triggered()), this, SLOT(addBookmark()));
    connect(StreamsModel::self()->configureDiAct(), SIGNAL(triggered()), this, SLOT(configureDi()));
    connect(StreamsModel::self()->reloadAct(), SIGNAL(triggered()), this, SLOT(reload()));
    connect(editAction, SIGNAL(triggered()), this, SLOT(edit()));
    connect(importAction, SIGNAL(triggered()), this, SLOT(importXml()));
    connect(exportAction, SIGNAL(triggered()), this, SLOT(exportXml()));
    connect(StreamsModel::self(), SIGNAL(error(const QString &)), this, SIGNAL(error(const QString &)));
    connect(StreamsModel::self(), SIGNAL(loading()), view, SLOT(showSpinner()));
    connect(StreamsModel::self(), SIGNAL(loaded()), view, SLOT(hideSpinner()));
    connect(StreamsModel::self(), SIGNAL(categoriesChanged()), view, SLOT(closeSearch()));
    connect(StreamsModel::self(), SIGNAL(favouritesLoaded()), SLOT(expandFavourites()));
    connect(StreamsModel::self(), SIGNAL(addedToFavourites(QString)), SLOT(addedToFavourites(QString)));
    connect(DigitallyImported::self(), SIGNAL(loginStatus(bool,QString)), SLOT(updateDiStatus()));
    connect(DigitallyImported::self(), SIGNAL(updated()), SLOT(updateDiStatus()));
    connect(view, SIGNAL(headerClicked(int)), SLOT(headerClicked(int)));
    StreamsModel::self()->configureDiAct()->setEnabled(false);

    proxy.setSourceModel(StreamsModel::self());
    view->setModel(&proxy);
    view->setDeleteAction(StdActions::self()->removeAction);
    view->setSearchResetLevel(1);
    view->alwaysShowHeader();

    Configuration config(metaObject()->className());
    view->setMode(ItemView::Mode_DetailedTree);
    view->load(config);

    MenuButton *menuButton=new MenuButton(this);
    Action *configureAction=new Action(Icons::self()->configureIcon, i18n("Configure"), this);
    connect(configureAction, SIGNAL(triggered()), SLOT(configure()));
    menuButton->addAction(createViewMenu(QList<ItemView::Mode>()  << ItemView::Mode_BasicTree << ItemView::Mode_SimpleTree
                                                                  << ItemView::Mode_DetailedTree << ItemView::Mode_List));
    menuButton->addAction(configureAction);
    menuButton->addAction(StreamsModel::self()->configureDiAct());
    menuButton->addSeparator();
    menuButton->addAction(addAction);
    menuButton->addAction(StdActions::self()->removeAction);
    menuButton->addAction(editAction);
    menuButton->addAction(StreamsModel::self()->reloadAct());
    menuButton->addSeparator();
    menuButton->addAction(importAction);
    menuButton->addAction(exportAction);

    diStatusLabel=new ServiceStatusLabel(this);
    diStatusLabel->setText("DI", i18nc("Service name", "Digitally Imported"));
    connect(diStatusLabel, SIGNAL(clicked()), SLOT(diSettings()));
    updateDiStatus();  
    ToolButton *searchButton=new ToolButton(this);
    searchButton->setDefaultAction(searchAction);
    init(ReplacePlayQueue, QList<QWidget *>() << menuButton << diStatusLabel, QList<QWidget *>() << searchButton);

    view->addAction(editAction);
    view->addAction(StdActions::self()->removeAction);
    view->addAction(StreamsModel::self()->addToFavouritesAct());
    view->addAction(StreamsModel::self()->addBookmarkAct());
    view->addAction(StreamsModel::self()->reloadAct());
}
QCategoryStoreServer::QCategoryStoreServer( QObject *parent )
    : QDocumentServerHost( "QCategoryStoreServer", parent )
{
    QObject::connect( QCategoryStore::instance(), SIGNAL(categoriesChanged()), this, SLOT(categoriesChanged()) );
    QObject::connect( this, SIGNAL(disconnected()), this, SLOT(deleteLater()) );
}
/*!
    \qmlproperty QPlace Place::place

    For details on how to use this property to interface between C++ and QML see
    "\l {location-cpp-qml.html#place} {Interfaces between C++ and QML Code}".
*/
void QDeclarativePlace::setPlace(const QPlace &src)
{
    QPlace previous = m_src;
    m_src = src;

    if (previous.categories() != m_src.categories()) {
        synchronizeCategories();
        emit categoriesChanged();
    }

    if (m_location && m_location->parent() == this) {
        m_location->setLocation(m_src.location());
    } else if (!m_location || m_location->parent() != this) {
        m_location = new QDeclarativeGeoLocation(m_src.location(), this);
        emit locationChanged();
    }

    if (m_ratings && m_ratings->parent() == this) {
        m_ratings->setRatings(m_src.ratings());
    } else if (!m_ratings || m_ratings->parent() != this) {
        m_ratings = new QDeclarativeRatings(m_src.ratings(), this);
        emit ratingsChanged();
    }

    if (m_supplier && m_supplier->parent() == this) {
        m_supplier->setSupplier(m_src.supplier(), m_plugin);
    } else if (!m_supplier || m_supplier->parent() != this) {
        m_supplier = new QDeclarativeSupplier(m_src.supplier(), m_plugin, this);
        emit supplierChanged();
    }

    if (m_icon && m_icon->parent() == this) {
        m_icon->setPlugin(m_plugin);
        m_icon->setIcon(m_src.icon());
    } else if (!m_icon || m_icon->parent() != this) {
        m_icon = new QDeclarativePlaceIcon(m_src.icon(), m_plugin, this);
        emit iconChanged();
    }

    if (previous.name() != m_src.name()) {
        emit nameChanged();
    }
    if (previous.placeId() != m_src.placeId()) {
        emit placeIdChanged();
    }
    if (previous.attribution() != m_src.attribution()) {
        emit attributionChanged();
    }
    if (previous.detailsFetched() != m_src.detailsFetched()) {
        emit detailsFetchedChanged();
    }
    if (previous.primaryPhone() != m_src.primaryPhone()) {
        emit primaryPhoneChanged();
    }
    if (previous.primaryFax() != m_src.primaryFax()) {
        emit primaryFaxChanged();
    }
    if (previous.primaryEmail() != m_src.primaryEmail()) {
        emit primaryEmailChanged();
    }
    if (previous.primaryWebsite() != m_src.primaryWebsite()) {
        emit primaryWebsiteChanged();
    }

    if (m_reviewModel && m_src.totalContentCount(QPlaceContent::ReviewType) >= 0) {
        m_reviewModel->initializeCollection(m_src.totalContentCount(QPlaceContent::ReviewType),
                                            m_src.content(QPlaceContent::ReviewType));
    }
    if (m_imageModel && m_src.totalContentCount(QPlaceContent::ImageType) >= 0) {
        m_imageModel->initializeCollection(m_src.totalContentCount(QPlaceContent::ImageType),
                                           m_src.content(QPlaceContent::ImageType));
    }
    if (m_editorialModel && m_src.totalContentCount(QPlaceContent::EditorialType) >= 0) {
        m_editorialModel->initializeCollection(m_src.totalContentCount(QPlaceContent::EditorialType),
                                               m_src.content(QPlaceContent::EditorialType));
    }

    synchronizeExtendedAttributes();
    synchronizeContacts();
}
QTM_USE_NAMESPACE

LandmarkBrowser::LandmarkBrowser(QWidget *parent, Qt::WindowFlags flags)
    :currentLandmarkOffset(0),
     currentCategoryOffset(0),
     limit(20), filterDialog(0),
     landmarkFetch(0), landmarkImport(0), landmarkExport(0), landmarkRemove(0),
     landmarkSave(0), categoryFetch(0), categoryRemove(0),progress(0),
     manager(0)


{
    setupUi(this);

    categoryTable->removeColumn(2);
    categoryTable->hideColumn(1);
    categoryTable->setHorizontalHeaderItem(0, new QTableWidgetItem("Name"));

    manager = new QLandmarkManager(this);
    if (manager->error() == QLandmarkManager::InvalidManagerError) {
        QMessageBox::warning(this,"Warning", "Manager is invalid closing application, please view any warnings "
                             "on the the console", QMessageBox::Ok, QMessageBox::NoButton);
        QTimer::singleShot(0, this,SLOT(close()));
        return;
    }


    landmarkFetch = new QLandmarkFetchRequest(manager, this);
    QObject::connect(landmarkFetch, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    landmarkImport = new QLandmarkImportRequest(manager, this);
    connect(landmarkImport, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    landmarkExport = new QLandmarkExportRequest(manager, this);
    QObject::connect(landmarkExport, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    landmarkRemove = new QLandmarkRemoveRequest(manager, this);
    landmarkSave = new QLandmarkSaveRequest(manager, this);
    categoryRemove = new QLandmarkCategoryRemoveRequest(manager, this);

     categoryFetch = new QLandmarkCategoryFetchRequest(manager, this);
     QObject::connect(categoryFetch, SIGNAL(stateChanged(QLandmarkAbstractRequest::State)),
                      this,SLOT(fetchHandler(QLandmarkAbstractRequest::State)));

    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    categoryTable->setSelectionBehavior(QAbstractItemView::SelectRows);

    table->setHorizontalHeaderItem(0, new QTableWidgetItem("Lat"));
    table->setHorizontalHeaderItem(1, new QTableWidgetItem("Long"));
    table->setHorizontalHeaderItem(2, new QTableWidgetItem("Name"));

    prevLandmarkButton->setEnabled(false);

    filterDialog = new LandmarkFilterDialog(landmarkFetch, manager, this);
    connect(filterDialog,SIGNAL(doFetchAll()), this, SLOT(doFetchAll()));

    progress = new QProgressDialog (tr("Please wait..."),tr("Cancel"),0,0, this);
    progress->setWindowTitle(tr("Loading Landmarks"));
    QObject::connect(progress,SIGNAL(canceled()), this, SLOT(cancel()));

    landmarkFetch->setLimit(limit);
    landmarkFetch->setOffset(currentLandmarkOffset);
    landmarkFetch->setSorting(QLandmarkNameSort());
    if (!landmarkFetch->start() && landmarkFetch->error() == QLandmarkManager::InvalidManagerError) {
        QMessageBox::warning(this,"Warning", "Manager is invalid closing application", QMessageBox::Ok, QMessageBox::NoButton);
        QTimer::singleShot(0, this,SLOT(close()));
        return;
    }

    categoryFetch->setLimit(limit);
    categoryFetch->setOffset(currentCategoryOffset);
    categoryFetch->start();

    progress->show();

    #ifdef Q_OS_SYMBIAN
        gpxRadioButton->setEnabled(false);
        gpxRadioButton->setVisible(false);
    #endif

        connect(manager, SIGNAL(landmarksAdded(QList<QLandmarkId>)),this,SLOT(landmarksAdded(QList<QLandmarkId>)));
        connect(manager,SIGNAL(landmarksChanged(QList<QLandmarkId>)), this, SLOT(landmarksChanged()));
        connect(manager, SIGNAL(landmarksRemoved(QList<QLandmarkId>)),this,SLOT(landmarksRemoved()));

        connect(manager, SIGNAL(categoriesAdded(QList<QLandmarkCategoryId>)), this, SLOT(categoriesAdded()));
        connect(manager, SIGNAL(categoriesChanged(QList<QLandmarkCategoryId>)), this,SLOT(categoriesChanged()));
        connect(manager, SIGNAL(categoriesRemoved(QList<QLandmarkCategoryId>)), this,SLOT(categoriesRemoved()));

        connect(manager, SIGNAL(dataChanged()),this, SLOT(dataChanged()));
}
Beispiel #23
0
TransfersView::TransfersView(QWidget *parent) :
    QWidget(parent),
    m_model(new TransferModel(this)),
    m_transferMenu(new QMenu(tr("&Transfer"), this)),
    m_categoryMenu(new QMenu(tr("&Category"), this)),
    m_priorityMenu(new QMenu(tr("&Priority"), this)),
    m_propertiesMenu(new QMenu(tr("&Properties"), this)),
    m_concurrentMenu(new QMenu(tr("Maximum &concurrent transfers"), this)),
    m_categoryGroup(new QActionGroup(this)),
    m_priorityGroup(new QActionGroup(this)),
    m_concurrentGroup(new QActionGroup(this)),
    m_startAction(new QAction(QIcon::fromTheme("media-playback-start"), tr("&Start all downloads"), this)),
    m_pauseAction(new QAction(QIcon::fromTheme("media-playback-pause"), tr("&Pause all downloads"), this)),
    m_propertiesAction(new QAction(QIcon::fromTheme("document-properties"), tr("&Properties"), this)),
    m_transferCommandAction(new QAction(QIcon::fromTheme("system-run"), tr("Set &custom command"), this)),
    m_transferStartAction(new QAction(QIcon::fromTheme("media-playback-start"), tr("&Start"), this)),
    m_transferPauseAction(new QAction(QIcon::fromTheme("media-playback-pause"), tr("&Pause"), this)),
    m_transferRemoveAction(new QAction(QIcon::fromTheme("edit-delete"), tr("&Remove"), this)),
    m_toolBar(new QToolBar(this)),
    m_view(new QTreeView(this)),
    m_layout(new QVBoxLayout(this))
{
    m_transferMenu->addAction(m_transferCommandAction);
    m_transferMenu->addAction(m_transferStartAction);
    m_transferMenu->addAction(m_transferPauseAction);
    m_transferMenu->addMenu(m_categoryMenu);
    m_transferMenu->addMenu(m_priorityMenu);
    m_transferMenu->addAction(m_transferRemoveAction);
    m_transferMenu->setEnabled(false);
    
    setCategoryMenuActions();
    
    const QStringList priorities = QStringList() << tr("High") << tr("Normal") << tr("Low");
    
    for (int i = 0; i < priorities.size(); i++) {
        QAction *action = m_priorityMenu->addAction(priorities.at(i), this, SLOT(setTransferPriority()));
        action->setCheckable(true);
        action->setData(i);
        m_priorityGroup->addAction(action);
    }
    
    const int max = Settings::maximumConcurrentTransfers();
    
    for (int i = 1; i <= MAX_CONCURRENT_TRANSFERS; i++) {
        QAction *action = m_concurrentMenu->addAction(QString::number(i), this, SLOT(setMaximumConcurrentTransfers()));
        action->setCheckable(true);
        action->setChecked(i == max);
        action->setData(i);
        m_concurrentGroup->addAction(action);
    }
    
    m_propertiesMenu->addMenu(m_concurrentMenu);
    
    m_toolBar->setMovable(false);
    m_toolBar->addAction(m_startAction);
    m_toolBar->addAction(m_pauseAction);
    m_toolBar->addAction(m_propertiesAction);
    
    m_view->setModel(m_model);
    m_view->setItemDelegate(new TransferDelegate(m_view));
    m_view->setAlternatingRowColors(true);
    m_view->setSelectionBehavior(QTreeView::SelectRows);
    m_view->setContextMenuPolicy(Qt::CustomContextMenu);
    m_view->setEditTriggers(QTreeView::NoEditTriggers);
    m_view->setItemsExpandable(false);
    m_view->setUniformRowHeights(true);
    m_view->setAllColumnsShowFocus(true);
    m_view->setRootIsDecorated(false);
    m_view->header()->restoreState(Settings::transfersHeaderViewState());

    m_layout->addWidget(m_toolBar);
    m_layout->addWidget(m_view);
    m_layout->setContentsMargins(0, 0, 0, 0);
    
    connect(m_categoryMenu, SIGNAL(aboutToShow()), this, SLOT(setActiveCategoryMenuAction()));
    connect(m_priorityMenu, SIGNAL(aboutToShow()), this, SLOT(setActivePriorityMenuAction()));
    connect(m_startAction, SIGNAL(triggered()), Transfers::instance(), SLOT(start()));
    connect(m_pauseAction, SIGNAL(triggered()), Transfers::instance(), SLOT(pause()));
    connect(m_propertiesAction, SIGNAL(triggered()), this, SLOT(showPropertiesMenu()));
    connect(m_transferCommandAction, SIGNAL(triggered()), this, SLOT(setTransferCustomCommand()));
    connect(m_transferStartAction, SIGNAL(triggered()), this, SLOT(queueTransfer()));
    connect(m_transferPauseAction, SIGNAL(triggered()), this, SLOT(pauseTransfer()));
    connect(m_transferRemoveAction, SIGNAL(triggered()), this, SLOT(removeTransfer()));
    connect(m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    connect(m_view->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
            this, SLOT(onCurrentTransferChanged(QModelIndex)));
    connect(Settings::instance(), SIGNAL(categoriesChanged()), this, SLOT(setCategoryMenuActions()));
    connect(Settings::instance(), SIGNAL(maximumConcurrentTransfersChanged(int)),
            this, SLOT(onMaximumConcurrentTransfersChanged(int)));
}
Beispiel #24
0
void QLandmarkManagerEngineSqlite::databaseChanged()
{
    QSqlDatabase db = QSqlDatabase::database(m_dbConnectionName);

    QSqlQuery query(db);
    if (!query.prepare("SELECT landmarkId,action, timestamp FROM landmark_notification WHERE timestamp >= ?")) {
#ifdef QT_LANDMARK_SQLITE_ENGINE_DEBUG
        qWarning() << "Could not prepare statement: " << query.lastQuery() << " \nReason:" << query.lastError().text();
#endif
        return;
    }
    query.addBindValue(m_latestLandmarkTimestamp);
    if (!query.exec()) {
#ifdef QT_LANDMARK_SQLITE_ENGINE_DEBUG
        qWarning() << "Could not execute statement:" << query.lastQuery() << " \nReason:" << query.lastError().text();
#endif
        return;
    }

    QList<QLandmarkId> addedLandmarkIds;
    QList<QLandmarkId> changedLandmarkIds;
    QList<QLandmarkId> removedLandmarkIds;

    QString action;
    QLandmarkId landmarkId;
    landmarkId.setManagerUri(managerUri());
    bool ok;
    qint64 timestamp;
    bool landmarkTimestampWasModified = true;

    while(query.next()) {
        timestamp = query.value(2).toLongLong(&ok);
        if (!ok) //this should never happen
            continue;

        if (timestamp > m_latestLandmarkTimestamp) {
            m_latestLandmarkTimestamp = timestamp;
            landmarkTimestampWasModified = true;
        }

        action = query.value(1).toString();
        landmarkId.setLocalId((query.value(0).toString()));

        if (action == "ADD") {
            if (!addedLandmarkIds.contains(landmarkId))
                addedLandmarkIds << landmarkId;
        } else if (action == "CHANGE") {
            if (!changedLandmarkIds.contains(landmarkId))
                changedLandmarkIds << landmarkId;
        } else if (action == "REMOVE") {
            if (!removedLandmarkIds.contains(landmarkId))
                removedLandmarkIds << landmarkId;
        }
    }

    //now check for added/modified/removed categories
    if (!query.prepare("SELECT categoryId,action, timestamp FROM category_notification WHERE timestamp >= ?")) {
#ifdef QT_LANDMARK_SQLITE_ENGINE_DEBUG
        qWarning() << "Could not prepare statement: " << query.lastQuery() << " \nReason:" << query.lastError().text();
#endif
        return;
    }
    query.addBindValue(m_latestCategoryTimestamp);
    if (!query.exec()) {
#ifdef QT_LANDMARK_SQLITE_ENGINE_DEBUG
        qWarning() << "Could not execute statement:" << query.lastQuery() << " \nReason:" << query.lastError().text();
#endif
        return;
    }
    QList<QLandmarkCategoryId> addedCategoryIds;
    QList<QLandmarkCategoryId> changedCategoryIds;
    QList<QLandmarkCategoryId> removedCategoryIds;

    QLandmarkCategoryId categoryId;
    categoryId.setManagerUri(managerUri());
    bool categoryTimestampWasModified = false;

    while(query.next()) {
        timestamp = query.value(2).toLongLong(&ok);
        if (!ok) //this should never happen
            continue;

        if (timestamp > m_latestCategoryTimestamp) {
            categoryTimestampWasModified = true;
            m_latestCategoryTimestamp = timestamp;
        }
        action = query.value(1).toString();
        categoryId.setLocalId(query.value(0).toString());

        if (action == "ADD") {
            if (!addedCategoryIds.contains(categoryId))
                addedCategoryIds << categoryId;
        } else if (action == "CHANGE") {
            if (!changedCategoryIds.contains(categoryId))
            changedCategoryIds << categoryId;
        } else if (action == "REMOVE") {
            if (!removedCategoryIds.contains(categoryId))
                removedCategoryIds << categoryId;
        }
    }

    if(landmarkTimestampWasModified)
        m_latestLandmarkTimestamp +=1;

    if (categoryTimestampWasModified)
        m_latestCategoryTimestamp +=1;

    int totalChangeCount = addedCategoryIds.count() + changedCategoryIds.count() + removedCategoryIds.count()
                           + addedLandmarkIds.count() + changedLandmarkIds.count() + removedLandmarkIds.count();
    if (totalChangeCount > 50 ) {
        emit dataChanged();
    } else {
        if (addedCategoryIds.count() > 0)
            emit categoriesAdded(addedCategoryIds);

        if (changedCategoryIds.count() > 0)
            emit categoriesChanged(changedCategoryIds);

        if (removedCategoryIds.count() > 0) {
            emit categoriesRemoved(removedCategoryIds);
        }

        if (addedLandmarkIds.count() > 0)
            emit landmarksAdded(addedLandmarkIds);

        if (changedLandmarkIds.count() > 0)
            emit landmarksChanged(changedLandmarkIds);

        if (removedLandmarkIds.count() > 0)
            emit landmarksRemoved(removedLandmarkIds);
    }
}