diff --git a/src/libs/main/KoPrintJob.h b/src/libs/main/KoPrintJob.h index b14472d3..1399c33d 100644 --- a/src/libs/main/KoPrintJob.h +++ b/src/libs/main/KoPrintJob.h @@ -1,95 +1,95 @@ /* This file is part of the KDE project * Copyright (C) 2007 Thomas Zander * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KOPRINTJOB_H #define KOPRINTJOB_H #include #include #include #include #include "komain_export.h" class QWidget; /** * A print job is an interface that the KoView uses to create an application-specific * class that can take care of printing. * The printjob should be able to print again after a print job has been completed, * using the same QPrinter to allow the user to alter settings on the QPrinter and * call print again. * The printjob can thus see startPrinting() called more than once, and the implementation * of that signal should honor the removePolicy passed to it. */ class KOMAIN_EXPORT KoPrintJob : public QObject { Q_OBJECT public: /** * Constructor. * @param parent the parent qobject that is passed for memory management purposes. */ explicit KoPrintJob(QObject *parent = 0); virtual ~KoPrintJob(); /// A policy to allow the printjob to delete itself after its done printing. enum RemovePolicy { DeleteWhenDone, ///< Delete the job when its done with printing. DoNotDelete ///< Keep the job around so it can be started again. }; /// Returns the printer that is used for this print job so others can alter the details of the print-job. virtual QPrinter &printer() = 0; /// If this print job is used in combination with a printdialog the option widgets this method /// returns will be shown in the print dialog. virtual QList createOptionWidgets() const = 0; virtual int documentFirstPage() const { return 1; } virtual int documentLastPage() const { return 1; } virtual int documentCurrentPage() const { return 1; } virtual QAbstractPrintDialog::PrintDialogOptions printDialogOptions() const; /** *@brief Check if the painter can print to the printer *@returns true if the print job can print to the given printer */ virtual bool canPrint(); public Q_SLOTS: /** * This is called every time the job should be executed. * When called the document should be printed a new painter using the printer * of this printJob in order to honor the settings the user made on the printer. * canPrint() should be called before startPrinting to check if the painter can print * to the printer * @param removePolicy a policy that should be honored so the caller can make sure * this job doesn't leak memory after being used. */ - virtual void startPrinting(RemovePolicy removePolicy = DoNotDelete); + virtual void startPrinting(KoPrintJob::RemovePolicy removePolicy = DoNotDelete); }; #endif diff --git a/src/libs/main/KoPrintingDialog.h b/src/libs/main/KoPrintingDialog.h index 7f5c9b4f..2659d869 100644 --- a/src/libs/main/KoPrintingDialog.h +++ b/src/libs/main/KoPrintingDialog.h @@ -1,160 +1,160 @@ /* This file is part of the KDE project * Copyright (C) 2007, 2009 Thomas Zander * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KOPRINTINGDIALOG_H #define KOPRINTINGDIALOG_H #include #include #include "komain_export.h" class KoShapeManager; class KoShape; class KoPrintingDialogPrivate; /** * Dialog that will allow you to print any flake-based document, with full interaction and ability to stop. * Using this class allows any application to print a set of shapes that are contained in the shapeManager() * in a thread-safe manner, while ensuring that the full content is present before printing. A requirement * for any shape that may use the network or simply use a lot of processing power to prepare its content * before it can be painted. * This class is of the type of 'create and forget'. Meaning that you create the dialog, initialize it with * data and then call show() on it. It then continues to print and delete itself when ready. * @code KoPrintingDialog *dia = new KoPrintingDialog(myWidget); dia->printer().setOutputFormat(QPrinter::PdfFormat); dia->printer().setOutputFileName("output.pdf"); dia->printer().setResolution(600); dia->printer().setFullPage(true); // ignore printer margins dia->setShapeManager(m_canvas->shapeManager()) QList pages; pages.append(1); dia->setPageRange(pages); dia->startPrinting(); @endcode * The dialog works by looping over all pages in the page-range and sequentially calling preparePage(int) and * then using the shapeManager() to actually print the shapes. * * Since preparePage(int) is pure virtual the application wanting to implement printing should inherit from * this class and make sure that after the preparePage returns a simple paint can be called on the shapeManager * with the painter(). * * XXX: preparePage(int) is no longer pure virtual! Only Calligra Sheets reimplements it -- what should be changed * to the docs? (BSAR) * * This typically means that the preparePage() makes sure the shapeManager is updated and the correct cliprect * is set on the painter(). */ class KOMAIN_EXPORT KoPrintingDialog : public KoPrintJob { Q_OBJECT public: /** * Create a new dialog. * @param parent the widget this dialog will use as a child. */ explicit KoPrintingDialog(QWidget *parent); virtual ~KoPrintingDialog(); /** * Set the shape manager that should be used to print. * @param sm the shapeManager used for the next page(s) */ // void setShapeManager(KoShapeManager *sm); /** * Set a list of all the pages that should be used to loop over and print. * Note that any calls made to this method after printing started are ignored. * @param pages a list of page numbers that the preparePage() gets passed. */ void setPageRange(const QList &pages); /** * Return the printer used to print. * @return the printer used to print. */ QPrinter &printer(); public Q_SLOTS: /** * @see KoPrintJob::startPrinting */ - virtual void startPrinting(RemovePolicy removePolicy = DoNotDelete); + virtual void startPrinting(KoPrintJob::RemovePolicy removePolicy = DoNotDelete); protected: /** * Reimplement this method to setup the shapeManager and painter and maybe the shapes for * printing the passed in page number. The printing itself will not happen in this method. * This method will be called in a thread that is not the main-thread. So the processing can take * a reasonably long time within posing problems for user interaction. * @param pageNumber the number of the page to prepare. * @see isStopped() printPage() * @returns a cliprect. If the rect is valid then it will be set on the painter right after * newPage is called. */ virtual QRectF preparePage(int pageNumber); /** * This is a similar method to preparePage(), but is guaranteed to be called in the Ui thread. * @param pageNumber the number of the page to prepare. * @see isStopped() */ virtual void printPage(int pageNumber, QPainter &painter); /** * Implement to return the shapes on the requested page. */ // virtual QList shapesOnPage(int pageNumber) = 0; /** * @returns the shapeManager. * Returns the shapeManager as it has been set on the setShapeManager() * @see setShapeManager */ // KoShapeManager *shapeManager() const; /** * Return the painter that will be used to print the shape data. */ QPainter &painter() const; /** * Return true if the user pressed stop. * It is suggested to query this setting in long loops and abort the process as soon at it returns yes. */ bool isStopped() const; /** * This virtual hook is called at the end of the printing process, either on success of on failure. * The method is empty by default. */ virtual void printingDone() { } private: KoPrintingDialogPrivate * const d; friend class KoPrintingDialogPrivate; Q_PRIVATE_SLOT(d, void preparePage(const QVariant &page)) Q_PRIVATE_SLOT(d, void printPage(const QVariant &page)) Q_PRIVATE_SLOT(d, void stopPressed()) }; #endif diff --git a/src/libs/ui/CMakeLists.txt b/src/libs/ui/CMakeLists.txt index 9842049c..f90550a6 100644 --- a/src/libs/ui/CMakeLists.txt +++ b/src/libs/ui/CMakeLists.txt @@ -1,183 +1,184 @@ include_directories( ${PLANKERNEL_INCLUDES} ${PLANMODELS_INCLUDES} ${PLANMAIN_INCLUDES} + ${PLANWIDGETS_INCLUDES} ${KDEPIMLIBS_INCLUDE_DIR} ) #add_subdirectory( tests ) ########### KPlato private library ############### if (PLAN_USE_KREPORT) message(STATUS "-- Building plan with reports capability") add_subdirectory(reports/items) set(planreports_LIB_SRC reports/reportview.cpp reports/reportdata.cpp reports/reportsourceeditor.cpp reports/reportscripts.cpp ) set(planreports_ui_LIB_SRCS reports/reportsourceeditor.ui reports/reportnavigator.ui reports/reportsectionswidget.ui reports/reportgroupsectionswidget.ui reports/reporttoolswidget.ui ) endif() set(planui_LIB_SRCS ${planreports_LIB_SRC} Help.cpp TasksEditController.cpp TasksEditDialog.cpp welcome/WelcomeView.cpp reportsgenerator/ReportsGeneratorView.cpp kptganttitemdelegate.cpp kptworkpackagesendpanel.cpp kptworkpackagesenddialog.cpp kptdocumentseditor.cpp kptdocumentspanel.cpp kptitemviewsettup.cpp kptsplitterview.cpp kptrelationeditor.cpp kptdependencyeditor.cpp kptusedefforteditor.cpp kpttaskstatusview.cpp kptcalendareditor.cpp kptviewbase.cpp kptaccountseditor.cpp kptperteditor.cpp kptpertresult.cpp kpttaskeditor.cpp kptresourceeditor.cpp kptscheduleeditor.cpp kptsummarytaskdialog.cpp kptsummarytaskgeneralpanel.cpp kptresourceappointmentsview.cpp kptaccountsviewconfigdialog.cpp kptaccountsview.cpp kpttaskcostpanel.cpp kptmilestoneprogresspanel.cpp kptmilestoneprogressdialog.cpp kpttaskdialog.cpp kptmainprojectdialog.cpp kptmainprojectpanel.cpp kptganttview.cpp kptrelationdialog.cpp kptrequestresourcespanel.cpp kptresourcedialog.cpp kptstandardworktimedialog.cpp kptintervaledit.cpp kpttaskgeneralpanel.cpp kpttaskprogresspanel.cpp kpttaskprogressdialog.cpp kpttaskdescriptiondialog.cpp kptwbsdefinitiondialog.cpp kptwbsdefinitionpanel.cpp kptresourceassignmentview.cpp kptperformancetablewidget.cpp kptresourceallocationeditor.cpp kptworkpackagemergedialog.cpp kptrecalculatedialog.cpp kpthtmlview.cpp locale/localemon.cpp kptlocaleconfigmoneydialog.cpp ResourceAllocationView.cpp ) ki18n_wrap_ui(planui_LIB_SRCS ${planreports_ui_LIB_SRCS} welcome/WelcomeView.ui kptresourceappointmentsdisplayoptions.ui kptganttchartdisplayoptions.ui kptprintingheaderfooter.ui kptganttprintingoptions.ui kptworkpackagesendpanel.ui kptdocumentspanel.ui kptperformancestatus.ui kptcpmwidget.ui kptitemviewsettings.ui kptpertresult.ui standardworktimedialogbase.ui kptwbsdefinitionpanelbase.ui kptaccountsviewconfigurepanelbase.ui kptintervaleditbase.ui kpttaskcostpanelbase.ui kpttaskdescriptionpanelbase.ui kptsummarytaskgeneralpanelbase.ui kptmilestoneprogresspanelbase.ui resourcedialogbase.ui kptmainprojectpanelbase.ui relationpanel.ui kpttaskgeneralpanelbase.ui kpttaskprogresspanelbase.ui kptperteditor.ui kptresourceassignmentview.ui kpttaskstatusviewsettingspanel.ui kptperformancestatusviewsettingspanel.ui kptworkpackagemergepanel.ui kptrecalculatedialog.ui kptscheduleeditor.ui locale/localemon.ui ) add_library(planui SHARED ${planui_LIB_SRCS}) generate_export_header(planui) target_link_libraries(planui PUBLIC planmain planmodels KF5::KHtml PRIVATE KChart KF5::ItemViews KF5::IconThemes KF5::Archive KF5::TextWidgets # Qt5::Sql ) if (PLAN_USE_KREPORT) target_link_libraries(planui PUBLIC KReport PRIVATE KPropertyWidgets) endif() if(KF5AkonadiContact_FOUND) target_link_libraries(planui PRIVATE KF5::AkonadiContact) endif() set_target_properties(planui PROPERTIES VERSION ${GENERIC_PLAN_LIB_VERSION} SOVERSION ${GENERIC_PLAN_LIB_SOVERSION} ) install(TARGETS planui ${INSTALL_TARGETS_DEFAULT_ARGS}) # reports files install(FILES reportsgenerator/ProjectPerformanceCost.odt reportsgenerator/ProjectPerformance.odt reportsgenerator/TaskStatus.odt DESTINATION ${DATA_INSTALL_DIR}/calligraplan/reports ) diff --git a/src/libs/ui/kptviewbase.h b/src/libs/ui/kptviewbase.h index 516b87d8..8ed0fb40 100644 --- a/src/libs/ui/kptviewbase.h +++ b/src/libs/ui/kptviewbase.h @@ -1,683 +1,684 @@ /* This file is part of the KDE project Copyright (C) 2006 -2010 Dag Andersen This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KPTVIEWBASE_H #define KPTVIEWBASE_H #include "planui_export.h" #include "kptitemmodelbase.h" #include "ui_kptprintingheaderfooter.h" #include #include +#include #include //#include #include #include #include #include #include #include class QMetaEnum; class QAbstractItemModel; class QDomElement; class QModelIndex; class KoDocument; class KoPrintJob; class KoPart; /// The main namespace namespace KPlato { class Project; class Node; class Resource; class ResourceGroup; class Relation; class Calendar; class ViewBase; class TreeViewBase; class DoubleTreeViewBase; //------------------ class PLANUI_EXPORT DockWidget : public QDockWidget { Q_OBJECT public: DockWidget( ViewBase *v, const QString &identity, const QString &title ); void activate( KoMainWindow *mainWindow ); void deactivate( KoMainWindow *mainWindow ); bool shown() const; bool saveXml( QDomElement &context ) const; void loadXml( const KoXmlElement &context ); const ViewBase *view; /// The view this docker belongs to QString id; /// Docker identity Qt::DockWidgetArea location; /// The area the docker should go when visible bool editor; /// Editor dockers will not be shown in read only mode public Q_SLOTS: void setShown( bool show ); void setLocation( Qt::DockWidgetArea area ); private: bool m_shown; /// The dockers visibility when the view is active }; //------------------ class PLANUI_EXPORT PrintingOptions { public: PrintingOptions() { headerOptions.group = true; headerOptions.project = Qt::Checked; headerOptions.date = Qt::Checked; headerOptions.manager = Qt::Checked; headerOptions.page = Qt::Checked; footerOptions.group = false; footerOptions.project = Qt::Checked; footerOptions.date = Qt::Checked; footerOptions.manager = Qt::Checked; footerOptions.page = Qt::Checked; } ~PrintingOptions() {} bool loadXml( KoXmlElement &element ); void saveXml( QDomElement &element ) const; struct Data { bool group; Qt::CheckState project; Qt::CheckState date; Qt::CheckState manager; Qt::CheckState page; }; struct Data headerOptions; struct Data footerOptions; }; //------------------ class PLANUI_EXPORT PrintingHeaderFooter : public QWidget, public Ui::PrintingHeaderFooter { Q_OBJECT public: explicit PrintingHeaderFooter( const PrintingOptions &opt, QWidget *parent = 0 ); ~PrintingHeaderFooter(); void setOptions( const PrintingOptions &options ); PrintingOptions options() const; Q_SIGNALS: void changed(const KPlato::PrintingOptions&); protected Q_SLOTS: void slotChanged(); private: PrintingOptions m_options; }; //------------------ class PLANUI_EXPORT PrintingDialog : public KoPrintingDialog { Q_OBJECT public: explicit PrintingDialog(ViewBase *view); ~PrintingDialog(); virtual QList createOptionWidgets() const; // virtual QList shapesOnPage(int); QRect headerRect() const; QRect footerRect() const; void paintHeaderFooter( QPainter &p, const PrintingOptions &options, int pageNumber, const Project &project ); PrintingOptions printingOptions() const; QWidget *createPageLayoutWidget() const; QAbstractPrintDialog::PrintDialogOptions printDialogOptions() const; Q_SIGNALS: void changed(const KPlato::PrintingOptions &opt); void changed(); public Q_SLOTS: void setPrintingOptions(const KPlato::PrintingOptions &opt); void setPrinterPageLayout( const KoPageLayout &pagelayout ); - virtual void startPrinting(RemovePolicy removePolicy = DoNotDelete); + void startPrinting(KoPrintJob::RemovePolicy removePolicy = DoNotDelete) override; protected: virtual void paint( QPainter &p, const PrintingOptions::Data &options, const QRect &rect, int pageNumber, const Project &project ); int headerFooterHeight( const PrintingOptions::Data &options ) const; void drawRect( QPainter &p, const QRect &r, Qt::Edges edges = Qt::LeftEdge | Qt::RightEdge | Qt::BottomEdge ); protected: ViewBase *m_view; PrintingHeaderFooter *m_widget; int m_textheight; }; class PLANUI_EXPORT ViewActionLists { public: ViewActionLists() : actionOptions( 0 ) {} virtual ~ViewActionLists() {} /// Returns the list of action lists that shall be plugged/unplugged virtual QStringList actionListNames() const { return m_actionListMap.keys(); } /// Returns the list of actions associated with the action list name virtual QList actionList( const QString &name ) const { return m_actionListMap[name]; } /// Add an action to the specified action list void addAction( const QString &list, QAction *action ) { m_actionListMap[list].append( action ); } virtual QList viewlistActionList() const { return m_viewlistActionList; } void addViewlistAction( QAction *action ) { m_viewlistActionList.append( action ); } QList contextActionList() const { return m_contextActionList; } void addContextAction( QAction *action ) { m_contextActionList.append( action ); } protected: /// List of all menu/toolbar actions (used for plug/unplug) QMap > m_actionListMap; /// List of actions that will be shown in the viewlist context menu QList m_viewlistActionList; /// List of actions that will be shown in the views header context menu QList m_contextActionList; // View options context menu QAction *actionOptions; }; /** ViewBase is the baseclass of all sub-views to View. */ class PLANUI_EXPORT ViewBase : public KoView, public ViewActionLists { Q_OBJECT public: enum OptionTypes { OptionExpand = 1, OptionCollapse = 2, OptionPrint = 4, OptionPrintPreview = 8, OptionPrintPdf = 16, OptionPrintConfig = 32, OptionViewConfig = 64, OptionAll = 0xffff }; /// Constructor ViewBase(KoPart *part, KoDocument *doc, QWidget *parent); /// Destructor virtual ~ViewBase(); /// Return the part (document) this view handles KoDocument *part() const; /// Return the page layout used for printing this view virtual KoPageLayout pageLayout() const; /// Return the type of view this is (class name) QString viewType() const { return metaObject()->className(); } /// Returns true if this view or any child widget has focus bool isActive() const; /// Set the project this view shall handle. virtual void setProject( Project *project ); /// Return the project virtual Project *project() const { return m_proj; } /// Return the schedule manager virtual ScheduleManager *scheduleManager() const { return m_schedulemanager; } /// Draw data from current part / project virtual void draw() {} /// Draw data from project. virtual void draw(Project &/*project*/) {} /// Draw changed data from project. virtual void drawChanges(Project &project) { draw(project); } /// Set readWrite mode virtual void updateReadWrite( bool ); bool isReadWrite() const { return m_readWrite; } /// Reimplement if your view handles nodes virtual Node* currentNode() const { return 0; } /// Reimplement if your view handles resources virtual Resource* currentResource() const { return 0; } /// Reimplement if your view handles resource groups virtual ResourceGroup* currentResourceGroup() const { return 0; } /// Reimplement if your view handles calendars virtual Calendar* currentCalendar() const { return 0; } /// Reimplement if your view handles relations virtual Relation *currentRelation() const { return 0; } /// Reimplement if your view handles zoom // virtual KoZoomController *zoomController() const { return 0; } /// Loads context info (printer settings) into this view. virtual bool loadContext( const KoXmlElement &context ); /// Save context info (printer settings) from this view. virtual void saveContext( QDomElement &context ) const; virtual KoPrintJob *createPrintJob(); PrintingOptions printingOptions() const { return m_printingOptions; } static QWidget *createPageLayoutWidget( ViewBase *view ); static PrintingHeaderFooter *createHeaderFooterWidget( ViewBase *view ); void addAction( const QString &list, QAction *action ) { ViewActionLists::addAction( list, action ); } virtual void createDockers() {} void addDocker( DockWidget *ds ); QList dockers() const; DockWidget *findDocker( const QString &id ) const; public Q_SLOTS: void setPrintingOptions(const KPlato::PrintingOptions &opt) { m_printingOptions = opt; } /// Activate/deactivate the gui virtual void setGuiActive( bool activate ); virtual void setScheduleManager(KPlato::ScheduleManager *sm) { m_schedulemanager = sm; } void slotUpdateReadWrite( bool ); virtual void slotHeaderContextMenuRequested( const QPoint &pos ); virtual void slotEditCopy() {} virtual void slotEditCut() {} virtual void slotEditPaste() {} virtual void slotRefreshView() {} void setPageLayout( const KoPageLayout &layout ); Q_SIGNALS: /// Emitted when the gui has been activated or deactivated void guiActivated(KPlato::ViewBase*, bool); /// Request for a context menu popup void requestPopupMenu( const QString&, const QPoint & ); /// Emitted when options are modified void optionsModified(); void projectChanged(KPlato::Project *project); void readWriteChanged( bool ); void expandAll(); void collapseAll(); void openDocument(const QUrl &url); protected Q_SLOTS: virtual void slotOptions() {} virtual void slotOptionsFinished( int result ); protected: void createOptionActions(int actions); bool m_readWrite; PrintingOptions m_printingOptions; Project *m_proj; ScheduleManager *m_schedulemanager; KoPageLayout m_pagelayout; QList m_dockers; }; //------------------ class PLANUI_EXPORT TreeViewPrintingDialog : public PrintingDialog { Q_OBJECT public: TreeViewPrintingDialog( ViewBase *view, TreeViewBase *treeview, Project *project = 0 ); ~TreeViewPrintingDialog() {} virtual int documentFirstPage() const { return 1; } virtual int documentLastPage() const; QList createOptionWidgets() const; protected: virtual void printPage( int pageNumber, QPainter &painter ); int firstRow( int page ) const; private: TreeViewBase *m_tree; Project *m_project; int m_firstRow; }; //----------------- class PLANUI_EXPORT TreeViewBase : public QTreeView { Q_OBJECT public: explicit TreeViewBase( QWidget *parent = 0 ); void setReadWrite( bool rw ); virtual void createItemDelegates( ItemModelBase *model ); void setArrowKeyNavigation( bool on ) { m_arrowKeyNavigation = on; } bool arrowKeyNavigation() const { return m_arrowKeyNavigation; } /// Move move to first visual QModelIndex firstColumn( int row, const QModelIndex &parent ); /// Move move to last visual QModelIndex lastColumn( int row, const QModelIndex &parent ); /// Move from @p current to next item QModelIndex nextColumn( const QModelIndex ¤t ); /// Move from @p current to next item QModelIndex previousColumn( const QModelIndex ¤t ); /// Move to first editable index in @p row with @p parent QModelIndex firstEditable( int row, const QModelIndex &parent ); /// Move to last editable index in @p row with @p parent QModelIndex lastEditable( int row, const QModelIndex &parent ); void setAcceptDropsOnView( bool mode ) { m_acceptDropsOnView = mode; } virtual void setModel( QAbstractItemModel *model ); virtual void setSelectionModel( QItemSelectionModel *model ); void setStretchLastSection( bool ); void mapToSection( int column, int section ); int section( int col ) const; void setColumnsHidden( const QList &list ); /// Loads context info into this view. Reimplement. virtual bool loadContext(const QMetaEnum &map, const KoXmlElement &element, bool expand = true); /// Save context info from this view. Reimplement. virtual void saveContext(const QMetaEnum &map, QDomElement &context , bool expand = true) const; /** Reimplemented to fix qt bug 160083: Doesn't scroll horizontally. Scroll the contents of the tree view until the given model item \a index is visible. The \a hint parameter specifies more precisely where the item should be located after the operation. If any of the parents of the model item are collapsed, they will be expanded to ensure that the model item is visible. */ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible); void setDefaultColumns( const QList &lst ) { m_defaultColumns = lst; } QList defaultColumns() const { return m_defaultColumns; } KoPrintJob *createPrintJob( ViewBase *parent ); QModelIndex firstVisibleIndex( const QModelIndex &idx ) const; ItemModelBase *itemModel() const; void setContextMenuIndex(const QModelIndex &idx); void loadExpanded(const KoXmlElement &element); void saveExpanded(QDomElement &element, const QModelIndex &parent = QModelIndex()) const; void expandRecursivly(QDomElement element, const QModelIndex &parent = QModelIndex()); void doExpand(QDomDocument &doc); public Q_SLOTS: void slotExpand(); void slotCollapse(); Q_SIGNALS: /// Context menu requested from viewport at global position @p pos void contextMenuRequested( const QModelIndex&, const QPoint &pos, const QModelIndexList& ); /// Context menu requested from header at global position @p pos void headerContextMenuRequested( const QPoint &pos ); void moveAfterLastColumn( const QModelIndex & ); void moveBeforeFirstColumn( const QModelIndex & ); void editAfterLastColumn( const QModelIndex & ); void editBeforeFirstColumn( const QModelIndex & ); void dropAllowed( const QModelIndex &index, int dropIndicatorPosition, QDragMoveEvent *event ); protected: void keyPressEvent(QKeyEvent *event); void mousePressEvent( QMouseEvent *event ); /** Reimplemented from QTreeView to make tab/backtab in editor work reasonably well. Move the cursor in the way described by \a cursorAction, *not* using the information provided by the button \a modifiers. */ QModelIndex moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ); /// Move cursor from @p index in direction @p cursorAction. @p modifiers is not used. QModelIndex moveCursor( const QModelIndex &index, CursorAction cursorAction, Qt::KeyboardModifiers = Qt::NoModifier ); /// Move from @p index to next editable item, in direction @p cursorAction. QModelIndex moveToEditable( const QModelIndex &index, CursorAction cursorAction ); void contextMenuEvent ( QContextMenuEvent * event ); void dragMoveEvent(QDragMoveEvent *event); void dropEvent( QDropEvent *e ); void updateSelection( const QModelIndex &oldidx, const QModelIndex &newidx, QKeyEvent *event ); void expandRecursive(const QModelIndex &parent, bool xpand); protected Q_SLOTS: /// Close the @p editor, using sender()->endEditHint(). /// Use @p hint if sender is not of type ItemDelegate. virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint); virtual void slotCurrentChanged ( const QModelIndex & current, const QModelIndex & previous ); void slotHeaderContextMenuRequested( const QPoint& ); //Copied from QAbstractItemView inline QItemSelectionModel::SelectionFlags selectionBehaviorFlags() const { switch (selectionBehavior()) { case QAbstractItemView::SelectRows: return QItemSelectionModel::Rows; case QAbstractItemView::SelectColumns: return QItemSelectionModel::Columns; case QAbstractItemView::SelectItems: default: return QItemSelectionModel::NoUpdate; } } void doContextExpanded(); void doExpanded(); protected: virtual void focusInEvent(QFocusEvent *event); bool m_arrowKeyNavigation; bool m_acceptDropsOnView; QList m_hideList; bool m_readWrite; QList m_defaultColumns; QPersistentModelIndex m_contextMenuIndex; QDomDocument m_loadContextDoc; QDomDocument m_expandDoc; }; //------------------ class PLANUI_EXPORT DoubleTreeViewPrintingDialog : public PrintingDialog { Q_OBJECT public: DoubleTreeViewPrintingDialog( ViewBase *view, DoubleTreeViewBase *treeview, Project *project ); ~DoubleTreeViewPrintingDialog() {} virtual int documentFirstPage() const { return 1; } virtual int documentLastPage() const; QList createOptionWidgets() const; protected: virtual void printPage( int pageNumber, QPainter &painter ); int firstRow( int page ) const; private: DoubleTreeViewBase *m_tree; Project *m_project; int m_firstRow; }; class PLANUI_EXPORT DoubleTreeViewBase : public QSplitter { Q_OBJECT public: explicit DoubleTreeViewBase( QWidget *parent ); DoubleTreeViewBase( bool mode, QWidget *parent ); ~DoubleTreeViewBase(); void setReadWrite( bool rw ); void closePersistentEditor( const QModelIndex &index ); void setModel( QAbstractItemModel *model ); QAbstractItemModel *model() const; void setArrowKeyNavigation( bool on ) { m_arrowKeyNavigation = on; } bool arrowKeyNavigation() const { return m_arrowKeyNavigation; } QItemSelectionModel *selectionModel() const { return m_selectionmodel; } void setSelectionModel( QItemSelectionModel *model ); void setSelectionMode( QAbstractItemView::SelectionMode mode ); void setSelectionBehavior( QAbstractItemView::SelectionBehavior mode ); virtual void createItemDelegates( ItemModelBase *model ); void setItemDelegateForColumn( int col, QAbstractItemDelegate * delegate ); void setEditTriggers ( QAbstractItemView::EditTriggers ); QAbstractItemView::EditTriggers editTriggers() const; void setAcceptDrops( bool ); void setAcceptDropsOnView( bool ); void setDropIndicatorShown( bool ); void setDragDropMode( QAbstractItemView::DragDropMode mode ); void setDragDropOverwriteMode( bool mode ); void setDragEnabled ( bool mode ); void setDefaultDropAction( Qt::DropAction action ); void setStretchLastSection( bool ); /// Hide columns in the @p hideList, show all other columns. /// If the hideList.last() == -1, the rest of the columns are hidden. void hideColumns( TreeViewBase *view, const QList &hideList ); void hideColumns( const QList &masterList, const QList &slaveList = QList() ); void hideColumn( int col ) { m_leftview->hideColumn( col ); if ( m_rightview ) m_rightview->hideColumn( col ); } void showColumn( int col ) { if ( col == 0 || m_rightview == 0 ) m_leftview->showColumn( col ); else m_rightview->showColumn( col ); } bool isColumnHidden( int col ) const { return m_rightview ? m_rightview->isColumnHidden( col ) : m_leftview->isColumnHidden( col ); } TreeViewBase *masterView() const { return m_leftview; } TreeViewBase *slaveView() const { return m_rightview; } /// Loads context info into this view. Reimplement. virtual bool loadContext( const QMetaEnum &map, const KoXmlElement &element ); /// Save context info from this view. Reimplement. virtual void saveContext( const QMetaEnum &map, QDomElement &context ) const; void setViewSplitMode( bool split ); bool isViewSplit() const { return m_mode; } QAction *actionSplitView() const { return m_actionSplitView; } void setRootIsDecorated ( bool show ); KoPrintJob *createPrintJob( ViewBase *parent ); void setStretchFactors(); QModelIndex indexAt( const QPoint &pos ) const; void setParentsExpanded( const QModelIndex &idx, bool expanded ); void setSortingEnabled( bool on ) { m_leftview->setSortingEnabled( on ); m_rightview->setSortingEnabled( on ); } void sortByColumn( int col, Qt::SortOrder order = Qt::AscendingOrder ) { if ( ! m_leftview->isColumnHidden( col ) || ! m_rightview->isVisible() || m_rightview->isColumnHidden( col ) ) { m_leftview->sortByColumn( col, order ); } else { m_rightview->sortByColumn( col, order ); } } void setContextMenuIndex(const QModelIndex &idx); Q_SIGNALS: /// Context menu requested from the viewport, pointer over @p index at global position @p pos void contextMenuRequested( const QModelIndex &index, const QPoint& pos, const QModelIndexList& ); /// Context menu requested from master- or slave header at global position @p pos void headerContextMenuRequested( const QPoint &pos ); /// Context menu requested from master header at global position @p pos void masterHeaderContextMenuRequested( const QPoint &pos ); /// Context menu requested from slave header at global position @p pos void slaveHeaderContextMenuRequested( const QPoint &pos ); void currentChanged ( const QModelIndex & current, const QModelIndex & previous ); void selectionChanged( const QModelIndexList& ); void dropAllowed( const QModelIndex &index, int dropIndicatorPosition, QDragMoveEvent *event ); public Q_SLOTS: void edit( const QModelIndex &index ); void slotExpand(); void slotCollapse(); protected Q_SLOTS: void slotSelectionChanged( const QItemSelection &sel, const QItemSelection & ); void slotToRightView( const QModelIndex &index ); void slotToLeftView( const QModelIndex &index ); void slotEditToRightView( const QModelIndex &index ); void slotEditToLeftView( const QModelIndex &index ); void slotRightHeaderContextMenuRequested( const QPoint &pos ); void slotLeftHeaderContextMenuRequested( const QPoint &pos ); void slotLeftSortIndicatorChanged( int logicalIndex, Qt::SortOrder order ); void slotRightSortIndicatorChanged( int logicalIndex, Qt::SortOrder order ); protected: void init(); QList expandColumnList( const QList &lst ) const; protected: TreeViewBase *m_leftview; TreeViewBase *m_rightview; QItemSelectionModel *m_selectionmodel; bool m_arrowKeyNavigation; bool m_readWrite; bool m_mode; QAction *m_actionSplitView; }; } // namespace KPlato #endif diff --git a/src/libs/widgets/KoDialog.h b/src/libs/widgets/KoDialog.h index 729f7d80..efaec188 100644 --- a/src/libs/widgets/KoDialog.h +++ b/src/libs/widgets/KoDialog.h @@ -1,835 +1,835 @@ /* This file is part of the KDE Libraries * Copyright (C) 1998 Thomas Tanghus (tanghus@earthling.net) * Additions 1999-2000 by Espen Sand (espen@kde.org) * and Holger Freyther * 2005-2009 Olivier Goffart * 2006 Tobias Koenig * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KODIALOG_H #define KODIALOG_H class QPushButton; class QMenu; class KoDialogPrivate; #include #include #include #include /** * @short A dialog base class with standard buttons and predefined layouts. * * Provides basic functionality needed by nearly all dialogs. * * It offers the standard action buttons you'd expect to find in a * dialog as well as the capability to define at most three configurable * buttons. You can define a main widget that contains your specific * dialog layout * * The class takes care of the geometry management. You only need to define * a minimum size for the widget you want to use as the main widget. * * By default, the dialog is non-modal. * * Standard buttons (action buttons):\n * * You select which buttons should be displayed, but you do not choose the * order in which they are displayed. This ensures a standard interface in * KDE. The button order can be changed, but this ability is only available * for a central KDE control tool. The following buttons are available: * OK, Cancel/Close, Apply/Try, Default, Help and three user definable * buttons: User1, User2 and User3. You must specify the text of the UserN * buttons. Each button emit a signal, so you can choose to connect that signal. * * The default action of the Help button will open the help system if you have * provided a path to the help text. * The default action of Ok and Cancel will run QDialog::accept() and QDialog::reject(), * which you can override by reimplementing slotButtonClicked(). The default * action of the Close button will close the dialog. * * Note that the KoDialog will animate a button press * when the user presses Escape. The button that is enabled is either Cancel, * Close or the button that is defined by setEscapeButton(). * Your custom dialog code should reimplement the keyPressEvent and * animate the cancel button so that the dialog behaves like regular * dialogs. * * Layout:\n * * The dialog consists of a help area on top (becomes visible if you define * a help path and use enableLinkedHelp()), the main area which is * the built-in dialog face or your own widget in the middle and by default * a button box at the bottom. The button box can also be placed at the * right edge (to the right of the main widget). Use * setButtonsOrientation() to control this behavior. A separator * can be placed above the button box (or to the left when the button box * is at the right edge). * * Standard compliance:\n * * The marginHint() and spacingHint() sizes shall be used * whenever you lay out the interior of a dialog. One special note. If * you make your own action buttons (OK, Cancel etc), the space * between the buttons shall be spacingHint(), whereas the space * above, below, to the right and to the left shall be marginHint(). * If you add a separator line above the buttons, there shall be a * marginHint() between the buttons and the separator and a * marginHint() above the separator as well. * * Example:\n * * \code * KoDialog *dialog = new KoDialog( this ); * dialog->setCaption( "My title" ); * dialog->setButtons( KoDialog::Ok | KoDialog::Cancel | KoDialog::Apply ); * * FooWidget *widget = new FooWidget( dialog ); * dialog->setMainWidget( widget ); * connect( dialog, SIGNAL(applyClicked()), widget, SLOT(save()) ); * connect( dialog, SIGNAL(okClicked()), widget, SLOT(save()) ); * connect( widget, SIGNAL(changed(bool)), dialog, SLOT(enableButtonApply(bool)) ); * * dialog->enableButtonApply( false ); * dialog->show(); * \endcode * * \image html kdialog.png "KDE Dialog example" * * This class can be used in many ways. Note that most KDE ui widgets * and many of KDE core applications use the KoDialog so for more * inspiration you should study the code for these. * * * @see KPageDialog * @author Thomas Tanghus * @author Espen Sand * @author Mirko Boehm * @author Olivier Goffart * @author Tobias Koenig */ class KOWIDGETS_EXPORT KoDialog : public QDialog //krazy:exclude=qclasses { Q_OBJECT Q_DECLARE_PRIVATE(KoDialog) public: enum ButtonCode { None = 0x00000000, Help = 0x00000001, ///< Show Help button. (this button will run the help set with setHelp) Default = 0x00000002, ///< Show Default button. Ok = 0x00000004, ///< Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted) Apply = 0x00000008, ///< Show Apply button. Try = 0x00000010, ///< Show Try button. Cancel = 0x00000020, ///< Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected) Close = 0x00000040, ///< Show Close-button. (this button closes the dialog) No = 0x00000080, ///< Show No button. (this button closes the dialog and sets the result to KoDialog::No) Yes = 0x00000100, ///< Show Yes button. (this button closes the dialog and sets the result to KoDialog::Yes) Reset = 0x00000200, ///< Show Reset button Details = 0x00000400, ///< Show Details button. (this button will show the detail widget set with setDetailsWidget) User1 = 0x00001000, ///< Show User defined button 1. User2 = 0x00002000, ///< Show User defined button 2. User3 = 0x00004000, ///< Show User defined button 3. NoDefault = 0x00008000 ///< Used when specifying a default button; indicates that no button should be marked by default. }; Q_ENUM(ButtonCode) // TODO KDE5: remove NoDefault and use the value None instead Q_DECLARE_FLAGS(ButtonCodes, ButtonCode) enum ButtonPopupMode { InstantPopup = 0, DelayedPopup = 1 }; Q_DECLARE_FLAGS(ButtonPopupModes, ButtonPopupMode) public: /** * Creates a dialog. * * @param parent The parent of the dialog. * @param flags The widget flags passed to the QDialog constructor */ explicit KoDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); /** * Destroys the dialog. */ ~KoDialog(); /** * Creates (or recreates) the button box and all the buttons in it. * * Note that some combinations are not possible. That means, you can't * have the following pairs of buttons in a dialog: * - Default and Details * - Cancel and Close * - Ok and Try * * This will reset all default KGuiItem of all button. * * @param buttonMask Specifies what buttons will be made. * * @deprecated Since 5.0 use QDialogButtonBox */ void setButtons(ButtonCodes buttonMask); /** * Sets the orientation of the button box. * * It can be @p Vertical or @p Horizontal. If @p Horizontal * (default), the button box is positioned at the bottom of the * dialog. If @p Vertical it will be placed at the right edge of the * dialog. * * @param orientation The button box orientation. */ void setButtonsOrientation(Qt::Orientation orientation); /** * Sets the button that will be activated when the Escape key * is pressed. * * By default, the Escape key is mapped to either the Cancel or the Close button * if one of these buttons are defined. The user expects that Escape will * cancel an operation so use this function with caution. * * @param id The button code. */ void setEscapeButton(ButtonCode id); /** * Sets the button that will be activated when the Enter key * is pressed. * * By default, this is the Ok button if it is present * * @param id The button code. */ void setDefaultButton(ButtonCode id); /** * Returns the button code of the default button, * or NoDefault if there is no default button. */ ButtonCode defaultButton() const; /** * Hide or display the a separator line drawn between the action * buttons an the main widget. */ void showButtonSeparator(bool state); /** * Hide or display a general action button. * * Only buttons that have * been created in the constructor can be displayed. This method will * not create a new button. * * @param id Button identifier. * @param state true display the button(s). */ void showButton(ButtonCode id, bool state); /** * Sets the text of any button. * * @param id The button identifier. * @param text Button text. */ void setButtonText(ButtonCode id, const QString &text); /** * Returns the text of any button. */ QString buttonText(ButtonCode id) const; /** * Sets the icon of any button. * * @param id The button identifier. * @param icon Button icon. */ void setButtonIcon(ButtonCode id, const QIcon &icon); /** * Returns the icon of any button. */ QIcon buttonIcon(ButtonCode id) const; /** * Sets the tooltip text of any button. * * @param id The button identifier. * @param text Button text. */ void setButtonToolTip(ButtonCode id, const QString &text); /** * Returns the tooltip of any button. */ QString buttonToolTip(ButtonCode id) const; /** * Sets the "What's this?" text of any button. * * @param id The button identifier. * @param text Button text. */ void setButtonWhatsThis(ButtonCode id, const QString &text); /** * Returns the "What's this?" text of any button. */ QString buttonWhatsThis(ButtonCode id) const; /** * Sets the KGuiItem directly for the button instead of using 3 methods to * set the text, tooltip and whatsthis strings. This also allows to set an * icon for the button which is otherwise not possible for the extra * buttons beside Ok, Cancel and Apply. * * @param id The button identifier. * @param item The KGuiItem for the button. */ void setButtonGuiItem(ButtonCode id, const KGuiItem &item); /** * Sets the focus to the button of the passed @p id. */ void setButtonFocus(ButtonCode id); /** * Convenience method. Sets the initial dialog size. * * This method should only be called right before show() or exec(). * The initial size will be ignored if smaller than * the dialog's minimum size. * * @param size Startup size. */ void setInitialSize(const QSize &size); /** * Convenience method. Add a size to the default minimum size of a * dialog. * * This method should only be called right before show() or exec(). * * @param size Size added to minimum size. */ void incrementInitialSize(const QSize &size); /** * Returns the help link text. * * If no text has been defined, * "Get help..." (internationalized) is returned. * * @return The help link text. * * @see enableLinkedHelp() * @see setHelpLinkText() * @see setHelp() */ QString helpLinkText() const; /** * Returns whether any button is enabled. */ bool isButtonEnabled(ButtonCode id) const; /** * Returns the button that corresponds to the @p id. * * Normally you should not use this function. * @em Never delete the object returned by this function. * See also enableButton(), showButton(), setButtonGuiItem(). * * @param id Identifier of the button. * @return The button or 0 if the button does not exist. */ QPushButton *button(ButtonCode id) const; /** * Returns the number of pixels that should be used between a * dialog edge and the outermost widget(s) according to the KDE standard. * * @deprecated Use the style's pixelMetric() function to query individual margins. * Different platforms may use different values for the four margins. */ static int marginHint(); /** * Returns the number of pixels that should be used between * widgets inside a dialog according to the KDE standard. * * @deprecated Use the style's layoutSpacing() function to query individual spacings. * Different platforms may use different values depending on widget types and pairs. */ static int spacingHint(); /** * Returns the number of pixels that should be used to visually * separate groups of related options in a dialog according to * the KDE standard. * @since 4.2 */ static int groupSpacingHint(); /** * @enum StandardCaptionFlag * Used to specify how to construct a window caption * * @value AppName Indicates that the method shall include * the application name when making the caption string. * @value Modified Causes a 'modified' sign will be included in the * returned string. This is useful when indicating that a file is * modified, i.e., it contains data that has not been saved. * @value HIGCompliant The base minimum flags required to align a * caption with the KDE Human Interface Guidelines */ enum CaptionFlag { NoCaptionFlags = 0, AppNameCaption = 1, ModifiedCaption = 2, HIGCompliantCaption = AppNameCaption }; Q_DECLARE_FLAGS(CaptionFlags, CaptionFlag) /** * Builds a caption that contains the application name along with the * userCaption using a standard layout. * * To make a compliant caption for your window, simply do: * @p setWindowTitle(KoDialog::makeStandardCaption(yourCaption)); * * To ensure that the caption is appropriate to the desktop in which the * application is running, pass in a pointer to the window the caption will * be applied to. * * If using a KoDialog or KMainWindow subclass, call setCaption instead and * an appropriate standard caption will be created for you * * @param userCaption The caption string you want to display in the * window caption area. Do not include the application name! * @param window a pointer to the window this application will apply to * @param flags * @return the created caption */ static QString makeStandardCaption(const QString &userCaption, QWidget *window = 0, CaptionFlags flags = HIGCompliantCaption); /** * Resize every layout manager used in @p widget and its nested children. * * @param widget The widget used. * @param margin The new layout margin. * @param spacing The new layout spacing. * * @deprecated Use QLayout functions where necessary. Setting margin and spacing * values recursively for all children prevents QLayout from creating platform native * layouts. */ static void resizeLayout(QWidget *widget, int margin, int spacing); /** * Resize every layout associated with @p lay and its children. * * @param lay layout to be resized * @param margin The new layout margin * @param spacing The new layout spacing * * @deprecated Use QLayout functions where necessary. Setting margin and spacing * values recursively for all children prevents QLayout from creating platform native * layouts. */ static void resizeLayout(QLayout *lay, int margin, int spacing); /** * Centers @p widget on the desktop, taking multi-head setups into * account. If @p screen is -1, @p widget will be centered on its * current screen (if it was shown already) or on the primary screen. * If @p screen is -3, @p widget will be centered on the screen that * currently contains the mouse pointer. * @p screen will be ignored if a merged display (like Xinerama) is not * in use, or merged display placement is not enabled in kdeglobals. */ static void centerOnScreen(QWidget *widget, int screen = -1); /** * Places @p widget so that it doesn't cover a certain @p area of the screen. * This is typically used by the "find dialog" so that the match it finds can * be read. * For @p screen, see centerOnScreen * @return true on success (widget doesn't cover area anymore, or never did), * false on failure (not enough space found) */ static bool avoidArea(QWidget *widget, const QRect &area, int screen = -1); /** * Sets the main widget of the dialog. */ void setMainWidget(QWidget *widget); /** * @return The current main widget. Will create a QWidget as the mainWidget * if none was set before. This way you can write * \code * ui.setupUi(mainWidget()); * \endcode * when using designer. */ QWidget *mainWidget(); /** * Reimplemented from QDialog. */ QSize sizeHint() const Q_DECL_OVERRIDE; /** * Reimplemented from QDialog. */ QSize minimumSizeHint() const Q_DECL_OVERRIDE; public Q_SLOTS: /** * Make a KDE compliant caption. * * @param caption Your caption. Do @p not include the application name * in this string. It will be added automatically according to the KDE * standard. * * @deprecated Since 5.0 use QWidget::setWindowTitle */ virtual void setCaption(const QString &caption); /** * Makes a KDE compliant caption. * * @param caption Your caption. @em Do @em not include the application name * in this string. It will be added automatically according to the KDE * standard. * @param modified Specify whether the document is modified. This displays * an additional sign in the title bar, usually "**". * * @deprecated Since 5.0 use QWidget::setWindowTitle and QWidget::setWindowModified. */ virtual void setCaption(const QString &caption, bool modified); /** * Make a plain caption without any modifications. * * @param caption Your caption. This is the string that will be * displayed in the window title. */ virtual void setPlainCaption(const QString &caption); /** * Enable or disable (gray out) a general action button. * * @param id Button identifier. * @param state @p true enables the button(s). */ - void enableButton(ButtonCode id, bool state); + void enableButton(KoDialog::ButtonCode id, bool state); /** * Enable or disable (gray out) the OK button. * * @param state @p true enables the button. */ void enableButtonOk(bool state); /** * Enable or disable (gray out) the Apply button. * * @param state true enables the button. */ void enableButtonApply(bool state); /** * Enable or disable (gray out) the Cancel button. * * @param state true enables the button. */ void enableButtonCancel(bool state); /** * Display or hide the help link area on the top of the dialog. * * @param state @p true will display the area. * * @see helpLinkText() * @see setHelpLinkText() * @see setHelp() */ void enableLinkedHelp(bool state); /** * Sets the text that is shown as the linked text. * * If text is empty, * the text "Get help..." (internationalized) is used instead. * * @param text The link text. * * @see helpLinkText() * @see enableLinkedHelp() * @see setHelp() */ void setHelpLinkText(const QString &text); /** * Sets the help path and topic. * * @param anchor Defined anchor in your docbook sources * @param appname Defines the appname the help belongs to * If empty it's the current one * * @note The help button works differently for the class * KCMultiDialog, so it does not make sense to call this * function for Dialogs of that type. See * KCMultiDialog::slotHelp() for more information. */ void setHelp(const QString &anchor, const QString &appname = QString()); /** * Returns the status of the Details button. */ bool isDetailsWidgetVisible() const; /** * Sets the status of the Details button. */ void setDetailsWidgetVisible(bool visible); /** * Sets the widget that gets shown when "Details" is enabled. * * The dialog takes over ownership of the widget. * Any previously set widget gets deleted. */ void setDetailsWidget(QWidget *detailsWidget); /** * Destruct the dialog delayed. * * You can call this function from slots like closeClicked() and hidden(). * You should not use the dialog any more after calling this function. * @deprecated use hide()+deleteLater() */ void delayedDestruct(); Q_SIGNALS: /** * Emitted when the margin size and/or spacing size * have changed. * * Use marginHint() and spacingHint() in your slot * to get the new values. * * @deprecated This signal is not emitted. Listen to QEvent::StyleChange events instead. */ void layoutHintChanged(); /** * The Help button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void helpClicked(); /** * The Default button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void defaultClicked(); /** * The Reset button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void resetClicked(); /** * The User3 button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void user3Clicked(); /** * The User2 button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void user2Clicked(); /** * The User1 button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void user1Clicked(); /** * The Apply button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void applyClicked(); /** * The Try button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void tryClicked(); /** * The OK button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void okClicked(); /** * The Yes button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void yesClicked(); /** * The No button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void noClicked(); /** * The Cancel button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void cancelClicked(); /** * The Close button was pressed. This signal is only emitted if * slotButtonClicked() is not replaced */ void closeClicked(); /** * A button has been pressed. This signal is only emitted if * slotButtonClicked() is not replaced * @param button is the code of the pressed button. */ void buttonClicked(KoDialog::ButtonCode button); /** * The dialog is about to be hidden. * * A dialog is hidden after a user clicks a button that ends * the dialog or when the user switches to another desktop or * minimizes the dialog. */ void hidden(); /** * The dialog has finished. * * A dialog emits finished after a user clicks a button that ends * the dialog. * * This signal is also emitted when you call hide() * * If you have stored a pointer to the * dialog do @em not try to delete the pointer in the slot that is * connected to this signal. * * You should use deleteLater() instead. */ void finished(); /** * The detailsWidget is about to get shown. This is your last chance * to call setDetailsWidget if you haven't done so yet. */ void aboutToShowDetails(); protected: /** * Emits the #hidden signal. You can connect to that signal to * detect when a dialog has been closed. */ void hideEvent(QHideEvent *) Q_DECL_OVERRIDE; /** * Detects when a dialog is being closed from the window manager * controls. If the Cancel or Close button is present then the button * is activated. Otherwise standard QDialog behavior * will take place. */ void closeEvent(QCloseEvent *e) Q_DECL_OVERRIDE; /** * @internal */ void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE; protected Q_SLOTS: /** * Activated when the button @p button is clicked * * Sample that shows how to catch and handle button clicks within * an own dialog; * @code * class MyDialog : public KoDialog { * protected Q_SLOTS: * virtual void slotButtonClicked(int button) { * if (button == KoDialog::Ok) * accept(); * else * KoDialog::slotButtonClicked(button); * } * } * @endcode * * @param button is the type @a KoDialog::ButtonCode * * @deprecated since 5.0 use QDialogButtonBox and connect to the clicked signal */ virtual void slotButtonClicked(int button); /** * Updates the margins and spacings. * * @deprecated KoDialog respects the style's margins and spacings automatically. Calling * this function has no effect. */ void updateGeometry(); private: KoDialog(KoDialogPrivate &dd, QWidget *parent, Qt::WindowFlags flags = 0); KoDialogPrivate *const d_ptr; private: Q_DISABLE_COPY(KoDialog) Q_PRIVATE_SLOT(d_ptr, void queuedLayoutUpdate()) Q_PRIVATE_SLOT(d_ptr, void helpLinkClicked()) }; Q_DECLARE_OPERATORS_FOR_FLAGS(KoDialog::ButtonCodes) Q_DECLARE_OPERATORS_FOR_FLAGS(KoDialog::CaptionFlags) #endif // KODIALOG_H