- Timestamp:
- Jun 22, 2009, 1:37:12 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 1 *.idb 2 *.ini 2 3 *.ncb 3 4 *.pdb
-
- Property svn:ignore
-
trunk/resources/tspsg.qrc
r1 r21 1 1 <RCC> 2 <qresource prefix="/images" > 3 <file>About.bmp</file> 4 <file>Icon.png</file> 5 <file>Settings.png</file> 6 <file>Task.bmp</file> 7 </qresource> 8 <qresource prefix="/images/buttons" > 9 <file>buttons/Critical.png</file> 10 <file>buttons/Delete.png</file> 11 <file>buttons/Document.png</file> 12 <file>buttons/Font.png</file> 13 <file>buttons/Help.png</file> 14 <file>buttons/NoAction.png</file> 15 <file>buttons/OK.png</file> 16 <file>buttons/OpenFolder.png</file> 17 <file>buttons/Print.png</file> 18 <file>buttons/PrintSetup.png</file> 19 <file>buttons/Properties.png</file> 20 <file>buttons/Save.png</file> 21 <file>buttons/book_open.png</file> 22 <file>buttons/infoBubble.png</file> 23 </qresource> 2 <qresource prefix="/images" > 3 <file>About.bmp</file> 4 <file>Icon.png</file> 5 <file>Settings.png</file> 6 <file>Task.bmp</file> 7 </qresource> 8 <qresource prefix="/images/buttons" > 9 <file>buttons/Color.png</file> 10 <file>buttons/Critical.png</file> 11 <file>buttons/Delete.png</file> 12 <file>buttons/Document.png</file> 13 <file>buttons/Font.png</file> 14 <file>buttons/Help.png</file> 15 <file>buttons/NoAction.png</file> 16 <file>buttons/OK.png</file> 17 <file>buttons/OpenFolder.png</file> 18 <file>buttons/Print.png</file> 19 <file>buttons/PrintSetup.png</file> 20 <file>buttons/Properties.png</file> 21 <file>buttons/Save.png</file> 22 <file>buttons/book_open.png</file> 23 <file>buttons/infoBubble.png</file> 24 </qresource> 24 25 </RCC> -
trunk/src/main.cpp
r18 r21 30 30 { 31 31 QApplication app(argc, argv); 32 app.setOrganizationName("..::Lёppsville::.."); 33 app.setOrganizationDomain("www.leppsville.com"); 34 app.setApplicationName("TSPSG"); 32 35 /*/ i18n 33 36 // TODO: Make English as program's "native" language -
trunk/src/mainwindow.cpp
r17 r21 26 26 #include <QPrintDialog> 27 27 #endif // Q_OS_WINCE 28 #include "defines.h" 28 29 #include "mainwindow.h" 29 30 30 // TODO: Saving window state on close31 32 31 MainWindow::MainWindow(QWidget *parent) 33 : QMainWindow(parent) , randMin(1), randMax(10)32 : QMainWindow(parent) 34 33 { 35 34 setupUi(this); 35 QSettings settings(INI_FILE,QSettings::IniFormat); 36 spinCities->setValue(settings.value("NumCities",5).toInt()); 36 37 connect(actionSettingsSettings,SIGNAL(triggered()),this,SLOT(ChangeSettings())); 38 connect(actionHelpAbout,SIGNAL(triggered()),this,SLOT(showAbout())); 37 39 #ifndef Q_OS_WINCE 38 40 connect(actionFilePrintSetup,SIGNAL(triggered()),this,SLOT(PrintSetup())); … … 48 50 tabWidget->resize(rect.width(),rect.height() - toolBar->size().height()); 49 51 #else 50 // Centering MainWindow 51 // TODO: Loading of saved window state 52 rect.moveCenter(QApplication::desktop()->availableGeometry().center()); 52 if (settings.value("SavePos",false).toBool()) { 53 // Loading of saved window state 54 settings.beginGroup("MainWindow"); 55 resize(settings.value("Size",size()).toSize()); 56 move(settings.value("Position",pos()).toPoint()); 57 if (settings.value("Maximized",false).toBool()) 58 setWindowState(windowState() | Qt::WindowMaximized); 59 settings.endGroup(); 60 } else { 61 // Centering main window 62 rect.moveCenter(QApplication::desktop()->availableGeometry(this).center()); 63 setGeometry(rect); 64 } 53 65 #endif // Q_OS_WINCE 54 setGeometry(rect);55 66 qsrand(QDateTime().currentDateTime().toTime_t()); 56 67 tspmodel = new CTSPModel(); 57 tspmodel->randMin = randMin;58 tspmodel->randMax = randMax;59 68 tspmodel->setNumCities(spinCities->value()); 60 69 taskView->setModel(tspmodel); 70 #ifdef Q_OS_WINCE 71 taskView->resizeColumnsToContents(); 72 taskView->resizeRowsToContents(); 73 #endif // Q_OS_WINCE 61 74 } 62 75 63 76 void MainWindow::CitiesNumberChanged(int n) 64 77 { 78 #ifdef Q_OS_WINCE 79 int count = tspmodel->numCities(); 80 #endif // Q_OS_WINCE 65 81 tspmodel->setNumCities(n); 82 #ifdef Q_OS_WINCE 83 if (n > count) 84 for (int k = count; k < n; k++) { 85 taskView->resizeColumnToContents(k); 86 taskView->resizeRowToContents(k); 87 } 88 #endif // Q_OS_WINCE 66 89 } 67 90 … … 69 92 { 70 93 SettingsDialog sd(this); 71 sd.spinRandMin->setValue(randMin); 72 sd.spinRandMax->setValue(randMax); 73 if (sd.exec() == QDialog::Accepted) { 74 randMin = sd.spinRandMin->value(); 75 randMax = sd.spinRandMax->value(); 76 } 94 sd.exec(); 77 95 } 78 96 … … 88 106 { 89 107 tspmodel->randomize(); 108 #ifdef Q_OS_WINCE 109 taskView->resizeColumnsToContents(); 110 taskView->resizeRowsToContents(); 111 #endif // Q_OS_WINCE 90 112 } 91 113 … … 114 136 // tabWidget->setCurrentIndex(1); 115 137 } 138 139 void MainWindow::showAbout() 140 { 141 // TODO: Normal about window :-) 142 QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n\ 143 Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n\ 144 Qt library versions:\n\ 145 Compile time: %2\n\ 146 Runtime: %3\n\ 147 \n\ 148 TSPSG is licensed under the terms of the GNU General Public License. You should have received a copy of the GNU General Public License along with TSPSG.").arg(QDate().toString("%Y"),QT_VERSION_STR,qVersion()); 149 QMessageBox(QMessageBox::Information,"About",about).exec(); 150 } 151 152 #ifndef Q_OS_WINCE 153 void MainWindow::closeEvent(QCloseEvent *event) 154 { 155 // Saving windows state 156 QSettings settings(INI_FILE,QSettings::IniFormat); 157 settings.setValue("NumCities",spinCities->value()); 158 if (settings.value("SavePos",false).toBool()) { 159 settings.beginGroup("MainWindow"); 160 settings.setValue("Maximized",isMaximized()); 161 if (!isMaximized()) { 162 settings.setValue("Size",size()); 163 settings.setValue("Position",pos()); 164 } 165 settings.endGroup(); 166 } 167 QMainWindow::closeEvent(event); 168 } 169 #endif // Q_OS_WINCE -
trunk/src/mainwindow.h
r17 r21 40 40 public: 41 41 MainWindow(QWidget *parent = 0); 42 #ifndef Q_OS_WINCE 43 void closeEvent(QCloseEvent *event); 44 #endif // Q_OS_WINCE 42 45 private slots: 43 46 void ChangeSettings(); 47 void showAbout(); 44 48 #ifndef Q_OS_WINCE 45 49 void PrintSetup(); … … 50 54 private: 51 55 CTSPModel *tspmodel; 52 int randMin;53 int randMax;54 56 }; 55 57 -
trunk/src/settingsdialog.cpp
r17 r21 25 25 #include <QStatusTipEvent> 26 26 #include <QFontDialog> 27 #include <QColorDialog> 28 #include "defines.h" 27 29 #include "settingsdialog.h" 28 30 … … 35 37 connect(spinRandMin,SIGNAL(valueChanged(int)),this,SLOT(spinRandMinValueChanged(int))); 36 38 connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked())); 39 connect(buttonColor,SIGNAL(clicked()),this,SLOT(buttonColorClicked())); 37 40 // setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint); 38 41 setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint); … … 47 50 labelHint->setMinimumHeight(labelHint->height()); 48 51 #endif // Q_OS_WINCE 52 settings = new QSettings(INI_FILE,QSettings::IniFormat); 53 spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt()); 54 spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt()); 55 #ifndef Q_OS_WINCE 56 cbSaveState->setChecked(settings->value("SavePos",false).toBool()); 57 #endif // Q_OS_WINCE 58 settings->beginGroup("Print"); 59 font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>(); 60 color = settings->value("Color",DEF_FONT_COLOR).value<QColor>(); 61 #ifndef Q_OS_WINCE 62 spinLeftMargin->setValue(settings->value("Offset",DEF_OFFSET).toInt()); 63 #endif // Q_OS_WINCE 64 settings->endGroup(); 49 65 } 50 66 … … 69 85 void SettingsDialog::buttonFontClicked() 70 86 { 71 // TODO: Pass current font to dialog and save selected. 72 QFontDialog fd; 73 fd.exec(); 87 bool ok; 88 QFont font = QFontDialog::getFont(&ok,this->font,this); 89 if (ok) 90 this->font = font; 74 91 } 92 93 void SettingsDialog::buttonColorClicked() 94 { 95 QColorDialog cd(color,this); 96 if (cd.exec() == QDialog::Accepted) 97 color = cd.selectedColor(); 98 } 99 100 void SettingsDialog::accept() 101 { 102 #ifndef Q_OS_WINCE 103 settings->setValue("SavePos",cbSaveState->isChecked()); 104 #endif // Q_OS_WINCE 105 settings->setValue("MinCost",spinRandMin->value()); 106 settings->setValue("MaxCost",spinRandMax->value()); 107 settings->beginGroup("Print"); 108 settings->setValue("Font",font); 109 settings->setValue("Color",color); 110 #ifndef Q_OS_WINCE 111 settings->setValue("Offset",spinLeftMargin->value()); 112 #endif // Q_OS_WINCE 113 settings->endGroup(); 114 QDialog::accept(); 115 } -
trunk/src/settingsdialog.h
r17 r21 26 26 27 27 #include <QDialog> 28 #include <QSettings> 28 29 #ifdef Q_OS_WINCE 29 30 #include "ui_settingsdialog.ce.h" … … 39 40 40 41 private: 41 #ifndef WINCE 42 QSettings *settings; 43 QFont font; 44 QColor color; 45 #ifndef Q_OS_WINCE 42 46 bool event(QEvent *); 43 47 #endif 44 48 45 49 private slots: 50 void accept(); 46 51 void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val + 1); } 47 52 void buttonFontClicked(); 53 void buttonColorClicked(); 48 54 }; 49 55 -
trunk/src/tspmodel.cpp
r19 r21 23 23 24 24 #include <QtGui> 25 #include "defines.h" 25 26 #include "tspmodel.h" 26 27 27 28 CTSPModel::CTSPModel(QObject *parent) 28 : QAbstractTableModel(parent), randMin(1), randMax(10),nCities(0)29 : QAbstractTableModel(parent), nCities(0) 29 30 { 31 settings = new QSettings(INI_FILE,QSettings::IniFormat); 30 32 } 31 33 … … 115 117 void CTSPModel::setNumCities(int n) 116 118 { 119 int randMin = settings->value("MinCost",DEF_RAND_MIN).toInt(); 120 int randMax = settings->value("MaxCost",DEF_RAND_MAX).toInt(); 117 121 if (n == nCities) 118 122 return; … … 140 144 void CTSPModel::randomize() 141 145 { 146 int randMin = settings->value("MinCost",DEF_RAND_MIN).toInt(); 147 int randMax = settings->value("MaxCost",DEF_RAND_MAX).toInt(); 142 148 for (int r = 0; r < nCities; r++) 143 149 for (int c = 0; c < nCities; c++) -
trunk/src/tspmodel.h
r17 r21 31 31 #define MAX_CITIES 100 32 32 // This value means infinity :-) 33 #define INFINITY 1.7E+308 33 #ifndef INFINITY 34 #define INFINITY 1.7E+308 35 #endif 34 36 // This is string, which represents infinite value in table 35 37 #define INFSTR "---" 36 38 37 39 #include <QAbstractTableModel> 40 #include <QSettings> 38 41 39 42 class CTSPModel: public QAbstractTableModel … … 51 54 void setNumCities(int); 52 55 void randomize(); 53 int randMin;54 int randMax;55 56 private: 57 QSettings *settings; 56 58 double table[MAX_CITIES][MAX_CITIES]; 57 59 int nCities; -
trunk/ui/mainwindow.ce.ui
r17 r21 350 350 <string>Сохранить ход и граф решения</string> 351 351 </property> 352 <property name="shortcut">353 <string>Ctrl+S</string>354 </property>355 352 </action> 356 353 <action name="actionFileNew"> -
trunk/ui/mainwindow.ui
r17 r21 369 369 <string>Сохранить ход и граф решения</string> 370 370 </property> 371 <property name="shortcut">372 <string>Ctrl+S</string>373 </property>374 371 </action> 375 372 <action name="actionFileNew"> -
trunk/ui/settingsdialog.ce.ui
r17 r21 7 7 <x>0</x> 8 8 <y>0</y> 9 <width>2 29</width>9 <width>235</width> 10 10 <height>264</height> 11 11 </rect> … … 195 195 </item> 196 196 <item> 197 <widget class="QPushButton" name="buttonColor"> 198 <property name="text"> 199 <string>&Цвет...</string> 200 </property> 201 <property name="icon"> 202 <iconset resource="../resources/tspsg.qrc"> 203 <normaloff>:/images/buttons/buttons/Color.png</normaloff>:/images/buttons/buttons/Color.png</iconset> 204 </property> 205 </widget> 206 </item> 207 <item> 197 208 <widget class="QPushButton" name="buttonFont"> 198 209 <property name="cursor"> … … 226 237 </spacer> 227 238 </item> 228 <item>229 <layout class="QHBoxLayout" name="horizontalLayout">230 <item>231 <spacer name="horizontalSpacer">232 <property name="orientation">233 <enum>Qt::Horizontal</enum>234 </property>235 <property name="sizeHint" stdset="0">236 <size>237 <width>40</width>238 <height>20</height>239 </size>240 </property>241 </spacer>242 </item>243 <item>244 <widget class="QCheckBox" name="checkBox">245 <property name="cursor">246 <cursorShape>PointingHandCursor</cursorShape>247 </property>248 <property name="statusTip">249 <string>Восстанавливать состояние и размеры окна после перезапуска программы</string>250 </property>251 <property name="text">252 <string>Сохранять состояние и253 положение главного окна</string>254 </property>255 <property name="checked">256 <bool>false</bool>257 </property>258 </widget>259 </item>260 <item>261 <spacer name="horizontalSpacer_2">262 <property name="orientation">263 <enum>Qt::Horizontal</enum>264 </property>265 <property name="sizeHint" stdset="0">266 <size>267 <width>40</width>268 <height>20</height>269 </size>270 </property>271 </spacer>272 </item>273 </layout>274 </item>275 239 </layout> 276 240 </widget> -
trunk/ui/settingsdialog.ui
r17 r21 7 7 <x>0</x> 8 8 <y>0</y> 9 <width>4 36</width>9 <width>466</width> 10 10 <height>172</height> 11 11 </rect> … … 235 235 <string>Настройки печати:</string> 236 236 </property> 237 <layout class="QVBoxLayout" >237 <layout class="QVBoxLayout" name="verticalLayout"> 238 238 <item> 239 239 <layout class="QHBoxLayout"> … … 270 270 </item> 271 271 <item> 272 <widget class="Q PushButton" name="buttonFont">273 <property name=" cursor">274 < cursorShape>PointingHandCursor</cursorShape>272 <widget class="QSplitter" name="splitter"> 273 <property name="orientation"> 274 <enum>Qt::Horizontal</enum> 275 275 </property> 276 <property name="statusTip"> 277 <string>Задать параметры шрифта, используемого при печати</string> 278 </property> 279 <property name="text"> 280 <string>&Шрифт...</string> 281 </property> 282 <property name="icon"> 283 <iconset resource="../resources/tspsg.qrc"> 284 <normaloff>:/images/buttons/buttons/Font.png</normaloff>:/images/buttons/buttons/Font.png</iconset> 285 </property> 276 <widget class="QPushButton" name="buttonColor"> 277 <property name="cursor"> 278 <cursorShape>PointingHandCursor</cursorShape> 279 </property> 280 <property name="text"> 281 <string>&Цвет...</string> 282 </property> 283 <property name="icon"> 284 <iconset resource="../resources/tspsg.qrc"> 285 <normaloff>:/images/buttons/buttons/Color.png</normaloff>:/images/buttons/buttons/Color.png</iconset> 286 </property> 287 </widget> 288 <widget class="QPushButton" name="buttonFont"> 289 <property name="cursor"> 290 <cursorShape>PointingHandCursor</cursorShape> 291 </property> 292 <property name="statusTip"> 293 <string>Задать параметры шрифта, используемого при печати</string> 294 </property> 295 <property name="text"> 296 <string>&Шрифт...</string> 297 </property> 298 <property name="icon"> 299 <iconset resource="../resources/tspsg.qrc"> 300 <normaloff>:/images/buttons/buttons/Font.png</normaloff>:/images/buttons/buttons/Font.png</iconset> 301 </property> 302 </widget> 286 303 </widget> 287 304 </item> … … 292 309 </item> 293 310 <item> 294 <widget class="QCheckBox" name="c heckBox">311 <widget class="QCheckBox" name="cbSaveState"> 295 312 <property name="cursor"> 296 313 <cursorShape>PointingHandCursor</cursorShape> … … 427 444 <resources> 428 445 <include location="../resources/tspsg.qrc"/> 446 <include location="../resources/tspsg.qrc"/> 429 447 </resources> 430 448 <connections/>
Note: See TracChangeset
for help on using the changeset viewer.