Changeset 2fb523720a in tspsg for src
- Timestamp:
- Aug 23, 2009, 1:26:42 AM (15 years ago)
- Branches:
- 0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
- Children:
- 5a81a64d74
- Parents:
- 281303f1f7
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/globals.h
r281303f1f7 r2fb523720a 43 43 #define DEF_FONT_COLOR Qt::black 44 44 45 // Maximum available number of cities 46 #define MAX_NUM_CITIES 30 47 // Maximum for random generation limit settings 48 #define MAX_RAND_VALUE 1000 49 50 // Paths 51 #if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) 52 #define PATH_I18N "/usr/share/tspsg/i18n" 53 #define PATH_DOCS "/usr/share/doc/tspsg" 54 #else 55 #define PATH_I18N "i18n" 56 #define PATH_DOCS "help" 57 #endif // Q_OS_LINUX 58 45 59 // TSPSG Task file signature - letters TSPT 46 60 #define TSPT quint32(0x54535054) … … 56 70 #define ZKT_VERSION quint8(1) 57 71 58 // Maximum available number of cities59 #define MAX_NUM_CITIES 3060 72 // This value means infinity :-) 61 73 #ifndef INFINITY … … 65 77 #define INFSTR "---" 66 78 67 // Let's check that default number of cities is sane (<= MAX_NUM_CITIES)79 // Check that default number of cities is sane (<= MAX_NUM_CITIES) 68 80 #if DEF_NUM_CITIES > MAX_NUM_CITIES 69 81 #undef DEF_NUM_CITIES 70 82 #define DEF_NUM_CITIES MAX_NUM_CITIES 71 83 #endif 84 // Check that maximum for random generation is sane (<= MAX_RAND_VALUE) 85 #if DEF_RAND_MAX > MAX_RAND_VALUE 86 #undef DEF_RAND_MAX 87 #define DEF_RAND_MAX MAX_RAND_VALUE 88 #endif 89 // Check that DEF_RAND_MIN <= DEF_RAND_MAX 90 #if DEF_RAND_MIN > DEF_RAND_MAX 91 #undef DEF_RAND_MIN 92 #define DEF_RAND_MIN DEF_RAND_MAX 93 #endif 72 94 73 95 #endif // GLOBALS_H -
src/main.cpp
r281303f1f7 r2fb523720a 43 43 app.setOrganizationDomain("l-homes.org"); 44 44 app.setApplicationName("TSPSG"); 45 app.setApplicationVersion(BUILD_VERSION); 45 46 MainWindow mainwindow; 46 47 mainwindow.show(); -
src/mainwindow.cpp
r281303f1f7 r2fb523720a 96 96 taskView->setModel(tspmodel); 97 97 connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int))); 98 connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged( )));98 connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged(const QModelIndex &, const QModelIndex &))); 99 99 connect(tspmodel,SIGNAL(layoutChanged()),this,SLOT(dataChanged())); 100 100 if ((QCoreApplication::arguments().count() > 1) && (tspmodel->loadTask(QCoreApplication::arguments().at(1)))) … … 148 148 else 149 149 // No luck. Let's try to load bundled one. 150 if (qtTranslator->load("qt_" + lang, "i18n"))150 if (qtTranslator->load("qt_" + lang,PATH_I18N)) 151 151 qApp->installTranslator(qtTranslator); 152 152 else { … … 156 156 } 157 157 // Now let's load application translation. 158 if (translator->load(lang, "i18n"))158 if (translator->load(lang,PATH_I18N)) 159 159 qApp->installTranslator(translator); 160 160 else { … … 191 191 int count = tspmodel->numCities(); 192 192 tspmodel->setNumCities(n); 193 if ( n > count)193 if ((n > count) && settings->value("Autosize",true).toBool()) 194 194 for (int k = count; k < n; k++) { 195 195 taskView->resizeColumnToContents(k); … … 217 217 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 218 218 tspmodel->clear(); 219 taskView->resizeColumnsToContents();220 taskView->resizeRowsToContents();221 219 setFileName(); 222 220 setWindowModified(false); … … 250 248 } 251 249 setFileName(files.first()); 252 taskView->resizeColumnsToContents();253 taskView->resizeRowsToContents();254 250 tabWidget->setCurrentIndex(0); 255 251 setWindowModified(false); … … 411 407 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); 412 408 tspmodel->randomize(); 413 setWindowModified(true);414 taskView->resizeColumnsToContents();415 taskView->resizeRowsToContents();416 409 QApplication::restoreOverrideCursor(); 417 410 } … … 521 514 void MainWindow::loadLangList() 522 515 { 523 QSettings langinfo( "i18n/languages.ini",QSettings::IniFormat);516 QSettings langinfo(PATH_I18N"/languages.ini",QSettings::IniFormat); 524 517 #if QT_VERSION >= 0x040500 525 518 // In Qt < 4.5 QSettings doesn't have method setIniCodec. 526 519 langinfo.setIniCodec("UTF-8"); 527 520 #endif 528 QDir dir( "i18n","*.qm",QDir::Name | QDir::IgnoreCase,QDir::Files);521 QDir dir(PATH_I18N,"*.qm",QDir::Name | QDir::IgnoreCase,QDir::Files); 529 522 if (!dir.exists()) 530 523 return; … … 606 599 } 607 600 601 void MainWindow::dataChanged(const QModelIndex &tl, const QModelIndex &br) 602 { 603 setWindowModified(true); 604 if (settings->value("Autosize",true).toBool()) { 605 for (int k = tl.row(); k <= br.row(); k++) 606 taskView->resizeRowToContents(k); 607 for (int k = tl.column(); k <= br.column(); k++) 608 taskView->resizeColumnToContents(k); 609 } 610 } 611 608 612 void MainWindow::numCitiesChanged(int nCities) 609 613 { -
src/mainwindow.h
r281303f1f7 r2fb523720a 50 50 void actionHelpAboutTriggered(); 51 51 void dataChanged(); 52 void dataChanged(const QModelIndex &, const QModelIndex &); 52 53 #ifndef QT_NO_PRINTER 53 54 void printPreview(QPrinter *); -
src/settingsdialog.cpp
r281303f1f7 r2fb523720a 44 44 spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding); 45 45 vbox2->addItem(spacer); 46 vbox2->addWidget(cbAutosize); 46 47 47 48 // Output settings group … … 92 93 labelHint->setObjectName("labelHint"); 93 94 labelHint->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 94 labelHint->setMinimumSize(QSize(1 75,28));95 labelHint->setMinimumSize(QSize(190,28)); 95 96 labelHint->setMaximumSize(QSize(0xFFFFFF,28)); 96 97 labelHint->setTextFormat(Qt::PlainText); … … 130 131 vbox2->addItem(spacer); 131 132 vbox2->addLayout(hbox2); 133 vbox2->addWidget(cbAutosize); 132 134 vbox2->addWidget(cbSaveState); 133 135 spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding); … … 164 166 #endif // Q_OS_WINCE 165 167 settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg"); 168 spinRandMin->setMaximum(MAX_RAND_VALUE); 166 169 spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt()); 170 spinRandMax->setMaximum(MAX_RAND_VALUE); 167 171 spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt()); 172 cbAutosize->setChecked(settings->value("Autosize",true).toBool()); 168 173 #ifndef Q_OS_WINCE 169 174 cbSaveState->setChecked(settings->value("SavePos",false).toBool()); … … 180 185 settings->setValue("SavePos",cbSaveState->isChecked()); 181 186 #endif // Q_OS_WINCE 187 settings->setValue("Autosize",cbAutosize->isChecked()); 182 188 settings->setValue("MinCost",spinRandMin->value()); 183 189 settings->setValue("MaxCost",spinRandMax->value()); -
src/settingsdialog.h
r281303f1f7 r2fb523720a 57 57 void buttonColorClicked(); 58 58 void buttonFontClicked(); 59 void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val + 1); }59 void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val); } 60 60 }; 61 61
Note: See TracChangeset
for help on using the changeset viewer.