Beispiel #1
0
/******************************************************************************
*  Undo or redo a specified item.
*  Reply = true if success, or if the item no longer exists.
*/
bool Undo::undo(Undo::Iterator it, Undo::Type type, QWidget *parent, const QString &action)
{
    UndoItem::mRestoreError   = UndoItem::ERR_NONE;
    UndoItem::mRestoreWarning = UndoItem::WARN_NONE;
    UndoItem::mRestoreWarningCount = 0;
    if(it != mUndoList.end()  &&  it != mRedoList.end()  && (*it)->type() == type)
    {
        (*it)->restore();
        delete *it;    // N.B. 'delete' removes the object from its list
        emitChanged();
    }

    QString err;
    switch(UndoItem::mRestoreError)
    {
        case UndoItem::ERR_NONE:
        {
            KAlarm::KOrgUpdateError errcode;
            switch(UndoItem::mRestoreWarning)
            {
                case UndoItem::WARN_KORG_ADD:
                    errcode = KAlarm::KORG_ERR_ADD;
                    break;
                case UndoItem::WARN_KORG_MODIFY:
                    errcode = KAlarm::KORG_ERR_MODIFY;
                    break;
                case UndoItem::WARN_KORG_DELETE:
                    errcode = KAlarm::KORG_ERR_DELETE;
                    break;
                case UndoItem::WARN_NONE:
                default:
                    return true;
            }
            KAlarm::displayKOrgUpdateError(parent, errcode, UndoItem::mRestoreWarningCount);
            return true;
        }
        case UndoItem::ERR_NOT_FOUND:
            err = i18n("Alarm not found");
            break;
        case UndoItem::ERR_CREATE:
            err = i18n("Error recreating alarm");
            break;
        case UndoItem::ERR_TEMPLATE:
            err = i18n("Error recreating alarm template");
            break;
        case UndoItem::ERR_EXPIRED:
            err = i18n("Cannot reactivate expired alarm");
            break;
        case UndoItem::ERR_PROG:
            err = i18n("Program error");
            break;
        default:
            err = i18n("Unknown error");
            break;
    }
    KMessageBox::sorry(parent, i18n("Undo-action: message", "%1: %2").arg(action).arg(err));
    return false;
}
Beispiel #2
0
void QClipboard::setMimeData(QMimeData* src, Mode mode)
{
    QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
    if (!clipboard->supportsMode(mode)) return;

    clipboard->setMimeData(src,mode);

    emitChanged(mode);
}
Beispiel #3
0
void Undo::saveReactivates(const QValueList<KAEvent> &events)
{
    int count = events.count();
    if(count == 1)
        saveReactivate(events.first());
    else if(count > 1)
    {
        new UndoReactivates(UNDO, events);
        emitChanged();
    }
}
Beispiel #4
0
void KBookmarkManager::scan( const char * _path )
{
  m_Root.clear();
  
  // Do not emit 'changed' signals here.
  m_bAllowSignalChanged = false;
  scanIntern( &m_Root, _path );
  m_lstParsedDirs.clear();
  m_bAllowSignalChanged = true;
   
  emitChanged();
}
Beispiel #5
0
void Undo::saveDeletes(const QValueList<KAEvent> &events)
{
    int count = events.count();
    if(count == 1)
        saveDelete(events.first());
    else if(count > 1)
    {
        new UndoDeletes(UNDO, events);
        for(QValueList<KAEvent>::ConstIterator it = events.begin();  it != events.end();  ++it)
            removeRedos((*it).id());    // remove any redos which are made invalid by these deletions
        emitChanged();
    }
}
Beispiel #6
0
/******************************************************************************
*  Clear the lists of undo and redo items.
*/
void Undo::clear()
{
    if(!mUndoList.isEmpty()  ||  !mRedoList.isEmpty())
    {
        mInstance->blockSignals(true);
        while(mUndoList.count())
            delete mUndoList.first();    // N.B. 'delete' removes the object from the list
        while(mRedoList.count())
            delete mRedoList.first();    // N.B. 'delete' removes the object from the list
        mInstance->blockSignals(false);
        emitChanged();
    }
}
Beispiel #7
0
bool QClipboard::event(QEvent *e)
{
    if (e->type() != QEvent::Clipboard)
        return QObject::event(e);

    QClipboardData *d = clipboardData();

    MSG *m = (MSG *)((QClipboardEvent*)e)->data();
    if (!m) {
        // this is sent to render all formats at app shut down
        if (ownsClipboard()) {
            OleFlushClipboard();
            d->releaseIData();
        }
        return true;
    }

    bool propagate = false;

    if (m->message == WM_CHANGECBCHAIN) {
        if ((HWND)m->wParam == d->nextClipboardViewer)
            d->nextClipboardViewer = (HWND)m->lParam;
        else
            propagate = true;
    } else if (m->message == WM_DRAWCLIPBOARD) {
        emitChanged(QClipboard::Clipboard);
        if (!ownsClipboard() && d->iData)
            // clean up the clipboard object if we no longer own the clipboard
            d->releaseIData();
        propagate = true;
    }
    if (propagate && d->nextClipboardViewer) {
        if (ptrIsHungAppWindow == 0) {
            QSystemLibrary library(QLatin1String("User32"));
            ptrIsHungAppWindow = (PtrIsHungAppWindow)library.resolve("IsHungAppWindow");
        }
        if (ptrIsHungAppWindow && ptrIsHungAppWindow(d->nextClipboardViewer)) {
            qWarning("%s: Cowardly refusing to send clipboard message to hung application...", Q_FUNC_INFO);
        } else if (isProcessBeingDebugged(d->nextClipboardViewer)) {
            // Also refuse if the process is being debugged, specifically, if it is
            // displaying a runtime assert, which is not caught by isHungAppWindow().
            qWarning("%s: Cowardly refusing to send clipboard message to application under debugger...", Q_FUNC_INFO);
        } else {
            SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
        }
    }

    return true;
}
void QMirClientClipboard::updateMimeData(const QByteArray &serializedMimeData)
{
    if (mUpdatesDisabled)
        return;

    QMimeData *newMimeData = deserializeMimeData(serializedMimeData);
    if (newMimeData) {
        delete mMimeData;
        mMimeData = newMimeData;
        mIsOutdated = false;
        emitChanged(QClipboard::Clipboard);
    } else {
        qWarning("QMirClientClipboard - Got invalid serialized mime data. Ignoring it.");
    }
}
void ComponentChooser::restoreDefault() {
    if (configWidget)
    {
        dynamic_cast<CfgPlugin*>(configWidget)->defaults();
        emitChanged(true);
    }

/*
	txtEMailClient->setText("kmail");
	chkRunTerminal->setChecked(false);

	// Check if -e is needed, I do not think so
	terminalLE->setText("xterm");  //No need for i18n
	terminalCB->setChecked(true);
	emitChanged(false);
*/
}
void WindowDefinitionListWidget::doCopyFromObject()
    {
    // We are asked to copy again from object. Recreate our working copy
    if (_working) delete _working;
    _working = _windowdefs->copy();

    ui.comment->setText(_working->comment());

    for ( KHotKeys::Windowdef_list::ConstIterator it(_working->constBegin());
            it != _working->constEnd();
            ++it)
        {
        new QListWidgetItem((*it)->description(), ui.list);
        }

    emitChanged(false);
    }
