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

List:       kde-doc-english
Subject:    [kde-doc-english]
From:       Paul Mendez <paulestebanms () gmail ! com>
Date:       2011-06-20 20:51:24
Message-ID: 20110620205124.5F8E1A60A4 () git ! kde ! org
[Download RAW message or body]

Git commit dea7542549809027171c38ae03cc9c0ca1f8b5bd by Paul Mendez.
Committed on 20/06/2011 at 22:45.
Pushed by mendez into branch 'master'.

Add edition of slides names to Stage Slides Sorter

Model of slides sorter view provides now name edition. Shortcuts and
context menu entry has also been added.
REVIEW: 101661
GUI: Stage Slides Sorter context menu lets now rename slides

M  +36   -2    kpresenter/part/KPrSlidesSorterDocumentModel.cpp     
M  +2    -0    kpresenter/part/KPrSlidesSorterDocumentModel.h     
M  +30   -0    kpresenter/part/KPrViewModeSlidesSorter.cpp     
M  +9    -0    kpresenter/part/KPrViewModeSlidesSorter.h     

http://commits.kde.org/calligra/dea7542549809027171c38ae03cc9c0ca1f8b5bd

diff --git a/kpresenter/part/KPrSlidesSorterDocumentModel.cpp \
b/kpresenter/part/KPrSlidesSorterDocumentModel.cpp index 18360d3..e8f4159 100644
--- a/kpresenter/part/KPrSlidesSorterDocumentModel.cpp
+++ b/kpresenter/part/KPrSlidesSorterDocumentModel.cpp
@@ -30,6 +30,7 @@
 #include <KoPAPageMoveCommand.h>
 #include <KoPAOdfPageSaveHelper.h>
 #include <KoDrag.h>
+#include <KoShapeRenameCommand.h>
 
 //KDE Headers
 #include <KIcon>
@@ -89,7 +90,7 @@ QVariant KPrSlidesSorterDocumentModel::data(const QModelIndex \
&index, int role)  QString name = i18n("Unknown");
             if (page)
             {
-                name = page->name ();
+                name = page->name();
                 if (name.isEmpty())
                 {
                     //Default case
@@ -102,11 +103,42 @@ QVariant KPrSlidesSorterDocumentModel::data(const QModelIndex \
&index, int role)  {
             return QIcon(page->thumbnail(m_viewModeSlidesSorter->iconSize()));
         }
+        case Qt::EditRole:
+        {
+            return page->name();
+        }
         default:
             return QVariant();
     }
 }
 
+bool KPrSlidesSorterDocumentModel::setData(const QModelIndex &index, const QVariant \
&value, int role) +{
+    if(! index.isValid() || !m_document) {
+        return false;
+    }
+
+    Q_ASSERT(index.model() == this);
+    Q_ASSERT(index.internalPointer());
+
+    KoShape *shape = static_cast<KoShape*>(index.internalPointer());
+    switch (role)
+    {
+        case Qt::EditRole:
+        {
+            QUndoCommand *cmd = new KoShapeRenameCommand(shape, value.toString());
+            // TODO 2.1 use different text for the command if e.g. it is a \
page/slide or layer +            m_document->addCommand(cmd);
+            break;
+        }
+        default:
+            return false;
+    }
+
+    emit dataChanged(index, index);
+    return true;
+}
+
 int KPrSlidesSorterDocumentModel::rowCount(const QModelIndex &parent) const
 {
     Q_UNUSED(parent);
@@ -173,7 +205,7 @@ Qt::ItemFlags KPrSlidesSorterDocumentModel::flags(const \
QModelIndex &index) cons  Qt::ItemFlags defaultFlags = QAbstractListModel::flags \
(index);  
     if (index.isValid()) {
-        return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
+        return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable | \
defaultFlags;  }
     else {
         return Qt::ItemIsDropEnabled | defaultFlags;
@@ -297,6 +329,7 @@ void KPrSlidesSorterDocumentModel::doDrop(QList<KoPAPageBase *> \
                slides, KoPAPage
         KoPAPageMoveCommand *command = new KoPAPageMoveCommand(m_document, slides, \
pageAfter);  m_document->addCommand(command);
         m_viewModeSlidesSorter->view()->setActivePage(slides.first());
+        m_viewModeSlidesSorter->selectSlides(slides);
         return;
     }
     case Qt::CopyAction: {
@@ -307,6 +340,7 @@ void KPrSlidesSorterDocumentModel::doDrop(QList<KoPAPageBase *> \
slides, KoPAPage  m_viewModeSlidesSorter->view()->setActivePage(pageAfter);
         m_viewModeSlidesSorter->editPaste();
         m_viewModeSlidesSorter->view()->setActivePage(slides.first());
+        m_viewModeSlidesSorter->selectSlides(slides);
         return;
     }
     default:
diff --git a/kpresenter/part/KPrSlidesSorterDocumentModel.h \
b/kpresenter/part/KPrSlidesSorterDocumentModel.h index 70c1aac..a5b65a4 100644
--- a/kpresenter/part/KPrSlidesSorterDocumentModel.h
+++ b/kpresenter/part/KPrSlidesSorterDocumentModel.h
@@ -50,6 +50,8 @@ public:
 
     QVariant data(const QModelIndex &index, int role) const;
 
+    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = \
Qt::EditRole); +
     int rowCount(const QModelIndex &parent) const;
 
     virtual QStringList mimeTypes() const;
diff --git a/kpresenter/part/KPrViewModeSlidesSorter.cpp \
b/kpresenter/part/KPrViewModeSlidesSorter.cpp index 2b9c8b6..dc10bfd 100644
--- a/kpresenter/part/KPrViewModeSlidesSorter.cpp
+++ b/kpresenter/part/KPrViewModeSlidesSorter.cpp
@@ -335,6 +335,13 @@ void KPrViewModeSlidesSorter::addSlide()
     }
 }
 
