Warning, file /games/kmuddy/plugins/converter/converterdialog.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // 0002 // C++ Implementation: converterdialog 0003 // 0004 // Description: Converter Dialog. 0005 // 0006 /* 0007 Copyright 2008-2011 Tomas Mecir <kmuddy@kmuddy.com> 0008 0009 This program is free software; you can redistribute it and/or 0010 modify it under the terms of the GNU General Public License as 0011 published by the Free Software Foundation; either version 2 of 0012 the License, or (at your option) any later version. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #include "converterdialog.h" 0024 0025 #include <klocale.h> 0026 0027 #include <QLabel> 0028 #include <QTreeWidget> 0029 #include <QVBoxLayout> 0030 0031 struct cConverterDialog::Private { 0032 QTreeWidget *tree; 0033 }; 0034 0035 cConverterDialog::cConverterDialog (QWidget *parent) : KDialog (parent) 0036 { 0037 d = new Private; 0038 0039 setInitialSize (QSize (500, 400)); 0040 setCaption (i18n ("Profile Converter")); 0041 0042 setButtons (KDialog::Ok | KDialog::Cancel); 0043 0044 //create main dialog's widget 0045 QWidget *page = new QWidget (this); 0046 QVBoxLayout *layout = new QVBoxLayout (page); 0047 setMainWidget (page); 0048 0049 QLabel *label = new QLabel (i18n ("Pick profiles that you would like to convert and press Ok. This tool will create a new profile containing the information from the chosen profiles. Existing profiles will not be overwritten, even if they have the same name. The old profiles will be kept intact."), this); 0050 label->setWordWrap (true); 0051 0052 d->tree = new QTreeWidget (page); 0053 d->tree->setColumnCount (2); 0054 d->tree->setHeaderLabels (QStringList() << i18n ("Name") << i18n ("Path")); 0055 d->tree->setRootIsDecorated (false); 0056 d->tree->setUniformRowHeights (true); 0057 d->tree->setItemsExpandable (false); 0058 0059 layout->addWidget (label); 0060 layout->addWidget (d->tree); 0061 } 0062 0063 cConverterDialog::~cConverterDialog () 0064 { 0065 delete d; 0066 } 0067 0068 bool cConverterDialog::display (std::list<ConversionDialogItem *> items) 0069 { 0070 d->tree->clear (); 0071 std::list<ConversionDialogItem *>::iterator it; 0072 for (it = items.begin(); it != items.end(); ++it) { 0073 QTreeWidgetItem *item = new QTreeWidgetItem; 0074 item->setText (0, (*it)->name); 0075 item->setText (1, (*it)->path); 0076 item->setFlags (Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); 0077 item->setCheckState (0, Qt::Unchecked); 0078 d->tree->addTopLevelItem (item); 0079 } 0080 0081 // execute the dialog 0082 if (!exec()) return false; 0083 0084 // update the checked flags 0085 int idx = 0; 0086 QTreeWidgetItem *root = d->tree->invisibleRootItem (); 0087 for (it = items.begin(); it != items.end(); ++it) { 0088 QTreeWidgetItem *item = root->child (idx); 0089 (*it)->convert = (item->checkState(0) == Qt::Checked); 0090 ++idx; 0091 } 0092 return true; 0093 } 0094 0095 #include "moc_converterdialog.cpp"