Changeset 57 in tspsg-svn for trunk/src


Ignore:
Timestamp:
Aug 23, 2009, 1:26:42 AM (15 years ago)
Author:
laleppa
Message:

+ Created installation (INSTALLS and DEPLOYMENT) entries for *nix, windows and wince platforms in tspsg.pro file. Now qmake generates install rules in Makefile.
+ Automatic resize of columns after their content changes can be turned on/off in settings now.

  • Different search path for translations on different platforms.
  • Updated translations.
Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/globals.h

    r55 r57  
    4343#define DEF_FONT_COLOR Qt::black
    4444
     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
    4559// TSPSG Task file signature - letters TSPT
    4660#define TSPT quint32(0x54535054)
     
    5670#define ZKT_VERSION quint8(1)
    5771
    58 // Maximum available number of cities
    59 #define MAX_NUM_CITIES 30
    6072// This value means infinity :-)
    6173#ifndef INFINITY
     
    6577#define INFSTR "---"
    6678
    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)
    6880#if DEF_NUM_CITIES > MAX_NUM_CITIES
    6981        #undef DEF_NUM_CITIES
    7082        #define DEF_NUM_CITIES MAX_NUM_CITIES
    7183#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
    7294
    7395#endif // GLOBALS_H
  • trunk/src/main.cpp

    r45 r57  
    4343        app.setOrganizationDomain("l-homes.org");
    4444        app.setApplicationName("TSPSG");
     45        app.setApplicationVersion(BUILD_VERSION);
    4546MainWindow mainwindow;
    4647        mainwindow.show();
  • trunk/src/mainwindow.cpp

    r55 r57  
    9696        taskView->setModel(tspmodel);
    9797        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 &)));
    9999        connect(tspmodel,SIGNAL(layoutChanged()),this,SLOT(dataChanged()));
    100100        if ((QCoreApplication::arguments().count() > 1) && (tspmodel->loadTask(QCoreApplication::arguments().at(1))))
     
    148148                else
    149149                        // No luck. Let's try to load bundled one.
    150                         if (qtTranslator->load("qt_" + lang,"i18n"))
     150                        if (qtTranslator->load("qt_" + lang,PATH_I18N))
    151151                                qApp->installTranslator(qtTranslator);
    152152                        else {
     
    156156                        }
    157157                // Now let's load application translation.
    158                 if (translator->load(lang,"i18n"))
     158                if (translator->load(lang,PATH_I18N))
    159159                        qApp->installTranslator(translator);
    160160                else {
     
    191191int count = tspmodel->numCities();
    192192        tspmodel->setNumCities(n);
    193         if (n > count)
     193        if ((n > count) && settings->value("Autosize",true).toBool())
    194194                for (int k = count; k < n; k++) {
    195195                        taskView->resizeColumnToContents(k);
     
    217217        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    218218        tspmodel->clear();
    219         taskView->resizeColumnsToContents();
    220         taskView->resizeRowsToContents();
    221219        setFileName();
    222220        setWindowModified(false);
     
    250248        }
    251249        setFileName(files.first());
    252         taskView->resizeColumnsToContents();
    253         taskView->resizeRowsToContents();
    254250        tabWidget->setCurrentIndex(0);
    255251        setWindowModified(false);
     
    411407        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    412408        tspmodel->randomize();
    413         setWindowModified(true);
    414         taskView->resizeColumnsToContents();
    415         taskView->resizeRowsToContents();
    416409        QApplication::restoreOverrideCursor();
    417410}
     
    521514void MainWindow::loadLangList()
    522515{
    523 QSettings langinfo("i18n/languages.ini",QSettings::IniFormat);
     516QSettings langinfo(PATH_I18N"/languages.ini",QSettings::IniFormat);
    524517#if QT_VERSION >= 0x040500
    525518        // In Qt < 4.5 QSettings doesn't have method setIniCodec.
    526519        langinfo.setIniCodec("UTF-8");
    527520#endif
    528 QDir dir("i18n","*.qm",QDir::Name | QDir::IgnoreCase,QDir::Files);
     521QDir dir(PATH_I18N,"*.qm",QDir::Name | QDir::IgnoreCase,QDir::Files);
    529522        if (!dir.exists())
    530523                return;
     
    606599}
    607600
     601void 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
    608612void MainWindow::numCitiesChanged(int nCities)
    609613{
  • trunk/src/mainwindow.h

    r54 r57  
    5050        void actionHelpAboutTriggered();
    5151        void dataChanged();
     52        void dataChanged(const QModelIndex &, const QModelIndex &);
    5253#ifndef QT_NO_PRINTER
    5354        void printPreview(QPrinter *);
  • trunk/src/settingsdialog.cpp

    r56 r57  
    4444        spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
    4545        vbox2->addItem(spacer);
     46        vbox2->addWidget(cbAutosize);
    4647
    4748        // Output settings group
     
    9293        labelHint->setObjectName("labelHint");
    9394        labelHint->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    94         labelHint->setMinimumSize(QSize(175,28));
     95        labelHint->setMinimumSize(QSize(190,28));
    9596        labelHint->setMaximumSize(QSize(0xFFFFFF,28));
    9697        labelHint->setTextFormat(Qt::PlainText);
     
    130131        vbox2->addItem(spacer);
    131132        vbox2->addLayout(hbox2);
     133        vbox2->addWidget(cbAutosize);
    132134        vbox2->addWidget(cbSaveState);
    133135        spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
     
    164166#endif // Q_OS_WINCE
    165167        settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
     168        spinRandMin->setMaximum(MAX_RAND_VALUE);
    166169        spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt());
     170        spinRandMax->setMaximum(MAX_RAND_VALUE);
    167171        spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt());
     172        cbAutosize->setChecked(settings->value("Autosize",true).toBool());
    168173#ifndef Q_OS_WINCE
    169174        cbSaveState->setChecked(settings->value("SavePos",false).toBool());
     
    180185        settings->setValue("SavePos",cbSaveState->isChecked());
    181186#endif // Q_OS_WINCE
     187        settings->setValue("Autosize",cbAutosize->isChecked());
    182188        settings->setValue("MinCost",spinRandMin->value());
    183189        settings->setValue("MaxCost",spinRandMax->value());
  • trunk/src/settingsdialog.h

    r56 r57  
    5757        void buttonColorClicked();
    5858        void buttonFontClicked();
    59         void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val + 1); }
     59        void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val); }
    6060};
    6161
Note: See TracChangeset for help on using the changeset viewer.