- Timestamp:
- Dec 7, 2009, 5:06:44 PM (15 years ago)
- Location:
- trunk/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/main.cpp
r70 r71 33 33 #endif 34 34 35 #ifdef STATIC_BUILD 36 Q_IMPORT_PLUGIN(qjpeg) 37 Q_IMPORT_PLUGIN(qsvg) 38 #endif 39 35 40 int main(int argc, char *argv[]) 36 41 { -
trunk/src/mainwindow.cpp
r69 r71 83 83 connect(spinCities,SIGNAL(valueChanged(int)),this,SLOT(spinCitiesValueChanged(int))); 84 84 setCentralWidget(tabWidget); 85 #ifndef Q_OS_WINCE 86 QRect rect = geometry(); 87 if (settings->value("SavePos",false).toBool()) { 85 86 if (settings->value("SavePos", false).toBool()) { 88 87 // Loading of saved window state 89 88 settings->beginGroup("MainWindow"); 90 resize(settings->value("Size",size()).toSize()); 91 move(settings->value("Position",pos()).toPoint());92 if (settings->value("Maximized",false).toBool()) 93 setWindowState(windowState() | Qt::WindowMaximized);89 #ifndef Q_OS_WINCE 90 restoreGeometry(settings->value("Geometry").toByteArray()); 91 #endif // Q_OS_WINCE 92 restoreState(settings->value("State").toByteArray()); 94 93 settings->endGroup(); 94 #ifndef Q_OS_WINCE 95 95 } else { 96 96 // Centering main window 97 QRect rect = geometry(); 97 98 rect.moveCenter(QApplication::desktop()->availableGeometry(this).center()); 98 99 setGeometry(rect); 99 }100 100 #endif // Q_OS_WINCE 101 } 102 101 103 qsrand(QDateTime().currentDateTime().toTime_t()); 102 tspmodel = new CTSPModel( );104 tspmodel = new CTSPModel(this); 103 105 taskView->setModel(tspmodel); 104 106 connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int))); … … 440 442 } 441 443 442 void MainWindow::closeEvent(QCloseEvent *ev ent)444 void MainWindow::closeEvent(QCloseEvent *ev) 443 445 { 444 446 if (!maybeSave()) { 445 event->ignore(); 446 return; 447 } 448 settings->setValue("NumCities",spinCities->value()); 447 ev->ignore(); 448 return; 449 } 450 settings->setValue("NumCities", spinCities->value()); 451 452 // Saving Main Window state 453 if (settings->value("SavePos", false).toBool()) { 454 settings->beginGroup("MainWindow"); 449 455 #ifndef Q_OS_WINCE 450 // Saving windows state 451 if (settings->value("SavePos",false).toBool()) { 452 settings->beginGroup("MainWindow"); 453 settings->setValue("Maximized",isMaximized()); 454 if (!isMaximized()) { 455 settings->setValue("Size",size()); 456 settings->setValue("Position",pos()); 457 } 456 settings->setValue("Geometry", saveGeometry()); 457 #endif // Q_OS_WINCE 458 settings->setValue("State", saveState()); 458 459 settings->endGroup(); 459 460 } 460 #endif // Q_OS_WINCE 461 QMainWindow::closeEvent(ev ent);461 462 QMainWindow::closeEvent(ev); 462 463 } 463 464 … … 520 521 } 521 522 522 bool MainWindow::loadLanguage( QStringlang)523 bool MainWindow::loadLanguage(const QString &lang) 523 524 { 524 525 // i18n 525 526 bool ad = false; 526 if (lang.isEmpty()) { 527 QString lng = lang; 528 if (lng.isEmpty()) { 527 529 ad = settings->value("Language","").toString().isEmpty(); 528 l ang = settings->value("Language",QLocale::system().name()).toString();530 lng = settings->value("Language",QLocale::system().name()).toString(); 529 531 } 530 532 static QTranslator *qtTranslator; // Qt library translator … … 541 543 } 542 544 translator = new QTranslator(); 543 if (l ang.compare("en") && !lang.startsWith("en_")) {545 if (lng.compare("en") && !lng.startsWith("en_")) { 544 546 // Trying to load system Qt library translation... 545 if (qtTranslator->load("qt_" + l ang,QLibraryInfo::location(QLibraryInfo::TranslationsPath)))547 if (qtTranslator->load("qt_" + lng,QLibraryInfo::location(QLibraryInfo::TranslationsPath))) 546 548 qApp->installTranslator(qtTranslator); 547 549 else 548 550 // No luck. Let's try to load bundled one. 549 if (qtTranslator->load("qt_" + l ang,PATH_I18N))551 if (qtTranslator->load("qt_" + lng,PATH_I18N)) 550 552 qApp->installTranslator(qtTranslator); 551 553 else { … … 555 557 } 556 558 // Now let's load application translation. 557 if (translator->load(l ang,PATH_I18N))559 if (translator->load(lng,PATH_I18N)) 558 560 qApp->installTranslator(translator); 559 561 else { … … 581 583 } 582 584 583 void MainWindow::outputMatrix( tMatrixmatrix, QStringList &output, int nRow, int nCol)585 void MainWindow::outputMatrix(const tMatrix &matrix, QStringList &output, int nRow, int nCol) 584 586 { 585 587 int n = spinCities->value(); … … 589 591 line = "<tr>"; 590 592 for (int c = 0; c < n; c++) { 591 if (matrix [r][c]== INFINITY)593 if (matrix.at(r).at(c) == INFINITY) 592 594 line += "<td align=\"center\">"INFSTR"</td>"; 593 595 else if ((r == nRow) && (c == nCol)) 594 line += "<td align=\"center\" class=\"selected\">" + QVariant(matrix [r][c]).toString() + "</td>";596 line += "<td align=\"center\" class=\"selected\">" + QVariant(matrix.at(r).at(c)).toString() + "</td>"; 595 597 else 596 line += "<td align=\"center\">" + QVariant(matrix [r][c]).toString() + "</td>";598 line += "<td align=\"center\">" + QVariant(matrix.at(r).at(c)).toString() + "</td>"; 597 599 } 598 600 line += "</tr>"; … … 626 628 } 627 629 628 void MainWindow::setFileName( QStringfileName)630 void MainWindow::setFileName(const QString &fileName) 629 631 { 630 632 this->fileName = fileName; -
trunk/src/mainwindow.h
r69 r71 60 60 #endif // QT_NO_PRINTER 61 61 void actionSettingsPreferencesTriggered(); 62 void actionSettingsLanguageAutodetectTriggered(bool );63 void groupSettingsLanguageListTriggered(QAction * );62 void actionSettingsLanguageAutodetectTriggered(bool checked); 63 void groupSettingsLanguageListTriggered(QAction *action); 64 64 void actionHelpAboutTriggered(); 65 65 // Buttons … … 69 69 70 70 void dataChanged(); 71 void dataChanged(const QModelIndex & , const QModelIndex &);72 void numCitiesChanged(int );71 void dataChanged(const QModelIndex &tl, const QModelIndex &br); 72 void numCitiesChanged(int nCities); 73 73 #ifndef QT_NO_PRINTER 74 74 void printPreview(QPrinter *printer); 75 75 #endif // QT_NO_PRINTER 76 void spinCitiesValueChanged(int );76 void spinCitiesValueChanged(int nCities); 77 77 78 78 private: … … 86 86 CTSPModel *tspmodel; 87 87 88 void closeEvent(QCloseEvent * );88 void closeEvent(QCloseEvent *ev); 89 89 void enableSolutionActions(bool enable = true); 90 90 void initDocStyleSheet(); 91 91 void loadLangList(); 92 bool loadLanguage( QString lang = "");92 bool loadLanguage(const QString &lang = QString()); 93 93 bool maybeSave(); 94 void outputMatrix( tMatrix, QStringList &, int nRow = -1, int nCol = -1);94 void outputMatrix(const tMatrix &matrix, QStringList &output, int nRow = -1, int nCol = -1); 95 95 bool saveTask(); 96 void setFileName( QStringfileName = trUtf8("Untitled") + ".tspt");96 void setFileName(const QString &fileName = trUtf8("Untitled") + ".tspt"); 97 97 }; 98 98 -
trunk/src/settingsdialog.h
r67 r71 57 57 QFrame *lineVertical; 58 58 59 bool event(QEvent * );59 bool event(QEvent *ev); 60 60 #endif // Q_OS_WINCE 61 61 … … 64 64 void buttonColorClicked(); 65 65 void buttonFontClicked(); 66 void spinRandMinValueChanged(int );66 void spinRandMinValueChanged(int val); 67 67 }; 68 68 -
trunk/src/tspmodel.cpp
r70 r71 133 133 * \sa saveTask() 134 134 */ 135 bool CTSPModel::loadTask( QStringfname)135 bool CTSPModel::loadTask(const QString &fname) 136 136 { 137 137 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); … … 220 220 * \sa loadTask() 221 221 */ 222 bool CTSPModel::saveTask( QStringfname)222 bool CTSPModel::saveTask(const QString &fname) 223 223 { 224 224 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); -
trunk/src/tspmodel.h
r67 r71 42 42 CTSPModel(QObject *parent = 0); 43 43 void clear(); 44 int columnCount(const QModelIndex & ) const;45 QVariant data(const QModelIndex & , int) const;46 Qt::ItemFlags flags(const QModelIndex & ) const;47 QVariant headerData(int , Qt::Orientation, int) const;48 bool loadTask( QString);44 int columnCount(const QModelIndex &parent = QModelIndex()) const; 45 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 46 Qt::ItemFlags flags(const QModelIndex &index) const; 47 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 48 bool loadTask(const QString &fname); 49 49 quint16 numCities() const; 50 50 void randomize(); 51 int rowCount(const QModelIndex & ) const;52 bool saveTask( QString);53 bool setData(const QModelIndex & , const QVariant &, int);54 void setNumCities(int );51 int rowCount(const QModelIndex &parent = QModelIndex()) const; 52 bool saveTask(const QString &fname); 53 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 54 void setNumCities(int n); 55 55 56 56 signals: -
trunk/src/tspsolver.cpp
r67 r71 209 209 } 210 210 211 bool CTSPSolver::findCandidate( tMatrix matrix, int &nRow, int &nCol)211 bool CTSPSolver::findCandidate(const tMatrix &matrix, int &nRow, int &nCol) const 212 212 { 213 213 nRow = -1; … … 232 232 } 233 233 234 double CTSPSolver::findMinInCol(int nCol, tMatrix matrix, int exr)234 double CTSPSolver::findMinInCol(int nCol, const tMatrix &matrix, int exr) const 235 235 { 236 236 double min = INFINITY; … … 241 241 } 242 242 243 double CTSPSolver::findMinInRow(int nRow, tMatrix matrix, int exc)243 double CTSPSolver::findMinInRow(int nRow, const tMatrix &matrix, int exc) const 244 244 { 245 245 double min = INFINITY; … … 250 250 } 251 251 252 bool CTSPSolver::hasSubCycles(int nRow, int nCol) 252 bool CTSPSolver::hasSubCycles(int nRow, int nCol) const 253 253 { 254 254 if ((nRow < 0) || (nCol < 0) || route.isEmpty() || !(route.size() < nCities - 1) || !route.contains(nCol)) -
trunk/src/tspsolver.h
r67 r71 76 76 static QString getVersionId(); 77 77 bool isOptimal() const; 78 sStep *solve(int , tMatrix, QWidget *parent = 0);78 sStep *solve(int numCities, tMatrix task, QWidget *parent = 0); 79 79 80 80 private: … … 85 85 // QHash<int,int> forbidden; 86 86 87 double align(tMatrix & );87 double align(tMatrix &matrix); 88 88 void cleanup(); 89 bool findCandidate( tMatrix, int &, int &);90 double findMinInCol(int , tMatrix, int exr = -1);91 double findMinInRow(int , tMatrix, int exc = -1);92 bool hasSubCycles(int , int);93 void subCol(tMatrix & , int, double);94 void subRow(tMatrix & , int, double);89 bool findCandidate(const tMatrix &matrix, int &nRow, int &nCol) const; 90 double findMinInCol(int nCol, const tMatrix &matrix, int exr = -1) const; 91 double findMinInRow(int nRow, const tMatrix &matrix, int exc = -1) const; 92 bool hasSubCycles(int nRow, int nCol) const; 93 void subCol(tMatrix &matrix, int nCol, double val); 94 void subRow(tMatrix &matrix, int nRow, double val); 95 95 }; 96 96 -
trunk/src/version.h
r67 r71 57 57 //! Minor version of current TSPSG build 58 58 #define BUILD_VERSION_MINOR 1 59 //! TSPSG release number 59 /*! 60 * \brief TSPSG release number 61 * 62 * Release number meanings: 63 * - 1 -- 3: <b>alpha</b> 1 to 3 64 * - 4 -- 7: <b>beta</b> 1 to 4 65 * - 8 -- 10: <b>rc</b> 1 to 3 66 * - 11 -- x: <b>release</b> 1 to x-10 67 */ 60 68 #define BUILD_RELEASE 2 61 69 … … 63 71 * \brief Current TSPSG build number 64 72 * 65 * This will only change on releases and will be the same as revision number. 66 * 67 * Build number meanings: 68 * - 1 -- 3: <b>alpha</b> 1 to 3 69 * - 4 -- 7: <b>beta</b> 1 to 4 70 * - 8 -- 10: <b>rc</b> 1 to 3 71 * - 11 -- x: <b>release</b> 1 to x-10 73 * This will only change on releases and will be the same as revision number. 72 74 */ 73 75 #define BUILD_NUMBER 65535 … … 77 79 * \brief TSPSG build status 78 80 * 79 * Determined based on BUILD_NUMBER .81 * Determined based on BUILD_NUMBER and BUILD_RELEASE. 80 82 */ 81 83 #if BUILD_NUMBER == 65535 82 84 #define BUILD_STATUS (dev build) 83 #elif BUILD_RELEASE < 4 84 #define BUILD_STATUS (alpha) 85 #elif BUILD_RELEASE < 8 86 #define BUILD_STATUS (beta) 87 #elif BUILD_RELEASE < 11 88 #define BUILD_STATUS (rc) 85 #else 86 #if BUILD_RELEASE < 4 87 #define BUILD_STATUS (alpha) 88 #elif BUILD_RELEASE < 8 89 #define BUILD_STATUS (beta) 90 #elif BUILD_RELEASE < 11 91 #define BUILD_STATUS (rc) 92 #else 93 #define BUILD_STATUS 94 #endif 89 95 #endif // BUILD_NUMBER == 65535 90 96
Note: See TracChangeset
for help on using the changeset viewer.