Changeset 21 in tspsg-svn for trunk/src/mainwindow.cpp
- Timestamp:
- Jun 22, 2009, 1:37:12 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 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/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
Note: See TracChangeset
for help on using the changeset viewer.