DataSettingsWidget::DataSettingsWidget(DataSettingsObject *object)
	: m_object(object), m_form(0)
{
    m_layout = new QVBoxLayout(this);
    m_layout->setMargin(0);
    connect(object, SIGNAL(itemChanged(qutim_sdk_0_3::DataItem)),
            this, SLOT(onItemChanged(qutim_sdk_0_3::DataItem)));
}
Example #2
0
//------------------------------------------------------------------------------
//!
void ComboBox::itemId( const String& str )
{
   _itemId = str;
   _item   = _menu->findWidget( _itemId );
   callShader();

   onItemChanged( _itemId );
}
Example #3
0
//------------------------------------------------------------------------------
//!
void ComboBox::item( Widget* widget )
{
   _item   = widget;
   _itemId = widget->id();
   callShader();

   onItemChanged( _itemId );
}
Example #4
0
ItemWeb::ItemWeb(const QString &html, QWidget *parent)
    : QWebView(parent)
    , ItemWidget(this)
{
    QWebFrame *frame = page()->mainFrame();
    frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
    frame->setScrollBarPolicy(Qt::Vertical,   Qt::ScrollBarAlwaysOff);

    const QFont &defaultFont = font();
    settings()->setFontFamily(QWebSettings::StandardFont, defaultFont.family());
    // DPI resolution can be different than the one used by this widget.
    QWidget* window = QApplication::desktop()->screen();
    int dpi = window->logicalDpiX();
    int pt = defaultFont.pointSize();
    settings()->setFontSize(QWebSettings::DefaultFontSize, pt * dpi / 72);

    history()->setMaximumItemCount(0);

    QPalette pal(palette());
    pal.setBrush(QPalette::Base, Qt::transparent);
    page()->setPalette(pal);
    setAttribute(Qt::WA_OpaquePaintEvent, false);

    connect( frame, SIGNAL(loadFinished(bool)),
             this, SLOT(onItemChanged()) );
    connect( frame, SIGNAL(contentsSizeChanged(QSize)),
             this, SLOT(onItemChanged()) );

    connect( frame, SIGNAL(loadFinished(bool)),
             this, SLOT(onItemChanged()) );
    connect( frame, SIGNAL(contentsSizeChanged(QSize)),
             this, SLOT(onItemChanged()) );

    // Selecting text copies it to clipboard.
    connect( this, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()) );

    setHtml(html);
    updateSize();
    updateItem();
}
void ItemsComponent::setupUi(QWidget *container)
{
    ui.setupUi(container);
    createModels();

    // Wiring
    QObject::connect(ui.tblItems->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(onItemsSelectionChanged()));
    QObject::connect(ui.tblItemDetails->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(onItemDetailsSelectionChanged()));
    QObject::connect(ui.btnRemoveFromItem, SIGNAL(clicked()), this, SLOT(removeEntriesFromCurrentItem()));
    QObject::connect(document, SIGNAL(onItemChanged()), this, SLOT(updateTotalSizeLabel()));

    // When an item is deleted, we remove it from the details model
    QObject::connect(document, SIGNAL(beforeRemovingItem(const Item *)), itemDetailsModel, SLOT(onBeforeRemovingItem(const Item *)));
}
int WidgetDataTreeImpl::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
	_id = QTreeView::qt_metacall(_c, _id, _a);
	if (_id < 0)
		return _id;
	if (_c == QMetaObject::InvokeMetaMethod) {
		switch (_id) {
			case 0: onItemChanged(*reinterpret_cast<QStandardItem**>(_a[1])); break;
			default: ;
		}
		_id -= 1;
	}
	return _id;
}
Example #7
0
int FileBrowser::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QSplitter::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: picked((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 1: onItemChanged((*reinterpret_cast< QListWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QListWidgetItem*(*)>(_a[2]))); break;
        case 2: onSelectionChanged(); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
int MoodBox::SelectAvatarDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = MoodBoxDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_addAvatarButton_clicked(); break;
        case 1: on_okButton_clicked(); break;
        case 2: onApplyAvatar(); break;
        case 3: onItemChanged((*reinterpret_cast< QListWidgetItem*(*)>(_a[1])),(*reinterpret_cast< QListWidgetItem*(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}
Example #9
0
//-----------------------------------------------------------------------------
// Function: ViewsEditor::ViewsEditor()
//-----------------------------------------------------------------------------
ViewsEditor::ViewsEditor(QSharedPointer<Component> component, LibraryInterface* handler, QWidget* parent):
ItemEditor(component, handler, parent),
    view_(this),
    proxy_(this),
    model_(component, this)
{
	// display a label on top the table
	SummaryLabel* summaryLabel = new SummaryLabel(tr("Views summary"), this);

	QVBoxLayout* layout = new QVBoxLayout(this);
	layout->addWidget(summaryLabel, 0, Qt::AlignCenter);
	layout->addWidget(&view_);
	layout->setContentsMargins(0, 0, 0, 0);

	proxy_.setSourceModel(&model_);	
    proxy_.setDynamicSortFilter(false);

	view_.setModel(&proxy_);    
    view_.sortByColumn(ViewsModel::NAME_COLUMN, Qt::AscendingOrder);
    view_.sortByColumn(ViewsModel::TYPE_COLUMN, Qt::AscendingOrder);
    //view_.sortByColumn(ViewsModel::TYPE_COLUMN, Qt::AscendingOrder);

	const QString compPath = ItemEditor::handler()->getDirectoryPath(*ItemEditor::component()->getVlnv());
	QString defPath = QString("%1/viewListing.csv").arg(compPath);
	view_.setDefaultImportExportPath(defPath);
	view_.setAllowImportExport(true);

	// items can not be dragged
	view_.setItemsDraggable(false);

	view_.setItemDelegate(new ViewsDelegate(this));

	connect(&model_, SIGNAL(contentChanged()), this, SIGNAL(contentChanged()), Qt::UniqueConnection);
    connect(&model_, SIGNAL(contentChanged()), this, SLOT(onItemChanged()), Qt::UniqueConnection);
	connect(&model_, SIGNAL(viewAdded(int)), this, SIGNAL(childAdded(int)), Qt::UniqueConnection);
	connect(&model_, SIGNAL(viewRemoved(int)), this, SIGNAL(childRemoved(int)), Qt::UniqueConnection);

	connect(&view_, SIGNAL(addItem(const QModelIndex&)),
        &model_, SLOT(onAddItem(const QModelIndex&)), Qt::UniqueConnection);
	connect(&view_, SIGNAL(removeItem(const QModelIndex&)),
		&model_, SLOT(onRemoveItem(const QModelIndex&)), Qt::UniqueConnection);
}
ScrollableView::ScrollableView() :
		_tiView(NULL),
		_currentIndex(0),
		_indexCount(0)
{
	_listView = new bb::cascades::ListView();

	bb::cascades::StackListLayout* layout = static_cast<bb::cascades::StackListLayout*>(_listView->layout());

	layout->setOrientation(bb::cascades::LayoutOrientation::LeftToRight);

	_listView->setSnapMode(bb::cascades::SnapMode::LeadingEdge);
	_listView->setFlickMode(bb::cascades::FlickMode::SingleItem);
	_listView->setScrollIndicatorMode(bb::cascades::ScrollIndicatorMode::None);
	_listView->setListItemProvider(new ScrollableItemProvider());
	_listView->setDataModel(new bb::cascades::ArrayDataModel());

	bb::cascades::ListScrollStateHandler::create(_listView)
		.onFirstVisibleItemChanged(this, SLOT(onItemChanged(QVariantList)));

	setRoot(_listView);
}
Example #11
0
void KStandardItemModel::changeItem(int index, KStandardItem* item)
{
    if (index < 0 || index >= count() || !item) {
        delete item;
        return;
    }

    item->m_model = this;

    QSet<QByteArray> changedRoles;

    KStandardItem* oldItem = m_items[index];
    const QHash<QByteArray, QVariant> oldData = oldItem->data();
    const QHash<QByteArray, QVariant> newData = item->data();

    // Determine which roles have been changed
    QHashIterator<QByteArray, QVariant> it(oldData);
    while (it.hasNext()) {
        it.next();
        const QByteArray role = it.key();
        const QVariant oldValue = it.value();
        if (newData.contains(role) && newData.value(role) != oldValue) {
            changedRoles.insert(role);
        }
    }

    m_indexesForItems.remove(oldItem);
    delete oldItem;
    oldItem = 0;

    m_items[index] = item;
    m_indexesForItems.insert(item, index);

    onItemChanged(index, changedRoles);
    emit itemsChanged(KItemRangeList() << KItemRange(index, 1), changedRoles);
}
Example #12
0
//-----------------------------------------------------------------------------
// Function: ViewsEditor::refresh()
//-----------------------------------------------------------------------------
void ViewsEditor::refresh()
{    
    onItemChanged();
    view_.update();
}
Example #13
0
bool ItemDelegate::eventFilter(QObject *object, QEvent *event)
{
    if (object->objectName() == "editor") {
        QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>(object);
        if (editor == NULL)
            return false;

        QEvent::Type type = event->type();
        if ( type == QEvent::KeyPress ) {
            QKeyEvent *keyevent = static_cast<QKeyEvent *>(event);
            switch ( keyevent->key() ) {
                case Qt::Key_Enter:
                case Qt::Key_Return:
                    // Commit data on Ctrl+Return or Enter?
                    if (m_saveOnReturnKey) {
                        if (keyevent->modifiers() == Qt::ControlModifier) {
                            editor->insertPlainText("\n");
                            return true;
                        } else if (keyevent->modifiers() != Qt::NoModifier) {
                            return false;
                        }
                    } else {
                        if (keyevent->modifiers() != Qt::ControlModifier)
                            return false;
                    }
                    emit commitData(editor);
                    emit closeEditor(editor);
                    return true;
                case Qt::Key_S:
                    // Commit data on Ctrl+S.
                    if (keyevent->modifiers() != Qt::ControlModifier)
                        return false;
                    emit commitData(editor);
                    emit closeEditor(editor);
                    return true;
                case Qt::Key_F2:
                    // Commit data on F2.
                    emit commitData(editor);
                    emit closeEditor(editor);
                    return true;
                case Qt::Key_Escape:
                    // Close editor without committing data.
                    emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
                    return true;
                default:
                    return false;
            }
        } else if ( type == QEvent::ContextMenu ) {
            QAction *act;
            QMenu *menu = editor->createStandardContextMenu();
            connect( menu, SIGNAL(aboutToHide()), menu, SLOT(deleteLater()) );
            menu->setParent(editor);

            act = menu->addAction( tr("&Save Item") );
            act->setShortcut( QKeySequence(tr("F2, Ctrl+Enter")) );
            connect( act, SIGNAL(triggered()), this, SLOT(editorSave()) );

            act = menu->addAction( tr("Cancel Editing") );
            act->setShortcut( QKeySequence(tr("Escape")) );
            connect( act, SIGNAL(triggered()), this, SLOT(editorCancel()) );

            QContextMenuEvent *menuEvent = static_cast<QContextMenuEvent *>(event);
            menu->popup( menuEvent->globalPos() );
        }
    } else {
        // resize event for items
        if (event->type() == QEvent::Resize) {
            QResizeEvent *resize = static_cast<QResizeEvent *>(event);
            ItemWidget *item = dynamic_cast<ItemWidget *>(object);
            if (item != NULL) {
                item->widget()->resize(resize->size());
                onItemChanged(item);
                return true;
            }
        }
    }

    return false;
}
Example #14
0
DirModel::DirModel(QObject *parent)
    : DirItemAbstractListModel(parent)
    , mFilterDirectories(false)
    , mShowDirectories(true)
    , mAwaitingResults(false)
    , mIsRecursive(false)
    , mReadsMediaMetadata(false)
    , mShowHiddenFiles(false)
    , mOnlyAllowedPaths(false)
    , mSortBy(SortByName)
    , mSortOrder(SortAscending)
    , mCompareFunction(0)
    , mExtFSWatcher(false)
    , mClipboard(new Clipboard(this))
    , mLocationFactory(new LocationsFactory(this))
    , mCurLocation(0)
    , m_fsAction(new FileSystemAction(this) )
{
    mNameFilters = QStringList() << "*";

    mSelection   =  new DirSelection(this, &mDirectoryContents);

    connect(m_fsAction, SIGNAL(progress(int,int,int)),
            this,     SIGNAL(progress(int,int,int)));

    connect(m_fsAction, SIGNAL(added(DirItemInfo)),
            this,     SLOT(onItemAdded(DirItemInfo)));

    connect(m_fsAction, SIGNAL(added(QString)),
            this,     SLOT(onItemAdded(QString)));

    connect(m_fsAction, SIGNAL(removed(DirItemInfo)),
            this,     SLOT(onItemRemoved(DirItemInfo)));

    connect(m_fsAction, SIGNAL(removed(QString)),
            this,     SLOT(onItemRemoved(QString)));

    connect(m_fsAction, SIGNAL(error(QString,QString)),
            this,     SIGNAL(error(QString,QString)));

    connect(this,     SIGNAL(pathChanged(QString)),
            m_fsAction, SLOT(pathChanged(QString)));

    connect(mClipboard, SIGNAL(clipboardChanged()),
            this,       SIGNAL(clipboardChanged()));

    connect(m_fsAction,  SIGNAL(changed(DirItemInfo)),
           this,        SLOT(onItemChanged(DirItemInfo)));

    connect(mClipboard, SIGNAL(clipboardChanged()),
            m_fsAction, SLOT(onClipboardChanged()));

    connect(m_fsAction, SIGNAL(recopy(QStringList,QString)),
            mClipboard, SLOT(copy(QStringList,QString)));

    setCompareAndReorder();

    if (QIcon::themeName().isEmpty() && !FMUtil::hasTriedThemeName())
    {
        FMUtil::setThemeName();
    }

    foreach (const Location* l, mLocationFactory->availableLocations())
    {
       connect(l,     SIGNAL(itemsAdded(DirItemInfoList)),
               this,  SLOT(onItemsAdded(DirItemInfoList)));

       connect(l,     SIGNAL(itemsFetched()),
               this,  SLOT(onItemsFetched()));

       connect(l,     SIGNAL(extWatcherItemAdded(DirItemInfo)),
               this,  SLOT(onItemAddedOutsideFm(DirItemInfo)));

       connect(l,     SIGNAL(extWatcherItemRemoved(DirItemInfo)),
               this,  SLOT(onItemRemovedOutSideFm(DirItemInfo)));

       connect(l,     SIGNAL(extWatcherItemChanged(DirItemInfo)),
               this,  SLOT(onItemChangedOutSideFm(DirItemInfo)));

       connect(l,     SIGNAL(extWatcherChangesFetched(int)),
               this,  SLOT(onExternalFsWorkerFinished(int)));

       connect(l,     SIGNAL(extWatcherPathChanged(QString)),
               this,  SLOT(onThereAreExternalChanges(QString)));

       connect(this,  SIGNAL(enabledExternalFSWatcherChanged(bool)),
               l,     SLOT(setUsingExternalWatcher(bool)));
    }
}