Added column size resizing to content.
[emufront] / src / views / setupeditview.cpp
1 /*
2 ** EmuFront
3 ** Copyright 2010 Mikko Keinänen
4 **
5 ** This file is part of EmuFront.
6 **
7 **
8 ** EmuFront is free software: you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License version 2 as published by
10 ** the Free Software Foundation and appearing in the file gpl.txt included in the
11 ** packaging of this file.
12 **
13 ** EmuFront is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include <QtGui>
22 #include "setupeditview.h"
23 #include "setupmodel.h"
24 #include "comboboxdelegate.h"
25 #include "stringlistdelegate.h"
26 #include "platformmodel.h"
27 #include "mediatypemodel.h"
28 #include <QSqlTableModel>
29
30 SetupEditView::SetupEditView(PlatformModel *plfModel, MediaTypeModel *mdtModel, SetupModel *supModel, QWidget *parent) :
31     EmuFrontEditView(parent), plfModel(plfModel), mdtModel(mdtModel)
32 {
33     setWindowTitle(tr("Setups"));
34     model = supModel;
35     objectList->setModel(model);
36     ComboBoxDelegate *platformDelegate = new ComboBoxDelegate(
37             plfModel,
38             PlatformModel::EmuFrontFileObject_Id,
39             PlatformModel::EmuFrontFileObject_Name,
40             this
41         );
42     objectList->setItemDelegateForColumn(SetupModel::Setup_PlatformId, platformDelegate);
43     ComboBoxDelegate *mediatypeDelegate = new ComboBoxDelegate(
44             mdtModel,
45             MediaTypeModel::EmuFrontFileObject_Id,
46             MediaTypeModel::EmuFrontFileObject_Name,
47             this
48         );
49     objectList->setItemDelegateForColumn(SetupModel::Setup_MediaTypeId, mediatypeDelegate);
50
51     StringListDelegate *fileTypeDelegate = new StringListDelegate(SetupModel::FILE_TYPE_EXTENSION_SEPARATOR, this);
52     objectList->setItemDelegateForColumn(SetupModel::Setup_FileTypeExtensions, fileTypeDelegate);
53         //objectList->setColumnWidth(SetupModel::Setup_FileTypeExtensions, StringListDelegate::WIDTH);
54         objectList->resizeColumnToContents(SetupModel::Setup_FileTypeExtensions);
55     postInit();
56 }
57
58 void SetupEditView::setHiddenColumns()
59 {
60         hiddenColumns << SetupModel::Setup_Id;
61         hiddenColumns << SetupModel::Setup_Name; 
62 }
63
64