Changeset 13400


Ignore:
Timestamp:
2012-10-16T10:49:20+02:00 (12 years ago)
Author:
hkiel
Message:

# 1836

  • added history of documentation viewer and backward/forward buttons to navigate
Location:
trunk/OMEdit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/OMEdit/OMEditGUI/DocumentationWidget.cpp

    r12926 r13400  
    5050  mpDocumentationViewer = new DocumentationViewer(this);
    5151  mpDocumentationEditor = new DocumentationEditor(this);
    52   setIsCustomModel(false);
     52  mpUrlHistory = new QList<UrlSrc>();
     53  mUrlHistoryPos = -1;
    5354  mpHeadingLabel = new QPlainTextEdit;
    5455  mpHeadingLabel->setObjectName("DocumentationLabel");
     
    6465  mpEditButton->setAutoDefault(true);
    6566  mpEditButton->setMaximumSize(QSize(120,20));
     67  mpEditButton->setVisible(false);
    6668  connect(mpEditButton, SIGNAL(clicked()), SLOT(editDocumentation()));
    6769  mpSaveButton = new QPushButton(Helper::save);
    6870  mpSaveButton->setAutoDefault(false);
    6971  mpSaveButton->setMaximumSize(QSize(100,20));
     72  mpSaveButton->setVisible(false);
    7073  connect(mpSaveButton, SIGNAL(clicked()), SLOT(saveChanges()));
     74  mpBackButton = new QPushButton(Helper::backwardBrush);
     75  mpBackButton->setAutoDefault(false);
     76  mpBackButton->setMaximumSize(QSize(120,20));
     77  mpBackButton->setVisible(false);
     78  connect(mpBackButton, SIGNAL(clicked()), SLOT(back()));
     79  mpForwardButton = new QPushButton(Helper::forwardBrush);
     80  mpForwardButton->setAutoDefault(false);
     81  mpForwardButton->setMaximumSize(QSize(120,20));
     82  mpForwardButton->setVisible(false);
     83  connect(mpForwardButton, SIGNAL(clicked()), SLOT(forward()));
    7184  QHBoxLayout *horizontalLayout = new QHBoxLayout;
    7285  horizontalLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    7386  horizontalLayout->addWidget(mpPixmapLabel);
    7487  horizontalLayout->addWidget(mpHeadingLabel);
    75   horizontalLayout->addWidget(mpSaveButton);
    76   horizontalLayout->addWidget(mpEditButton);
     88  QHBoxLayout *horizontalLayout2 = new QHBoxLayout;
     89  horizontalLayout2->setAlignment(Qt::AlignTop | Qt::AlignLeft);
     90  horizontalLayout2->addWidget(mpBackButton);
     91  horizontalLayout2->addWidget(mpForwardButton);
     92  QHBoxLayout *horizontalLayout3 = new QHBoxLayout;
     93  horizontalLayout3->setAlignment(Qt::AlignTop | Qt::AlignLeft);
     94  horizontalLayout3->addWidget(mpSaveButton);
     95  horizontalLayout3->addWidget(mpEditButton);
    7796  // set layout
    7897  QVBoxLayout *verticalLayout = new QVBoxLayout;
    7998  verticalLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    8099  verticalLayout->addLayout(horizontalLayout);
    81   verticalLayout->addWidget(mpDocumentationViewer);
    82   verticalLayout->addWidget(mpDocumentationEditor);
     100  verticalLayout->addLayout(horizontalLayout2);
     101  verticalLayout->addLayout(horizontalLayout3);
     102  verticalLayout->addWidget(mpDocumentationViewer,1);
     103  verticalLayout->addWidget(mpDocumentationEditor,1);
    83104  setLayout(verticalLayout);
     105  mpDocumentationViewer->setVisible(false);
     106  mpDocumentationEditor->setVisible(false);
     107  mpPixmapLabel->setVisible(false);
    84108}
    85109
     
    94118//! Shows the documentation of a model
    95119//! @param className the model name
    96 void DocumentationWidget::show(QString className)
     120void DocumentationWidget::show(QString className, bool isCustomModel)
    97121{
    98122  mClassName = className;
     
    110134  }
    111135  // show edit and save buttons if show is called for a custom model
    112   if (isCustomModel())
     136  if (isCustomModel)
    113137  {
    114138    mpEditButton->setVisible(true);
    115     mpEditButton->setDisabled(false);
     139    //mpEditButton->setDisabled(false);
     140    mpEditButton->setText(Helper::edit);
    116141    mpSaveButton->setVisible(true);
    117142    mpSaveButton->setDisabled(true);
     
    135160  mDocumentationFile.close();
    136161
     162  if ((mUrlHistoryPos >= 0) && (className == mpUrlHistory->at(mUrlHistoryPos).url))
     163  {
     164    /* reload url */
     165  }
     166  else
     167  {
     168    /* new url */
     169    /* remove all following urls */
     170    while (mpUrlHistory->count() > (mUrlHistoryPos+1))
     171    {
     172      mpUrlHistory->removeLast();
     173    }
     174    /* append new url */
     175    mpUrlHistory->append(UrlSrc(className, isCustomModel));
     176    mUrlHistoryPos++;
     177  }
     178  if (mUrlHistoryPos > 0)
     179  {
     180      mpBackButton->setDisabled(false);
     181  }
     182  else
     183  {
     184      mpBackButton->setDisabled(true);
     185  }
     186  if (mpUrlHistory->count() == (mUrlHistoryPos+1))
     187  {
     188      mpForwardButton->setDisabled(true);
     189  }
     190  else
     191  {
     192      mpForwardButton->setDisabled(false);
     193  }
     194
    137195  mpDocumentationViewer->setUrl(mDocumentationFile.fileName());
    138196  mpDocumentationViewer->setVisible(true);
    139   mpDocumentationEditor->setVisible(false);
     197  mpBackButton->setVisible(true);
     198  mpForwardButton->setVisible(true);
     199
     200  mpDocumentationEditor->hide();
    140201}
    141202
     
    146207  mpDocumentationViewer->hide();
    147208  // get the already existing documentation text of the model
    148   mpDocumentationEditor->toPlainText();
    149   if (!mpParentMainWindow->mpOMCProxy->getDocumentationAnnotation(className).isEmpty())
    150     mpDocumentationEditor->setPlainText(mpParentMainWindow->mpOMCProxy->getDocumentationAnnotation(className));
     209  QString doc = mpParentMainWindow->mpOMCProxy->getDocumentationAnnotation(className);
     210  if (!doc.isEmpty())
     211    mpDocumentationEditor->setPlainText(doc);
    151212  else
    152213    mpDocumentationEditor->setPlainText("<html>\n\n</html>");
    153214  mpDocumentationEditor->setFocus();
    154215  mpDocumentationEditor->show();
    155 }
    156 
    157 //! Sets the model as custom model.
    158 //! @param isCustomModel
    159 void DocumentationWidget::setIsCustomModel(bool isCustomModel)
    160 {
    161   mIsCustomModel = isCustomModel;
    162 }
    163 
    164 //! Returns true if the model is a custom model.
    165 //! @return bool true if model is a custom model
    166 bool DocumentationWidget::isCustomModel()
    167 {
    168   return mIsCustomModel;
    169216}
    170217
     
    183230void DocumentationWidget::editDocumentation()
    184231{
    185   showDocumentationEditView(mClassName);
    186   mpEditButton->setDisabled(true);
    187   mpSaveButton->setDisabled(false);
     232  if (mpSaveButton->isEnabled() == false)
     233  {
     234    showDocumentationEditView(mClassName);
     235    //mpEditButton->setDisabled(true);
     236    mpEditButton->setText(Helper::cancel);
     237    mpSaveButton->setDisabled(false);
     238    mpBackButton->setDisabled(true);
     239    mpForwardButton->setDisabled(true);
     240  }
     241  else
     242  {
     243    show(mClassName,true);
     244  }
    188245}
    189246
     
    195252  {
    196253    mpParentMainWindow->mpOMCProxy->addClassAnnotation(mClassName,"annotate=Documentation(info = \""+StringHandler::escape(doc)+"\")");
    197     show(mClassName);
     254    show(mClassName,true);
    198255  }
    199256  else
     
    202259    mpParentMainWindow->mpMessageWidget->addGUIProblem(new ProblemItem("", false, 0, 0, 0, 0, message, Helper::scriptingKind,
    203260                                                                       Helper::errorLevel, 0, mpParentMainWindow->mpMessageWidget->mpProblem));
     261  }
     262}
     263
     264//! Go to previous document
     265void DocumentationWidget::back()
     266{
     267  if (mUrlHistoryPos > 0)
     268  {
     269      mUrlHistoryPos--;
     270      show(mpUrlHistory->at(mUrlHistoryPos).url,mpUrlHistory->at(mUrlHistoryPos).isCustomModel);
     271  }
     272}
     273
     274//! Go to next document
     275void DocumentationWidget::forward()
     276{
     277  if ((mUrlHistoryPos+1) < mpUrlHistory->count())
     278  {
     279      mUrlHistoryPos++;
     280      show(mpUrlHistory->at(mUrlHistoryPos).url,mpUrlHistory->at(mUrlHistoryPos).isCustomModel);
    204281  }
    205282}
     
    266343    className = url.toString().mid(10, url.toString().length() - 1);
    267344    // send the new className to DocumentationWidget
    268     mpParentDocumentationWidget->show(className);
     345    mpParentDocumentationWidget->show(className, false);
    269346  }
    270347  // if it is normal http request then check if its not redirected to https
     
    325402{
    326403    Q_UNUSED(type);
    327  
     404
    328405    QWebView *webView = new QWebView;
    329406    QWebPage *newWeb = new QWebPage(webView);
     
    331408    webView->setPage(newWeb);
    332409    webView->show();
    333  
     410
    334411    return webView;
    335412}
  • trunk/OMEdit/OMEditGUI/DocumentationWidget.h

    r12926 r13400  
    4747class DocumentationEditor;
    4848
     49class UrlSrc
     50{
     51public:
     52    QString url;
     53    bool    isCustomModel;
     54
     55    UrlSrc(QString u, bool i){url = u; isCustomModel = i;}
     56};
     57
    4958class DocumentationWidget : public QWidget
    5059{
    5160  Q_OBJECT
    5261private:
    53   bool mIsCustomModel;
     62  QList<UrlSrc> * mpUrlHistory;
     63  int mUrlHistoryPos;
    5464public slots:
    5565  void editDocumentation();
    5666  void saveChanges();
     67  void back();
     68  void forward();
    5769public:
    5870  DocumentationWidget(MainWindow *pParent);
    5971  ~DocumentationWidget();
    60   void show(QString className);
     72  void show(QString className, bool isCustomModel);
    6173  void showDocumentationEditView(QString className);
    62   void setIsCustomModel(bool isCustomModel);
    63   bool isCustomModel();
    6474
    6575  MainWindow *mpParentMainWindow;
     
    7080  QPushButton *mpEditButton;
    7181  QPushButton *mpSaveButton;
     82  QPushButton *mpForwardButton;
     83  QPushButton *mpBackButton;
    7284  QDialogButtonBox *mpButtonBox;
    7385  QFile mDocumentationFile;
  • trunk/OMEdit/OMEditGUI/LibraryWidget.cpp

    r11739 r13400  
    875875  pMainWindow->mpDocumentationDockWidget->show();
    876876  LibraryTreeNode *pItem = dynamic_cast<LibraryTreeNode*>(mpParentLibraryWidget->mSelectedLibraryNode);
    877   pMainWindow->mpDocumentationWidget->setIsCustomModel(false);
    878   pMainWindow->mpDocumentationWidget->show(pItem->mNameStructure);
     877  pMainWindow->mpDocumentationWidget->show(pItem->mNameStructure,false);
    879878}
    880879
  • trunk/OMEdit/OMEditGUI/ProjectTabWidget.cpp

    r11739 r13400  
    888888
    889889void GraphicsView::createBitmapShape(QPointF point)
    890 {       
     890{
    891891  if (mpParentProjectTab->isReadOnly())
    892892    return;
     
    17441744{
    17451745  mpParentProjectTabWidget->mpParentMainWindow->mpDocumentationDockWidget->show();
    1746   mpParentProjectTabWidget->mpParentMainWindow->mpDocumentationWidget->setIsCustomModel(true);
    1747   mpParentProjectTabWidget->mpParentMainWindow->mpDocumentationWidget->show(mModelNameStructure);
     1746  mpParentProjectTabWidget->mpParentMainWindow->mpDocumentationWidget->show(mModelNameStructure,true);
    17481747}
    17491748
  • trunk/OMEdit/README.txt

    r13271 r13400  
    2323  - Load the file OMEditGUI/OMEditGUI.pro in Qt Creator IDE. Qt Creator is included in Qt SDK.
    2424  - Build and run the project.
    25   - Copy omniORB416_rt.dll, omniORB416_rtd.dll, omnithread34_rt.dll and omnithread34_rtd.dll from c:/OMDev/omniORB-4.1.6-mingw/bin/x86_win32 to /location-where-OMEdit.exe-is-created.
    26   - Copy qwt5.dll and qwtd5.dll from c:/OMDev/qwt-5.2.1-mingw/lib to /location-where-OMEdit.exe-is-created.
     25  - Copy omniORB416_rt.dll, omniORB416_rtd.dll, omnithread34_rt.dll and omnithread34_rtd.dll from c:/OMDev/lib/omniORB-4.1.6-mingw/bin/x86_win32 to /location-where-OMEdit.exe-is-created.
     26  - Copy qwt5.dll and qwtd5.dll from c:/OMDev/lib/qwt-5.2.1-mingw/lib to /location-where-OMEdit.exe-is-created.
    2727
    2828Linux
Note: See TracChangeset for help on using the changeset viewer.