Changeset 003e4193be in tspsg for src/mainwindow.cpp


Ignore:
Timestamp:
Oct 14, 2007, 5:26:42 AM (17 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.3.145-beta1-symbian, 0.1.4.170-beta2-bb10, appveyor, imgbot, master, readme
Children:
7672bc895b
Parents:
f99964aa0b
Message:

Converted source files to UTF-8
Some code changes :-)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mainwindow.cpp

    rf99964aa0b r003e4193be  
    11/*
    22 *      TSPSG - TSP Solver and Generator
    3  *      Copyright (C) 2007 L¸ppa <lacontacts[at]gmail[dot]com>
     3 *      Copyright (C) 2007 Lёppa <lacontacts[at]gmail[dot]com>
     4 *
     5 *      $Id$
     6 *      $URL$
    47 *
    58 *      This file is part of TSPSG.
     
    2932        setupUi(this);
    3033        connect(actionSettingsSettings,SIGNAL(triggered()),this,SLOT(ChangeSettings()));
     34        connect(spinCities,SIGNAL(valueChanged(int)),this,SLOT(CitiesNumberChanged(int)));
    3135        // Centering MainWindow
    3236        // TODO: Loading of saved window state
     
    3438    rect.moveCenter(QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen()).center());
    3539        setGeometry(rect);
     40        for (int k = 0; k < tableTask->rowCount(); k++) {
     41                QTableWidgetItem *item = new QTableWidgetItem(trUtf8("Город ")+QVariant(k + 1).toString());
     42                tableTask->setVerticalHeaderItem(k,item);
     43        }
     44        for (int k = 0; k < tableTask->columnCount(); k++) {
     45                QTableWidgetItem *item = new QTableWidgetItem(trUtf8("Город ")+QVariant(k + 1).toString());
     46                tableTask->setHorizontalHeaderItem(k,item);
     47        }
     48        tableTask->resizeRowsToContents();
     49        tableTask->resizeColumnsToContents();
     50}
    3651
     52void MainWindow::CitiesNumberChanged(int n)
     53{
     54        // Adding row, setting header and adjusting its size
     55bool increased = tableTask->rowCount() < n ? true : false;
     56        tableTask->setRowCount(n);
     57QTableWidgetItem *item = new QTableWidgetItem(trUtf8("Город ")+QVariant(n).toString());
     58        tableTask->setVerticalHeaderItem(n - 1,item);
     59        if (increased)
     60                tableTask->resizeRowToContents(n - 1);
     61        // Adding column, setting header and adjusting its size
     62        increased = tableTask->columnCount() < n ? true : false;
     63        tableTask->setColumnCount(n);
     64        item = new QTableWidgetItem(trUtf8("Город ")+QVariant(n).toString());
     65        tableTask->setHorizontalHeaderItem(n - 1,item);
     66        if (increased)
     67        tableTask->resizeColumnToContents(n - 1);
     68        tableTask->setMinimumSize(tableTask->sizeHint());
    3769}
    3870
Note: See TracChangeset for help on using the changeset viewer.