[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kexi/plugins/reportspgz
From:       Adam Pigg <adam () piggz ! co ! uk>
Date:       2009-07-24 18:22:17
Message-ID: 1248459737.818600.18803.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1001993 by piggz:

Put actions on the main toolbar

 M  +6 -14     kexireportdesignview.cpp  
 M  +4 -11     kexireportdesignview.h  
 M  +33 -7     kexireportpart.cpp  
 M  +6 -0      kexireportpart.h  
 M  +66 -35    koreport/wrtembed/reportdesigner.cpp  
 M  +4 -1      koreport/wrtembed/reportdesigner.h  
 D             reportentityselector.cpp  
 D             reportentityselector.h  


--- trunk/koffice/kexi/plugins/reportspgz/kexireportdesignview.cpp #1001992:1001993
@@ -23,15 +23,13 @@
 #include <kdebug.h>
 #include <QScrollArea>
 #include <core/KexiWindow.h>
-#include "reportentityselector.h"
 #include "kexisourceselector.h"
 #include <KPushButton>
 
-KexiReportDesignView::KexiReportDesignView ( QWidget *parent, ReportEntitySelector* \
r , KexiSourceSelector *s) +KexiReportDesignView::KexiReportDesignView ( QWidget \
*parent, KexiSourceSelector *s)  : KexiView ( parent ) {
     scr = new QScrollArea ( this );
     layout()->addWidget ( scr );
-    res = r;
     srcsel = s;
     
     _rd = 0;
@@ -182,17 +180,6 @@
 
     connect ( sectionEdit, SIGNAL ( activated() ), _rd, SLOT ( slotSectionEditor() ) \
);  
-    //Control Actions
-    connect ( res->itemLabel, SIGNAL ( clicked() ), this, SLOT ( slotLabel() ) );
-    connect ( res->itemField, SIGNAL ( clicked() ), this, SLOT ( slotField() ) );
-    connect ( res->itemText, SIGNAL ( clicked() ), this, SLOT ( slotText() ) );
-    connect ( res->itemLine, SIGNAL ( clicked() ), this, SLOT ( slotLine() ) );
-    connect ( res->itemBarcode, SIGNAL ( clicked() ), this, SLOT ( slotBarcode() ) \
                );
-    connect ( res->itemChart, SIGNAL ( clicked() ),this, SLOT ( slotChart() ) );
-    connect ( res->itemImage, SIGNAL ( clicked() ), this, SLOT ( slotImage() ) );
-    connect ( res->itemShape, SIGNAL ( clicked() ), this, SLOT ( slotShape() ) );
-    connect ( res->itemCheck, SIGNAL ( clicked() ), this, SLOT ( slotCheck() ) );
-
     //Raise/Lower
     connect ( itemRaiseAction, SIGNAL ( activated() ), _rd, SLOT ( \
                slotRaiseSelected() ) );
     connect ( itemLowerAction, SIGNAL ( activated() ), _rd, SLOT ( \
slotLowerSelected() ) ); @@ -206,3 +193,8 @@
 void KexiReportDesignView::slotSetData ( KoReportData* kodata ) {
     _rd->setReportData ( kodata );
 }
+
+void KexiReportDesignView::triggerAction(const QString &action)
+{
+    _rd->slotItem(action);
+}
\ No newline at end of file
--- trunk/koffice/kexi/plugins/reportspgz/kexireportdesignview.h #1001992:1001993
@@ -28,7 +28,6 @@
 #include "koreportdata.h"
 
 class QScrollArea;
-class ReportEntitySelector;
 class KexiSourceSelector;
 
 /**
@@ -38,11 +37,14 @@
 {
     Q_OBJECT
 public:
-    KexiReportDesignView(QWidget *parent, ReportEntitySelector*, \
KexiSourceSelector*); +    KexiReportDesignView(QWidget *parent, \
KexiSourceSelector*);  
     ~KexiReportDesignView();
     virtual tristate afterSwitchFrom(Kexi::ViewMode mode);
     virtual tristate beforeSwitchTo(Kexi::ViewMode mode, bool &dontStore);
+
+    void triggerAction(const QString &);
+    
 private:
     ReportDesigner *_rd;
     KoProperty::Set *_set;
@@ -59,7 +61,6 @@
     KAction *itemRaiseAction;
     KAction *itemLowerAction;
 
-    ReportEntitySelector* res;
     KexiSourceSelector *srcsel;
 protected:
     virtual KoProperty::Set *propertySet();
@@ -68,14 +69,6 @@
 
 private slots:
     void slotDesignerPropertySetChanged();
-    void slotLabel(){_rd->slotItem(KRObjectData::EntityLabel);};
-    void slotField(){_rd->slotItem(KRObjectData::EntityField);};
-    void slotText(){_rd->slotItem(KRObjectData::EntityText);};
-    void slotChart(){_rd->slotItem(KRObjectData::EntityChart);};
-    void slotBarcode(){_rd->slotItem(KRObjectData::EntityBarcode);};
-    void slotImage(){_rd->slotItem(KRObjectData::EntityImage);};
-    void slotLine(){_rd->slotItem(KRObjectData::EntityLine);};
-    void slotCheck(){_rd->slotItem(KRObjectData::EntityCheck);};
 
     public slots:
     void slotSetData(KoReportData*);
--- trunk/koffice/kexi/plugins/reportspgz/kexireportpart.cpp #1001992:1001993
@@ -31,7 +31,6 @@
 #include <core/KexiMainWindowIface.h>
 #include <ktabwidget.h>
 
-#include "reportentityselector.h"
 #include "kexisourceselector.h"
 
 //! @internal
@@ -39,12 +38,10 @@
 {
 public:
     Private() {
-        res = 0;
         ksrc = 0;
     }
     ~Private() {
     }
-    ReportEntitySelector *res;
     KexiSourceSelector *ksrc;
 };
 
@@ -79,12 +76,23 @@
         view = new KexiReportView(parent);
         
     } else if (viewMode == Kexi::DesignViewMode) {
-        view = new KexiReportDesignView(parent, d->res, d->ksrc);
+        view = new KexiReportDesignView(parent, d->ksrc);
         connect(d->ksrc, SIGNAL(setData(KoReportData*)), view, \
SLOT(slotSetData(KoReportData*)));  }
     return view;
 }
 
+void KexiReportPart::initPartActions()
+{
+    KexiMainWindowIface *win = KexiMainWindowIface::global();
+    QList<QAction*> reportActions = ReportDesigner::actions();
+    
+    foreach( QAction* action, reportActions ) {
+        connect(action, SIGNAL(triggered()), this, SLOT(slotActionTriggered()));
+        win->addToolBarAction("report", action);
+    }
+}
+
 QString KexiReportPart::loadReport(const QString& name)
 {
     //_internal->_reportName = pReportName;
@@ -133,10 +141,28 @@
     if (!d->ksrc)
         d->ksrc = new KexiSourceSelector(tab, \
KexiMainWindowIface::global()->project()->dbConnection() );  tab->addTab(d->ksrc, \
i18n("Source")); +}
+
+void KexiReportPart::slotActionTriggered()
+{
+    QObject *theSender = sender();
+    if (!theSender)
+        return;
     
-    if (!d->res)
-        d->res = new ReportEntitySelector(tab);
-    tab->addTab(d->res, i18n("Controls"));
+    QString senderName = sender()->objectName();
+    KexiMainWindowIface *mainwin = KexiMainWindowIface::global();
+
+    KexiWindow *win = mainwin->currentWindow();
+
+    if (!win)
+        return;
+
+    KexiView *designView = win->viewForMode(Kexi::DesignViewMode);
+
+    if (designView) {
+        KexiReportDesignView *dv = dynamic_cast<KexiReportDesignView*>(designView);
+        dv->triggerAction(senderName);
+    }
 }
 
 #include "kexireportpart.moc"
--- trunk/koffice/kexi/plugins/reportspgz/kexireportpart.h #1001992:1001993
@@ -45,11 +45,14 @@
          * Default Destructor
          */
         virtual ~KexiReportPart();
+
         virtual KexiView* createView ( QWidget *parent, KexiWindow* win,
                                        KexiPart::Item &item, Kexi::ViewMode = \
Kexi::DataViewMode, QMap<QString, QVariant>* staticObjectArgs = 0 );  virtual \
KexiWindowData* createWindowData ( KexiWindow* window );  
         virtual void setupCustomPropertyPanelTabs ( KTabWidget *tab );
+
+        virtual void initPartActions();
         
         class TempData : public KexiWindowData {
             public:
@@ -65,6 +68,9 @@
                 QString name;
         };
 
+    private slots:
+        void slotActionTriggered();
+        
     private:
         QString loadReport ( const QString& );
         class Private;
--- trunk/koffice/kexi/plugins/reportspgz/koreport/wrtembed/reportdesigner.cpp \
#1001992:1001993 @@ -606,11 +606,6 @@
     title.appendChild(doc.createTextNode(reportTitle()));
     root.appendChild(title);
 
-//TODO    QDomElement rds = doc.createElement("datasource");
-//    rds.setAttribute("external", m_externalData->value().toBool());
-//    rds.appendChild(doc.createTextNode(reportDataSource()));
-//    root.appendChild(rds);
-
     QDomElement scr = doc.createElement("script");
     scr.setAttribute("interpreter", m_interpreter->value().toString());
     scr.appendChild(doc.createTextNode(m_script->value().toString()));
@@ -764,20 +759,6 @@
     return m_title->value().toString();
 }
 
-//TODO
-//QString ReportDesigner::reportDataSource()
-//{
-//    return m_dataSource->value().toString();
-//}
-
-//void ReportDesigner::setReportDataSource(const QString &q)
-//{
-//    if (m_dataSource->value().toString() != q) {
-//        m_dataSource->setValue(q);
-//        setModified(true);
-//    }
-//}
-
 bool ReportDesigner::isModified()
 {
     return m_modified;
@@ -859,12 +840,6 @@
 
     m_title = new KoProperty::Property("Title", "Report", "Title", "Report Title");
 
-//    keys = queryList();
-//    m_dataSource = new KoProperty::Property("DataSource", keys, keys, "", "Data \
                Source");
-//    m_dataSource->setOption("extraValueAllowed", "true");
-    
-//    m_externalData = new KoProperty::Property("ExternalData", QVariant(false), \
                "External Data", "External Data");
-    
     keys.clear();
     keys = pageFormats();
     m_pageSize = new KoProperty::Property("PageSize", keys, keys, "A4", "Page \
Size"); @@ -901,8 +876,6 @@
     m_script = new KoProperty::Property("Script", keys, keys, "", "Object Script");
     
     m_set->addProperty(m_title);
-//    m_set->addProperty(m_externalData);
-//    m_set->addProperty(m_dataSource);
     m_set->addProperty(m_pageSize);
     m_set->addProperty(m_orientation);
     m_set->addProperty(m_unit);
@@ -1180,23 +1153,36 @@
     return activeScene()->selectedItems().count();
 }
 
