From: arif Date: Fri, 25 Feb 2011 19:37:19 +0000 (+0000) Subject: gvedit dynamic attribute loading added X-Git-Tag: LAST_LIBGRAPH~32^2~993 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=81d724fc45db43169536b2b2321b61cc1169a227;p=graphviz gvedit dynamic attribute loading added --- diff --git a/cmd/gvedit/csettings.cpp b/cmd/gvedit/csettings.cpp index 12600fef3..ceddbfadf 100644 --- a/cmd/gvedit/csettings.cpp +++ b/cmd/gvedit/csettings.cpp @@ -2,9 +2,51 @@ #include "qmessagebox.h" #include "qfiledialog.h" #include +#include #include "mdichild.h" +#include "string.h" +#define WIDGET(t,f) ((t*)findChild(#f)) +bool loadAttrs(const QString fileName,QComboBox* cbNameG,QComboBox* cbNameN,QComboBox* cbNameE) +{ + QStringList lines; + QFile file(fileName); + if ( file.open(QIODevice::ReadOnly ) ) { + QTextStream stream( &file ); + QString line; + int i = 1; + while ( !stream.atEnd() ) { + line = stream.readLine(); // line of text excluding '\n' + if(line.left(1)==":") + { + QString attrName; + QStringList sl= line.split(":"); + for (int id=0;id < sl.count(); id ++) + { + if(id==1) + attrName=sl[id]; + if(id==2) + { + if(sl[id].contains("G")) + cbNameG->addItem(attrName); + if(sl[id].contains("N")) + cbNameN->addItem(attrName); + if(sl[id].contains("E")) + cbNameE->addItem(attrName); + } + printf ("%s\n",sl[id].constData()); + }; + } + } + file.close(); + } + return false; + + + + +} QString stripFileExtension(QString fileName) { int idx; @@ -44,6 +86,10 @@ CFrmSettings::CFrmSettings() connect(WIDGET(QPushButton,pbSave),SIGNAL(clicked()),this,SLOT(saveSlot())); connect(WIDGET(QPushButton,btnOK),SIGNAL(clicked()),this,SLOT(okSlot())); connect(WIDGET(QPushButton,pbOut),SIGNAL(clicked()),this,SLOT(outputSlot())); + connect(WIDGET(QComboBox,cbScope),SIGNAL(currentIndexChanged(int)),this,SLOT(scopeChangedSlot(int))); + + + loadAttrs("c:/graphviz-ms/bin/attrs.txt",WIDGET(QComboBox,cbNameG),WIDGET(QComboBox,cbNameN),WIDGET(QComboBox,cbNameE)); } void CFrmSettings::outputSlot() @@ -53,10 +99,28 @@ void CFrmSettings::outputSlot() if (!fileName.isEmpty()) WIDGET(QLineEdit,leOutput)->setText(fileName); } +void CFrmSettings::scopeChangedSlot(int id) +{ + WIDGET(QComboBox,cbNameG)->setVisible(id==0); + WIDGET(QComboBox,cbNameN)->setVisible(id==1); + WIDGET(QComboBox,cbNameE)->setVisible(id==2); +} void CFrmSettings::addSlot() { QString _scope=WIDGET (QComboBox,cbScope)->currentText(); - QString _name=WIDGET (QComboBox,cbName)->currentText(); + QString _name; + switch (WIDGET (QComboBox,cbScope)->currentIndex()) + { + case 0: + _name=WIDGET (QComboBox,cbNameG)->currentText(); + break; + case 1: + _name=WIDGET (QComboBox,cbNameN)->currentText(); + break; + case 2: + _name=WIDGET (QComboBox,cbNameE)->currentText(); + break; + } QString _value=WIDGET(QLineEdit,leValue)->text(); if (_value.trimmed().length() == 0) @@ -213,8 +277,6 @@ void CFrmSettings::refreshContent() WIDGET(QLineEdit,leOutput)->setText(stripFileExtension(activeWindow->currentFile())+ "."+WIDGET(QComboBox,cbExtension)->currentText()); WIDGET(QTextEdit,teAttributes)->setText(activeWindow->attributes); - WIDGET(QCheckBox,chbPreview)->setChecked(activeWindow->preview); - WIDGET(QCheckBox,chbCairo)->setChecked(activeWindow->applyCairo); WIDGET(QLineEdit,leValue)->setText(""); @@ -224,11 +286,8 @@ void CFrmSettings::saveContent() { activeWindow->layoutIdx=WIDGET(QComboBox,cbLayout)->currentIndex(); activeWindow->renderIdx=WIDGET(QComboBox,cbExtension)->currentIndex(); - activeWindow->outputFile=WIDGET(QLineEdit,leOutput)->text(); activeWindow->attributes=WIDGET(QTextEdit,teAttributes)->toPlainText(); - activeWindow->preview= WIDGET(QCheckBox,chbPreview)->isChecked(); - activeWindow->applyCairo= WIDGET(QCheckBox,chbCairo)->isChecked(); } int CFrmSettings::drawGraph() { diff --git a/cmd/gvedit/csettings.h b/cmd/gvedit/csettings.h index 532785fe1..b005699b3 100644 --- a/cmd/gvedit/csettings.h +++ b/cmd/gvedit/csettings.h @@ -12,7 +12,6 @@ class MdiChild; #endif #include "gvc.h" -#define WIDGET(t,f) ((t*)findChild(#f)) @@ -36,6 +35,7 @@ private slots: void newSlot(); void openSlot(); void saveSlot(); + void scopeChangedSlot(int); private: //Actions Agraph_t* graph; diff --git a/cmd/gvedit/mainwindow.cpp b/cmd/gvedit/mainwindow.cpp index 111c8e86e..824fd5c29 100644 --- a/cmd/gvedit/mainwindow.cpp +++ b/cmd/gvedit/mainwindow.cpp @@ -84,7 +84,7 @@ CMainWindow::CMainWindow() this, SLOT(slotRefreshMenus())); windowMapper = new QSignalMapper(this); connect(windowMapper, SIGNAL(mapped(QWidget*)), - this, SLOT(setActiveSubWindow(QWidget*))); + this, SLOT(activateChild(QWidget*))); frmSettings= new CFrmSettings(); @@ -392,7 +392,7 @@ void CMainWindow::actions() layoutAct = new QAction(QIcon(":/images/cut.png"),tr("Layout"), this); layoutAct->setStatusTip(tr("Layout the active graph")); - connect(layoutAct, SIGNAL(triggered()), this, SLOT(about())); + connect(layoutAct, SIGNAL(triggered()), this, SLOT(slotAbout())); } @@ -503,7 +503,7 @@ QMdiSubWindow *CMainWindow::findMdiChild(const QString &fileName) return 0; } -void CMainWindow::setActiveSubWindow(QWidget *window) +void CMainWindow::activateChild(QWidget *window) { if (!window) return; diff --git a/cmd/gvedit/mdi.vcproj b/cmd/gvedit/mdi.vcproj index 85c944ff0..56253105d 100644 --- a/cmd/gvedit/mdi.vcproj +++ b/cmd/gvedit/mdi.vcproj @@ -207,6 +207,10 @@ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -233,6 +237,10 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + + @@ -367,6 +375,10 @@ /> + + @@ -638,6 +650,32 @@ Filter="ui" UniqueIdentifier="{99349809-55BA-4b9d-BF79-8FDBB0286EB3}" > + + + + + + + + diff --git a/cmd/gvedit/mdi.vcproj.RESEARCH.arif.user b/cmd/gvedit/mdi.vcproj.RESEARCH.arif.user index f7aea540f..f69bb6e79 100644 --- a/cmd/gvedit/mdi.vcproj.RESEARCH.arif.user +++ b/cmd/gvedit/mdi.vcproj.RESEARCH.arif.user @@ -2,7 +2,7 @@ 0 0 - 405 + 403 512 @@ -19,7 +19,7 @@ 0 0 401 - 181 + 151 @@ -37,7 +37,7 @@ 10 10 381 - 161 + 131 @@ -244,66 +244,6 @@ - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Preview Output File - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Apply Cairo Filters - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -313,9 +253,9 @@ 0 - 180 + 150 401 - 71 + 61 @@ -324,20 +264,20 @@ QFrame::Raised - + - 10 + 2 0 - 381 - 62 + 391 + 61 - + @@ -372,33 +312,13 @@ - - - - color - - - - - Font - - - - - fontname - - - - - fontcolor - - - - - bgcolor - - - + + + + + + + @@ -480,9 +400,9 @@ 0 - 250 + 210 401 - 261 + 301 @@ -497,7 +417,7 @@ 7 6 391 - 251 + 291 diff --git a/cmd/gvedit/ui_settings.h b/cmd/gvedit/ui_settings.h index 8c7743107..87986c4f2 100644 --- a/cmd/gvedit/ui_settings.h +++ b/cmd/gvedit/ui_settings.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'settings.ui' ** -** Created: Thu Feb 24 12:31:24 2011 +** Created: Fri Feb 25 14:25:48 2011 ** by: Qt User Interface Compiler version 4.7.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -50,22 +49,17 @@ public: QLabel *label_2; QLineEdit *leOutput; QPushButton *pbOut; - QHBoxLayout *horizontalLayout_4; - QHBoxLayout *horizontalLayout_11; - QSpacerItem *horizontalSpacer_4; - QCheckBox *chbPreview; - QSpacerItem *horizontalSpacer_6; - QCheckBox *chbCairo; - QSpacerItem *horizontalSpacer_5; QFrame *frame_2; - QWidget *layoutWidget1; + QWidget *widget; QHBoxLayout *horizontalLayout_7; QVBoxLayout *verticalLayout_2; QHBoxLayout *horizontalLayout_5; QLabel *label_5; QComboBox *cbScope; QLabel *label_6; - QComboBox *cbName; + QComboBox *cbNameG; + QComboBox *cbNameN; + QComboBox *cbNameE; QHBoxLayout *horizontalLayout_6; QLabel *label_7; QLineEdit *leValue; @@ -74,7 +68,7 @@ public: QSpacerItem *verticalSpacer; QPushButton *pushButton_4; QFrame *frame_3; - QWidget *layoutWidget2; + QWidget *layoutWidget1; QVBoxLayout *verticalLayout_4; QTextEdit *teAttributes; QHBoxLayout *horizontalLayout_10; @@ -91,18 +85,18 @@ public: { if (Dialog->objectName().isEmpty()) Dialog->setObjectName(QString::fromUtf8("Dialog")); - Dialog->resize(405, 512); + Dialog->resize(403, 512); actionCSettingsOK = new QAction(Dialog); actionCSettingsOK->setObjectName(QString::fromUtf8("actionCSettingsOK")); frame = new QFrame(Dialog); frame->setObjectName(QString::fromUtf8("frame")); - frame->setGeometry(QRect(0, 0, 401, 181)); + frame->setGeometry(QRect(0, 0, 401, 151)); frame->setFrameShape(QFrame::StyledPanel); frame->setFrameShadow(QFrame::Sunken); frame->setLineWidth(2); layoutWidget = new QWidget(frame); layoutWidget->setObjectName(QString::fromUtf8("layoutWidget")); - layoutWidget->setGeometry(QRect(10, 10, 381, 161)); + layoutWidget->setGeometry(QRect(10, 10, 381, 131)); verticalLayout_5 = new QVBoxLayout(layoutWidget); verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5")); verticalLayout_5->setContentsMargins(0, 0, 0, 0); @@ -176,93 +170,67 @@ public: verticalLayout->addLayout(horizontalLayout_2); - horizontalLayout_4 = new QHBoxLayout(); - horizontalLayout_4->setObjectName(QString::fromUtf8("horizontalLayout_4")); - - verticalLayout->addLayout(horizontalLayout_4); - verticalLayout_5->addLayout(verticalLayout); - horizontalLayout_11 = new QHBoxLayout(); - horizontalLayout_11->setObjectName(QString::fromUtf8("horizontalLayout_11")); - horizontalSpacer_4 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - horizontalLayout_11->addItem(horizontalSpacer_4); - - chbPreview = new QCheckBox(layoutWidget); - chbPreview->setObjectName(QString::fromUtf8("chbPreview")); - - horizontalLayout_11->addWidget(chbPreview); - - horizontalSpacer_6 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - horizontalLayout_11->addItem(horizontalSpacer_6); - - chbCairo = new QCheckBox(layoutWidget); - chbCairo->setObjectName(QString::fromUtf8("chbCairo")); - - horizontalLayout_11->addWidget(chbCairo); - - horizontalSpacer_5 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - horizontalLayout_11->addItem(horizontalSpacer_5); - - - verticalLayout_5->addLayout(horizontalLayout_11); - frame_2 = new QFrame(Dialog); frame_2->setObjectName(QString::fromUtf8("frame_2")); - frame_2->setGeometry(QRect(0, 180, 401, 71)); + frame_2->setGeometry(QRect(0, 150, 401, 61)); frame_2->setFrameShape(QFrame::StyledPanel); frame_2->setFrameShadow(QFrame::Raised); - layoutWidget1 = new QWidget(frame_2); - layoutWidget1->setObjectName(QString::fromUtf8("layoutWidget1")); - layoutWidget1->setGeometry(QRect(10, 0, 381, 62)); - horizontalLayout_7 = new QHBoxLayout(layoutWidget1); + widget = new QWidget(frame_2); + widget->setObjectName(QString::fromUtf8("widget")); + widget->setGeometry(QRect(2, 0, 391, 61)); + horizontalLayout_7 = new QHBoxLayout(widget); horizontalLayout_7->setObjectName(QString::fromUtf8("horizontalLayout_7")); horizontalLayout_7->setContentsMargins(0, 0, 0, 0); verticalLayout_2 = new QVBoxLayout(); verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2")); horizontalLayout_5 = new QHBoxLayout(); horizontalLayout_5->setObjectName(QString::fromUtf8("horizontalLayout_5")); - label_5 = new QLabel(layoutWidget1); + label_5 = new QLabel(widget); label_5->setObjectName(QString::fromUtf8("label_5")); horizontalLayout_5->addWidget(label_5); - cbScope = new QComboBox(layoutWidget1); + cbScope = new QComboBox(widget); cbScope->setObjectName(QString::fromUtf8("cbScope")); horizontalLayout_5->addWidget(cbScope); - label_6 = new QLabel(layoutWidget1); + label_6 = new QLabel(widget); label_6->setObjectName(QString::fromUtf8("label_6")); horizontalLayout_5->addWidget(label_6); - cbName = new QComboBox(layoutWidget1); - cbName->setObjectName(QString::fromUtf8("cbName")); + cbNameG = new QComboBox(widget); + cbNameG->setObjectName(QString::fromUtf8("cbNameG")); + + horizontalLayout_5->addWidget(cbNameG); - horizontalLayout_5->addWidget(cbName); + cbNameN = new QComboBox(widget); + cbNameN->setObjectName(QString::fromUtf8("cbNameN")); + + horizontalLayout_5->addWidget(cbNameN); + + cbNameE = new QComboBox(widget); + cbNameE->setObjectName(QString::fromUtf8("cbNameE")); + + horizontalLayout_5->addWidget(cbNameE); - horizontalLayout_5->setStretch(0, 1); - horizontalLayout_5->setStretch(1, 2); - horizontalLayout_5->setStretch(2, 1); - horizontalLayout_5->setStretch(3, 2); verticalLayout_2->addLayout(horizontalLayout_5); horizontalLayout_6 = new QHBoxLayout(); horizontalLayout_6->setObjectName(QString::fromUtf8("horizontalLayout_6")); - label_7 = new QLabel(layoutWidget1); + label_7 = new QLabel(widget); label_7->setObjectName(QString::fromUtf8("label_7")); label_7->setMinimumSize(QSize(40, 0)); label_7->setMaximumSize(QSize(47, 16777215)); horizontalLayout_6->addWidget(label_7); - leValue = new QLineEdit(layoutWidget1); + leValue = new QLineEdit(widget); leValue->setObjectName(QString::fromUtf8("leValue")); horizontalLayout_6->addWidget(leValue); @@ -275,7 +243,7 @@ public: verticalLayout_3 = new QVBoxLayout(); verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3")); - pbAdd = new QPushButton(layoutWidget1); + pbAdd = new QPushButton(widget); pbAdd->setObjectName(QString::fromUtf8("pbAdd")); pbAdd->setMinimumSize(QSize(75, 0)); @@ -285,7 +253,7 @@ public: verticalLayout_3->addItem(verticalSpacer); - pushButton_4 = new QPushButton(layoutWidget1); + pushButton_4 = new QPushButton(widget); pushButton_4->setObjectName(QString::fromUtf8("pushButton_4")); pushButton_4->setMinimumSize(QSize(75, 0)); @@ -296,16 +264,16 @@ public: frame_3 = new QFrame(Dialog); frame_3->setObjectName(QString::fromUtf8("frame_3")); - frame_3->setGeometry(QRect(0, 250, 401, 261)); + frame_3->setGeometry(QRect(0, 210, 401, 301)); frame_3->setFrameShape(QFrame::StyledPanel); frame_3->setFrameShadow(QFrame::Raised); - layoutWidget2 = new QWidget(frame_3); - layoutWidget2->setObjectName(QString::fromUtf8("layoutWidget2")); - layoutWidget2->setGeometry(QRect(7, 6, 391, 251)); - verticalLayout_4 = new QVBoxLayout(layoutWidget2); + layoutWidget1 = new QWidget(frame_3); + layoutWidget1->setObjectName(QString::fromUtf8("layoutWidget1")); + layoutWidget1->setGeometry(QRect(7, 6, 391, 291)); + verticalLayout_4 = new QVBoxLayout(layoutWidget1); verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4")); verticalLayout_4->setContentsMargins(0, 0, 0, 0); - teAttributes = new QTextEdit(layoutWidget2); + teAttributes = new QTextEdit(layoutWidget1); teAttributes->setObjectName(QString::fromUtf8("teAttributes")); verticalLayout_4->addWidget(teAttributes); @@ -314,21 +282,21 @@ public: horizontalLayout_10->setObjectName(QString::fromUtf8("horizontalLayout_10")); horizontalLayout_8 = new QHBoxLayout(); horizontalLayout_8->setObjectName(QString::fromUtf8("horizontalLayout_8")); - pbNew = new QPushButton(layoutWidget2); + pbNew = new QPushButton(layoutWidget1); pbNew->setObjectName(QString::fromUtf8("pbNew")); pbNew->setMinimumSize(QSize(40, 0)); pbNew->setMaximumSize(QSize(40, 16777215)); horizontalLayout_8->addWidget(pbNew); - pbOpen = new QPushButton(layoutWidget2); + pbOpen = new QPushButton(layoutWidget1); pbOpen->setObjectName(QString::fromUtf8("pbOpen")); pbOpen->setMinimumSize(QSize(40, 0)); pbOpen->setMaximumSize(QSize(40, 16777215)); horizontalLayout_8->addWidget(pbOpen); - pbSave = new QPushButton(layoutWidget2); + pbSave = new QPushButton(layoutWidget1); pbSave->setObjectName(QString::fromUtf8("pbSave")); pbSave->setMinimumSize(QSize(40, 0)); pbSave->setMaximumSize(QSize(40, 16777215)); @@ -344,12 +312,12 @@ public: horizontalLayout_9 = new QHBoxLayout(); horizontalLayout_9->setObjectName(QString::fromUtf8("horizontalLayout_9")); - pbCancel = new QPushButton(layoutWidget2); + pbCancel = new QPushButton(layoutWidget1); pbCancel->setObjectName(QString::fromUtf8("pbCancel")); horizontalLayout_9->addWidget(pbCancel); - btnOK = new QPushButton(layoutWidget2); + btnOK = new QPushButton(layoutWidget1); btnOK->setObjectName(QString::fromUtf8("btnOK")); horizontalLayout_9->addWidget(btnOK); @@ -395,8 +363,6 @@ public: ); label_2->setText(QApplication::translate("Dialog", "Output File Name", 0, QApplication::UnicodeUTF8)); pbOut->setText(QApplication::translate("Dialog", "...", 0, QApplication::UnicodeUTF8)); - chbPreview->setText(QApplication::translate("Dialog", "Preview Output File", 0, QApplication::UnicodeUTF8)); - chbCairo->setText(QApplication::translate("Dialog", "Apply Cairo Filters", 0, QApplication::UnicodeUTF8)); label_5->setText(QApplication::translate("Dialog", "Scope", 0, QApplication::UnicodeUTF8)); cbScope->clear(); cbScope->insertItems(0, QStringList() @@ -405,14 +371,6 @@ public: << QApplication::translate("Dialog", "edge", 0, QApplication::UnicodeUTF8) ); label_6->setText(QApplication::translate("Dialog", "Name", 0, QApplication::UnicodeUTF8)); - cbName->clear(); - cbName->insertItems(0, QStringList() - << QApplication::translate("Dialog", "color", 0, QApplication::UnicodeUTF8) - << QApplication::translate("Dialog", "Font", 0, QApplication::UnicodeUTF8) - << QApplication::translate("Dialog", "fontname", 0, QApplication::UnicodeUTF8) - << QApplication::translate("Dialog", "fontcolor", 0, QApplication::UnicodeUTF8) - << QApplication::translate("Dialog", "bgcolor", 0, QApplication::UnicodeUTF8) - ); label_7->setText(QApplication::translate("Dialog", "Value", 0, QApplication::UnicodeUTF8)); pbAdd->setText(QApplication::translate("Dialog", "Add", 0, QApplication::UnicodeUTF8)); pushButton_4->setText(QApplication::translate("Dialog", "Help", 0, QApplication::UnicodeUTF8)); diff --git a/cmd/gvedit/vc90.idb b/cmd/gvedit/vc90.idb index 27f21fc59..4e41e76cb 100644 Binary files a/cmd/gvedit/vc90.idb and b/cmd/gvedit/vc90.idb differ diff --git a/cmd/gvedit/vc90.pdb b/cmd/gvedit/vc90.pdb index b05d57282..dfdb1d317 100644 Binary files a/cmd/gvedit/vc90.pdb and b/cmd/gvedit/vc90.pdb differ