Implemented combobox for game file selection

actorid
graffy76 12 years ago
parent bfb71f23c9
commit 84e5c2610a

@ -101,7 +101,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
//connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter()));

@ -41,6 +41,8 @@ FileDialog::FileDialog(QWidget *parent) :
QCheckBox checkBox;
unsigned int height = checkBox.sizeHint().height() + 4;
masterView->setModel(mMastersProxyModel);
mastersTable->setModel(mMastersProxyModel);
mastersTable->setObjectName("MastersTable");
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
@ -83,12 +85,12 @@ FileDialog::FileDialog(QWidget *parent) :
mNameLabel = new QLabel(tr("File Name:"), this);
QRegExpValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9\\s]*$"));
mNameLineEdit = new LineEdit(this);
mNameLineEdit->setValidator(validator);
//mNameLineEdit = new LineEdit(this);
//mNameLineEdit->setValidator(validator);
nameLayout->addSpacerItem(spacer);
nameLayout->addWidget(mNameLabel);
nameLayout->addWidget(mNameLineEdit);
//nameLayout->addWidget(mNameLineEdit);
mButtonBox = new QDialogButtonBox(this);
@ -109,9 +111,9 @@ FileDialog::FileDialog(QWidget *parent) :
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
//connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
//connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
@ -223,7 +225,7 @@ QStringList FileDialog::checkedItemsPaths()
QString FileDialog::fileName()
{
return mNameLineEdit->text();
//return mNameLineEdit->text();
}
void FileDialog::openFile()
@ -231,7 +233,7 @@ void FileDialog::openFile()
setWindowTitle(tr("Open"));
mNameLabel->hide();
mNameLineEdit->hide();
//mNameLineEdit->hide();
mCreateButton->hide();
mButtonBox->removeButton(mCreateButton);
@ -249,8 +251,8 @@ void FileDialog::newFile()
setWindowTitle(tr("New"));
mNameLabel->show();
mNameLineEdit->clear();
mNameLineEdit->show();
//mNameLineEdit->clear();
//mNameLineEdit->show();
mCreateButton->show();
mButtonBox->setStandardButtons(QDialogButtonBox::Cancel);

@ -51,7 +51,7 @@ private slots:
private:
QLabel *mNameLabel;
LineEdit *mNameLineEdit;
//LineEdit *mNameLineEdit;
QPushButton *mCreateButton;
QDialogButtonBox *mButtonBox;

@ -90,3 +90,19 @@ void ProfilesComboBox::slotIndexChanged(int index)
emit(profileChanged(mOldProfile, currentText()));
mOldProfile = itemText(index);
}
void ProfilesComboBox::paintEvent(QPaintEvent *)
{
QStylePainter painter(this);
painter.setPen(palette().color(QPalette::Text));
// draw the combobox frame, focusrect and selected etc.
QStyleOptionComboBox opt;
initStyleOption(&opt);
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
// draw the icon and text
if (!opt.editable && currentIndex() == -1) // <<< we adjust the text displayed when nothing is selected
opt.currentText = tr("Select a game file...");
painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
}

@ -2,7 +2,7 @@
#define PROFILESCOMBOBOX_HPP
#include <QComboBox>
#include <QStylePainter>
class QString;
class QRegExpValidator;
@ -25,6 +25,9 @@ private slots:
private:
QString mOldProfile;
QRegExpValidator *mValidator;
protected:
void paintEvent(QPaintEvent *);
};
#endif // PROFILESCOMBOBOX_HPP

@ -14,28 +14,12 @@
<item>
<layout class="QHBoxLayout" name="filterLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Filter:</string>
<widget class="ProfilesComboBox" name="masterView">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="LineEdit" name="filterLineEdit"/>
</item>
</layout>
</item>
<item>
@ -151,11 +135,6 @@
</action>
</widget>
<customwidgets>
<customwidget>
<class>LineEdit</class>
<extends>QLineEdit</extends>
<header location="global">components/fileorderlist/utils/lineedit.hpp</header>
</customwidget>
<customwidget>
<class>ProfilesComboBox</class>
<extends>QComboBox</extends>

Loading…
Cancel
Save