+void ReportDesigner::changeSet(KoProperty::Set *s)
+{
+    m_itmset = s;
+    emit(propertySetChanged());
+}
+
+//
+// Actions
+//
+
 void ReportDesigner::slotItem(KRObjectData::EntityTypes typ)
 {
     m_sectionData->mouseAction = ReportWriterSectionData::MA_Insert;
     m_sectionData->insertItem = typ;
 }
 
-void ReportDesigner::changeSet(KoProperty::Set *s)
+void ReportDesigner::slotItem(const QString &entity)
 {
-    m_itmset = s;
-    emit(propertySetChanged());
+    if (entity == "action-insert-label") slotItem(KRObjectData::EntityLabel);
+    if (entity == "action-insert-field") slotItem(KRObjectData::EntityField);
+    if (entity == "action-insert-text") slotItem(KRObjectData::EntityText);
+    if (entity == "action-insert-line") slotItem(KRObjectData::EntityLine);
+    if (entity == "action-insert-barcode") slotItem(KRObjectData::EntityBarcode);
+    if (entity == "action-insert-chart") slotItem(KRObjectData::EntityChart);
+    if (entity == "action-insert-check") slotItem(KRObjectData::EntityCheck);
+    if (entity == "action-insert-image") slotItem(KRObjectData::EntityImage);
+    if (entity == "action-insert-shape") slotItem(KRObjectData::EntityShape);
+    
 }
 
