Exemplo n.º 1
0
WPopupWidget::WPopupWidget(WWidget *impl, WObject *parent)
    : WCompositeWidget(),
      fakeParent_(0),
      anchorWidget_(0),
      orientation_(Vertical),
      transient_(false),
      autoHideDelay_(0),
      deleteWhenHidden_(false),
      hidden_(this),
      shown_(this),
      jsHidden_(impl, "hidden"),
      jsShown_(impl, "shown")
{
    setImplementation(impl);

    if (parent)
        parent->addChild(this);

    WApplication::instance()->addGlobalWidget(this);

    hide();
    setPopup(true);
    setPositionScheme(Absolute);

    jsHidden_.connect(this, &WWidget::hide);
    jsShown_.connect(this, &WWidget::show);
}
Exemplo n.º 2
0
/*!
    Sets the model which provides completions to \a model. The \a model can
    be list model or a tree model. If a model has been already previously set
    and it has the QCompleter as its parent, it is deleted.

    For convenience, if \a model is a QFileSystemModel, QCompleter switches its
    caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive
    on other platforms.

    \sa completionModel(), modelSorting, {Handling Tree Models}
*/
void QCompleter::setModel(QAbstractItemModel *model)
{
    Q_D(QCompleter);
    QAbstractItemModel *oldModel = d->proxy->sourceModel();
    d->proxy->setSourceModel(model);
    if (d->popup)
        setPopup(d->popup); // set the model and make new connections
    if (oldModel && oldModel->QObject::parent() == this)
        delete oldModel;
#ifndef QT_NO_DIRMODEL
    if (qobject_cast<QDirModel *>(model)) {
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
        setCaseSensitivity(Qt::CaseInsensitive);
#else
        setCaseSensitivity(Qt::CaseSensitive);
#endif
    }
#endif // QT_NO_DIRMODEL
#ifndef QT_NO_FILESYSTEMMODEL
    QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);
    if (fsModel) {
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
        setCaseSensitivity(Qt::CaseInsensitive);
#else
        setCaseSensitivity(Qt::CaseSensitive);
#endif
        setCompletionRole(QFileSystemModel::FileNameRole);
        connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString)));
    }