void WindowDefinitionListWidget::doCopyToObject()
    {
    // Delete the old content
    qDeleteAll(*_windowdefs);
    _windowdefs->clear();

    _windowdefs->set_comment(ui.comment->text());

    for (int i=0; i<_working->size(); ++i)
        {
        _windowdefs->append(_working->at(i)->copy());
        }

    // Reset our _changed state
    _changed = false;
    emitChanged(false);
    }
bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
{
    enum { wMClipboardUpdate = 0x031D };

    *result = 0;
    if (QWindowsContext::verbose)
        qCDebug(lcQpaMime) << __FUNCTION__ << hwnd << message << QWindowsGuiEventDispatcher::windowsMessageName(message);

    switch (message) {
    case WM_CHANGECBCHAIN: {
        const HWND toBeRemoved = (HWND)wParam;
        if (toBeRemoved == m_nextClipboardViewer) {
            m_nextClipboardViewer = (HWND)lParam;
        } else {
            propagateClipboardMessage(message, wParam, lParam);
        }
    }
        return true;
    case wMClipboardUpdate:  // Clipboard Format listener (Vista onwards)
    case WM_DRAWCLIPBOARD: { // Clipboard Viewer Chain handling (up to XP)
        const bool owned = ownsClipboard();
        qCDebug(lcQpaMime) << "Clipboard changed owned " << owned;
        emitChanged(QClipboard::Clipboard);
        // clean up the clipboard object if we no longer own the clipboard
        if (!owned && m_data)
            releaseIData();
        if (!m_formatListenerRegistered)
            propagateClipboardMessage(message, wParam, lParam);
    }
        return true;
    case WM_DESTROY:
        // Recommended shutdown
        if (ownsClipboard()) {
            qCDebug(lcQpaMime) << "Clipboard owner on shutdown, releasing.";
            OleFlushClipboard();
            releaseIData();
        }
        return true;
    } // switch (message)
    return false;
}
Beispiel #13
0
bool QWindowsClipboard::clipboardViewerWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result)
{
    *result = 0;
    if (QWindowsContext::verboseOLE)
            qDebug("%s HWND=%p 0x%x %s", __FUNCTION__, hwnd, message,
                   QWindowsGuiEventDispatcher::windowsMessageName(message));

    switch (message) {
    case WM_CHANGECBCHAIN: {
        const HWND toBeRemoved = (HWND)wParam;
        if (toBeRemoved == m_nextClipboardViewer) {
            m_nextClipboardViewer = (HWND)lParam;
        } else {
            propagateClipboardMessage(message, wParam, lParam);
        }
    }
        return true;
    case WM_DRAWCLIPBOARD: {
        const bool owned = ownsClipboard();
        if (QWindowsContext::verboseOLE)
            qDebug("Clipboard changed owned %d", owned);
        emitChanged(QClipboard::Clipboard);
        // clean up the clipboard object if we no longer own the clipboard
        if (!owned && m_data)
            releaseIData();
        propagateClipboardMessage(message, wParam, lParam);
    }
        return true;
    case WM_DESTROY:
        // Recommended shutdown
        if (ownsClipboard()) {
            if (QWindowsContext::verboseOLE)
                qDebug("Clipboard owner on shutdown, releasing.");
            OleFlushClipboard();
            releaseIData();
        }
        return true;
    } // switch (message)
    return false;
}
bool QClipboard::event(QEvent *e)
{
    static bool recursionWatch = false;
    if (e->type() != QEvent::Clipboard || recursionWatch)
        return QObject::event(e);

    recursionWatch = true;
    QWSPropertyNotifyEvent *event = (QWSPropertyNotifyEvent *)(((QClipboardEvent *)e)->data());
    if (event && event->simpleData.state == QWSPropertyNotifyEvent::PropertyNewValue) {
	QClipboardData *d = clipboardData();
	QString t = qwsClipboardText();
	if( (d->source() == 0 && !t.isEmpty()) || (d->source() != 0 && d->source()->text() != t) ) {
	    if( !d->source() )
		d->setSource(new QMimeData);
	    d->source()->setText( t );
	    emitChanged(QClipboard::Clipboard);
	}
    }

    recursionWatch = false;
    return true;
}
Beispiel #15
0
bool QClipboard::event(QEvent *e)
{
    if (e->type() != QEvent::Clipboard)
        return QObject::event(e);

    QClipboardData *d = clipboardData();

    MSG *m = (MSG *)((QClipboardEvent*)e)->data();
    if (!m) {
        // this is sent to render all formats at app shut down
        if (ownsClipboard()) {
            OleFlushClipboard();
            d->releaseIData();
        }
        return true;
    }

    bool propagate = false;

    if (m->message == WM_CHANGECBCHAIN) {
        if ((HWND)m->wParam == d->nextClipboardViewer)
            d->nextClipboardViewer = (HWND)m->lParam;
        else
            propagate = true;
    } else if (m->message == WM_DRAWCLIPBOARD) {
        emitChanged(QClipboard::Clipboard);
        if (!ownsClipboard() && d->iData)
            // clean up the clipboard object if we no longer own the clipboard
            d->releaseIData();
        propagate = true;
    }

    if (propagate && d->nextClipboardViewer) {
        SendMessage(d->nextClipboardViewer, m->message, m->wParam, m->lParam);
    }

    return true;
}
void WindowDefinitionListWidget::slotDelete(bool)
    {
    // TODO: Deactivate buttons if nothing is selected
    if (ui.list->currentRow() == -1)
        return;

    Q_ASSERT(ui.list->currentRow() < _working->count());

    KHotKeys::Windowdef *def = _working->at(ui.list->currentRow());
    KHotKeys::Windowdef_simple *sim = dynamic_cast<KHotKeys::Windowdef_simple*>(def);
    Q_ASSERT(sim);

    // Remove it from the list
    ui.list->takeItem(ui.list->currentRow());

    // delete it
    _working->removeAll(sim);
    delete sim;

    emitChanged(true);

    return;
    }
