summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/comboboxviewdelegate.cpp55
-rw-r--r--rbutil/rbutilqt/comboboxviewdelegate.h31
-rw-r--r--rbutil/rbutilqt/configure.cpp28
-rw-r--r--rbutil/rbutilqt/rbutilqt.pri2
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro1
5 files changed, 106 insertions, 11 deletions
diff --git a/rbutil/rbutilqt/comboboxviewdelegate.cpp b/rbutil/rbutilqt/comboboxviewdelegate.cpp
new file mode 100644
index 0000000000..74e3dc76e1
--- /dev/null
+++ b/rbutil/rbutilqt/comboboxviewdelegate.cpp
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2011 by Dominik Riebeling
+ * $Id$
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <QtGui>
+#include <qdebug.h>
+#include "comboboxviewdelegate.h"
+
+void ComboBoxViewDelegate::paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ QPen pen;
+ QFont font;
+ pen = painter->pen();
+ font = painter->font();
+
+ painter->save();
+ // paint selection
+ if(option.state & QStyle::State_Selected) {
+ painter->setPen(QPen(Qt::NoPen));
+ painter->setBrush(QApplication::palette().highlight());
+ painter->drawRect(option.rect);
+ painter->restore();
+ painter->save();
+ pen.setColor(QApplication::palette().color(QPalette::HighlightedText));
+ }
+ else {
+ pen.setColor(QApplication::palette().color(QPalette::Text));
+ }
+ // draw data (text)
+ painter->setPen(pen);
+ painter->drawText(option.rect, Qt::AlignLeft, index.data().toString());
+
+ // draw user data right aligned, italic
+ font.setItalic(true);
+ painter->setFont(font);
+ painter->drawText(option.rect, Qt::AlignRight, index.data(Qt::UserRole).toString());
+ painter->restore();
+}
+
diff --git a/rbutil/rbutilqt/comboboxviewdelegate.h b/rbutil/rbutilqt/comboboxviewdelegate.h
new file mode 100644
index 0000000000..91edbe3958
--- /dev/null
+++ b/rbutil/rbutilqt/comboboxviewdelegate.h
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2011 by Dominik Riebeling
+ * $Id$
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <QtGui>
+
+class ComboBoxViewDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+ public:
+ ComboBoxViewDelegate(QObject* parent = 0) : QStyledItemDelegate(parent) { }
+
+ void paint(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+};
+
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index eeac492dff..4ce2acb5e6 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -31,7 +31,7 @@
#include "serverinfo.h"
#include "systeminfo.h"
#include "utils.h"
-#include <stdio.h>
+#include "comboboxviewdelegate.h"
#if defined(Q_OS_WIN32)
#if defined(UNICODE)
#define _UNICODE
@@ -65,6 +65,13 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
ui.listLanguages->addItem(i.key());
i++;
}
+
+ ComboBoxViewDelegate *delegate = new ComboBoxViewDelegate(this);
+ ui.mountPoint->setItemDelegate(delegate);
+#if !defined(DBG)
+ ui.mountPoint->setEditable(false);
+#endif
+
ui.listLanguages->setSelectionMode(QAbstractItemView::SingleSelection);
ui.proxyPass->setEchoMode(QLineEdit::Password);
ui.treeDevices->setAlternatingRowColors(true);
@@ -586,12 +593,11 @@ void Config::refreshMountpoint()
// later (to include volume label or similar)
// Skip unwritable mountpoints, they are not useable for us.
if(QFileInfo(mps.at(i)).isWritable()) {
- QString title = QString("%1 %4 (%2 GiB of %3 GiB free)")
- .arg(QDir::toNativeSeparators(mps.at(i)))
+ QString description = QString("%1 (%2 GiB of %3 GiB free)")
+ .arg(Utils::filesystemName(mps.at(i)))
.arg((double)Utils::filesystemFree(mps.at(i))/(1<<30), 0, 'f', 2)
- .arg((double)Utils::filesystemTotal(mps.at(i))/(1<<30), 0, 'f', 2)
- .arg(Utils::filesystemName(mps.at(i)));
- ui.mountPoint->addItem(title, mps.at(i));
+ .arg((double)Utils::filesystemTotal(mps.at(i))/(1<<30), 0, 'f', 2);
+ ui.mountPoint->addItem(QDir::toNativeSeparators(mps.at(i)), description);
}
}
if(!mountpoint.isEmpty()) {
@@ -604,7 +610,7 @@ void Config::refreshMountpoint()
void Config::updateMountpoint(QString m)
{
if(!m.isEmpty()) {
- mountpoint = m;
+ mountpoint = QDir::fromNativeSeparators(m);
qDebug() << "[Config] Mountpoint set to" << mountpoint;
}
}
@@ -615,9 +621,9 @@ void Config::updateMountpoint(int idx)
if(idx == -1) {
return;
}
- QString mp = ui.mountPoint->itemData(idx).toString();
+ QString mp = ui.mountPoint->itemText(idx);
if(!mp.isEmpty()) {
- mountpoint = mp;
+ mountpoint = QDir::fromNativeSeparators(mp);
qDebug() << "[Config] Mountpoint set to" << mountpoint;
}
}
@@ -628,14 +634,14 @@ void Config::setMountpoint(QString m)
if(m.isEmpty()) {
return;
}
- int index = ui.mountPoint->findData(m);
+ int index = ui.mountPoint->findText(QDir::toNativeSeparators(m));
if(index != -1) {
ui.mountPoint->setCurrentIndex(index);
}
else {
// keep a mountpoint that is not in the list for convenience (to allow
// easier development)
- ui.mountPoint->addItem(m);
+ ui.mountPoint->addItem(QDir::toNativeSeparators(m));
ui.mountPoint->setCurrentIndex(ui.mountPoint->findText(m));
}
qDebug() << "[Config] Mountpoint set to" << mountpoint;
diff --git a/rbutil/rbutilqt/rbutilqt.pri b/rbutil/rbutilqt/rbutilqt.pri
index b0052c38b5..0f887d7070 100644
--- a/rbutil/rbutilqt/rbutilqt.pri
+++ b/rbutil/rbutilqt/rbutilqt.pri
@@ -73,6 +73,7 @@ SOURCES += \
quazip/zip.c \
quazip/ioapi.c \
base/ziputil.cpp \
+ comboboxviewdelegate.cpp \
HEADERS += \
@@ -141,6 +142,7 @@ HEADERS += \
quazip/unzip.h \
quazip/zip.h \
base/ziputil.h \
+ comboboxviewdelegate.h \
FORMS += \
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index c2e3c93f13..7186c8b7e5 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -132,6 +132,7 @@ QT += network
dbg {
CONFIG += debug thread qt warn_on
DEFINES -= QT_NO_DEBUG_OUTPUT
+ DEFINES += DBG
message("debug")
}
!dbg {