diff --git a/src/core/KexiView.cpp b/src/core/KexiView.cpp --- a/src/core/KexiView.cpp +++ b/src/core/KexiView.cpp @@ -565,10 +565,7 @@ d->lastFocusedChildBeforeFocusOut = 0; w->setFocus(); } else { - if (hasFocus()) - setFocusInternal(); - else - setFocusInternal(); + setFocusInternal(); } KexiMainWindowIface::global()->invalidateSharedActions(this); } diff --git a/src/core/kexidbconnectionset.h b/src/core/kexidbconnectionset.h --- a/src/core/kexidbconnectionset.h +++ b/src/core/kexidbconnectionset.h @@ -53,7 +53,7 @@ \return true on success (data is then copied from \a newData to \a oldData) */ bool saveConnectionData(KDbConnectionData *oldData, const KDbConnectionData &newData); - /*! Removed \a data from this set. + /*! Removes \a data from this set without deleting the object. \return true on successful removing of corresponding .kexic file */ bool removeConnectionData(KDbConnectionData *data); diff --git a/src/core/kexidbconnectionset.cpp b/src/core/kexidbconnectionset.cpp --- a/src/core/kexidbconnectionset.cpp +++ b/src/core/kexidbconnectionset.cpp @@ -141,7 +141,6 @@ d->filenamesForData.remove(key(*data)); d->dataForFilenames.remove(filename); d->list.removeAt(d->list.indexOf(data)); - delete data; } bool KexiDBConnectionSet::removeConnectionData(KDbConnectionData *data) diff --git a/src/core/kexiguimsghandler.cpp b/src/core/kexiguimsghandler.cpp --- a/src/core/kexiguimsghandler.cpp +++ b/src/core/kexiguimsghandler.cpp @@ -150,7 +150,9 @@ } else { showErrorMessage(message, QString()); } - status->clearStatus(); + if (status) { + status->clearStatus(); + } } void @@ -214,7 +216,7 @@ if (!KMessageBox::shouldBeShownContinue(dontShowAgainName)) return; //! @todo what about the result? - KMessageBox::warningContinueCancel(parentWidget(), + (void)KMessageBox::warningContinueCancel(parentWidget(), title + (details.isEmpty() ? QString() : (QString("\n") + details)), QString(), KStandardGuiItem::cont(), diff --git a/src/core/kexiproject.cpp b/src/core/kexiproject.cpp --- a/src/core/kexiproject.cpp +++ b/src/core/kexiproject.cpp @@ -745,7 +745,7 @@ KexiPart::ItemDict* KexiProject::items(KexiPart::Info *i) { - //qDebug(); + clearResult(); KDbMessageGuard mg(this); if (!i || !isConnected()) return 0; diff --git a/src/core/kexiprojectdata.cpp b/src/core/kexiprojectdata.cpp --- a/src/core/kexiprojectdata.cpp +++ b/src/core/kexiprojectdata.cpp @@ -236,10 +236,11 @@ if (_groupKey) *_groupKey = groupKey; } else { - if (!config.hasGroup(*_groupKey)) + if (!config.hasGroup(*_groupKey)) { m_result = KDbResult(xi18n("File %1 does not contain group %2.", fileName, *_groupKey)); return false; + } groupKey = *_groupKey; } diff --git a/src/formeditor/commands.cpp b/src/formeditor/commands.cpp --- a/src/formeditor/commands.cpp +++ b/src/formeditor/commands.cpp @@ -1003,8 +1003,9 @@ } //assign item for its widget if it supports DesignTimeDynamicChildWidgetHandler interface //(e.g. KexiDBAutoField) - if (d->form->mode() == Form::DesignMode && dynamic_cast(w)) { - dynamic_cast(w)->assignItem(item); + DesignTimeDynamicChildWidgetHandler *childHandler = dynamic_cast(w); + if (d->form->mode() == Form::DesignMode && childHandler) { + childHandler->assignItem(item); } // We add the autoSaveProperties in the modifProp list of the ObjectTreeItem, so that they are saved later diff --git a/src/formeditor/container.cpp b/src/formeditor/container.cpp --- a/src/formeditor/container.cpp +++ b/src/formeditor/container.cpp @@ -420,10 +420,10 @@ return true; } else if (mev->buttons() == Qt::LeftButton && mev->modifiers() == Qt::ControlModifier) { - // draw the insert rect for the copied widget - if (s == widget()) { - return true; - } + //! @todo draw the insert rect for the copied widget +// if (s == widget()) { +// return true; +// } return true; } else if ( ( (mev->buttons() == Qt::LeftButton && mev->modifiers() == Qt::NoModifier) diff --git a/src/formeditor/form.cpp b/src/formeditor/form.cpp --- a/src/formeditor/form.cpp +++ b/src/formeditor/form.cpp @@ -476,6 +476,7 @@ flags = LastSelection; } selectWidget(widget, flags); + ++i; } } @@ -794,10 +795,11 @@ if (saveExecutingCommand) d->executingCommand = command; - d->undoStack.push(command); + const bool pushed = d->undoStack.push(command); - if (saveExecutingCommand) + if (saveExecutingCommand || !pushed) { d->executingCommand = 0; + } //qDebug() << "ADDED:" << *command; return true; } @@ -1518,8 +1520,8 @@ const char* propertyName = meta.name(); QWidget *subwidget = subMeta.isValid()//subpropIface ? subpropIface->subwidget() : w; - WidgetInfo *subwinfo = library()->widgetInfoForClassName( - subwidget->metaObject()->className()); + WidgetInfo *subwinfo = subwidget ? library()->widgetInfoForClassName( + subwidget->metaObject()->className()) : 0; // qDebug() << "$$$ " << subwidget->className(); if ( subwinfo @@ -1561,7 +1563,7 @@ else { int realType = subwinfo->customTypeForProperty(propertyName); if (realType == KProperty::Invalid || realType == KProperty::Auto) { - realType = meta.type(); + realType = int(meta.type()); } newProp = new KProperty( propertyName, diff --git a/src/formeditor/formIO.cpp b/src/formeditor/formIO.cpp --- a/src/formeditor/formIO.cpp +++ b/src/formeditor/formIO.cpp @@ -1141,8 +1141,9 @@ } //assign item for its widget if it supports DesignTimeDynamicChildWidgetHandler interface //(e.g. KexiDBAutoField) - if (container->form()->mode() == Form::DesignMode && dynamic_cast(w)) { - dynamic_cast(w)->assignItem(item); + DesignTimeDynamicChildWidgetHandler *childHandler = dynamic_cast(w); + if (container->form()->mode() == Form::DesignMode && childHandler) { + childHandler->assignItem(item); } // if we are inside a Grid, we need to insert the widget in the good cell diff --git a/src/formeditor/form_p.cpp b/src/formeditor/form_p.cpp --- a/src/formeditor/form_p.cpp +++ b/src/formeditor/form_p.cpp @@ -45,7 +45,8 @@ template static StyleOptionClass *cloneStyleOption(const QStyleOption *option) { - return new StyleOptionClass( *qstyleoption_cast(option) ); + const StyleOptionClass *o = qstyleoption_cast(option); + return o ? new StyleOptionClass(*o) : new StyleOptionClass(); } QStyleOption* DesignModeStyle::alterOption(ControlElement element, const QStyleOption *option) const diff --git a/src/formeditor/kexiactionselectiondialog.cpp b/src/formeditor/kexiactionselectiondialog.cpp --- a/src/formeditor/kexiactionselectiondialog.cpp +++ b/src/formeditor/kexiactionselectiondialog.cpp @@ -68,16 +68,17 @@ } using QTreeWidgetItem::data; - QVariant data(ActionRole role) { + QVariant data(ActionRole role) const + { return QTreeWidgetItem::data(0, role); }; using QTreeWidgetItem::setData; void setData(ActionRole role, QVariant value) { QTreeWidgetItem::setData(0, role, value); } - QIcon icon() { + QIcon icon() const { return QTreeWidgetItem::icon(0); } @@ -518,6 +519,19 @@ d->actionToExecuteLbl->setText(xi18n("Action to execute:")); d->secondAnd3rdColumnGrLyr->addWidget(d->actionToExecuteLbl, 0, 1, Qt::AlignTop | Qt::AlignLeft); + // buttons + d->buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); + QPushButton *okButton = d->buttonBox->button(QDialogButtonBox::Ok); + okButton->setDefault(true); + okButton->setShortcut(Qt::CTRL | Qt::Key_Return); + connect(d->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(d->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + d->actionWidgetName = actionWidgetName; + d->buttonBox->button(QDialogButtonBox::Ok)->setText(xi18nc("Assign action", "&Assign")); + //buttonBox->button(QDialogButtonBox::Ok)->setIcon(koIconName("dialog-ok")); + d->buttonBox->button(QDialogButtonBox::Ok)->setToolTip(xi18n("Assign action")); + mainLayout->addWidget(d->buttonBox); + // temporary show all sections to avoid resizing the dialog in the future d->actionCategoriesListView->selectAction("table"); d->setActionToExecuteSectionVisible(true); @@ -558,19 +572,6 @@ d->actionCategoriesListView->selectAction("noaction"); d->actionCategoriesListView->setFocus(); } - - // buttons - d->buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); - QPushButton *okButton = d->buttonBox->button(QDialogButtonBox::Ok); - okButton->setDefault(true); - okButton->setShortcut(Qt::CTRL | Qt::Key_Return); - connect(d->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(d->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - d->actionWidgetName = actionWidgetName; - d->buttonBox->button(QDialogButtonBox::Ok)->setText(xi18nc("Assign action", "&Assign")); - //buttonBox->button(QDialogButtonBox::Ok)->setIcon(koIconName("dialog-ok")); - d->buttonBox->button(QDialogButtonBox::Ok)->setToolTip(xi18n("Assign action")); - mainLayout->addWidget(d->buttonBox); } KexiActionSelectionDialog::~KexiActionSelectionDialog() @@ -666,7 +667,7 @@ vlyr->addWidget(d->currentFormActionsPageLabel); vlyr->addWidget(d->currentFormActionsListView); d->secondAnd3rdColumnStack->addWidget(d->currentFormActionsPageWidget); - connect(d->currentFormActionsListView, SIGNAL(itemActivated(QTreeWidgetItem*)), + connect(d->currentFormActionsListView, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(slotCurrentFormActionItemExecuted(QTreeWidgetItem*))); connect(d->currentFormActionsListView, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(slotCurrentFormActionItemSelected(QTreeWidgetItem*))); @@ -715,25 +716,29 @@ ActionSelectorDialogTreeItem *categoryItm = dynamic_cast(d->actionCategoriesListView->currentItem()); if (categoryItm) { - QString actionCategory = categoryItm->data(ActionSelectorDialogTreeItem::ActionCategoryRole).toString(); + const QString actionCategory = categoryItm->data(ActionSelectorDialogTreeItem::ActionCategoryRole).toString(); if (actionCategory == "kaction") { - if (d->kactionListView->currentItem()) { + const ActionSelectorDialogTreeItem* actionToExecute = dynamic_cast( + d->kactionListView->currentItem()); + if (actionToExecute) { data.string = QString("kaction:") - + dynamic_cast(d->kactionListView->currentItem())->data(ActionSelectorDialogTreeItem::ActionDataRole).toString(); + + actionToExecute->data(ActionSelectorDialogTreeItem::ActionDataRole).toString(); return data; } } else if (actionCategory == "currentForm") { - if (d->currentFormActionsListView->currentItem()) { + const ActionSelectorDialogTreeItem *actionToExecute = dynamic_cast( + d->currentFormActionsListView->currentItem()); + if (actionToExecute) { data.string = QString("currentForm:") - + dynamic_cast( - d->currentFormActionsListView->currentItem())->data(ActionSelectorDialogTreeItem::ActionDataRole).toString(); + + actionToExecute->data(ActionSelectorDialogTreeItem::ActionDataRole).toString(); return data; } } else if (actionCategory == "noaction") { return data; } else if (actionCategory == "navObject") { - ActionSelectorDialogTreeItem *actionToExecute = dynamic_cast(d->actionToExecuteListView->currentItem()); + const ActionSelectorDialogTreeItem *actionToExecute = dynamic_cast( + d->actionToExecuteListView->currentItem()); if (d->objectsListView && actionToExecute && !actionToExecute->data(ActionSelectorDialogTreeItem::ActionDataRole).toString().isEmpty()) { KexiPart::Item* partItem = d->objectsListView->selectedPartItem(); KexiPart::Info* partInfo = partItem ? Kexi::partManager().infoForPluginId(partItem->pluginId()) : 0; diff --git a/src/formeditor/richtextdialog.cpp b/src/formeditor/richtextdialog.cpp --- a/src/formeditor/richtextdialog.cpp +++ b/src/formeditor/richtextdialog.cpp @@ -179,19 +179,19 @@ else if (action == d->superscriptTextAction) { if (isChecked && d->subscriptTextAction->isChecked()) { d->subscriptTextAction->setChecked(false); - QTextCharFormat currentCharFormat = d->edit->currentCharFormat(); - currentCharFormat.setVerticalAlignment( - isChecked ? QTextCharFormat::AlignSuperScript : QTextCharFormat::AlignNormal); - d->edit->setCurrentCharFormat(currentCharFormat); } + QTextCharFormat currentCharFormat = d->edit->currentCharFormat(); + currentCharFormat.setVerticalAlignment( + isChecked ? QTextCharFormat::AlignSuperScript : QTextCharFormat::AlignNormal); + d->edit->setCurrentCharFormat(currentCharFormat); } else if (action == d->subscriptTextAction) { - if (isChecked && d->subscriptTextAction->isChecked()) { - d->subscriptTextAction->setChecked(false); - QTextCharFormat currentCharFormat = d->edit->currentCharFormat(); - currentCharFormat.setVerticalAlignment( - isChecked ? QTextCharFormat::AlignSubScript : QTextCharFormat::AlignNormal); - d->edit->setCurrentCharFormat(currentCharFormat); + if (isChecked && d->superscriptTextAction->isChecked()) { + d->superscriptTextAction->setChecked(false); } + QTextCharFormat currentCharFormat = d->edit->currentCharFormat(); + currentCharFormat.setVerticalAlignment( + isChecked ? QTextCharFormat::AlignSubScript : QTextCharFormat::AlignNormal); + d->edit->setCurrentCharFormat(currentCharFormat); } else if (action == d->alignLeftAction) { if (isChecked) d->edit->setAlignment(Qt::AlignLeft); diff --git a/src/formeditor/widgetwithsubpropertiesinterface.cpp b/src/formeditor/widgetwithsubpropertiesinterface.cpp --- a/src/formeditor/widgetwithsubpropertiesinterface.cpp +++ b/src/formeditor/widgetwithsubpropertiesinterface.cpp @@ -56,15 +56,15 @@ d->subwidget = widget; d->subproperties.clear(); QSet addedSubproperties; - if (d->subwidget) { + const QObject *thisObject = dynamic_cast(this); + if (thisObject && d->subwidget) { //remember properties in the subwidget that are not present in the parent for (const QMetaObject *metaObject = d->subwidget->metaObject(); metaObject; metaObject = metaObject->superClass()) { QList properties( KexiUtils::propertiesForMetaObjectWithInherited(metaObject)); foreach(const QMetaProperty &property, properties) { - if (dynamic_cast(this) - && -1 != dynamic_cast(this)->metaObject()->indexOfProperty(property.name()) + if (-1 != thisObject->metaObject()->indexOfProperty(property.name()) && !addedSubproperties.contains(property.name())) { d->subproperties.insert(property.name()); diff --git a/src/kexiutils/KexiFadeWidgetEffect.cpp b/src/kexiutils/KexiFadeWidgetEffect.cpp --- a/src/kexiutils/KexiFadeWidgetEffect.cpp +++ b/src/kexiutils/KexiFadeWidgetEffect.cpp @@ -97,7 +97,6 @@ : QWidget(destWidget ? destWidget->parentWidget() : 0), d(new KexiFadeWidgetEffectPrivate(destWidget)) { - d->q = this; d->defaultDuration = defaultDuration; Q_ASSERT(destWidget && destWidget->parentWidget()); if (!destWidget || !destWidget->parentWidget() || !destWidget->isVisible() || diff --git a/src/kexiutils/KexiFadeWidgetEffect_p.h b/src/kexiutils/KexiFadeWidgetEffect_p.h --- a/src/kexiutils/KexiFadeWidgetEffect_p.h +++ b/src/kexiutils/KexiFadeWidgetEffect_p.h @@ -29,8 +29,7 @@ class KexiFadeWidgetEffectPrivate { public: - KexiFadeWidgetEffectPrivate(QWidget *_destWidget); - KexiFadeWidgetEffect *q; + explicit KexiFadeWidgetEffectPrivate(QWidget *_destWidget); QPixmap transition(const QPixmap &from, const QPixmap &to, qreal amount) const; void finished(); diff --git a/src/main/KexiMainWindow.cpp b/src/main/KexiMainWindow.cpp --- a/src/main/KexiMainWindow.cpp +++ b/src/main/KexiMainWindow.cpp @@ -250,21 +250,28 @@ void KexiMainWindowTabWidget::closeTab() { - dynamic_cast(KexiMainWindowIface::global())->closeWindowForTab(m_tabIndex); + KexiMainWindow *main = dynamic_cast(KexiMainWindowIface::global()); + if (main) { + main->closeWindowForTab(m_tabIndex); + } } tristate KexiMainWindowTabWidget::closeAllTabs() { tristate alternateResult = true; QList windowList; + KexiMainWindow *main = dynamic_cast(KexiMainWindowIface::global()); + if (!main) { + return alternateResult; + } for (int i = 0; i < count(); i++) { - KexiWindow *window = dynamic_cast(KexiMainWindowIface::global())->windowForTab(i); + KexiWindow *window = main->windowForTab(i); if (window) { windowList.append(window); } } foreach (KexiWindow *window, windowList) { - tristate result = dynamic_cast(KexiMainWindowIface::global())->closeWindow(window); + tristate result = main->closeWindow(window); if (result != true && result != false) { return result; } @@ -3366,7 +3373,6 @@ if (window) {//close existing window const bool tmp = d->forceWindowClosing; - window->partItem()->neverSaved(); d->forceWindowClosing = true; res = closeWindow(window); d->forceWindowClosing = tmp; //restore diff --git a/src/main/KexiMainWindow_p.cpp b/src/main/KexiMainWindow_p.cpp --- a/src/main/KexiMainWindow_p.cpp +++ b/src/main/KexiMainWindow_p.cpp @@ -1345,6 +1345,9 @@ KexiDockWidget *dockWidget, bool visible) { KMultiTabBar *mtbar = multiTabBars.value(position); + if (!mtbar) { + return; + } if (!visible) { mtbar->removeTab(id); } diff --git a/src/main/KexiMenuWidget.cpp b/src/main/KexiMenuWidget.cpp --- a/src/main/KexiMenuWidget.cpp +++ b/src/main/KexiMenuWidget.cpp @@ -928,7 +928,10 @@ //actually performs the scrolling void KexiMenuWidgetPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active) { - return; + Q_UNUSED(action) + Q_UNUSED(location) + Q_UNUSED(active) +#if 0 if (!scroll || !scroll->scrollFlags) return; updateActionRects(); @@ -1037,11 +1040,14 @@ setCurrentAction(action); q->update(); //issue an update so we see all the new state.. +#endif } void KexiMenuWidgetPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool active) { - return; + Q_UNUSED(location) + Q_UNUSED(active) +#if 0 updateActionRects(); QList actionsList = q->actions(); if(location == QMenuScroller::ScrollBottom) { @@ -1075,12 +1081,16 @@ } } } +#endif } //only directional void KexiMenuWidgetPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, bool page, bool active) { - return; + Q_UNUSED(direction) + Q_UNUSED(page) + Q_UNUSED(active) +#if 0 if (!scroll || !(scroll->scrollFlags & direction)) //not really possible... return; updateActionRects(); @@ -1122,6 +1132,7 @@ q->update(); } } +#endif } /* This is poor-mans eventfilters. This avoids the use of @@ -2752,15 +2763,9 @@ case Qt::Key_Left: { if (d->currentAction && !d->scroll) { QAction *nextAction = 0; - if (key == Qt::Key_Left) { - QRect actionR = d->actionRect(d->currentAction); - for(int x = actionR.left()-1; !nextAction && x >= 0; x--) - nextAction = d->actionAt(QPoint(x, actionR.center().y())); - } else { - QRect actionR = d->actionRect(d->currentAction); - for(int x = actionR.right()+1; !nextAction && x < width(); x++) - nextAction = d->actionAt(QPoint(x, actionR.center().y())); - } + QRect actionR = d->actionRect(d->currentAction); + for(int x = actionR.left()-1; !nextAction && x >= 0; x--) + nextAction = d->actionAt(QPoint(x, actionR.center().y())); if (nextAction) { d->setCurrentAction(nextAction, /*popup*/-1, KexiMenuWidget::SelectedFromKeyboard); key_consumed = true; diff --git a/src/main/KexiSearchLineEdit.cpp b/src/main/KexiSearchLineEdit.cpp --- a/src/main/KexiSearchLineEdit.cpp +++ b/src/main/KexiSearchLineEdit.cpp @@ -554,8 +554,8 @@ case Qt::Key_Select: if (!QApplication::keypadNavigationEnabled()) break; -#endif d->completer->popup()->hide(); // just hide. will end up propagating to parent +#endif default: break; // normal key processing } diff --git a/src/main/kexistatusbar.h b/src/main/kexistatusbar.h --- a/src/main/kexistatusbar.h +++ b/src/main/kexistatusbar.h @@ -44,8 +44,8 @@ virtual ~KexiStatusBar(); //! @todo extend to more generic API - QAction *m_showNavigatorAction; - QAction *m_showPropertyEditorAction; + //QAction *m_showNavigatorAction; + //QAction *m_showPropertyEditorAction; public Q_SLOTS: virtual void setStatus(const QString &str); diff --git a/src/main/startup/KexiRecentProjectsModel.cpp b/src/main/startup/KexiRecentProjectsModel.cpp --- a/src/main/startup/KexiRecentProjectsModel.cpp +++ b/src/main/startup/KexiRecentProjectsModel.cpp @@ -68,21 +68,20 @@ const int minutes = opened.secsTo(cur) / 60; const int hours = minutes / 60; if (hours < 1) { - if (minutes == 0) + if (minutes == 0) { return xi18n("Opened less than minute ago"); - else - return xi18np("Opened 1 minute ago", "Opened %1 minutes ago", minutes); - } else { - return xi18np("Opened 1 hour ago", "Opened %1 hours ago", hours); + } + return xi18np("Opened 1 minute ago", "Opened %1 minutes ago", minutes); } - } else { - if (days < 30) - return xi18np("Opened yesterday", "Opened %1 days ago", days); - if (days < 365) - return xi18np("Opened over a month ago", "Opened %1 months ago", days / 30); - return xi18np("Opened one year ago", "Opened %1 years ago", days / 365); + return xi18np("Opened 1 hour ago", "Opened %1 hours ago", hours); + } + if (days < 30) { + return xi18np("Opened yesterday", "Opened %1 days ago", days); + } + if (days < 365) { + return xi18np("Opened over a month ago", "Opened %1 months ago", days / 30); } - return QString(); + return xi18np("Opened one year ago", "Opened %1 years ago", days / 365); } QVariant KexiRecentProjectsModel::data(const QModelIndex& index, int role) const diff --git a/src/main/startup/KexiStartup.cpp b/src/main/startup/KexiStartup.cpp --- a/src/main/startup/KexiStartup.cpp +++ b/src/main/startup/KexiStartup.cpp @@ -707,7 +707,7 @@ KexiStartupData::setAction(ShowWelcomeScreen); return true; //! @todo remove startup dialog code - +#if 0 if (!d->startupDialog) { //create startup dialog for reuse because it can be used again after conn err. d->startupDialog = new KexiStartupDialog( @@ -783,6 +783,7 @@ if (!KexiStartupData::projectData()) return true; +#endif } if (KexiStartupData::projectData() && (openExisting || (createDB && isSet(options().createAndOpenDb)))) { diff --git a/src/plugins/forms/kexidatasourcepage.h b/src/plugins/forms/kexidatasourcepage.h --- a/src/plugins/forms/kexidatasourcepage.h +++ b/src/plugins/forms/kexidatasourcepage.h @@ -92,15 +92,17 @@ QWidget *m_widgetDataSourceComboSpacer; KexiDataSourceComboBox* m_formDataSourceCombo; QWidget *m_formDataSourceComboSpacer; - QLabel *m_dataSourceLabel, *m_noDataSourceAvailableLabel, - *m_widgetDSLabel, *m_availableFieldsLabel, - *m_mousePointerLabel, *m_availableFieldsDescriptionLabel; - QToolButton *m_gotoButton, *m_addField; + QLabel *m_dataSourceLabel, *m_noDataSourceAvailableLabel, *m_widgetDSLabel; + QToolButton *m_gotoButton; QString m_noDataSourceAvailableSingleText; QString m_noDataSourceAvailableMultiText; bool m_insideClearFormDataSourceSelection; #ifdef KEXI_AUTOFIELD_FORM_WIDGET_SUPPORT + KexiFieldListView* m_availableFieldsLabel; KexiFieldListView* m_fieldListView; + QLabel *m_mousePointerLabel; + QLabel *m_availableFieldsDescriptionLabel; + QToolButton *m_addField; #else KDbTableOrQuerySchema *m_tableOrQuerySchema; //!< temp. #endif diff --git a/src/plugins/forms/kexidatasourcepage.cpp b/src/plugins/forms/kexidatasourcepage.cpp --- a/src/plugins/forms/kexidatasourcepage.cpp +++ b/src/plugins/forms/kexidatasourcepage.cpp @@ -134,8 +134,6 @@ m_formDataSourceComboSpacer = addWidgetSpacer(); #ifndef KEXI_AUTOFIELD_FORM_WIDGET_SUPPORT - m_availableFieldsLabel = 0; - m_addField = 0; mainLayout()->addStretch(); #else //2. Inserting fields diff --git a/src/plugins/forms/kexiformmanager.cpp b/src/plugins/forms/kexiformmanager.cpp --- a/src/plugins/forms/kexiformmanager.cpp +++ b/src/plugins/forms/kexiformmanager.cpp @@ -345,17 +345,18 @@ KexiWindow *currentWindow = KexiMainWindowIface::global()->currentWindow(); if (!currentWindow) return 0; - KexiView *currentView = currentWindow->selectedView(); - KFormDesigner::Form *form; - if (!currentView - || currentView->viewMode()!=Kexi::DesignViewMode - || !dynamic_cast(currentView) - || !(form = dynamic_cast(currentView)->form()) - ) - { + KexiFormView *currentView = dynamic_cast(currentWindow->selectedView()); + if (!currentView || currentView->viewMode()!=Kexi::DesignViewMode) { + return 0; + } + KFormDesigner::Form *form = currentView->form(); + if (!form) { return 0; } KexiDBForm *dbform = dynamic_cast(form->formWidget()); + if (!dbform) { + return 0; + } KexiFormScrollView *scrollViewWidget = dynamic_cast(dbform->dataAwareObject()); if (!scrollViewWidget) return 0; diff --git a/src/plugins/forms/kexiformscrollview.cpp b/src/plugins/forms/kexiformscrollview.cpp --- a/src/plugins/forms/kexiformscrollview.cpp +++ b/src/plugins/forms/kexiformscrollview.cpp @@ -447,10 +447,15 @@ dbFormWidget()->editedItem = dynamic_cast(item); startEditCurrentCell(); } - fillDuplicatedDataItems(dynamic_cast(item), item->value()); - - //value changed: clear 'default value' mode (e.g. a blue italic text) - dynamic_cast(item)->setDisplayDefaultValue(dynamic_cast(item), false); + KexiFormDataItemInterface *formItem = dynamic_cast(item); + if (formItem) { + fillDuplicatedDataItems(formItem, item->value()); + QWidget *widget = dynamic_cast(item); + if (widget) { + //value changed: clear 'default value' mode (e.g. a blue italic text) + formItem->setDisplayDefaultValue(widget, false); + } + } } bool KexiFormScrollView::cursorAtNewRecord() const @@ -500,13 +505,14 @@ bool KexiFormScrollView::cancelEditor() { - if (!dynamic_cast(m_editor)) + KexiFormDataItemInterface *itemIface = dynamic_cast(m_editor); + if (!itemIface) { return false; + } if (m_errorMessagePopup) m_errorMessagePopup->close(); - KexiFormDataItemInterface *itemIface = dynamic_cast(m_editor); itemIface->undoChanges(); const bool displayDefaultValue = shouldDisplayDefaultValueForItem(itemIface); @@ -523,16 +529,14 @@ void KexiFormScrollView::updateAfterCancelRecordEditing() { foreach(KexiFormDataItemInterface *dataItemIface, m_dataItems) { - if (dynamic_cast(dataItemIface)) { - qDebug() - << dynamic_cast(dataItemIface)->metaObject()->className() << " " - << dynamic_cast(dataItemIface)->objectName(); + QWidget *w = dynamic_cast(dataItemIface); + if (w) { + qDebug() << w->metaObject()->className() << w->objectName(); + const bool displayDefaultValue = shouldDisplayDefaultValueForItem(dataItemIface); + dataItemIface->undoChanges(); + if (dataItemIface->hasDisplayedDefaultValue() != displayDefaultValue) + dataItemIface->setDisplayDefaultValue(w, displayDefaultValue); } - const bool displayDefaultValue = shouldDisplayDefaultValueForItem(dataItemIface); - dataItemIface->undoChanges(); - if (dataItemIface->hasDisplayedDefaultValue() != displayDefaultValue) - dataItemIface->setDisplayDefaultValue( - dynamic_cast(dataItemIface), displayDefaultValue); } recordNavigator()->showEditingIndicator(false); dbFormWidget()->editedItem = 0; diff --git a/src/plugins/forms/kexiformview.cpp b/src/plugins/forms/kexiformview.cpp --- a/src/plugins/forms/kexiformview.cpp +++ b/src/plugins/forms/kexiformview.cpp @@ -833,7 +833,7 @@ if (widgetItem) widgetItem->addModifiedProperty("storedPixmapId", oldStoredPixmapId); else - qWarning() << "no" << widgetItem->name() << "widget found within a form"; + qWarning() << "no" << it.key()->objectName() << "widget found within a form"; } } diff --git a/src/plugins/forms/widgets/kexidbautofield.cpp b/src/plugins/forms/widgets/kexidbautofield.cpp --- a/src/plugins/forms/widgets/kexidbautofield.cpp +++ b/src/plugins/forms/widgets/kexidbautofield.cpp @@ -176,11 +176,11 @@ if (newSubwidget) { newSubwidget->setObjectName( QString::fromLatin1("KexiDBAutoField_") + newSubwidget->metaObject()->className()); - dynamic_cast(newSubwidget)->setParentDataItemInterface(this); - dynamic_cast(newSubwidget) - ->setColumnInfo(columnInfo()); //needed at least by KexiDBImageBox - dynamic_cast(newSubwidget) - ->setVisibleColumnInfo(visibleColumnInfo()); //needed at least by KexiDBComboBox + KexiDataItemInterface *iface = dynamic_cast(newSubwidget); + iface->setParentDataItemInterface(this); + KexiFormDataItemInterface *formIface = dynamic_cast(newSubwidget); + formIface->setColumnInfo(columnInfo()); //needed at least by KexiDBImageBox + formIface->setVisibleColumnInfo(visibleColumnInfo()); //needed at least by KexiDBComboBox newSubwidget->setProperty("dataSource", dataSource()); //needed at least by KexiDBImageBox KFormDesigner::DesignTimeDynamicChildWidgetHandler::childWidgetAdded(this); newSubwidget->show(); @@ -252,7 +252,7 @@ if (position == Left && d->widgetType != Boolean) d->layout->addSpacing(KexiDBAutoField_SPACING); d->layout->addWidget(subwidget(), 1); - KexiSubwidgetInterface *subwidgetInterface = dynamic_cast((QWidget*)subwidget()); + KexiSubwidgetInterface *subwidgetInterface = dynamic_cast(subwidget()); if (subwidgetInterface) { if (subwidgetInterface->appendStretchRequired(this)) d->layout->addStretch(0); @@ -276,9 +276,10 @@ //a hack to force layout to be refreshed (any better idea for this?) resize(size() + QSize(1, 0)); resize(size() - QSize(1, 0)); - if (dynamic_cast((QWidget*)subwidget())) { + KexiDBAutoField* autoField = dynamic_cast(subwidget()); + if (autoField) { //needed for KexiDBComboBox - dynamic_cast((QWidget*)subwidget())->setLabelPosition(position); + autoField->setLabelPosition(position); } } @@ -773,8 +774,9 @@ void KexiDBAutoField::setDisplayDefaultValue(QWidget* widget, bool displayDefaultValue) { KexiFormDataItemInterface::setDisplayDefaultValue(widget, displayDefaultValue); - if (dynamic_cast((QWidget*)subwidget())) - dynamic_cast((QWidget*)subwidget())->setDisplayDefaultValue(subwidget(), displayDefaultValue); + KexiFormDataItemInterface *formIface = dynamic_cast(subwidget()); + if (formIface) + formIface->setDisplayDefaultValue(subwidget(), displayDefaultValue); } void KexiDBAutoField::moveCursorToEnd() diff --git a/src/plugins/forms/widgets/kexidbdatepicker.h b/src/plugins/forms/widgets/kexidbdatepicker.h --- a/src/plugins/forms/widgets/kexidbdatepicker.h +++ b/src/plugins/forms/widgets/kexidbdatepicker.h @@ -1,6 +1,6 @@ /* This file is part of the KDE project Copyright (C) 2005 Cedric Pasteur - Copyright (C) 2004-2005 Jarosław Staniek + Copyright (C) 2004-2016 Jarosław Staniek Copyright (C) 2012 Oleg Kukharchuk This program is free software; you can redistribute it and/or @@ -88,10 +88,7 @@ private: bool m_invalidState; - bool m_cursorAtEnd; - bool m_cursorAtStart; bool m_readOnly; - bool m_dateEditFocused; }; #endif diff --git a/src/plugins/forms/widgets/kexidbdatepicker.cpp b/src/plugins/forms/widgets/kexidbdatepicker.cpp --- a/src/plugins/forms/widgets/kexidbdatepicker.cpp +++ b/src/plugins/forms/widgets/kexidbdatepicker.cpp @@ -1,6 +1,6 @@ /* This file is part of the KDE project Copyright (C) 2005 Cedric Pasteur - Copyright (C) 2004-2005 Jarosław Staniek + Copyright (C) 2004-2016 Jarosław Staniek Copyright (C) 2012 Oleg Kukharchuk This program is free software; you can redistribute it and/or @@ -26,7 +26,8 @@ KexiDBDatePicker::KexiDBDatePicker(QWidget *parent) : KDatePicker(parent) , KexiFormDataItemInterface() - , m_dateEditFocused(false) + , m_invalidState(false) + , m_readOnly(false) { connect(this, SIGNAL(dateChanged(QDate)), this, SLOT(slotValueChanged())); connect(this, SIGNAL(dateEntered(QDate)), this, SLOT(slotValueChanged())); diff --git a/src/plugins/forms/widgets/kexidbform.cpp b/src/plugins/forms/widgets/kexidbform.cpp --- a/src/plugins/forms/widgets/kexidbform.cpp +++ b/src/plugins/forms/widgets/kexidbform.cpp @@ -262,7 +262,7 @@ QObject *o = watched; //focusWidget(); QWidget* realWidget = dynamic_cast(o); //will beused below (for tab/backtab handling) - if (!tab && !backtab) { + if (realWidget && !tab && !backtab) { //for buttons, left/up and right/down keys act like tab/backtab (see qbutton.cpp) if (realWidget->inherits("QButton")) { if (ke->modifiers() == Qt::NoModifier && (key == Qt::Key_Right || key == Qt::Key_Down)) @@ -319,8 +319,10 @@ if (widgetToFocus) { widgetToFocus->setFocus(); - if (dynamic_cast(widgetToFocus)) - dynamic_cast(widgetToFocus)->selectAllOnFocusIfNeeded(); + KexiFormDataItemInterface *formItem = dynamic_cast(widgetToFocus); + if (formItem) { + formItem->selectAllOnFocusIfNeeded(); + } } else { qWarning() << "widgetToFocus not found!"; @@ -360,11 +362,18 @@ return true; //ignore //the watched widget can be a subwidget of a real widget, e.g. autofield: find it //QWidget* realWidget = static_cast(watched); - while (dynamic_cast(realWidget) && dynamic_cast(realWidget)->parentDataItemInterface()) - realWidget = dynamic_cast(dynamic_cast(realWidget)->parentDataItemInterface()); + KexiDataItemInterface *iface; + while ((iface = dynamic_cast(realWidget)) + && iface->parentDataItemInterface()) + { + realWidget = dynamic_cast(iface->parentDataItemInterface()); + } d->setOrderedFocusWidgetsIteratorTo(realWidget); - dynamic_cast(realWidget)->moveCursorToEnd(); + iface = dynamic_cast(realWidget); + if (iface) { + iface->moveCursorToEnd(); + } //qDebug() << realWidget->objectName(); @@ -429,9 +438,10 @@ (*d->orderedFocusWidgetsIterator)->setFocus(); //qDebug() << "focusing " << (*d->orderedFocusWidgetsIterator)->objectName(); } - if (dynamic_cast(widgetToSelectAll)) { + KexiFormDataItemInterface *formItem = dynamic_cast(widgetToSelectAll); + if (formItem) { //qDebug() << "widgetToSelectAll:" << widgetToSelectAll; - dynamic_cast(widgetToSelectAll)->selectAllOnFocusIfNeeded(); + formItem->selectAllOnFocusIfNeeded(); } } return true; @@ -531,8 +541,8 @@ bool KexiDBForm::isPreviewing() const { - return dynamic_cast(d->dataAwareObject) - ? dynamic_cast(d->dataAwareObject)->isPreviewing() : false; + const KexiFormScrollView *view = dynamic_cast(d->dataAwareObject); + return view ? view->isPreviewing() : false; } void KexiDBForm::dragMoveEvent(QDragMoveEvent *e) diff --git a/src/plugins/forms/widgets/kexidblineedit.cpp b/src/plugins/forms/widgets/kexidblineedit.cpp --- a/src/plugins/forms/widgets/kexidblineedit.cpp +++ b/src/plugins/forms/widgets/kexidblineedit.cpp @@ -70,7 +70,7 @@ QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget = 0) const { const KFormDesigner::FormWidgetInterface *formWidget = dynamic_cast(widget); - if (formWidget->designMode()) { + if (formWidget && formWidget->designMode()) { const KexiFormDataItemInterface *dataItemIface = dynamic_cast(widget); if (dataItemIface && !dataItemIface->dataSource().isEmpty() && !formWidget->editingMode()) { if (element == SE_LineEditContents) { diff --git a/src/plugins/forms/widgets/kexidbutils.cpp b/src/plugins/forms/widgets/kexidbutils.cpp --- a/src/plugins/forms/widgets/kexidbutils.cpp +++ b/src/plugins/forms/widgets/kexidbutils.cpp @@ -125,9 +125,10 @@ // title QString icon; - if (dynamic_cast(d->iface)) { + const QWidget *thisWidget = dynamic_cast(d->iface); + if (thisWidget) { icon = KexiFormManager::self()->library()->iconName( - dynamic_cast(d->iface)->metaObject()->className()); + thisWidget->metaObject()->className()); } KexiContextMenuUtils::updateTitle( menu, d->iface->columnInfo()->captionOrAliasOrName(), diff --git a/src/plugins/importexport/csv/kexicsvimportdialog.cpp b/src/plugins/importexport/csv/kexicsvimportdialog.cpp --- a/src/plugins/importexport/csv/kexicsvimportdialog.cpp +++ b/src/plugins/importexport/csv/kexicsvimportdialog.cpp @@ -432,18 +432,22 @@ KexiPart::Part *part = Kexi::partManager().partForPluginId("org.kexi-project.table"); KDbObject tmp; - tristate res = m_conn->loadObjectData( + tristate res = (part && part->info()) ? m_conn->loadObjectData( project->typeIdForPluginId(part->info()->pluginId()), m_newTableWidget->nameText(), - &tmp); + &tmp) + : false; if (res == true) { KMessageBox::information(this, "