void WindowDefinitionListWidget::slotDuplicate(bool)
    {
    // TODO: Deactivate buttons if nothing is selected
    if (ui.list->currentRow() == -1)
        return;

    Q_ASSERT(ui.list->currentRow() < _working->count());

    // Get the template
    KHotKeys::Windowdef *def = _working->at(ui.list->currentRow());
    KHotKeys::Windowdef_simple *orig = dynamic_cast<KHotKeys::Windowdef_simple*>(def);
    Q_ASSERT(orig);

    // Create a copy
    KHotKeys::Windowdef_simple *sim = orig->copy();
    Q_ASSERT(sim);

    WindowDefinitionDialog dialog(sim, this);
    switch (dialog.exec())
        {
        case QDialog::Accepted:
            // Update our list if necessary
            new QListWidgetItem(sim->description(), ui.list);
            _working->append(sim);
            emitChanged(true);
            break;

        case QDialog::Rejected:
            // Nothing to do
            delete sim;
            break;

        default:
            Q_ASSERT(false);
            delete sim;
        }
    }
void WindowDefinitionListWidget::slotNew(bool)
    {
    KHotKeys::Windowdef_simple *sim = new KHotKeys::Windowdef_simple();

    WindowDefinitionDialog dialog(sim, this);
    switch (dialog.exec())
        {
        case QDialog::Accepted:
            // Update our list if necessary
            new QListWidgetItem(sim->description(), ui.list);
            _working->append(sim);
            emitChanged(true);
            break;

        case QDialog::Rejected:
            // Nothing to do
            delete sim;
            break;

        default:
            Q_ASSERT(false);
            delete sim;
        }
    }