+void KPrViewModeSlidesSorter::renameCurrentSlide()
+{
+    QModelIndexList selectedItems = \
m_slidesSorter->selectionModel()->selectedIndexes(); +    \
m_slidesSorter->edit(selectedItems.first()); +
+}
+
 void KPrViewModeSlidesSorter::editCut()
 {
     editCopy();
@@ -427,6 +434,12 @@ void \
                KPrViewModeSlidesSorter::slidesSorterContextMenu(QContextMenuEvent \
                *event)
     menu.addAction(KIcon("edit-copy"), i18n("Copy"), this,  SLOT(editCopy()));
     menu.addAction(KIcon("edit-paste"), i18n("Paste"), this, SLOT(editPaste()));
 
+    QModelIndexList selectedItems = \
m_slidesSorter->selectionModel()->selectedIndexes(); +
+    if (selectedItems.count() == 1 && selectedItems.first().isValid()) {
+        menu.addAction(KIcon("edit-rename"), i18n("Rename"), this, \
SLOT(renameCurrentSlide())); +    }
+
     menu.exec(event->globalPos());
 }
 
@@ -445,3 +458,20 @@ void KPrViewModeSlidesSorter::disableEditActions()
     ac->action("edit_cut")->setEnabled(false);
     ac->action("edit_delete")->setEnabled(false);
 }
+
+void KPrViewModeSlidesSorter::selectSlides(const QList<KoPAPageBase *> &slides)
+{
+    if (slides.isEmpty()) {
+        return;
+    }
+
+    m_slidesSorter->clearSelection();
+
+    foreach (KoPAPageBase *slide, slides) {
+        int row = m_view->kopaDocument()->pageIndex(slide);
+        QModelIndex index = m_documentModel->index(row, 0, QModelIndex());
+        if (index.isValid()) {
+            m_slidesSorter->selectionModel()->select(index, \
QItemSelectionModel::Select); +        }
+    }
+}
diff --git a/kpresenter/part/KPrViewModeSlidesSorter.h \
b/kpresenter/part/KPrViewModeSlidesSorter.h index 8a6d9f9..240bd9e 100644
--- a/kpresenter/part/KPrViewModeSlidesSorter.h
+++ b/kpresenter/part/KPrViewModeSlidesSorter.h
@@ -78,6 +78,12 @@ public:
      */
     QSize iconSize() const;
 
+    /**
+     * Clear selection and select a list of slides on slides sorter view
+     * @param slides list to be selected
+     */
+    void selectSlides(const QList<KoPAPageBase *> &slides);
+
 protected:
 
     /**
@@ -142,6 +148,9 @@ private slots:
     /** add a new slide after the current active page*/
     void addSlide();
 
+    /** Rename current slide on Slides Sorter View */
+    void renameCurrentSlide();
+
     /** cut the current selected slides*/
     void editCut();
 
_______________________________________________
kde-doc-english mailing list
kde-doc-english@kde.org
https://mail.kde.org/mailman/listinfo/kde-doc-english


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

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