#endif // QT_NO_FILESYSTEMMODEL
}
Exemplo n.º 3
0
HistoryCompleter::HistoryCompleter(QObject *parent)
    : QCompleter(parent)
    , d_ptr(new HistoryCompleterPrivate(this))
{
    // make an assumption to allow pressing of the down
    // key, before the first model run:
    // parent is likely the lineedit
    QWidget *p = qobject_cast<QWidget *>(parent);
    if (p) {
        p->installEventFilter(d_ptr->model);
        QString objectName = p->objectName();
        if (objectName.isEmpty())
            return;
        d_ptr->model->list = d_ptr->model->settings->value(objectName).toStringList();
    }

    QLineEdit *l = qobject_cast<QLineEdit *>(parent);
    if (l && d_ptr->model->list.count())
        l->setText(d_ptr->model->list.at(0));

    setModel(d_ptr->model);
    HistoryLineDelegate *delegate = new HistoryLineDelegate;
    HistoryLineView *view = new HistoryLineView(d_ptr, delegate->pixmap.width());
    setPopup(view);
    view->setItemDelegate(delegate);
}
Exemplo n.º 4
0
// CategoricalCompleter
CategoricalCompleter::CategoricalCompleter(QLineEdit *lineEdit, QList<CompletionCase> *data) : QCompleter(join((*data)[0])),
    _tableView(new CCTableView(&(*data)[0])), _data(*data), _currentSubset(&(*data)[0])
{
    setPopup(_tableView);
    lineEdit->setCompleter(this);
    _tableView->setCompleter(this);
    _tableView->updateSuggestions();
    setCompletionMode(PopupCompletion);
    connect(lineEdit,SIGNAL(textChanged(QString)),_tableView,SLOT(updateSuggestions()));
    connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(updateCurrentSuggestions()));
    connect(lineEdit,SIGNAL(cursorPositionChanged(int,int)),this,SLOT(updateCurrentSuggestions()));
}
void E002_Base_P420_CompletePopup::showCompletePopup()
{
    setPopup();
    setButtions();
    
    if (!m_isFromIndex)
    {
        playCommonNarration("e002_common_snd_family_02_as.mp3");
    }
    
    playCommonEffect("e002_common_diary_sfx_complete_pop.mp3");
}
Exemplo n.º 6
0
void K3bPushButton::setDelayedPopupMenu( QPopupMenu* popup )
{
    if( !d->popupTimer ) {
        d->popupTimer = new QTimer( this );
        connect( d->popupTimer, SIGNAL(timeout()), this, SLOT(slotDelayedPopup()) );
    }

    setPopup( popup );

    // we need to do the popup handling ourselves so we cheat a little
    // QPushButton connects a popup slot to the pressed signal which we disconnect here
    disconnect( this );
}
KMultiTabBarButton::KMultiTabBarButton(const QString& text, QPopupMenu *popup,
		int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style)
	:QPushButton(QIconSet(),text,parent),m_style(style)
{
	setText(text);
	m_position=pos;
  	if (popup) setPopup(popup);
	setFlat(true);
	setFixedHeight(24);
	setFixedWidth(24);
	m_id=id;
	QToolTip::add(this,text);
	connect(this,SIGNAL(clicked()),this,SLOT(slotClicked()));
}
Exemplo n.º 8
0
CToolBarButton::CToolBarButton(QWidget * parent, int v, QPopupMenu *p)
: QToolButton(parent, "my_ToolButton")
{
#ifdef DEBUG
  qDebug("CToolBarButton::CToolBarButton(QWidget *, int, QPopupMenu *)");
#endif

  val = v;
  if (p != 0)
  {
    setPopup (p);
    setPopupDelay(0);
  }
  connect(this, SIGNAL(clicked()), this, SLOT(Clicked()));
}
Exemplo n.º 9
0
void HistoryCompleter::init()
{
    setPopup(new HistoryCompletionView());

    // we want to complete against our own faked role
    setCompletionRole(HistoryCompletionModel::HistoryCompletionRole);

    // and since we fake our completion role, we can take
    // advantage of the sorted-model optimizations in QCompleter
    setCaseSensitivity(Qt::CaseSensitive);
    setModelSorting(QCompleter::CaseSensitivelySortedModel);

    m_filterTimer.setSingleShot(true);
    connect(&m_filterTimer, SIGNAL(timeout()), this, SLOT(updateFilter()));
}
Exemplo n.º 10
0
void BrowserButton::initialize( const QString& icon, const QString& path )
{
    _icon = icon;

    // Don't parent to this, so that the tear of menu is not always-on-top.
    topMenu = new PanelBrowserMenu( path );
    setPopup(topMenu);

    _menuTimer = new QTimer( this );
    connect( _menuTimer, SIGNAL(timeout()), SLOT(slotDelayedPopup()) );

    QToolTip::add(this, i18n("Browse: %1").arg(path));
    setTitle( path );
    setIcon ( _icon );
}
Exemplo n.º 11
0
void MessageCompleter::update(const QString& strKbGUID)
{
    CWizBizUserDataArray arrayUser;
    if (CWizDatabaseManager::instance()->db().users(strKbGUID, arrayUser)) {
        MessageCompleterModel* model = new MessageCompleterModel(arrayUser, this);
        setModel(model);

        MessageCompleterPopup* popup = new MessageCompleterPopup();
        popup->setModel(model);
        popup->setSpacing(2);
        popup->setUniformItemSizes(true);
        popup->setResizeMode(QListView::Adjust);

        setPopup(popup);
    }
}
Exemplo n.º 12
0
void BrowserButton::properties()
{
    PanelBrowserDialog dlg( topMenu->path(), _icon, this );

    if( dlg.exec() == QDialog::Accepted ){
	_icon = dlg.icon();
	QString path = dlg.path();

	if ( path != topMenu->path() ) {
	    delete topMenu;
	    topMenu = new PanelBrowserMenu( path, this );
	    setPopup( topMenu );
	    setTitle( path );
	}
	setIcon( _icon );
	emit requestSave();
    }
}
Exemplo n.º 13
0
LocationCompleter::LocationCompleter(QObject* parent) :
    QCompleter(parent)
{
    setMaxVisibleItems(6);
    QStandardItemModel* completeModel = new QStandardItemModel();

    setModel(completeModel);
    QTreeView* treeView = new QTreeView;

    setPopup(treeView);
    treeView->setRootIsDecorated(false);
    treeView->header()->hide();
    treeView->header()->setStretchLastSection(false);
    treeView->header()->setResizeMode(0, QHeaderView::Stretch);
    treeView->header()->resizeSection(1, 0);

    setCompletionMode(QCompleter::PopupCompletion);
    setCaseSensitivity(Qt::CaseInsensitive);
    setWrapAround(true);
    setCompletionColumn(1);
}
ZLQtToolButton::ZLQtToolButton(ZLQtApplicationWindow &window, ZLToolbar::AbstractButtonItem &item) : QToolButton(window.myToolBar), myWindow(window), myItem(item) {
	static std::string imagePrefix = ZLibrary::ApplicationImageDirectory() + ZLibrary::FileNameDelimiter;
	QPixmap icon((imagePrefix + myItem.iconName() + ".png").c_str());
	setIconSet(QIconSet(icon));
	QSize size = icon.size();
	QIconSet::setIconSize(QIconSet::Large, size);
	QIconSet::setIconSize(QIconSet::Small, size);
	if (item.type() == ZLToolbar::Item::TOGGLE_BUTTON) {
		setToggleButton(true);
	} else if (item.type() == ZLToolbar::Item::MENU_BUTTON) {
		ZLToolbar::MenuButtonItem &menuButtonItem = (ZLToolbar::MenuButtonItem&)myItem;
		shared_ptr<ZLPopupData> popupData = menuButtonItem.popupData();
		myWindow.myPopupIdMap[&menuButtonItem] =
			!popupData ? (size_t)-1 : (popupData->id() - 1);
		setPopup(new ZLQtPopupMenu(this));
	}
	QString text = QString::fromUtf8(myItem.tooltip().c_str());
	setTextLabel(text);
	setUsesTextLabel(false);
	QToolTip::add(this, text);
	connect(this, SIGNAL(clicked()), this, SLOT(onActivated()));
}
Exemplo n.º 15
0
void KexiComboBoxBase::createPopup(bool show)
{
    //kDebug() << show << field() << popup() << m_updatePopupSelectionOnShow;
    if (!field())
        return;
    m_insideCreatePopup = true;
    QWidget* thisWidget = dynamic_cast<QWidget*>(this);
    QWidget *widgetToFocus = internalEditor() ? internalEditor() : thisWidget;

    if (m_reinstantiatePopupOnShow) {
        QWidget *oldPopup = popup();
        setPopup(0);
        delete oldPopup;
    }

    if (!popup()) {
        setPopup(column() ? new KexiComboBoxPopup(thisWidget, *column())
                 : new KexiComboBoxPopup(thisWidget, *field()));
        QObject::connect(popup(), SIGNAL(rowAccepted(KexiDB::RecordData*,int)),
                         thisWidget, SLOT(slotRowAccepted(KexiDB::RecordData*,int)));
        QObject::connect(popup()->tableView(), SIGNAL(itemSelected(KexiDB::RecordData*)),
                         thisWidget, SLOT(slotItemSelected(KexiDB::RecordData*)));

        popup()->setFocusProxy(widgetToFocus);
        popup()->tableView()->setFocusProxy(widgetToFocus);
        popup()->installEventFilter(thisWidget);

        if (origValue().isNull())
            popup()->tableView()->clearSelection();
        else {
            popup()->tableView()->selectRow(0);
            popup()->tableView()->setHighlightedRecord(0);
        }
    }
    if (show && internalEditor() && !internalEditor()->isVisible())
        /*emit*/editRequested();

    QPoint posMappedToGlobal = mapFromParentToGlobal(thisWidget->pos());
    if (posMappedToGlobal != QPoint(-1, -1)) {
//! todo alter the position to fit the popup within screen boundaries
        popup()->hide();
        popup()->move(posMappedToGlobal + QPoint(0, thisWidget->height()));
        //kDebug() << "pos:" << posMappedToGlobal + QPoint(0, thisWidget->height());
        //to avoid flickering: first resize to 0-height, then show and resize back to prev. height
        const int w = popupWidthHint();
        popup()->resize(w, 0);
        if (show) {
            popup()->show();
            //kDebug(44010) << "SHOW!!!";
        }
        popup()->updateSize(w);
        if (m_updatePopupSelectionOnShow) {
            int rowToHighlight = -1;
            KexiDB::LookupFieldSchema *lookupFieldSchema = this->lookupFieldSchema();
            KexiTableViewData *relData = column() ? column()->relatedData() : 0;
            if (lookupFieldSchema) {
                rowToHighlight = rowToHighlightForLookupTable();
            } else if (relData) {
                (void)valueForString(origValue().toString(), &rowToHighlight, 0, 1);
            } else //enum hint
                rowToHighlight = origValue().toInt();

            /*-->*/ m_moveCursorToEndInInternalEditor_enabled = show;
            m_selectAllInInternalEditor_enabled = show;
            m_setValueInInternalEditor_enabled = show;
            if (rowToHighlight == -1) {
                rowToHighlight = qMax(popup()->tableView()->highlightedRecord(), 0);
                setValueInInternalEditor(QVariant());
            }
            popup()->tableView()->selectRow(rowToHighlight);
            popup()->tableView()->setHighlightedRecord(rowToHighlight);
            if (rowToHighlight < popup()->tableView()->rowsPerPage())
                popup()->tableView()->ensureCellVisible(0, -1);

            /*-->*/ m_moveCursorToEndInInternalEditor_enabled = true;
            m_selectAllInInternalEditor_enabled = true;
            m_setValueInInternalEditor_enabled = true;
        }
    }

    if (show) {
        moveCursorToEndInInternalEditor();
        selectAllInInternalEditor();
        widgetToFocus->setFocus();
        popup()->show();
        popup()->raise();
        popup()->repaint();
    }
    m_insideCreatePopup = false;
}