Beispiel #19
0
void Task::widgetDeleted()
{
    bool wasEmbeddable = isEmbeddable();

    QGraphicsWidget *w = static_cast<QGraphicsWidget*>(sender());
    QMutableHashIterator<Plasma::Applet *, QGraphicsWidget *> it(d->widgetsByHost);
    while (it.hasNext()) {
        it.next();
        if (it.value() == w) {
            it.remove();
        }
    }

    if (!wasEmbeddable && isEmbeddable()) {
        // we have to delay this call because some Task subclasses have a single widget that
        // becomes embedabble at this point (e.g. FdoTaskWidget). if the signal is emitted
        // immediately, another system tray will attempt to immediately embed it, and
        // part of that process involves removing the item from any previous layouts. now,
        // if that happens because a system tray is being deleted (removed, app exit, logout, etcS)
        // then the previous parent layout will be a dangling pointer at this point and
        // that will not get fixed up until everything is finished... so.. we delay the signal
        QTimer::singleShot(0, this, SLOT(emitChanged()));
    }
}
void QMirClientClipboard::setMimeData(QMimeData* mimeData, QClipboard::Mode mode)
{
    if (mode != QClipboard::Clipboard)
        return;

    if (!mPendingGetContentsCall.isNull()) {
        // Ignore whatever comes from the system clipboard as we are going to change it anyway
        QObject::disconnect(mPendingGetContentsCall.data(), 0, this, 0);
        mUpdatesDisabled = true;
        mPendingGetContentsCall->waitForFinished();
        mUpdatesDisabled = false;
        delete mPendingGetContentsCall.data();
    }

    if (mimeData != nullptr) {
        QByteArray serializedMimeData = serializeMimeData(mimeData);
        if (!serializedMimeData.isEmpty()) {
            setDBusClipboardContents(serializedMimeData);
        }

        mMimeData = mimeData;
        emitChanged(QClipboard::Clipboard);
    }
}
Beispiel #21
0
void BtStyle::setMenuHeight(int height) {
    menuHeight = height;
    emitChanged();
}
Beispiel #22
0
void BtStyle::setWindowTab(const QColor& color) {
    windowTab = color;
    emitChanged();
}
Beispiel #23
0
void BtStyle::setWindowTabTextSelected(const QColor& color) {
    windowTabTextSelected = color;
    emitChanged();
}
Beispiel #24
0
void BtStyle::setUiFontPointSize(double pointSize) {
    btConfig().setValue<int>("ui/uiFontSize", pointSize);
    emitChanged();
}
Beispiel #25
0
void BtStyle::setStyle(int style) {
    setCurrentStyle(style);
    emitChanged();
}
Beispiel #26
0
void BtStyle::setToolbarTextPointSize(double pointSize) {
    toolbarTextPointSize = pointSize;
    emitChanged();
}
Beispiel #27
0
void BtStyle::setToolbarButtonText(const QColor& color) {
    toolbarButtonText = color;
    emitChanged();
}
Beispiel #28
0
void BtStyle::setToolbarTextColor(const QColor& color) {
    toolbarTextColor = color;
    emitChanged();
}
Beispiel #29
0
void BtStyle::setMenuBorder(const QColor& color) {
    menuBorder = color;
    emitChanged();
}
Beispiel #30
0
void BtStyle::setMenuText(const QColor& color) {
    menuText = color;
    emitChanged();
}