" + part->i18nMessage("Object %1 already exists.", 0) .subs(m_newTableWidget->nameText()).toString() + "

" + xi18n("Please choose other name.") + "

" ); return; + } else if (res == false) { + qFatal("Plugin org.kexi-project.table not found"); + return; } } else { m_partItemForSavedTable = m_tablesList->selectedPartItem(); diff --git a/src/plugins/importexport/csv/kexicsvwidgets.cpp b/src/plugins/importexport/csv/kexicsvwidgets.cpp --- a/src/plugins/importexport/csv/kexicsvwidgets.cpp +++ b/src/plugins/importexport/csv/kexicsvwidgets.cpp @@ -71,7 +71,6 @@ QString commentSymbol; QVector availablecommentSymbols; KComboBox* combo; - QLineEdit* commentSymbolEdit; }; KexiCSVDelimiterWidget::KexiCSVDelimiterWidget(bool lineEditOnBottom, QWidget * parent) diff --git a/src/plugins/queries/kexiquerydesignerguieditor.cpp b/src/plugins/queries/kexiquerydesignerguieditor.cpp --- a/src/plugins/queries/kexiquerydesignerguieditor.cpp +++ b/src/plugins/queries/kexiquerydesignerguieditor.cpp @@ -396,9 +396,9 @@ //build query schema KexiQueryPart::TempData * temp = tempData(); if (temp->query()) { - KexiView *queryDataView = window()->viewForMode(Kexi::DataViewMode); + KexiQueryView *queryDataView = dynamic_cast(window()->viewForMode(Kexi::DataViewMode)); if (queryDataView) { - dynamic_cast(queryDataView)->setData(0); + queryDataView->setData(0); } temp->clearQuery(); } else { diff --git a/src/plugins/queries/kexiqueryview.cpp b/src/plugins/queries/kexiqueryview.cpp --- a/src/plugins/queries/kexiqueryview.cpp +++ b/src/plugins/queries/kexiqueryview.cpp @@ -122,7 +122,7 @@ const tristate result = executeQuery(querySchema); if (true != result) return result; - } else if (mode == Kexi::DesignViewMode || Kexi::TextViewMode) { + } else if (mode == Kexi::DesignViewMode || mode == Kexi::TextViewMode) { KexiQueryPart::TempData * temp = static_cast(window()->data()); const tristate result = executeQuery(temp->query()); if (true != result) @@ -136,20 +136,28 @@ bool *cancel) { KexiView * view = window()->viewThatRecentlySetDirtyFlag(); - if (dynamic_cast(view)) - return dynamic_cast(view)->storeNewData(object, options, cancel); - if (dynamic_cast(view)) - return dynamic_cast(view)->storeNewData(object, options, cancel); + KexiQueryDesignerGuiEditor *guiView = dynamic_cast(view); + if (guiView) { + return guiView->storeNewData(object, options, cancel); + } + KexiQueryDesignerSQLView *sqlView = dynamic_cast(view); + if (sqlView) { + return sqlView->storeNewData(object, options, cancel); + } return 0; } tristate KexiQueryView::storeData(bool dontAsk) { KexiView * view = window()->viewThatRecentlySetDirtyFlag(); - if (dynamic_cast(view)) - return dynamic_cast(view)->storeData(dontAsk); - if (dynamic_cast(view)) - return dynamic_cast(view)->storeData(dontAsk); + KexiQueryDesignerGuiEditor *guiView = dynamic_cast(view); + if (guiView) { + return guiView->storeData(dontAsk); + } + KexiQueryDesignerSQLView *sqlView = dynamic_cast(view); + if (sqlView) { + return sqlView->storeData(dontAsk); + } return false; } diff --git a/src/plugins/reports/kexidbreportdata.cpp b/src/plugins/reports/kexidbreportdata.cpp --- a/src/plugins/reports/kexidbreportdata.cpp +++ b/src/plugins/reports/kexidbreportdata.cpp @@ -72,11 +72,16 @@ return; KDbOrderByColumnList order; for (int i = 0; i < sorting.count(); i++) { - order.appendField(d->copySchema, sorting[i].field, sorting[i].order == Qt::AscendingOrder); + if (!order.appendField(d->copySchema, sorting[i].field, + sorting[i].order == Qt::AscendingOrder)) + { + qWarning() << "Cannot set sort field" << i << sorting[i].field; + return; + } } d->copySchema->setOrderByColumnList(order); } else { - qDebug() << "Unable to sort null schema"; + qWarning() << "Unable to sort null schema"; } } diff --git a/src/plugins/reports/kexireportdesignview.h b/src/plugins/reports/kexireportdesignview.h --- a/src/plugins/reports/kexireportdesignview.h +++ b/src/plugins/reports/kexireportdesignview.h @@ -51,7 +51,6 @@ private: KReportDesigner *m_reportDesigner; - KPropertySet *m_propertySet; KexiReportPart::TempData* tempData() const; QScrollArea * m_scrollArea; @@ -61,7 +60,6 @@ QAction *m_editPasteAction; QAction *m_editDeleteAction; QAction *m_editSectionAction; - QAction *m_parameterEdit; QAction *m_itemRaiseAction; QAction *m_itemLowerAction; diff --git a/src/plugins/reports/kexireportdesignview.cpp b/src/plugins/reports/kexireportdesignview.cpp --- a/src/plugins/reports/kexireportdesignview.cpp +++ b/src/plugins/reports/kexireportdesignview.cpp @@ -88,12 +88,12 @@ bool *cancel) { KDbObject *s = KexiView::storeNewData(object, options, cancel); - qDebug() << "new id:" << s->id(); - if (!s || *cancel) { delete s; return 0; } + qDebug() << "new id:" << s->id(); + if (!storeData()) { //failure: remove object's object data to avoid garbage KDbConnection *conn = KexiMainWindowIface::global()->project()->dbConnection(); diff --git a/src/plugins/reports/kexireportview.cpp b/src/plugins/reports/kexireportview.cpp --- a/src/plugins/reports/kexireportview.cpp +++ b/src/plugins/reports/kexireportview.cpp @@ -54,7 +54,7 @@ #include KexiReportView::KexiReportView(QWidget *parent) - : KexiView(parent), m_preRenderer(0), m_reportDocument(0) //! @todo KEXI3, m_kexi(0), m_functions(0) + : KexiView(parent), m_preRenderer(0), m_reportDocument(0), m_functions(0) //! @todo KEXI3, m_kexi(0) { setObjectName("KexiReportDesigner_DataView"); @@ -171,21 +171,20 @@ void KexiReportView::slotPrintReport() { + QScopedPointer renderer(m_factory.createInstance("print")); + if (!renderer) { + return; + } QPrinter printer(QPrinter::HighResolution); - QPainter painter; - KReportRendererBase *renderer; - - renderer = m_factory.createInstance("print"); - QPointer dialog = new QPrintDialog(&printer, this); - if (dialog->exec() == QDialog::Accepted) { + QPrintDialog dialog(&printer, this); + if (dialog.exec() == QDialog::Accepted) { KReportRendererContext cxt; + QPainter painter; cxt.printer = &printer; cxt.painter = &painter; renderer->render(cxt, m_reportDocument); } - delete dialog; - delete renderer; } void KexiReportView::slotExportAsPdf() @@ -254,12 +253,9 @@ void KexiReportView::slotExportAsSpreadsheet() { - KReportRendererBase *renderer; - KReportRendererContext cxt; - - renderer = m_factory.createInstance("ods"); - + QScopedPointer renderer(m_factory.createInstance("ods")); if (renderer) { + KReportRendererContext cxt; cxt.destinationUrl = getExportUrl(QLatin1String("application/vnd.oasis.opendocument.spreadsheet"), xi18n("Export Report as Spreadsheet"), "kfiledialog:///LastVisitedODSExportPath/", @@ -280,12 +276,11 @@ void KexiReportView::slotExportAsTextDocument() { - KReportRendererBase *renderer; - KReportRendererContext cxt; - - renderer = m_factory.createInstance("odt"); - + QScopedPointer renderer(m_factory.createInstance("odt")); + //! @todo Show error or don't show the commands to the user if the plugin isn't available. + //! The same for other createInstance() calls. if (renderer) { + KReportRendererContext cxt; cxt.destinationUrl = getExportUrl(QLatin1String("application/vnd.oasis.opendocument.text"), xi18n("Export Report as Text Document"), "kfiledialog:///LastVisitedODTExportPath/", @@ -306,10 +301,8 @@ void KexiReportView::slotExportAsWebPage() { - KReportRendererContext cxt; - KReportRendererBase *renderer; - const QString dialogTitle = xi18n("Export Report as Web Page"); + KReportRendererContext cxt; cxt.destinationUrl = getExportUrl(QLatin1String("text/html"), dialogTitle, "kfiledialog:///LastVisitedHTMLExportPath/", @@ -329,11 +322,10 @@ KGuiItem(xi18nc("@action:button", "Use CSS")), KGuiItem(xi18nc("@action:button", "Use Table"))); - if (answer == KMessageBox::Yes) { - renderer = m_factory.createInstance("htmlcss"); - } - else { - renderer = m_factory.createInstance("htmltable"); + QScopedPointer renderer( + m_factory.createInstance(answer == KMessageBox::Yes ? "htmlcss" : "htmltable")); + if (!renderer) { + return; } if (!renderer->render(cxt, m_reportDocument)) { @@ -380,7 +372,7 @@ // } // m_preRenderer->registerScriptObject(m_kexi, "Kexi"); //If using a kexidb source, add a functions scripting object - if (tempData()->connectionDefinition.attribute("type") == "internal") { + if (!m_functions && tempData()->connectionDefinition.attribute("type") == "internal") { m_functions = new KRScriptFunctions(reportData, KexiMainWindowIface::global()->project()->dbConnection()); m_preRenderer->registerScriptObject(m_functions, "field"); connect(m_preRenderer, SIGNAL(groupChanged(QMap)), diff --git a/src/plugins/tables/kexitabledesignerview.cpp b/src/plugins/tables/kexitabledesignerview.cpp --- a/src/plugins/tables/kexitabledesignerview.cpp +++ b/src/plugins/tables/kexitabledesignerview.cpp @@ -847,13 +847,9 @@ //refresh property editor: propertySetSwitched(); - if (record >= 0) { - if (d->addHistoryCommand_in_slotRecordUpdated_enabled) { - addHistoryCommand(new InsertFieldCommand(0, this, record, *newSet /*propertySet()*/), //, field /*will be copied*/ - false /* !execute */); - } - } else { - qWarning() << "record # not found !"; + if (d->addHistoryCommand_in_slotRecordUpdated_enabled) { + addHistoryCommand(new InsertFieldCommand(0, this, record, *newSet /*propertySet()*/), //, field /*will be copied*/ + false /* !execute */); } } } @@ -1562,9 +1558,11 @@ if (!execute) { command->setRedoEnabled(false); } - d->history->push(command); + const bool pushed = d->history->push(command); if (!execute) { - command->setRedoEnabled(true); + if (pushed) { // only if not merged, it merged it's deleted already (COVERITY CID #1354238) + command->setRedoEnabled(true); + } } updateUndoRedoActions(); #endif diff --git a/src/plugins/tables/kexitabledesignerview_p.cpp b/src/plugins/tables/kexitabledesignerview_p.cpp --- a/src/plugins/tables/kexitabledesignerview_p.cpp +++ b/src/plugins/tables/kexitabledesignerview_p.cpp @@ -94,8 +94,8 @@ KProperty& property = set[propertyName]; //remember because we'll change list data soon - KPropertyListData *oldListData = property.listData() ? - new KPropertyListData(*property.listData()) : 0; + const QScopedPointeroldListData(property.listData() ? + new KPropertyListData(*property.listData()) : 0); if (slist && nlist) { if (slist->isEmpty() || nlist->isEmpty()) { property.setListData(0); @@ -116,9 +116,8 @@ property.setValue(newValue, rememberOldValue); if (commandGroup) { new ChangeFieldPropertyCommand(commandGroup, designerView, set, propertyName, oldValue, newValue, - oldListData, property.listData()); + oldListData.data(), property.listData()); } - delete oldListData; addHistoryCommand_in_slotPropertyChanged_enabled = prev_addHistoryCommand_in_slotPropertyChanged_enabled; //restore } diff --git a/src/widget/KexiConnectionSelectorWidget.cpp b/src/widget/KexiConnectionSelectorWidget.cpp --- a/src/widget/KexiConnectionSelectorWidget.cpp +++ b/src/widget/KexiConnectionSelectorWidget.cpp @@ -303,9 +303,10 @@ const QString firstUrl(fileWidget->locationEdit()->lineEdit()->text()); if (QDir::isAbsolutePath(firstUrl)) path = QUrl::fromLocalFile(firstUrl); - else + else { path = path.adjusted(QUrl::StripTrailingSlash); path.setPath(path.path() + '/' + (firstUrl)); + } return path.toLocalFile(); } @@ -463,6 +464,7 @@ if (!d->conn_set->removeConnectionData(item->data())) return; + delete item->data(); delete item; if (nextItem) diff --git a/src/widget/dataviewcommon/kexidataawareobjectiface.cpp b/src/widget/dataviewcommon/kexidataawareobjectiface.cpp --- a/src/widget/dataviewcommon/kexidataawareobjectiface.cpp +++ b/src/widget/dataviewcommon/kexidataawareobjectiface.cpp @@ -1227,7 +1227,8 @@ } clearVariables(); - if (dynamic_cast(this) && dynamic_cast(this)->isVisible()) + const QWidget* thisWidget = dynamic_cast(this); + if (thisWidget && thisWidget->isVisible()) initDataContents(); else m_initDataContentsOnShow = true; @@ -1577,7 +1578,7 @@ if (m_scrollbarToolTipsEnabled && verticalScrollBar()->isSliderDown()) { QWidget* thisWidget = dynamic_cast(this); const int record = lastVisibleRecord() + 1; - if (record > 0) { + if (thisWidget && record > 0) { const QString toolTipText( xi18n("Record: %1", record) ); QToolTip::showText( QPoint( diff --git a/src/widget/dataviewcommon/kexidataprovider.cpp b/src/widget/dataviewcommon/kexidataprovider.cpp --- a/src/widget/dataviewcommon/kexidataprovider.cpp +++ b/src/widget/dataviewcommon/kexidataprovider.cpp @@ -94,9 +94,10 @@ indexForVisibleLookupValue = -1; //no const QVariant value(data->at(it.value())); QVariant visibleLookupValue; - if (indexForVisibleLookupValue != -1 && (int)data->count() > indexForVisibleLookupValue) + if (indexForVisibleLookupValue != -1 && (int)data->count() > indexForVisibleLookupValue) { visibleLookupValue = data->at(indexForVisibleLookupValue); - qDebug() << "fill data of '" << itemIface->dataSource() << "' at idx=" << it.value() + } + qDebug() << "fill data of '" << itemIface->dataSource() << "' at idx=" << it.value() << " data=" << value << (indexForVisibleLookupValue != -1 ? QString(" SPECIAL: indexForVisibleLookupValue=%1 visibleValue=%2") diff --git a/src/widget/dataviewcommon/kexiformdataiteminterface.cpp b/src/widget/dataviewcommon/kexiformdataiteminterface.cpp --- a/src/widget/dataviewcommon/kexiformdataiteminterface.cpp +++ b/src/widget/dataviewcommon/kexiformdataiteminterface.cpp @@ -72,7 +72,11 @@ void KexiFormDataItemInterface::cancelEditor() { - QWidget *parentWidget = dynamic_cast(this)->parentWidget(); + QWidget *thisWidget = dynamic_cast(this); + if (!thisWidget) { + return; + } + QWidget *parentWidget = thisWidget->parentWidget(); KexiDataAwareObjectInterface *dataAwareObject = KexiUtils::findParentByType(parentWidget); if (dataAwareObject) dataAwareObject->cancelEditor(); diff --git a/src/widget/kexiqueryparameters.cpp b/src/widget/kexiqueryparameters.cpp --- a/src/widget/kexiqueryparameters.cpp +++ b/src/widget/kexiqueryparameters.cpp @@ -136,6 +136,7 @@ case KDbField::BLOB: { //! @todo BLOB input unsupported values.append(QByteArray()); + break; } default: qWarning() << "unsupported type " << KDbField::typeName(parameter.type) diff --git a/src/widget/kexislider.cpp b/src/widget/kexislider.cpp --- a/src/widget/kexislider.cpp +++ b/src/widget/kexislider.cpp @@ -79,27 +79,27 @@ QStyleOptionSlider option; initStyleOption(&option); - const int& ticks( option.tickPosition ); + const QSlider::TickPosition ticks( option.tickPosition ); const int available(style()->proxy()->pixelMetric(QStyle::PM_SliderSpaceAvailable, &option, this)); int interval = option.tickInterval; if( interval < 1 ) interval = option.pageStep; if( interval < 1 ) return; - const QRect& r(option.rect); + const QRect r(option.rect); const QPalette palette(option.palette); const int fudge(style()->proxy()->pixelMetric(QStyle::PM_SliderLength, &option, this) / 2); int current(option.minimum); int nextLabel = current; - QFontMetrics fm(font()); + const QFontMetrics fm(fontMetrics()); int h = fm.height() + 3; int w = fm.width(QString::number(option.maximum)) + 3; if(availablepartItem()) { pm = d->itemMenu; KexiProjectModelItem *par_it = static_cast(bit->parent()); - d->itemMenu->update(par_it->partInfo(), bit->partItem()); + if (par_it->partInfo() && bit->partItem()) { + d->itemMenu->update(*par_it->partInfo(), *bit->partItem()); + } } if (pm) { pm->exec(event->globalPos()); @@ -343,7 +345,7 @@ return; } - const bool gotitem = it && it->partItem(); + const bool gotitem = it->partItem(); //! @todo also check if the item is not read only if (d->deleteAction) { d->deleteAction->setEnabled(gotitem && !d->readOnly); @@ -377,7 +379,7 @@ #endif } } - emit selectionChanged(it ? it->partItem() : 0); + emit selectionChanged(it->partItem()); } void KexiProjectNavigator::slotRemove() @@ -697,26 +699,26 @@ { } -void KexiItemMenu::update(KexiPart::Info* partInfo, KexiPart::Item* partItem) +void KexiItemMenu::update(const KexiPart::Info& partInfo, const KexiPart::Item& partItem) { clear(); addSection(QString()); - KexiContextMenuUtils::updateTitle(this, partItem->name(), partInfo->name(), - KexiIconName(partInfo->iconName())); + KexiContextMenuUtils::updateTitle(this, partItem.name(), partInfo.name(), + KexiIconName(partInfo.iconName())); if (m_actionCollection->action("open_object") && m_actionCollection->action("open_object")->isEnabled() - && partItem && (partInfo->supportedViewModes() & Kexi::DataViewMode)) { + && (partInfo.supportedViewModes() & Kexi::DataViewMode)) { addAction("open_object"); } if (m_actionCollection->action("design_object") && m_actionCollection->action("design_object")->isEnabled() - && partItem && (partInfo->supportedViewModes() & Kexi::DesignViewMode)) { + && (partInfo.supportedViewModes() & Kexi::DesignViewMode)) { addAction("design_object"); } if (m_actionCollection->action("editText_object") && m_actionCollection->action("editText_object")->isEnabled() - && partItem && (partInfo->supportedViewModes() & Kexi::TextViewMode)) { + && (partInfo.supportedViewModes() & Kexi::TextViewMode)) { addAction("editText_object"); } addSeparator(); @@ -727,21 +729,21 @@ //! @todo addSeparator(); #endif bool addSep = false; - if (partItem && partInfo->isExecuteSupported()) { + if (partInfo.isExecuteSupported()) { addAction("data_execute"); addSep = true; } - if (partItem && partInfo->isDataExportSupported()) { + if (partInfo.isDataExportSupported()) { addAction("export_object"); addSep = true; } if (addSep) addSeparator(); #ifdef KEXI_QUICK_PRINTING_SUPPORT - if (partItem && partInfo->isPrintingSupported()) + if (partInfo.isPrintingSupported()) addAction("print_object"); - if (partItem && partInfo->isPrintingSupported()) + if (partInfo.isPrintingSupported()) addAction("pageSetupForObject"); if (m_actionCollection->action("edit_rename") || m_actionCollection->action("edit_delete")) addSeparator(); diff --git a/src/widget/tableview/KexiDataTableView.cpp b/src/widget/tableview/KexiDataTableView.cpp --- a/src/widget/tableview/KexiDataTableView.cpp +++ b/src/widget/tableview/KexiDataTableView.cpp @@ -110,9 +110,10 @@ void KexiDataTableView::setData(KDbCursor *c) { - if (!dynamic_cast(mainWidget())) + KexiDataTableScrollArea* area = dynamic_cast(mainWidget()); + if (!area) return; - dynamic_cast(mainWidget())->setData(c); + area->setData(c); } void KexiDataTableView::filter() diff --git a/src/widget/tableview/KexiTableScrollArea.cpp b/src/widget/tableview/KexiTableScrollArea.cpp --- a/src/widget/tableview/KexiTableScrollArea.cpp +++ b/src/widget/tableview/KexiTableScrollArea.cpp @@ -733,7 +733,7 @@ if (!d->appearance.horizontalGridEnabled) y_offset++; //correction because we're not drawing cell borders - if (d->appearance.fullRecordSelection && d->appearance.fullRecordSelection) { + if (d->appearance.fullRecordSelection) { } if (m_currentRecord == data && (column == m_curColumn || d->appearance.fullRecordSelection)) { if (edit && ( (d->appearance.recordHighlightingEnabled && !d->appearance.fullRecordSelection) diff --git a/src/widget/tableview/KexiTableScrollAreaHeader.cpp b/src/widget/tableview/KexiTableScrollAreaHeader.cpp --- a/src/widget/tableview/KexiTableScrollAreaHeader.cpp +++ b/src/widget/tableview/KexiTableScrollAreaHeader.cpp @@ -51,42 +51,44 @@ const KexiTableScrollAreaHeader *headerWidget = qobject_cast(parent()); if (ce == CE_Header && option) { - QStyleOptionHeader newOption(*qstyleoption_cast(option)); + const QStyleOptionHeader *existingOption = qstyleoption_cast(option); + QScopedPointer newOption( + existingOption ? new QStyleOptionHeader(*existingOption) : new QStyleOptionHeader); const int currentSection = headerWidget->orientation() == Qt::Horizontal ? headerWidget->currentIndex().column() : headerWidget->currentIndex().row(); // qDebug() << headerWidget->orientation() << currentSection << // headerWidget->currentIndex().row() << headerWidget->currentIndex().column(); - if (newOption.section >= 0) { + if (newOption->section >= 0) { int f1 = 0, f2 = 0; - if (newOption.section == currentSection) { + if (newOption->section == currentSection) { f1 = 34; f2 = 66; } else if (headerWidget->scrollArea()->appearance().recordMouseOverHighlightingEnabled && headerWidget->orientation() == Qt::Vertical - && newOption.section == headerWidget->scrollArea()->highlightedRecordNumber()) + && newOption->section == headerWidget->scrollArea()->highlightedRecordNumber()) { f1 = 10; f2 = 90; } if (f1 > 0) { - newOption.palette.setColor(QPalette::Button, + newOption->palette.setColor(QPalette::Button, KexiUtils::blendedColors( headerWidget->selectionBackgroundColor(), headerWidget->palette().color(headerWidget->backgroundRole()), f1, f2)); //set background color as well (e.g. for thinkeramik) - newOption.palette.setColor(QPalette::Window, newOption.palette.color(QPalette::Button)); + newOption->palette.setColor(QPalette::Window, newOption->palette.color(QPalette::Button)); } if (headerWidget->orientation() == Qt::Vertical) { // For mouse-over styles such as Breeze fill color and animate, // what's in conflict with what we do: disable this. - newOption.state &= (0xffffffff ^ QStyle::State_MouseOver); - //qDebug() << newOption.rect; + newOption->state &= (0xffffffff ^ QStyle::State_MouseOver); + //qDebug() << newOption->rect; } - QProxyStyle::drawControl(ce, &newOption, painter, widget); + QProxyStyle::drawControl(ce, newOption.data(), painter, widget); return; } } diff --git a/src/widget/tableview/KexiTableScrollArea_p.h b/src/widget/tableview/KexiTableScrollArea_p.h --- a/src/widget/tableview/KexiTableScrollArea_p.h +++ b/src/widget/tableview/KexiTableScrollArea_p.h @@ -142,9 +142,6 @@ /*! Helper for "highlighted record" effect. */ int highlightedRecord; - /*! Id of context menu key (cached). */ - int contextMenuKey; - /*! Specifies currently displayed cell tooltip. Value of QPoint(-1,-1) means "no tooltip". */ QPoint recentCellWithToolTip; diff --git a/src/widget/tableview/kexiblobtableedit.cpp b/src/widget/tableview/kexiblobtableedit.cpp --- a/src/widget/tableview/kexiblobtableedit.cpp +++ b/src/widget/tableview/kexiblobtableedit.cpp @@ -151,7 +151,6 @@ bool KexiBlobTableEdit::valueIsNull() { //! @todo - d->value.size(); return d->value.isEmpty(); } @@ -209,6 +208,7 @@ // the key is unique for this tuple: (checksum, w, h) qulonglong sum((((qulonglong(qChecksum(array.constData(), array.length())) << 32) + w) << 16) + h); pp = d->cachedPixmaps.object(sum); + bool insertToCache = false; if (!pp) { QPixmap pixmap; if (val.canConvert(QVariant::ByteArray) && pixmap.loadFromData(val.toByteArray())) { @@ -224,13 +224,18 @@ pp = new PixmapAndPos; pp->pixmap = pixmap; pp->pos = pos; - d->cachedPixmaps.insert(sum, pp); + insertToCache = true; } } } if (pp) { p->drawPixmap(pp->pos, pp->pixmap); } + if (insertToCache) { + // Do that afterwards because in theory QCache can delete pp immediately (COVERITY CID #1354236) + //! @todo use cost other than 1 + d->cachedPixmaps.insert(sum, pp); + } } } @@ -423,7 +428,7 @@ QMouseEvent me(QEvent::MouseButtonPress, QPoint(2, 2), Qt::LeftButton, Qt::NoButton, Qt::NoModifier); QApplication::sendEvent(d->button, &me); - } else if (ke->modifiers() == Qt::NoButton + } else if (ke->modifiers() == Qt::NoModifier && (k == Qt::Key_F2 || k == Qt::Key_Space || k == Qt::Key_Enter || k == Qt::Key_Return)) { d->menu->insertFromFile(); } else @@ -459,9 +464,9 @@ { if (o == d->menu && e->type() == QEvent::KeyPress) { QKeyEvent* ke = static_cast(e); - const int mods = ke->modifiers(); + const Qt::KeyboardModifiers mods = ke->modifiers(); const int k = ke->key(); - if ((mods == Qt::NoButton && (k == Qt::Key_Tab || k == Qt::Key_Left || k == Qt::Key_Right)) + if ((mods == Qt::NoModifier && (k == Qt::Key_Tab || k == Qt::Key_Left || k == Qt::Key_Right)) || (mods == Qt::ShiftModifier && k == Qt::Key_Backtab) ) { d->menu->hide(); diff --git a/src/widget/tableview/kexicomboboxbase.cpp b/src/widget/tableview/kexicomboboxbase.cpp --- a/src/widget/tableview/kexicomboboxbase.cpp +++ b/src/widget/tableview/kexicomboboxbase.cpp @@ -28,6 +28,7 @@ #include +#include #include KexiComboBoxBase::KexiComboBoxBase() @@ -74,6 +75,9 @@ //! @todo for now we're assuming the id is INTEGER KDbTableViewData *tvData = popup()->tableView()->data(); const int boundColumn = boundColumnIndex(); + if (boundColumn < 0) { + return -1; + } int record = -1; for (KDbTableViewDataIterator it(tvData->begin()); it != tvData->end(); ++it) { record++; @@ -290,7 +294,8 @@ } data = selectRecordForEnteredValueInLookupTable(m_userEnteredValue); } - return data ? data->at(boundColumnIndex()) : QVariant(); + const int boundColumn = boundColumnIndex(); + return (data && boundColumn >= 0) ? data->at(boundColumn) : QVariant(); } else if (popup()) { //use 'enum hints' model const int record = popup()->tableView()->currentRecord(); @@ -377,8 +382,11 @@ //qDebug() << show << field() << popup() << m_updatePopupSelectionOnShow; if (!field()) return; - m_insideCreatePopup = true; QWidget* thisWidget = dynamic_cast(this); + if (!thisWidget) { + return; + } + QScopedValueRollback insideCreatePopuRollback(m_insideCreatePopup, true); QWidget *widgetToFocus = internalEditor() ? internalEditor() : thisWidget; //qDebug() << "widgetToFocus:" << widgetToFocus; @@ -465,7 +473,6 @@ widgetToFocus->setFocus(); } } - m_insideCreatePopup = false; } void KexiComboBoxBase::hide() @@ -524,7 +531,9 @@ if (valueToSet.toString().isEmpty() && !m_insideCreatePopup) { clear(); QWidget* thisWidget = dynamic_cast(this); - thisWidget->parentWidget()->setFocus(); + if (thisWidget) { + thisWidget->parentWidget()->setFocus(); + } return; } } diff --git a/src/widget/tableview/kexicomboboxpopup.cpp b/src/widget/tableview/kexicomboboxpopup.cpp --- a/src/widget/tableview/kexicomboboxpopup.cpp +++ b/src/widget/tableview/kexicomboboxpopup.cpp @@ -182,7 +182,7 @@ delete d->privateQuery; d->privateQuery = 0; const QList visibleColumns(lookupFieldSchema ? lookupFieldSchema->visibleColumns() : QList()); - if (!visibleColumns.isEmpty() && lookupFieldSchema->boundColumn() >= 0) { + if (!visibleColumns.isEmpty() && lookupFieldSchema && lookupFieldSchema->boundColumn() >= 0) { const bool multipleLookupColumnJoined = visibleColumns.count() > 1; //! @todo support more RowSourceType's, not only table and query KDbCursor *cursor = 0; @@ -439,7 +439,7 @@ if (e->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast(e); const int k = ke->key(); - if ((ke->modifiers() == Qt::NoButton && (k == Qt::Key_Escape || k == Qt::Key_F4)) + if ((ke->modifiers() == Qt::NoModifier && (k == Qt::Key_Escape || k == Qt::Key_F4)) || (ke->modifiers() == Qt::AltModifier && k == Qt::Key_Up)) { hide(); emit cancelled(); diff --git a/src/widget/tableview/kexicomboboxtableedit.cpp b/src/widget/tableview/kexicomboboxtableedit.cpp --- a/src/widget/tableview/kexicomboboxtableedit.cpp +++ b/src/widget/tableview/kexicomboboxtableedit.cpp @@ -263,7 +263,7 @@ { //qDebug() << ke; const int k = ke->key(); - if ((ke->modifiers() == Qt::NoButton && k == Qt::Key_F4) + if ((ke->modifiers() == Qt::NoModifier && k == Qt::Key_F4) || (ke->modifiers() == Qt::AltModifier && k == Qt::Key_Down)) { //show popup slotButtonClicked(); diff --git a/src/widget/tableview/kexitableedit.cpp b/src/widget/tableview/kexitableedit.cpp --- a/src/widget/tableview/kexitableedit.cpp +++ b/src/widget/tableview/kexitableedit.cpp @@ -268,8 +268,8 @@ void KexiTableEdit::repaintRelatedCell() { #ifndef KEXI_MOBILE - if (dynamic_cast(parentWidget())) { - dynamic_cast(parentWidget())->updateCurrentCell(); + if (KexiDataAwareObjectInterface *iface = dynamic_cast(parentWidget())) { + iface->updateCurrentCell(); } #endif } diff --git a/src/widget/undo/kundo2stack.h b/src/widget/undo/kundo2stack.h --- a/src/widget/undo/kundo2stack.h +++ b/src/widget/undo/kundo2stack.h @@ -84,7 +84,6 @@ class KEXIUNDO_EXPORT KUndo2Command { KUndo2CommandPrivate *d; - int timedID; public: explicit KUndo2Command(KUndo2Command *parent = 0); @@ -161,7 +160,7 @@ virtual ~KUndo2QStack(); void clear(); - void push(KUndo2Command *cmd); + bool push(KUndo2Command *cmd); bool canUndo() const; bool canRedo() const; diff --git a/src/widget/undo/kundo2stack.cpp b/src/widget/undo/kundo2stack.cpp --- a/src/widget/undo/kundo2stack.cpp +++ b/src/widget/undo/kundo2stack.cpp @@ -693,9 +693,10 @@ If \a cmd's id is not -1, and if the id is the same as that of the most recently executed command, KUndo2QStack will attempt to merge the two commands by calling KUndo2Command::mergeWith() on the most recently executed - command. If KUndo2Command::mergeWith() returns true, \a cmd is deleted. + command. If KUndo2Command::mergeWith() returns true, \a cmd is deleted and false + is returned. - In all other cases \a cmd is simply pushed on the stack. + In all other cases \a cmd is simply pushed on the stack and true is returned. If commands were undone before \a cmd was pushed, the current command and all commands above it are deleted. Hence \a cmd always ends up being the @@ -709,7 +710,7 @@ \sa KUndo2Command::id() KUndo2Command::mergeWith() */ -void KUndo2QStack::push(KUndo2Command *cmd) +bool KUndo2QStack::push(KUndo2Command *cmd) { cmd->redoMergedCommands(); cmd->setEndTime(); @@ -808,6 +809,7 @@ } if (try_merge && cur->mergeWith(cmd)) { delete cmd; + cmd = 0; if (!macro) { emit indexChanged(m_index); emit canUndoChanged(canUndo()); @@ -827,6 +829,7 @@ setIndex(m_index + 1, false); } } + return cmd; } /*! diff --git a/src/widget/undo/kundo2view.cpp b/src/widget/undo/kundo2view.cpp --- a/src/widget/undo/kundo2view.cpp +++ b/src/widget/undo/kundo2view.cpp @@ -90,45 +90,38 @@ class KUndo2ViewPrivate { public: - KUndo2ViewPrivate() : + KUndo2ViewPrivate(KUndo2View *view) : #ifndef QT_NO_UNDOGROUP group(0), #endif - model(0) {} + q(view) + { + model = new KUndo2Model(q); + q->setModel(model); + q->setSelectionModel(model->selectionModel()); + } #ifndef QT_NO_UNDOGROUP QPointer group; #endif KUndo2Model *model; - KUndo2View* q; - - void init(KUndo2View* view); + KUndo2View* const q; }; -void KUndo2ViewPrivate::init(KUndo2View* view) -{ - q = view; - model = new KUndo2Model(q); - q->setModel(model); - q->setSelectionModel(model->selectionModel()); -} - /*! Constructs a new view with parent \a parent. */ -KUndo2View::KUndo2View(QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate) +KUndo2View::KUndo2View(QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate(this)) { - d->init(this); } /*! Constructs a new view with parent \a parent and sets the observed stack to \a stack. */ -KUndo2View::KUndo2View(KUndo2QStack *stack, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate) +KUndo2View::KUndo2View(KUndo2QStack *stack, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate(this)) { - d->init(this); setStack(stack); } @@ -140,9 +133,8 @@ The view will update itself autmiatically whenever the active stack of the group changes. */ -KUndo2View::KUndo2View(KUndo2Group *group, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate) +KUndo2View::KUndo2View(KUndo2Group *group, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate(this)) { - d->init(this); setGroup(group); } diff --git a/src/widget/utils/kexidropdownbutton.cpp b/src/widget/utils/kexidropdownbutton.cpp --- a/src/widget/utils/kexidropdownbutton.cpp +++ b/src/widget/utils/kexidropdownbutton.cpp @@ -110,7 +110,7 @@ { const int k = e->key(); const bool dropDown = - (e->modifiers() == Qt::NoButton + (e->modifiers() == Qt::NoModifier && (k == Qt::Key_Space || k == Qt::Key_Enter || k == Qt::Key_Return || k == Qt::Key_F2 || k == Qt::Key_F4) )