]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide editing of toolbars
authorvsv <vsv@opencascade.com>
Thu, 1 Nov 2018 10:49:01 +0000 (13:49 +0300)
committervsv <vsv@opencascade.com>
Thu, 1 Nov 2018 10:49:01 +0000 (13:49 +0300)
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h
src/SHAPERGUI/SHAPERGUI_ToolbarsMgr.cpp
src/SHAPERGUI/SHAPERGUI_ToolbarsMgr.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/arrow-down.png [new file with mode: 0644]
src/XGUI/pictures/arrow-left.png [new file with mode: 0644]
src/XGUI/pictures/arrow-right.png [new file with mode: 0644]
src/XGUI/pictures/arrow-up.png [new file with mode: 0644]

index 0959e9cacbb19d718bc711876efb3d8376950e5e..53c7fcbbf83d608f45ca3f0cce196a810aeb3e1e 100644 (file)
@@ -67,6 +67,7 @@
 #include <QAction>
 #include <QTimer>
 #include <QMenu>
+#include <QToolBar>
 
 #define SALOME_PATCH_FOR_CTRL_WHEEL
 
@@ -571,7 +572,6 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theTBNam
     createTool(separator(), aWBTool);
     registerCommandToolbar(theTBName, -1);
   }
-
   return aAction;
 }
 
@@ -641,6 +641,7 @@ void SHAPERGUI::addDesktopMenuSeparator(const char* theMenuSourceText, const int
   createMenu(separator(), aMenu, -1, theMenuPosition);
 }
 
+//******************************************************
 bool SHAPERGUI::addActionInToolbar( QAction* theAction, const QString& theToolBarTitle )
 {
   if( !theAction )
@@ -812,8 +813,10 @@ void SHAPERGUI::updateModuleVisibilityState()
 
 void SHAPERGUI::onEditToolbars()
 {
-  SHAPERGUI_ToolbarsDlg aDlg(this, myActionsList, myToolbars);
-  aDlg.exec();
+  SHAPERGUI_ToolbarsDlg aDlg(this);
+  if (aDlg.exec() == QDialog::Accepted) {
+    updateToolbars(aDlg.result());
+  }
 }
 
 void SHAPERGUI::registerCommandToolbar(const QString& theToolName, int theCommandId)
@@ -828,7 +831,67 @@ int SHAPERGUI::getNextCommandId() const
   QtxActionMenuMgr* aMenuMgr = menuMgr();
   QIntList aIds = aMenuMgr->idList();
   int aId = aIds.count();
-  while (aIds.contains(aId))
+  while (action(aId) || myActionsList.contains(aId))
     aId++;
   return aId;
 }
+
+void SHAPERGUI::updateToolbars(const QMap<QString, QIntList>& theNewToolbars)
+{
+  QtxActionToolMgr* aMgr = toolMgr();
+  QStringList aToolbars = theNewToolbars.keys();
+  QIntList aCommands, aOldCmd;
+  int aToolbarId;
+  QAction* aAction;
+  int aActionId;
+  foreach(QString aName, aToolbars) {
+    aCommands = theNewToolbars[aName];
+    // Find or create toolbar
+    if (aMgr->hasToolBar(aName)) {
+      aToolbarId = aMgr->find(aMgr->toolBar(aName));
+      aOldCmd = myToolbars[aName];
+    }
+    else {
+      aToolbarId = aMgr->createToolBar(aName);
+    }
+    int aPos = 0;
+    foreach (int aCmd, aCommands) {
+      // Find action
+      if (aCmd == -1)
+        aAction = separator();
+      else
+        aAction = action(aCmd);
+      aActionId = aMgr->actionId(aAction);
+      if (aActionId == -1) {
+        // Add new action
+        aMgr->insert(aAction, aToolbarId, aPos);
+      }
+      else {
+        // Change position of action
+        if (aMgr->index(aActionId, aToolbarId) != aPos) {
+          if (aMgr->containsAction(aActionId, aToolbarId))
+            aMgr->remove(aActionId, aToolbarId);
+          aMgr->insert(aActionId, aToolbarId, aPos);
+        }
+      }
+      aOldCmd.removeAll(aCmd);
+      aPos++;
+    }
+    // remove extra actions
+    foreach(int aCmd, aOldCmd) {
+      aAction = action(aCmd);
+      aActionId = aMgr->actionId(aAction);
+      aMgr->remove(aActionId, aToolbarId);
+    }
+    myToolbars.remove(aName);
+  }
+  // Remove extra toolbars
+  aToolbars = myToolbars.keys();
+  QToolBar* aToolbar = 0;
+  QList<QAction*> aActionList;
+  foreach(QString aName, aToolbars) {
+    aMgr->removeToolBar(aName);
+  }
+  // Set new toolbars structure
+  myToolbars = theNewToolbars;
+}
index 8c06ccf46de0382acd93211f87eb8a0e6791d66c..afcc55bf61be8718fb433ff0ec3accf8fea63e74 100644 (file)
@@ -156,6 +156,11 @@ Q_OBJECT
 
   virtual void updateModuleVisibilityState();
 
