]> Shamusworld >> Repos - architektonas/commitdiff
Fixed Library Browser...
authorShamus Hammons <jlhamm@acm.org>
Sat, 28 Aug 2010 06:00:32 +0000 (06:00 +0000)
committerShamus Hammons <jlhamm@acm.org>
Sat, 28 Aug 2010 06:00:32 +0000 (06:00 +0000)
14 files changed:
src/actions/actionlayersadd.cpp
src/actions/actionlayersedit.cpp
src/actions/actionmodifyattributes.cpp
src/base/rs_eventhandler.cpp
src/base/rs_modification.cpp
src/forms/layerdialog.cpp
src/forms/librarywidget.cpp
src/forms/librarywidget.h
src/forms/librarywidget.ui
src/mainapp/applicationwindow.cpp
src/mainapp/applicationwindow.h
src/widgets/listviewitem.cpp
src/widgets/listviewitem.h
src/widgets/qg_dialogfactory.cpp

index ba484c5b8d93be108cad5cb582569c4744aef381..44575e36596f645540068a174b89d70093180245 100644 (file)
@@ -32,11 +32,11 @@ void ActionLayersAdd::trigger()
 {
        RS_DEBUG->print("add layer");
 
-       if (RS_DIALOGFACTORY != NULL && graphic)
+       if (RS_DIALOGFACTORY && graphic)
        {
                RS_Layer * layer = RS_DIALOGFACTORY->requestNewLayerDialog(graphic->getLayerList());
 
-               if (layer != NULL)
+               if (layer)
                        graphic->addLayer(layer);
        }
 
index 773b5efb31c3af4e24aee1f0aa8465fe0a15a612..864ef124097182829a6f444d1201adf94394ce40 100644 (file)
@@ -42,7 +42,7 @@ void ActionLayersEdit::trigger()
                {
                        graphic->editLayer(graphic->getActiveLayer(), *layer);
 
-                       // update updateable entities on the layer that has changed
+                       // Update updatable entities on the layer that has changed
                        for(RS_Entity * e=graphic->firstEntity(RS2::ResolveNone);
                                e!=NULL; e=graphic->nextEntity(RS2::ResolveNone))
                        {
index ab8481d93e5db9c1bd8dad55f03850e53824ebbf..f3cbd7e5e01017559e6851edfdfdaac5481ebac1 100644 (file)
@@ -49,13 +49,15 @@ void ActionModifyAttributes::trigger()
        data.changeWidth = false;
        data.changeLayer = false;
 
-       if (graphic != NULL)
+       if (graphic)
+       {
                if (RS_DIALOGFACTORY->requestAttributesDialog(data,
-                           *graphic->getLayerList()))
+                   *graphic->getLayerList()))
                {
                        RS_Modification m(*container, graphicView);
                        m.changeAttributes(data);
                }
+       }
 
        finish();
        graphicView->killSelectActions();
index 038dd42631970a4efb947b0f95ecd97fda61e1da..fa89eff725573f007b96697744b18476d1bd1d75 100644 (file)
@@ -103,7 +103,7 @@ void RS_EventHandler::mousePressEvent(QMouseEvent * e)
        }
        else
        {
-               if (defaultAction != NULL)
+               if (defaultAction)
                {
                        defaultAction->mousePressEvent(e);
                        e->accept();
@@ -667,6 +667,7 @@ void RS_EventHandler::setSnapMode(RS2::SnapMode sm)
                defaultAction->setSnapMode(sm);
 #else
 #warning "!!! Not sure if this is going to work correctly..."
+//seems to
        graphicView->snapper.setSnapMode(sm);
 #endif
 }
@@ -685,6 +686,7 @@ void RS_EventHandler::setSnapRestriction(RS2::SnapRestriction sr)
                defaultAction->setSnapRestriction(sr);
 #else
 #warning "!!! Not sure if this is going to work correctly..."
+//seems to
        graphicView->snapper.setSnapRestriction(sr);
 #endif
 }
