From: Shamus Hammons Date: Sat, 28 Aug 2010 06:00:32 +0000 (+0000) Subject: Fixed Library Browser... X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd2b29c8735d83ab48df13c3efee53f63570473e;p=architektonas Fixed Library Browser... --- diff --git a/src/actions/actionlayersadd.cpp b/src/actions/actionlayersadd.cpp index ba484c5..44575e3 100644 --- a/src/actions/actionlayersadd.cpp +++ b/src/actions/actionlayersadd.cpp @@ -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); } diff --git a/src/actions/actionlayersedit.cpp b/src/actions/actionlayersedit.cpp index 773b5ef..864ef12 100644 --- a/src/actions/actionlayersedit.cpp +++ b/src/actions/actionlayersedit.cpp @@ -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)) { diff --git a/src/actions/actionmodifyattributes.cpp b/src/actions/actionmodifyattributes.cpp index ab8481d..f3cbd7e 100644 --- a/src/actions/actionmodifyattributes.cpp +++ b/src/actions/actionmodifyattributes.cpp @@ -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(); diff --git a/src/base/rs_eventhandler.cpp b/src/base/rs_eventhandler.cpp index 038dd42..fa89eff 100644 --- a/src/base/rs_eventhandler.cpp +++ b/src/base/rs_eventhandler.cpp @@ -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 } diff --git a/src/base/rs_modification.cpp b/src/base/rs_modification.cpp index 9a39ff0..c43ae64 100644 --- a/src/base/rs_modification.cpp +++ b/src/base/rs_modification.cpp @@ -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 addList; -// addList.setAutoDelete(false); QList addList; - if (document != NULL) + if (document) document->startUndoCycle(); for(RS_Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity()) { //for (uint i=0; icount(); ++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; diff --git a/src/forms/layerdialog.cpp b/src/forms/layerdialog.cpp index bc6eefb..a3418bc 100644 --- a/src/forms/layerdialog.cpp +++ b/src/forms/layerdialog.cpp @@ -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 " diff --git a/src/forms/librarywidget.cpp b/src/forms/librarywidget.cpp index 75b0527..ebb8acb 100644 --- a/src/forms/librarywidget.cpp +++ b/src/forms/librarywidget.cpp @@ -12,10 +12,13 @@ // 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" @@ -24,11 +27,23 @@ 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; icurrentItem(); - 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; ichildCount(); 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; diff --git a/src/forms/librarywidget.h b/src/forms/librarywidget.h index 6cf96ef..aab6b92 100644 --- a/src/forms/librarywidget.h +++ b/src/forms/librarywidget.h @@ -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(); diff --git a/src/forms/librarywidget.ui b/src/forms/librarywidget.ui index 41fda9e..9513c2d 100644 --- a/src/forms/librarywidget.ui +++ b/src/forms/librarywidget.ui @@ -36,7 +36,7 @@ - + @@ -54,7 +54,7 @@ bInsert clicked() LibraryWidget - update() + insert() 22 @@ -66,5 +66,11 @@ + + lvDirectory + itemClicked(QTreeWidgetItem*,int) + LibraryWidget + updatePreview(QTreeWidgetItem*,int) + diff --git a/src/mainapp/applicationwindow.cpp b/src/mainapp/applicationwindow.cpp index 22580a0..a384573 100644 --- a/src/mainapp/applicationwindow.cpp +++ b/src/mainapp/applicationwindow.cpp @@ -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") + "
" + tr("Date: %1").arg(__DATE__) + "
" + QString("© 2010 Underground Software,
James Hammons") + + "
" + + QString("Portions © 2001-2003 RibbonSoft") + "
" #ifdef QC_ABOUT_ADD_COMPANY + QString("
") + QC_ABOUT_ADD_COMPANY diff --git a/src/mainapp/applicationwindow.h b/src/mainapp/applicationwindow.h index 588de6d..3e2a134 100644 --- a/src/mainapp/applicationwindow.h +++ b/src/mainapp/applicationwindow.h @@ -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. */ diff --git a/src/widgets/listviewitem.cpp b/src/widgets/listviewitem.cpp index f260c9c..612d461 100644 --- a/src/widgets/listviewitem.cpp +++ b/src/widgets/listviewitem.cpp @@ -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)); diff --git a/src/widgets/listviewitem.h b/src/widgets/listviewitem.h index a09cd4a..a96648a 100644 --- a/src/widgets/listviewitem.h +++ b/src/widgets/listviewitem.h @@ -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, diff --git a/src/widgets/qg_dialogfactory.cpp b/src/widgets/qg_dialogfactory.cpp index 6398633..b5093ce 100644 --- a/src/widgets/qg_dialogfactory.cpp +++ b/src/widgets/qg_dialogfactory.cpp @@ -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); }