OSDN Git Service

[denncoCreator] Implementing plugin cell editing functionality. The work is in progress.
authortkawata <tkawata@users.sourceforge.jp>
Thu, 31 Jan 2013 15:14:40 +0000 (00:14 +0900)
committertkawata <tkawata@users.sourceforge.jp>
Thu, 31 Jan 2013 15:14:40 +0000 (00:14 +0900)
Source/dccontainer.cpp
Source/dialog/dcrenamecelldialog.cpp
Source/dialog/dcrenamecelldialog.h
Source/visualizer/toolwindow/dctoolwindowcelleditor.cpp

index 5feb69e..e2c0671 100644 (file)
@@ -102,11 +102,11 @@ bool DCContainer::isScriptableCell(DCCell *cell) const
     }
     else if (type == CELLTYPE_PLUGIN_IN)
     {
-        noScript = false;
+        noScript = true;
     }
     else if (type == CELLTYPE_PLUGIN_OUT)
     {
-        noScript = false;
+        noScript = true;
     }
     else
     {
index c026baa..e0d6034 100644 (file)
 #include "utils/dcqtitemmodel.h"
 #include "dcsinglecolumntableview.h"
 #include "DNUtils.h"
+#include "dnplugininfo.h"
 
 #include <QLineEdit>
 #include <QTableView>
 #include <QHeaderView>
 
   DCRenameCellDialog::DCRenameCellDialog(DCContainer *container, DCCreator *creator, DCCell *cell, QWidget *parent) :
-      QDialog(parent), d_container(container), d_creator(creator), d_cell(cell)
+      QDialog(parent), d_container(container), d_creator(creator), d_cell(cell), d_pluginLibraryNameComboBox(NULL)
 {
     setWindowTitle(tr("Rename cell"));
 
     d_textField = new QLineEdit;
-    d_textField->setText(QString::fromStdString(cell->getName()));
+    if (d_container->getIsPluginType(cell->getType()))
+    {
+        d_pluginLibraryNameComboBox = new QComboBox;
+        d_pluginLibraryNameComboBox->setEditable(true);
+        d_pluginLibraryNameComboBox->addItems(d_container->getAvailablePluginLibraries());
+
+        DNPluginInfo info = DNPluginInfo::create(cell->getName());
+        d_textField->setText(QString::fromStdString(info.pluginValueName));
+        d_pluginLibraryNameComboBox->setEditText(QString::fromStdString(info.pluginName));
+    }
+    else
+    {
+        d_textField->setText(QString::fromStdString(cell->getName()));
+    }
 
     d_table = new DCSingleColumnTableView();
     QStringList headers;
     QGridLayout *glayout = new QGridLayout;
     glayout->addWidget(new QLabel(tr("name")),0,0);
     glayout->addWidget(d_textField,0,1);
+    if (d_pluginLibraryNameComboBox)
+    {
+        glayout->addWidget(new QLabel(tr("plugin")),1,0);
+        glayout->addWidget(d_pluginLibraryNameComboBox,1,1);
+    }
     ((QVBoxLayout*)layout())->addLayout(glayout);
     layout()->addWidget(d_table);
     d_statusText = new QLabel;
     connect(d_cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonClicked()));
     connect(d_table,SIGNAL(selectionChangedSignal(QItemSelection,QItemSelection)), this, SLOT(listSelectionChanged(QItemSelection,QItemSelection)));
     connect(d_creator, SIGNAL(commandExecuted(const QUndoCommand*)), this, SLOT(commandExecuted(const QUndoCommand*)));
+    connect(d_pluginLibraryNameComboBox, SIGNAL(editTextChanged(QString)),this, SLOT(pluginNameChanged(QString)));
 
     if (selection >= 0)
     {
@@ -109,36 +129,68 @@ DCRenameCellDialog::~DCRenameCellDialog()
 
 bool DCRenameCellDialog::checkInput()
 {
+    bool valid = true;
+
     d_message->setText("");
     d_statusText->setText("");
     if (d_selectedPagePath.length() == 0)
     {
         d_message->setText(tr("Select a page to place the cell"));
+        valid = false;
     }
     else if (d_textField->text().length() > 0)
     {
-        std::string path = getFQNString(d_selectedPagePath.toLocal8Bit().data(), d_textField->text().toLocal8Bit().data());
+        QString name;
+        if (d_container->getIsPluginType(d_cell->getType()))
+        {
+            if (d_pluginLibraryNameComboBox->currentText().length() == 0)
+            {
+                d_message->setText(tr("Input plugin name"));
+                valid = false;
+            }
+            else
+            {
+                name = d_container->createPluginCellName(d_textField->text(), d_cell->getType(),d_pluginLibraryNameComboBox->currentText());
+            }
+        }
+        else
+        {
+            name = d_textField->text();
+        }
+
+        std::string path = getFQNString(d_selectedPagePath.toLocal8Bit().data(), name.toLocal8Bit().data());
         TKCell *cell = d_container->getCell(path);
         if (cell)
         {
             if (cell != d_cell)
+            {
                 d_message->setText(tr("The cell name exists"));
+                valid = false;
+            }
         }
         else
         {
             d_statusText->setText(QString::fromStdString(path));
-            d_okButton->setEnabled(true);
-            d_okButton->setDefault(true);
-            return true;
         }
     }
     else
     {
         d_message->setText(tr("Input cell name"));
+        valid = false;
     }
-    d_okButton->setEnabled(false);
-    d_cancelButton->setDefault(true);
-    return false;
+
+    if (valid)
+    {
+        d_okButton->setEnabled(true);
+        d_okButton->setDefault(true);
+    }
+    else
+    {
+        d_okButton->setEnabled(false);
+        d_cancelButton->setDefault(true);
+    }
+
+    return valid;
 }
 
 void DCRenameCellDialog::textInputChanged(const QString &text)
@@ -152,7 +204,17 @@ void DCRenameCellDialog::okButtonClicked()
 {
     if (checkInput())
     {
-        d_creator->doCommandRenameCell(this, d_cell, d_selectedPagePath, d_textField->text());
+        QString newName;
+        if (d_container->getIsPluginType(d_cell->getType()))
+        {
+            newName = d_container->createPluginCellName(d_textField->text(), d_cell->getType(), d_pluginLibraryNameComboBox->currentText());
+        }
+        else
+        {
+            newName = d_textField->text();
+        }
+
+        d_creator->doCommandRenameCell(this, d_cell, d_selectedPagePath, newName);
     }
 }
 
@@ -177,6 +239,12 @@ void DCRenameCellDialog::listSelectionChanged(const QItemSelection &selected, co
     checkInput();
 }
 
+void DCRenameCellDialog::pluginNameChanged(const QString &text)
+{
+    (void)text;
+    checkInput();
+}
+
 void DCRenameCellDialog::commandExecuted(const QUndoCommand *executedCommand)
 {
     const DCCommand *command = dynamic_cast<const DCCommand*>(executedCommand);
index 2c73d17..a410bf8 100644 (file)
@@ -45,6 +45,7 @@ private:
     QPushButton                 *d_cancelButton;
     QString                     d_selectedPagePath;
     QLineEdit                   *d_textField;
+    QComboBox                   *d_pluginLibraryNameComboBox;
     QLabel                      *d_statusText;
     QLabel                      *d_message;
 
@@ -62,6 +63,7 @@ private slots:
     void okButtonClicked();
     void cancelButtonClicked();
     void listSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
+    void pluginNameChanged(const QString& text);
     void commandExecuted(const QUndoCommand* executedCommand);
 
 };
index b8fa801..bb04275 100644 (file)
@@ -377,7 +377,14 @@ void DCToolWindowCellEditor::updateView()
         }
 
         d_comboType->updateSelection();
-        d_comboType->setEnabled(!d_cell->getIsCellCodeAssgined());
+        if (container->getIsPluginType(d_cell->getType()))
+        {
+            d_comboType->setEnabled(false);
+        }
+        else
+        {
+            d_comboType->setEnabled(!d_cell->getIsCellCodeAssgined());
+        }
 
         d_textPage->setText(QString::fromStdString(d_cell->getLocation()));