+
+  QIntList shaperActions() const { return myActionsList; }
+  QMap<QString, QIntList> shaperToolbars() const { return myToolbars; }
+
+
  public slots:
   /// \brief The method is redefined to connect to the study viewer before the data
   /// model is filled by opened file. This file open will flush redisplay signals for,
@@ -218,6 +223,8 @@ private slots:
 
   int getNextCommandId() const;
 
+  // Update current toolbars
+  void updateToolbars(const QMap<QString, QIntList>& theNewToolbars);
 
   /// List of registered nested actions
   QStringList myNestedActionsList;
index 337871cdb73e03491f3d5be512b5ac231b7b854e..673bab04eec7f8409a38fb6294c87b5098e6f92f 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <CAM_Application.h>
 #include <SUIT_Desktop.h>
+#include <QtxActionToolMgr.h>
 
 #include <QLayout>
 #include <QDialogButtonBox>
 #include <QPushButton>
 #include <QInputDialog>
 #include <QMessageBox>
+#include <QMouseEvent>
 
 
+#define SEPARATOR "------"
+#define LIST_WIDTH 180
+
 class SHAPERGUI_CommandIdItem : public QListWidgetItem
 {
 public:
@@ -41,17 +46,28 @@ public:
 
 
   virtual QVariant data(int theRole) const {
-    if (theRole == Qt::DisplayRole) {
-      if (myId == -1)
-        return "------";
-      QAction* aAction = myModule->action(myId);
+    QAction* aAction = 0;
+    if (myId != -1)
+      aAction = myModule->action(myId);
+
+    switch (theRole) {
+    case Qt::DisplayRole:
       if (aAction)
         return aAction->text();
+      else
+        return SEPARATOR;
+    case Qt::DecorationRole:
+      if (aAction)
+        return aAction->icon();
+      else
+        return QIcon();
     }
     return QListWidgetItem::data(theRole);
   }
 
 
+  int id() const { return myId; }
+
 private:
   SHAPERGUI* myModule;
   int myId;
@@ -61,14 +77,13 @@ private:
 //************************************************************************************
 //************************************************************************************
 //************************************************************************************
-SHAPERGUI_ToolbarsDlg::SHAPERGUI_ToolbarsDlg(SHAPERGUI* theModule,
-  const QIntList& theActionsList,
-  const QMap<QString, QIntList>& theToolbars)
+SHAPERGUI_ToolbarsDlg::SHAPERGUI_ToolbarsDlg(SHAPERGUI* theModule)
   : QDialog(theModule->application()->desktop()),
   myModule(theModule),
-  myActionsList(theActionsList),
-  myToolbars(theToolbars)
+  myResult(theModule->shaperToolbars())
 {
+  myFreeCommands = getModuleFreeCommands();
+
   setWindowTitle(tr("Toolbars"));
   QVBoxLayout* aMailLayout = new QVBoxLayout(this);
 
@@ -87,9 +102,19 @@ SHAPERGUI_ToolbarsDlg::SHAPERGUI_ToolbarsDlg(SHAPERGUI* theModule,
   aListLayout->addWidget(new QLabel(tr("Toolbars:"), aListWgt));
 
   myToolbarsList = new QListWidget(aListWgt);
-  myToolbarsList->addItems(theToolbars.keys());
+  connect(myToolbarsList, SIGNAL(doubleClicked(const QModelIndex&)),
+    SLOT(onDoubleClick(const QModelIndex&)));
   aListLayout->addWidget(myToolbarsList);
 
+  QWidget* aFreeItemsWgt = new QWidget(aListWgt);
+  QHBoxLayout* aFreeLayout = new QHBoxLayout(aFreeItemsWgt);
+  aFreeLayout->setContentsMargins(0, 0, 0, 0);
+  aListLayout->addWidget(aFreeItemsWgt);
+
+  aFreeLayout->addWidget(new QLabel(tr("Number of commands out of toolbars:"), aFreeItemsWgt));
+  myFreeNbLbl = new QLabel(aFreeItemsWgt);
+  aFreeLayout->addWidget(myFreeNbLbl);
+
   // Left controls
   QWidget* aButtonsWgt = new QWidget(aControlsWgt);
   QVBoxLayout* aBtnLayout = new QVBoxLayout(aButtonsWgt);
@@ -115,6 +140,9 @@ SHAPERGUI_ToolbarsDlg::SHAPERGUI_ToolbarsDlg(SHAPERGUI* theModule,
   aMailLayout->addWidget(aButtons);
   connect(aButtons, SIGNAL(accepted()), SLOT(accept()));
   connect(aButtons, SIGNAL(rejected()), SLOT(reject()));
+
+  updateToolbarsList();
+  updateNumber();
 }
 
 void SHAPERGUI_ToolbarsDlg::onAdd()
@@ -122,8 +150,8 @@ void SHAPERGUI_ToolbarsDlg::onAdd()
   QString aNewToolbar =
     QInputDialog::getText(this, tr("Create toolbar"), tr("Name of a new toolbar"));
   if (!(aNewToolbar.isNull() || aNewToolbar.isEmpty())) {
-    if (!myToolbars.contains(aNewToolbar)) {
-      myToolbars[aNewToolbar] = QIntList();
+    if (!myResult.contains(aNewToolbar)) {
+      myResult[aNewToolbar] = QIntList();
       updateToolbarsList();
     }
     else {
@@ -138,10 +166,17 @@ void SHAPERGUI_ToolbarsDlg::onEdit()
   QList<QListWidgetItem*> aSelected = myToolbarsList->selectedItems();
   if (aSelected.size() == 1) {
     QString aToolbarName = aSelected.first()->text();
-    QIntList aFreeItems = getFreeCommands();
+    int aPos = aToolbarName.lastIndexOf(" (");
+    aToolbarName = aToolbarName.left(aPos);
+
     SHAPERGUI_ToolbarItemsDlg aDlg(this, myModule,
-      aToolbarName, aFreeItems, myToolbars[aToolbarName]);
-    aDlg.exec();
+      aToolbarName, myFreeCommands, myResult[aToolbarName]);
+    if (aDlg.exec() == QDialog::Accepted) {
+      myFreeCommands = aDlg.freeItems();
+      myResult[aToolbarName] = aDlg.toolbarItems();
+      updateNumber();
+      updateToolbarsList();
+    }
   }
 }
 
@@ -150,10 +185,17 @@ void SHAPERGUI_ToolbarsDlg::onDelete()
   QList<QListWidgetItem*> aSelected = myToolbarsList->selectedItems();
   if (aSelected.size() == 1) {
     QString aToolbarName = aSelected.first()->text();
+    int aPos = aToolbarName.lastIndexOf(" (");
+    aToolbarName = aToolbarName.left(aPos);
+
     QString aMsg = tr("Toolbar %1 will be deleted. Continue?").arg(aToolbarName);
     if (QMessageBox::question(this, tr("Delete toolbar"), aMsg) == QMessageBox::Yes) {
-      myToolbars.remove(aToolbarName);
+      myFreeCommands.append(myResult[aToolbarName]);
+      // remove separators from free items
+      myFreeCommands.removeAll(-1);
+      myResult.remove(aToolbarName);
       updateToolbarsList();
+      updateNumber();
     }
   }
 }
@@ -161,28 +203,43 @@ void SHAPERGUI_ToolbarsDlg::onDelete()
 void SHAPERGUI_ToolbarsDlg::updateToolbarsList()
 {
   myToolbarsList->clear();
-  myToolbarsList->addItems(myToolbars.keys());
+  QStringList aItems;
+  QMap<QString, QIntList>::const_iterator aIt;
+  for (aIt = myResult.cbegin(); aIt != myResult.cend(); aIt++) {
+    aItems.append(aIt.key() + tr(" (%1 items)").arg(aIt.value().size() - aIt.value().count(-1)));
+  }
+  myToolbarsList->addItems(aItems);
 }
 
-QIntList SHAPERGUI_ToolbarsDlg::getFreeCommands() const
+QIntList SHAPERGUI_ToolbarsDlg::getModuleFreeCommands() const
 {
   QIntList aFreeCommands;
+  QtxActionToolMgr* aMgr = myModule->toolMgr();
+  QAction* anAction;
+  int aId;
   QMap<QString, QIntList>::const_iterator aIt;
-  foreach(int aCmd, myActionsList) {
-    bool aIsFree = true;
-    for (aIt = myToolbars.cbegin(); aIt != myToolbars.cend(); aIt++) {
-      if (aIt.value().contains(aCmd)) {
-        aIsFree = false;
-        break;
-      }
-    }
-    if (aIsFree)
+  QIntList aShaperActions = myModule->shaperActions();
+  foreach(int aCmd, aShaperActions) {
+    anAction = myModule->action(aCmd);
+    aId = aMgr->actionId(anAction);
+    if (!aMgr->containsAction(aId))
       aFreeCommands.append(aCmd);
   }
   return aFreeCommands;
 }
 
 
+void SHAPERGUI_ToolbarsDlg::onDoubleClick(const QModelIndex& theIdx)
+{
+  if (theIdx.isValid())
+    onEdit();
+}
+
+void SHAPERGUI_ToolbarsDlg::updateNumber()
+{
+  myFreeNbLbl->setText(QString::number(myFreeCommands.size()));
+}
+
 //************************************************************************************
 //************************************************************************************
 //************************************************************************************
@@ -192,9 +249,7 @@ SHAPERGUI_ToolbarItemsDlg::SHAPERGUI_ToolbarItemsDlg(QWidget* theParent,
   const QIntList& theFreeItems,
   const QIntList& theItemsList)
   : QDialog(theParent),
-  myModule(theModule),
-  myFreeItems(theFreeItems),
-  myToolItems(theItemsList)
+  myModule(theModule)
 {
   setWindowTitle(tr("Edit toolbar items"));
 
@@ -228,10 +283,13 @@ SHAPERGUI_ToolbarItemsDlg::SHAPERGUI_ToolbarItemsDlg(QWidget* theParent,
 
   aCommandsLay->addWidget(new QLabel(tr("Out of toolbars:"), aCommandsWgt));
   myCommandsList = new QListWidget(aCommandsWgt);
-  foreach(int aId, myFreeItems) {
+  myCommandsList->setSortingEnabled(false);
+
+  myCommandsList->addItem(new SHAPERGUI_CommandIdItem(myCommandsList, -1, myModule));
+  foreach(int aId, theFreeItems) {
     myCommandsList->addItem(new SHAPERGUI_CommandIdItem(myCommandsList, aId, myModule));
   }
-  myCommandsList->setMaximumWidth(150);
+  myCommandsList->setMaximumWidth(LIST_WIDTH);
   aCommandsLay->addWidget(myCommandsList);
 
   // Middle buttons
@@ -241,13 +299,13 @@ SHAPERGUI_ToolbarItemsDlg::SHAPERGUI_ToolbarItemsDlg(QWidget* theParent,
   aCtrlLayout->addWidget(aButtonsWgt);
 
   aBtnLayout->addStretch(1);
-  QPushButton* aAddButton = new QPushButton("--->", aButtonsWgt);
+  QPushButton* aAddButton = new QPushButton(QIcon(":pictures/arrow-right.png"), "", aButtonsWgt);
   connect(aAddButton, SIGNAL(clicked(bool)), SLOT(onAddItem()));
   aBtnLayout->addWidget(aAddButton);
 
   aBtnLayout->addSpacing(20);
 
-  QPushButton* aDelButton = new QPushButton("<---", aButtonsWgt);
+  QPushButton* aDelButton = new QPushButton(QIcon(":pictures/arrow-left.png"), "", aButtonsWgt);
   connect(aDelButton, SIGNAL(clicked(bool)), SLOT(onDelItem()));
   aBtnLayout->addWidget(aDelButton);
   aBtnLayout->addStretch(1);
@@ -260,12 +318,32 @@ SHAPERGUI_ToolbarItemsDlg::SHAPERGUI_ToolbarItemsDlg(QWidget* theParent,
 
   aItemsLay->addWidget(new QLabel(tr("In the toolbar:"), aItemsWgt));
   myItemsList = new QListWidget(aItemsWgt);
-  foreach(int aId, myToolItems) {
+  myItemsList->setSortingEnabled(false);
+  foreach(int aId, theItemsList) {
     myItemsList->addItem(new SHAPERGUI_CommandIdItem(myItemsList, aId, myModule));
   }
-  myItemsList->setMaximumWidth(150);
+  myItemsList->setMaximumWidth(LIST_WIDTH);
+  myItemsList->viewport()->installEventFilter(this);
   aItemsLay->addWidget(myItemsList);
 
+  // Buttons of right list
+  QWidget* aBtnWgt = new QWidget(aControlsWgt);
+  QVBoxLayout* aBtnLay = new QVBoxLayout(aBtnWgt);
+  aBtnLay->setContentsMargins(0, 0, 0, 0);
+  aCtrlLayout->addWidget(aBtnWgt);
+
+  aBtnLay->addStretch(1);
+  QPushButton* aUpButton = new QPushButton(QIcon(":pictures/arrow-up.png"), "", aBtnWgt);
+  connect(aUpButton, SIGNAL(clicked(bool)), SLOT(onUp()));
+  aBtnLay->addWidget(aUpButton);
+
+  aBtnLay->addSpacing(20);
+
+  QPushButton* aDownButton = new QPushButton(QIcon(":pictures/arrow-down.png"), "", aBtnWgt);
+  connect(aDownButton, SIGNAL(clicked(bool)), SLOT(onDown()));
+  aBtnLay->addWidget(aDownButton);
+  aBtnLay->addStretch(1);
+
   // Buttons part of the dialog
   QDialogButtonBox* aButtons =
     new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
@@ -276,10 +354,101 @@ SHAPERGUI_ToolbarItemsDlg::SHAPERGUI_ToolbarItemsDlg(QWidget* theParent,
 
 void SHAPERGUI_ToolbarItemsDlg::onAddItem()
 {
-
+  QList<QListWidgetItem*> aCurrentList = myCommandsList->selectedItems();
+  if (aCurrentList.size() > 0) {
+    SHAPERGUI_CommandIdItem* aItem = dynamic_cast<SHAPERGUI_CommandIdItem*>(aCurrentList.first());
+    int aId = aItem->id();
+    if (aId != -1) {
+      myCommandsList->removeItemWidget(aItem);
+      delete aItem;
+    }
+    QModelIndex aIdx = myItemsList->currentIndex();
+    aItem = new SHAPERGUI_CommandIdItem(0, aId, myModule);
+    if (aIdx.isValid()) {
+      int aRow = aIdx.row();
+      myItemsList->insertItem(aRow, aItem);
+    }
+    else {
+      myItemsList->addItem(aItem);
+    }
+  }
 }
 
 void SHAPERGUI_ToolbarItemsDlg::onDelItem()
 {
+  QList<QListWidgetItem*> aCurrentList = myItemsList->selectedItems();
+  if (aCurrentList.size() > 0) {
+    SHAPERGUI_CommandIdItem* aItem = dynamic_cast<SHAPERGUI_CommandIdItem*>(aCurrentList.first());
+    int aId = aItem->id();
+    myItemsList->removeItemWidget(aItem);
+    delete aItem;
+    if (aId != -1) {
+      aItem = new SHAPERGUI_CommandIdItem(myCommandsList, aId, myModule);
+      myCommandsList->addItem(aItem);
+    }
+  }
+}
+
+
+bool SHAPERGUI_ToolbarItemsDlg::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+  if (theEvent->type() == QEvent::MouseButtonRelease) {
+    QMouseEvent* aMouseEvent = (QMouseEvent*)theEvent;
+    QModelIndex aIdx = myItemsList->indexAt(aMouseEvent->pos());
+    if (!aIdx.isValid() || aMouseEvent->button() == Qt::RightButton) {
+      myItemsList->setCurrentIndex(QModelIndex());
+    }
+  }
+  return QDialog::eventFilter(theObj, theEvent);
+}
+
+void SHAPERGUI_ToolbarItemsDlg::onUp()
+{
+  QModelIndex aCurrentIdx = myItemsList->currentIndex();
+  if (aCurrentIdx.isValid()) {
+    int aRow = aCurrentIdx.row();
+    if (aRow > 0) {
+      QListWidgetItem* aItem = myItemsList->takeItem(aRow);
+      aRow--;
+      myItemsList->insertItem(aRow, aItem);
+      myItemsList->setCurrentRow(aRow);
+    }
+  }
+}
+
+void SHAPERGUI_ToolbarItemsDlg::onDown()
+{
+  QModelIndex aCurrentIdx = myItemsList->currentIndex();
+  if (aCurrentIdx.isValid()) {
+    int aNb = myItemsList->count();
+    int aRow = aCurrentIdx.row();
+    if (aRow < (aNb - 1)) {
+      QListWidgetItem* aItem = myItemsList->takeItem(aRow);
+      aRow++;
+      myItemsList->insertItem(aRow, aItem);
+      myItemsList->setCurrentRow(aRow);
+    }
+  }
+}
 
-}
\ No newline at end of file
+QIntList SHAPERGUI_ToolbarItemsDlg::freeItems() const
+{
+  return getItems(myCommandsList, 1);
+}
+
+QIntList SHAPERGUI_ToolbarItemsDlg::toolbarItems() const
+{
+  return getItems(myItemsList, 0);
+}
+
+QIntList SHAPERGUI_ToolbarItemsDlg::getItems(QListWidget* theWidget, int theStart) const
+{
+  QIntList aList;
+  SHAPERGUI_CommandIdItem* aItem = 0;
+  int aNb = theWidget->count();
+  for (int i = theStart; i < aNb; i++) {
+    aItem = (SHAPERGUI_CommandIdItem*)theWidget->item(i);
+    aList.append(aItem->id());
+  }
+  return aList;
+}
index 1da7e8a2eb3bdb3f05f6fe61a5f09f7c8c04aa7e..9d6e77536227359c857014dc4850afd085f727f5 100644 (file)
 
 class QListWidget;
 class SHAPERGUI;
+class QLabel;
 
-
+/**
+* \ingroup Salome
+* A dialog box for editing of toolbar items
+*/
 class SHAPERGUI_ToolbarItemsDlg : public QDialog
 {
   Q_OBJECT
 public:
+  /// Constructor
+  /// \param theParent a parent for the dialog
+  /// \param theModule a module with toolbars
+  /// \param theToolbar a name of the toolbar for editing
+  /// \param theFreeItems a list of commands out of toolbars
+  /// \param theItemsList a list of command in the toolbar
   SHAPERGUI_ToolbarItemsDlg(QWidget* theParent,
     SHAPERGUI* theModule,
     const QString& theToolbar,
     const QIntList& theFreeItems,
     const QIntList& theItemsList);
 
+  /// Returns list of free commands
+  QIntList freeItems() const;
+
+  /// Returns list of commands in the toolbar
+  QIntList toolbarItems() const;
+
+protected:
+  /// An redifinition of a virtual function
+  /// \param theObj an object
+  /// \param theEvent an event
+  virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
+
 private slots:
+  /// A slot for button to add an item to toolbar commands
   void onAddItem();
+
+  /// A slot for button to remove an item from toolbar commands
   void onDelItem();
 
+  /// A slot to move a current item up in list of toolbar command
+  void onUp();
+
+  /// A slot to move a current item down in list of toolbar command
+  void onDown();
+
 private:
+  QIntList getItems(QListWidget* theWidget, int theStart) const;
+
   SHAPERGUI* myModule;
-  QIntList myFreeItems;
-  QIntList myToolItems;
 
   QListWidget* myCommandsList;
   QListWidget* myItemsList;
@@ -66,29 +97,42 @@ class SHAPERGUI_ToolbarsDlg : public QDialog
 {
   Q_OBJECT
 public:
-  SHAPERGUI_ToolbarsDlg(SHAPERGUI* theModule,
-    const QIntList& theActionsList,
-    const QMap<QString, QIntList>& theToolbars);
+  /// Constructor
+  /// \param theModule a SHAPER module
+  SHAPERGUI_ToolbarsDlg(SHAPERGUI* theModule);
 
-  QMap<QString, QIntList> result() const { return myToolbars; }
+  /// Returns result of editing
+  QMap<QString, QIntList> result() const { return myResult; }
 
 private slots:
+  /// A slot to add a new toolbar
   void onAdd();
 
+  /// A slot to edit a current toolbar
   void onEdit();
 
+  /// A slot to delete a current toolbar
   void onDelete();
 
+  /// A slot called on double click on item in list
+  void onDoubleClick(const QModelIndex& theIdx);
+
 private:
+  /// Update content of toolbars list
   void updateToolbarsList();
 
-  QIntList getFreeCommands() const;
+  /// Update number of free items
+  void updateNumber();
+
+  /// Returns free commands which are not in toolbars in the module
+  QIntList getModuleFreeCommands() const;
 
 private:
   SHAPERGUI* myModule;
-  QIntList myActionsList;
-  QMap<QString, QIntList> myToolbars;
+  QMap<QString, QIntList> myResult;
+  QIntList myFreeCommands;
 
+  QLabel* myFreeNbLbl;
   QListWidget* myToolbarsList;
 };
 
index ea9614f94e2b2d4bee5d4c0483a7c3b01981548b..8ea63a1e068ae987d4fc4780463334a7bcb332a9 100644 (file)
      <file>pictures/autoapply_start.png</file>
      <file>pictures/autoapply_stop.png</file>
      <file>pictures/whatis.png</file>
+
+     <file>pictures/arrow-left.png</file>
+     <file>pictures/arrow-right.png</file>
+     <file>pictures/arrow-up.png</file>
+     <file>pictures/arrow-down.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/arrow-down.png b/src/XGUI/pictures/arrow-down.png
new file mode 100644 (file)
index 0000000..b5d69ba
Binary files /dev/null and b/src/XGUI/pictures/arrow-down.png differ
diff --git a/src/XGUI/pictures/arrow-left.png b/src/XGUI/pictures/arrow-left.png
new file mode 100644 (file)
index 0000000..7895091
Binary files /dev/null and b/src/XGUI/pictures/arrow-left.png differ
diff --git a/src/XGUI/pictures/arrow-right.png b/src/XGUI/pictures/arrow-right.png
new file mode 100644 (file)
index 0000000..7d8f9ba
Binary files /dev/null and b/src/XGUI/pictures/arrow-right.png differ
diff --git a/src/XGUI/pictures/arrow-up.png b/src/XGUI/pictures/arrow-up.png
new file mode 100644 (file)
index 0000000..0ec1e0d
Binary files /dev/null and b/src/XGUI/pictures/arrow-up.png differ