index 9a39ff03dc92ee3e39565e4b9b1143b967a145eb..c43ae64b1eff4dc141fabdd8e1947d006d504fe8 100644 (file)
@@ -84,24 +84,22 @@ void RS_Modification::remove()
  */
 bool RS_Modification::changeAttributes(RS_AttributesData & data)
 {
-       if (container == NULL)
+       if (!container)
        {
                RS_DEBUG->print("RS_Modification::changeAttributes: no valid container", RS_Debug::D_WARNING);
                return false;
        }
 
-//     Q3PtrList<RS_Entity> addList;
-//     addList.setAutoDelete(false);
        QList<RS_Entity *> addList;
 
-       if (document != NULL)
+       if (document)
                document->startUndoCycle();
 
        for(RS_Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity())
        {
                //for (uint i=0; i<container->count(); ++i) {
                //RS_Entity* e = container->entityAt(i);
-               if (e != NULL && e->isSelected())
+               if (e && e->isSelected())
                {
                        RS_Entity * ec = e->clone();
                        ec->setSelected(false);
@@ -139,10 +137,10 @@ bool RS_Modification::changeAttributes(RS_AttributesData & data)
        deselectOriginals(true);
        addNewEntities(addList);
 
-       if (document != NULL)
+       if (document)
                document->endUndoCycle();
 
-       if (graphicView != NULL)
+       if (graphicView)
                graphicView->redraw();
 
        return true;
index bc6eefba9a4ddca7d371be363a23f51ffd4025e8..a3418bc0d58c8acb359852124e91568091f9eec9 100644 (file)
@@ -68,11 +68,11 @@ std::cout << ui.wPen->getPen();
 
 void LayerDialog::validate()
 {
-       if (layerList != NULL && (editLayer == FALSE || layerName != ui.leName->text()))
+       if (layerList && (!editLayer || layerName != ui.leName->text()))
        {
                RS_Layer * l = layerList->find(ui.leName->text().toLatin1());
 
-               if (l != NULL)
+               if (l)
                {
                        QMessageBox::information(parentWidget(), QMessageBox::tr("Layer Properties"),
                                 QMessageBox::tr("Layer with a name \"%1\" already exists. Please specify "
index 75b05279e5ae5a3e797cfd757f0cc0f9b71dee49..ebb8acb0319e19d11b904f0ba68558da7baa426e 100644 (file)
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JLH  05/10/2010  Created this file. :-)
+// JLH  08/28/2010  Restored functionality to library browser
 //
 
 #include "librarywidget.h"
 
+#include "actionhandler.h"
+#include "actionlibraryinsert.h"
 #include "drawing.h"
 #include "rs_staticgraphicview.h"
 #include "rs_system.h"
 LibraryWidget::LibraryWidget(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
        QWidget(parent, flags), actionHandler(NULL)
 {
+#if 0
+std::cout << "LibraryWidget::LibraryWidget()" << std::endl;
+#endif
        ui.setupUi(this);
+       ui.lvDirectory->setColumnCount(1);
 
        QStringList directoryList = RS_SYSTEM->getDirectoryList("library");
+#if 0
+std::cout << "directorySize = " << directoryList.size() << std::endl;
+
+for(int i=0; i<directoryList.size(); i++)
+       std::cout << directoryList.at(i).toLocal8Bit().constData() << std::endl;
 
-       for(QStringList::Iterator it = directoryList.begin(); it!=directoryList.end(); ++it)
+std::cout.flush();
+#endif
+
+       for(QStringList::Iterator it=directoryList.begin(); it!=directoryList.end(); it++)
                appendTree(NULL, (*it));
 }
 
@@ -59,22 +74,20 @@ void LibraryWidget::keyPressEvent(QKeyEvent * e)
 }
 
 /**
-* Insert.
-*/
+ * Insert.
+ */
 void LibraryWidget::insert()
 {
-#if 0
-//     Q3IconViewItem * item = ivPreview->currentItem();
-       QListWidgetItem * item = ivPreview->currentItem();
+       QListWidgetItem * item = ui.ivPreview->currentItem();
        QString dxfPath = getItemPath(item);
 
        if (QFileInfo(dxfPath).isReadable())
        {
-               if (actionHandler != NULL)
+               if (actionHandler)
                {
                        ActionInterface * a = actionHandler->setCurrentAction(RS2::ActionLibraryInsert);
 
-                       if (a != NULL)
+                       if (a)
                        {
                                ActionLibraryInsert * action = (ActionLibraryInsert *)a;
                                action->setFile(dxfPath);
@@ -91,101 +104,87 @@ void LibraryWidget::insert()
                RS_DEBUG->print(RS_Debug::D_ERROR,
                        "LibraryWidget::insert: Can't read file: '%s'", dxfPath.toLatin1().data());
        }
-#else
-#warning "!!! Need to port to Qt4 !!!"
-#endif
 }
 
 /**
-* Appends the given directory to the given list view item. Called recursively until all
-* library directories are appended.
-*/
-void LibraryWidget::appendTree(ListViewItem * item, QString directory)
+ * Appends the given directory to the given list view item. Called recursively until all
+ * library directories are appended.
+ */
+void LibraryWidget::appendTree(QTreeWidgetItem * item, QString directory)
 {
-#if 0
-       QStringList::Iterator it;
        QDir dir(directory);
 
-       // read subdirectories of this directory:
-       if (dir.exists())
-       {
-               QStringList lDirectoryList = dir.entryList(QDir::Dirs, QDir::Name);
+       if (!dir.exists())
+               return;
 
-               ListViewItem* newItem;
-               ListViewItem* searchItem;
+       // read subdirectories of this directory:
+       QStringList lDirectoryList = dir.entryList(QDir::Dirs, QDir::Name);
 
-               for(it=lDirectoryList.begin(); it!=lDirectoryList.end(); ++it)
+       for(QStringList::Iterator it=lDirectoryList.begin(); it!=lDirectoryList.end(); it++)
+       {
+               if ((*it) != "." && (*it) != "..")
                {
-                       if ((*it) != "." && (*it) != "..")
-                       {
-                               newItem = NULL;
-
-                               // Look for an item already existing and take this
-                               //   instead of making a new one:
-                               if (item != NULL)
-                                       searchItem = (ListViewItem *)item->firstChild();
-                               else
-                                       searchItem = (ListViewItem *)lvDirectory->firstChild();
+                       // Look for an item already existing and take this instead of
+                       // making a new one:
+                       QTreeWidgetItem * newItem = NULL;
+                       QTreeWidgetItem * searchItem =
+                               (item ? item->child(0) : ui.lvDirectory->topLevelItem(0));
 
-                               while (searchItem != NULL)
+                       if (searchItem)
+                       {
+                               for(int i=0; i<searchItem->childCount(); i++)
                                {
-                                       if (searchItem->text(0) == (*it))
+                                       if (searchItem->child(i)->text(0) == (*it))
                                        {
-                                               newItem=searchItem;
+                                               newItem = searchItem->child(i);
                                                break;
                                        }
-
-                                       searchItem = (ListViewItem *)searchItem->nextSibling();
-                               }
-
-                               // Create new item if no existing was found:
-                               if (newItem == NULL)
-                               {
-                                       if (item)
-                                               newItem = new ListViewItem(item, (*it));
-                                       else
-                                               newItem = new ListViewItem(lvDirectory, (*it));
                                }
+                       }
 
-                               appendTree(newItem, directory + "/" + (*it));
+                       // Create new item if no existing was found:
+                       if (!newItem)
+                       {
+                               QStringList list;
+                               list << (*it);
+                               newItem = (item ? new QTreeWidgetItem(item, list) : new QTreeWidgetItem(ui.lvDirectory, list));
                        }
+
+                       appendTree(newItem, directory + "/" + (*it));
                }
        }
-#else
-#warning "!!! Need to port to Qt4 !!!"
-#endif
 }
 
 /**
-* Updates the icon preview.
-*/
-//void LibraryWidget::updatePreview(Q3ListViewItem * item)
-void LibraryWidget::updatePreview(QListWidgetItem * item)
+ * Updates the icon preview.
+ */
+void LibraryWidget::updatePreview(QTreeWidgetItem * item, int /*column*/)
 {
-#if 0
-       if (item == NULL)
+       if (!item)
                return;
 
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
        // dir from the point of view of the library browser (e.g. /mechanical/screws)
        QString directory = getItemDir(item);
-       ivPreview->clear();
+       ui.ivPreview->clear();
 
        // List of all directories that contain part libraries:
        QStringList directoryList = RS_SYSTEM->getDirectoryList("library");
        QStringList::Iterator it;
        QDir itemDir;
        QStringList itemPathList;
+       QStringList filter;
+       filter << "*.dxf";
 
-       // look in all possible system directories for DXF files in the current library path:
+       // Look in all possible system directories for DXF files in the current library path:
        for(it=directoryList.begin(); it!=directoryList.end(); ++it)
        {
                itemDir.setPath((*it) + directory);
 
                if (itemDir.exists())
                {
-                       QStringList itemNameList = itemDir.entryList("*.dxf", QDir::Files, QDir::Name);
+                       QStringList itemNameList = itemDir.entryList(filter, QDir::Files, QDir::Name);
                        QStringList::Iterator it2;
 
                        for(it2=itemNameList.begin(); it2!=itemNameList.end(); ++it2)
@@ -197,60 +196,54 @@ void LibraryWidget::updatePreview(QListWidgetItem * item)
        itemPathList.sort();
 
        // Fill items into icon view:
-       Q3IconViewItem * newItem;
+       QListWidgetItem * newItem;
+
        for(it=itemPathList.begin(); it!=itemPathList.end(); ++it)
        {
-               QString label = QFileInfo(*it).baseName(true);
+//             QString label = QFileInfo(*it).baseName(true);
+               QString label = QFileInfo(*it).completeBaseName();
                QPixmap pixmap = getPixmap(directory, QFileInfo(*it).fileName(), (*it));
-               newItem = new Q3IconViewItem(ivPreview, label, pixmap);
+//             newItem = new QListWidgetItem(ui.ivPreview, label, pixmap);
+               newItem = new QListWidgetItem(QIcon(pixmap), label, ui.ivPreview);
+//Doesn't do what we want...
+//             newItem->setSizeHint(QSize(64, 64));
        }
 
        QApplication::restoreOverrideCursor();
-#else
-#warning "!!! Need to port to Qt4 !!!"
-#endif
 }
 
 /**
-* @return Directory (in terms of the List view) to the given item (e.g. /mechanical/screws)
-*/
-//QString LibraryWidget::getItemDir(Q3ListViewItem * item)
-QString LibraryWidget::getItemDir(QListWidgetItem * item)
+ * @return Directory (in terms of the List view) to the given item (e.g. /mechanical/screws)
+ * (called recursively)
+ */
+QString LibraryWidget::getItemDir(QTreeWidgetItem * item)
 {
-#if 0
-       QString ret = "";
+       if (!item)
+               return "";
 
-       if (item == NULL)
-               return ret;
+       QTreeWidgetItem * parent = item->parent();
 
-       Q3ListViewItem* parent = item->parent();
        return getItemDir(parent) + QString("/%1").arg(item->text(0));
-#else
-#warning "!!! Need to port to Qt4 !!!"
-       return "";
-#endif
 }
 
 /**
-* @return Path of the DXF file that is represented by the given item.
-*/
-//QString LibraryWidget::getItemPath(Q3IconViewItem * item)
+ * @return Path of the DXF file that is represented by the given item.
+ */
 QString LibraryWidget::getItemPath(QListWidgetItem * item)
 {
-#if 0
-       QString dir = getItemDir(lvDirectory->currentItem());
+       QString dir = getItemDir(ui.lvDirectory->currentItem());
 
-       if (item != NULL)
+       if (item)
        {
                // List of all directories that contain part libraries:
                QStringList directoryList = RS_SYSTEM->getDirectoryList("library");
                QStringList::Iterator it;
                QDir itemDir;
 
-               // look in all possible system directories for DXF files in the current library path:
+               // Look in all possible system directories for DXF files in the current library path:
                for(it=directoryList.begin(); it!=directoryList.end(); ++it)
                {
-                       itemDir.setPath((*it)+dir);
+                       itemDir.setPath((*it) + dir);
 
                        if (itemDir.exists())
                        {
@@ -260,46 +253,38 @@ QString LibraryWidget::getItemPath(QListWidgetItem * item)
                                        return f;
                        }
                }
-
-               return "";
-       }
-       else
-       {
-               return "";
        }
-#else
-#warning "!!! Need to port to Qt4 !!!"
+
        return "";
-#endif
 }
 
 /**
-* @return Pixmap that serves as icon for the given DXF File.
-* The existing PNG file is returned or created and returned..
-*
-* @param dir Library directory (e.g. "/mechanical/screws")
-* @param dxfFile File name (e.g. "screw1.dxf")
-* @param dxfPath Full path to the existing DXF file on disk
-*                          (e.g. /home/tux/.qcad/library/mechanical/screws/screw1.dxf)
-*/
+ * @return Pixmap that serves as icon for the given DXF File.
+ * The existing PNG file is returned or created and returned..
+ *
+ * @param dir Library directory (e.g. "/mechanical/screws")
+ * @param dxfFile File name (e.g. "screw1.dxf")
+ * @param dxfPath Full path to the existing DXF file on disk
+ *                          (e.g. /home/tux/.qcad/library/mechanical/screws/screw1.dxf)
+ */
 QPixmap LibraryWidget::getPixmap(const QString & dir, const QString & dxfFile,
        const QString & dxfPath)
 {
        QString pngFile = getPathToPixmap(dir, dxfFile, dxfPath);
        QFileInfo fiPng(pngFile);
 
-       // found existing thumbnail:
+       // Found existing thumbnail:
        if (fiPng.isFile())
                return QPixmap(pngFile);
-       // default thumbnail:
+       // Default thumbnail:
        else
                return QPixmap(64, 64);
 }
 
 /**
-* @return Path to the thumbnail of the given DXF file. If no thumbnail exists, one is
-* created in the user's home. If no thumbnail can be created, an empty string is returned.
-*/
+ * @return Path to the thumbnail of the given DXF file. If no thumbnail exists, one is
+ * created in the user's home. If no thumbnail can be created, an empty string is returned.
+ */
 QString LibraryWidget::getPathToPixmap(const QString & dir, const QString & dxfFile,
        const QString & dxfPath)
 {
@@ -404,7 +389,6 @@ QString LibraryWidget::getPathToPixmap(const QString & dir, const QString & dxfF
                gv.zoomAuto(false);
                gv.drawEntity(&graphic, true);
 
-#warning "Needs porting to Qt4... !!! FIX !!!"
 #if 0
                QImageIO iio;
                QImage img;
@@ -421,17 +405,15 @@ QString LibraryWidget::getPathToPixmap(const QString & dir, const QString & dxfF
                                "LibraryWidget::getPathToPixmap: Cannot write thumbnail: '%s'",
                                pngPath.toLatin1().data());
                }
+#else
+#warning "LibraryWidget::getPathToPixmap(): Needs porting to Qt4... !!! FIX !!!"
 #endif
        }
        else
        {
-               RS_DEBUG->print(RS_Debug::D_ERROR, "LibraryWidget::getPathToPixmap: Cannot open file: '%s'",
-                       dxfPath.toLatin1().data());
+               RS_DEBUG->print(RS_Debug::D_ERROR, "LibraryWidget::getPathToPixmap: Cannot open file: '%s'", dxfPath.toLatin1().data());
        }
 
-       // GraphicView deletes painter
-//     painter->end();
-       // No, it doesn't
        delete painter;
        delete buffer;
 
index 6cf96ef3474d4bf7bbb27bbd831608f2b6cc9b1e..aab6b928e6f525f15e6558f8b3f5d13b4fb12892 100644 (file)
@@ -15,9 +15,7 @@ class LibraryWidget: public QWidget
                LibraryWidget(QWidget * parent = 0, Qt::WindowFlags flags = 0);
                ~LibraryWidget();
 
-//             QString getItemDir(Q3ListViewItem * item);
-               QString getItemDir(QListWidgetItem * item);
-//             QString getItemPath(Q3IconViewItem * item);
+               QString getItemDir(QTreeWidgetItem * item);
                QString getItemPath(QListWidgetItem * item);
                QPixmap getPixmap(const QString & dir, const QString & dxfFile, const QString & dxfPath);
                QString getPathToPixmap(const QString & dir, const QString & dxfFile, const QString & dxfPath);
@@ -26,9 +24,8 @@ class LibraryWidget: public QWidget
                void setActionHandler(ActionHandler * ah);
                void keyPressEvent(QKeyEvent * e);
                void insert();
-               void appendTree(ListViewItem * item, QString directory);
-//             void updatePreview(Q3ListViewItem * item);
-               void updatePreview(QListWidgetItem * item);
+               void appendTree(QTreeWidgetItem * item, QString directory);
+               void updatePreview(QTreeWidgetItem * item, int /*column*/);
 
        signals:
                void escape();
index 41fda9ecdf915260b0edaf7ff8e883ee58a2d90b..9513c2dec25cb48b6777266c8db62f338709ade9 100644 (file)
@@ -36,7 +36,7 @@
     </widget>
    </item>
    <item>
-    <widget class="QListView" name="ivPreview"/>
+    <widget class="QListWidget" name="ivPreview"/>
    </item>
    <item>
     <widget class="QPushButton" name="bInsert">
@@ -54,7 +54,7 @@
    <sender>bInsert</sender>
    <signal>clicked()</signal>
    <receiver>LibraryWidget</receiver>
-   <slot>update()</slot>
+   <slot>insert()</slot>
    <hints>
     <hint type="sourcelabel">
      <x>22</x>
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>lvDirectory</sender>
+   <signal>itemClicked(QTreeWidgetItem*,int)</signal>
+   <receiver>LibraryWidget</receiver>
+   <slot>updatePreview(QTreeWidgetItem*,int)</slot>
+  </connection>
  </connections>
 </ui>
index 22580a043e344ce1b0a537721bc9fe9974ee6c44..a384573862f3d5c499bb9603251915b54a40d70a 100644 (file)
@@ -1498,9 +1498,11 @@ void ApplicationWindow::initView()
 //     dw->setCaption(tr("Library Browser"));
 //not sure how to fix this one
 #warning "QMainWindow::addDockWidget: invalid 'area' argument"
-       addDockWidget(Qt::NoDockWidgetArea, dw);
+//     addDockWidget(Qt::NoDockWidgetArea, dw);
+//This works, but sux
+       addDockWidget(Qt::RightDockWidgetArea, dw);
        libraryDockWindow = dw;
-       libraryDockWindow->hide();
+//     libraryDockWindow->hide();
 
        RS_DEBUG->print("  command widget..");
 //     dw = new QDockWidget(QDockWidget::InDock, this, "Command");
@@ -1627,6 +1629,7 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
 //which means the subwindow is NOT being activated!!!
        MDIWindow * m = getMDIWindow();
        RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m);
+
        if (m)
                RS_DEBUG->print(/*RS_Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument());
 
@@ -1661,7 +1664,7 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/)
                slotPenChanged(penToolBar->getPen());
 
                // update toggle button status:
-               if (m->getGraphic() != NULL)
+               if (m->getGraphic())
                {
                        emit(gridChanged(m->getGraphic()->isGridOn()));
                        emit(printPreviewChanged(m->getGraphicView()->isPrintPreview()));
@@ -2018,7 +2021,6 @@ void ApplicationWindow::slotFileOpenRecent(void)
 void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType type)
 {
        RS_DEBUG->print("ApplicationWindow::slotFileOpen(..)");
-
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 
        if (!fileName.isEmpty())
@@ -2026,10 +2028,6 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: creating new doc window");
                // Create new document window:
                MDIWindow * w = slotFileNew();
-//             RS_APP->processEvents(1000);
-//Really, is this needed???
-//             RS_APP->processEvents(QEventLoop::AllEvents, 1000);
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: linking layer list");
                // link the layer widget to the new document:
                layerWidget->setLayerList(w->getDocument()->getLayerList(), false);
@@ -2041,15 +2039,10 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t
                // link the layer widget to the new document:
                simulationControls->setGraphicView(w->getGraphicView());
 #endif
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: open file");
 
-//             RS_APP->processEvents(1000);
-//We no longer try to do Qt better than the Qt folks...
-//             RS_APP->processEvents(QEventLoop::AllEvents, 1000);
-
-               // open the file in the new view:
-               if (w->slotFileOpen(fileName, type) == false)
+               // Open the file in the new view:
+               if (!w->slotFileOpen(fileName, type))
                {
                        // error
                        QApplication::restoreOverrideCursor();
@@ -2070,24 +2063,20 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t
                        recentFiles->add(fileName);
 
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: 2");
-//             updateRecentFilesMenu();
                recentFiles->UpdateGUI();
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update recent file menu: OK");
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption");
                // update caption:
-//             w->setCaption(fileName);
                w->setWindowTitle(fileName);
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: set caption: OK");
-
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget");
                // update coordinate widget format:
                RS_DIALOGFACTORY->updateCoordinateWidget(Vector(0.0, 0.0), Vector(0.0, 0.0), true);
                RS_DEBUG->print("ApplicationWindow::slotFileOpen: update coordinate widget: OK");
-
+               // Update the layer and block widgets (document just loaded may have some)
+               layerWidget->update();
+               blockWidget->update();
                // show output of filter (if any):
-//             commandWidget->processStderr();
                QString message = tr("Loaded document: ") + fileName;
                commandWidget->appendHistory(message);
                statusBar()->showMessage(message, 2000);
@@ -2188,14 +2177,12 @@ void ApplicationWindow::slotFileSaveAs()
 void ApplicationWindow::slotFileExport()
 {
        RS_DEBUG->print("ApplicationWindow::slotFileExport()");
-
        statusBar()->showMessage(tr("Exporting drawing..."));
-
        MDIWindow * w = getMDIWindow();
-       QString fn;
 
-       if (w != NULL)
+       if (w)
        {
+               QString fn;
                // read default settings:
                settings.beginGroup("Paths");
                QString defDir = settings.value("ExportImage", RS_SYSTEM->getHomeDir()).toString();
@@ -2323,7 +2310,7 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for
 {
        MDIWindow * w = getMDIWindow();
 
-       if (w == NULL)
+       if (!w)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no window opened");
                return false;
@@ -2331,7 +2318,7 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for
 
        Drawing * graphic = w->getDocument()->getGraphic();
 
-       if (graphic == NULL)
+       if (!graphic)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic");
                return false;
@@ -2388,7 +2375,7 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for
                ret = true;
        }
 #else
-#warning "Need to port to Qt4... !!! FIX !!!"
+#warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!"
 #endif
 
        QApplication::restoreOverrideCursor();
@@ -2416,7 +2403,7 @@ void ApplicationWindow::slotFileClose()
 
        MDIWindow * m = getMDIWindow();
 
-       if (m != NULL)
+       if (m)
 //             m->close(true);
                m->close();
 
@@ -2489,6 +2476,7 @@ void ApplicationWindow::slotFilePrint()
        // printer setup:
 //     if (printer->setup(this))
        QPrintDialog dialog(printer, this);
+
        if (dialog.exec())
        {
                //printer->setOutputToFile(true);
@@ -2551,7 +2539,7 @@ void ApplicationWindow::slotFilePrintPreview(bool on)
        RS_DEBUG->print("  creating MDI window");
        MDIWindow * parent = getMDIWindow();
 
-       if (parent == NULL)
+       if (!parent)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "ApplicationWindow::slotFilePrintPreview: no window opened");
                return;
@@ -2660,6 +2648,7 @@ void ApplicationWindow::slotFileQuit()
                qApp->exit(0);
 }
 
+#if 0
 /**
  * Forces termination of QCad (demo version).
  */
@@ -2670,6 +2659,7 @@ void ApplicationWindow::slotFileDemoQuit()
        queryExit(true);
        qApp->exit(0);
 }
+#endif
 
 /**
  * Shows / hides the grid.
@@ -2957,7 +2947,7 @@ void ApplicationWindow::slotHelpAbout()
 
        QString modulesString;
 
-       if (modules.empty() == false)
+       if (!modules.empty())
                modulesString = modules.join(", ");
        else
                modulesString = tr("None");
@@ -2975,6 +2965,8 @@ void ApplicationWindow::slotHelpAbout()
                tr("Version: %1").arg("1.0.0") + "<br>" +
                tr("Date: %1").arg(__DATE__) + "<br>" +
                QString("&copy; 2010 Underground Software,<br>James Hammons") +
+               "<br>" +
+               QString("Portions &copy; 2001-2003 RibbonSoft") +
                "<br>"
 #ifdef QC_ABOUT_ADD_COMPANY
                + QString("<br>") + QC_ABOUT_ADD_COMPANY
index 588de6d67a01b9ff162214a799534dad29ebf605..3e2a1347203c37929c42ef0cc9e269177a2093f9 100644 (file)
@@ -104,8 +104,10 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface
                /** exits the application */
                void slotFileQuit();
 
+#if 0
                /** forces to quit QCad (demo) */
                void slotFileDemoQuit();
+#endif
 
                /** toggle the grid */
                void slotViewGrid(bool toggle);
@@ -183,9 +185,6 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface
                virtual ActionHandler * getActionHandler();
                virtual void showSimulationControls();
 
-               //virtual QToolBar* createToolBar(const QString& name);
-               //virtual void addToolBarButton(QToolBar* tb);
-
                /**
                * @return Pointer to the qsa object.
                */
index f260c9ca0408776a711a0634cde1095096a19fc2..612d461e0a6004c18b4bed7912f8583262db6b6e 100644 (file)
@@ -52,7 +52,7 @@ ListViewItem::ListViewItem(ListViewItem * par, const QString & label,
  */
 void ListViewItem::setOpen(bool open)
 {
-       if (open == true)
+       if (open)
 //             setPixmap(0, QPixmap(folderopen_xpm));
 //             setIcon(QIcon(folderopen_xpm));
                setIcon(QIcon(":/res/folderopen.xpm"));
@@ -83,7 +83,7 @@ QString ListViewItem::getFullPath()
 {
        QString s;
 
-       if (par != NULL)
+       if (par)
        {
                s = par->getFullPath();
                s.append(text(0));
index a09cd4a1f784bcc09a108ce759f9a4a8486d423d..a96648a0e4212381b027f72d482e98be306279c4 100644 (file)
@@ -7,7 +7,7 @@
  * An item in a hierarchical list view with a nice folder icon.
  */
 //class ListViewItem : public Q3ListViewItem
-class ListViewItem : public QListWidgetItem
+class ListViewItem: public QListWidgetItem
 {
        public:
 //             ListViewItem(Q3ListView * par, const QString & label,
index 6398633b6e61706cb555ff97f4db793d4f4325af..b5093ceed36a5d899ca325a28969ffbe280762bb 100644 (file)
@@ -339,17 +339,8 @@ RS_Layer * QG_DialogFactory::requestEditLayerDialog(RS_LayerList * layerList)
 {
        RS_DEBUG->print("QG_DialogFactory::requestEditLayerDialog");
        RS_Layer * layer = NULL;
-       /*
-       if (layerList==NULL) {
-               if (container!=NULL && container->rtti()==RS2::EntityGraphic) {
-                       layerList = (RS_LayerList*)container;
-               } else {
-                       return NULL;
-               }
-       }
-       */
 
-       if (layerList == NULL)
+       if (!layerList)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "QG_DialogFactory::requestEditLayerDialog(): "
                        "layerList is NULL");
@@ -357,7 +348,7 @@ RS_Layer * QG_DialogFactory::requestEditLayerDialog(RS_LayerList * layerList)
        }
 
        // Layer for parameter livery
-       if (layerList->getActive() != NULL)
+       if (layerList->getActive())
        {
                layer = new RS_Layer(*layerList->getActive());
 
@@ -1408,7 +1399,7 @@ void QG_DialogFactory::requestLibraryInsertOptions(ActionInterface * action, boo
  */
 void QG_DialogFactory::requestToolBar(RS2::ToolBarId id)
 {
-       if (cadToolBar != NULL)
+       if (cadToolBar)
                cadToolBar->showToolBar(id);
 }