-
-
-//
-// Edit Actions
-//
 void ReportDesigner::slotEditDelete()
 {
     QGraphicsItem * item = 0;
@@ -1496,3 +1482,48 @@
 
     return unique;
 }
+
+QList<QAction*> ReportDesigner::actions()
+{
+    QList<QAction*> actList;
+    QAction *act;
+
+    act = new QAction(KIcon("feed-subscribe"), i18n("Label"), 0);
+    act->setObjectName("action-insert-label");
+    actList << act;
+    
+    act = new QAction(KIcon("edit-rename"), i18n("Field"), 0);
+    act->setObjectName("action-insert-field");
+    actList << act;
+
+    act = new QAction(KIcon("insert-text"), i18n("Text"), 0);
+    act->setObjectName("action-insert-text");
+    actList << act;
+
+    act = new QAction(KIcon("draw-freehand"), i18n("Line"), 0);
+    act->setObjectName("action-insert-line");
+    actList << act;
+    
+    act = new QAction(KIcon("insert-barcode"), i18n("Barcode"), 0);
+    act->setObjectName("action-insert-barcode");
+    actList << act;
+
+    act = new QAction(KIcon("insert-image"), i18n("Image"), 0);
+    act->setObjectName("action-insert-image");
+    actList << act;
+    
+    act = new QAction(KIcon("office-chart-area"), i18n("Chart"), 0);
+    act->setObjectName("action-insert-chart");
+    actList << act;
+    
+    act = new QAction(KIcon("view-statistics"), i18n("Shape"), 0);
+    act->setObjectName("action-insert-shape");
+    actList << act;
+    
+    act = new QAction(KIcon("draw-cross"), i18n("Check"), 0);
+    act->setObjectName("action-insert-check");
+    actList << act;
+    
+    return actList;
+
+}
--- trunk/koffice/kexi/plugins/reportspgz/koreport/wrtembed/reportdesigner.h \
#1001992:1001993 @@ -139,6 +139,8 @@
 
     /**Checks if the supplied name is unique among all entities*/
     bool isEntityNameUnique(const QString &, KRObjectData* = 0) const;
+
+    static QList<QAction*> actions();
     
 public slots:
 
@@ -149,7 +151,8 @@
     void slotEditPaste(QGraphicsScene *, const QPointF &);
 
     void slotItem(KRObjectData::EntityTypes);
-
+    void slotItem(const QString&);
+    
     void slotSectionEditor();
 
     void slotRaiseSelected();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic