From 4e95d09c1392dc6d123ff0e0c553a3f39530fc46 Mon Sep 17 00:00:00 2001 From: "ivan.ilyin" Date: Tue, 27 Sep 2011 16:48:17 +0300 Subject: [PATCH] SANKORE-137 implement tooltip, testing on Win7 --- src/gui/UBLibraryWidget.cpp | 55 +++++++++++++++++++++++++++++++++++++ src/gui/UBLibraryWidget.h | 8 ++++++ 2 files changed, 63 insertions(+) diff --git a/src/gui/UBLibraryWidget.cpp b/src/gui/UBLibraryWidget.cpp index 1c0007f7..950c88ec 100644 --- a/src/gui/UBLibraryWidget.cpp +++ b/src/gui/UBLibraryWidget.cpp @@ -533,6 +533,8 @@ UBNewFolderDlg::UBNewFolderDlg(QWidget *parent, const char *name):QDialog(parent connect(mpButtons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept())); connect(mpButtons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject())); + connect(mpLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(text_Changed(const QString &))); + connect(mpLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(text_Edited(const QString &))); setMaximumHeight(100); setMinimumHeight(100); @@ -578,3 +580,56 @@ QString UBNewFolderDlg::folderName() { return mpLineEdit->text(); } + +void UBNewFolderDlg::text_Changed(const QString &newText) +{ + +} + +/* +http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx + +< (less than) +> (greater than) +: (colon) +" (double quote) +/ (forward slash) +\ (backslash) // Note: The C++ compiler transforms backslashes in strings. To include a \ in a regexp, enter it twice, i.e. \\. To match the backslash character itself, enter it four times, i.e. \\\\. +| (vertical bar or pipe) +? (question mark) +* (asterisk) + +*/ + +void UBNewFolderDlg::text_Edited(const QString &newText) +{ + + QString new_text = newText; + +#ifdef Q_WS_WIN // Defined on Windows. + QString illegalCharList(" < > : \" / \\ | ? * "); + QRegExp regExp("[<>:\"/\\\\|?*]"); +#endif + +#ifdef Q_WS_QWS // Defined on Qt for Embedded Linux. + QString illegalCharList(" < > : \" / \\ | ? * "); + QRegExp regExp("[<>:\"/\\\\|?*]"); +#endif + +#ifdef Q_WS_MAC // Defined on Mac OS X. + QString illegalCharList(" < > : \" / \\ | ? * "); + QRegExp regExp("[<>:\"/\\\\|?*]"); +#endif + +#ifdef Q_WS_X11 // Defined on X11. + QString illegalCharList(" < > : \" / \\ | ? * "); + QRegExp regExp("[<>:\"/\\\\|?*]"); +#endif + + if(new_text.indexOf(regExp) > -1) + { + new_text.remove(regExp); + mpLineEdit->setText(new_text); + QToolTip::showText(mpLineEdit->mapToGlobal(QPoint()), "A file name can`t contain any of the following characters:\r\n"+illegalCharList); + } +} diff --git a/src/gui/UBLibraryWidget.h b/src/gui/UBLibraryWidget.h index f54bd916..3f05a008 100644 --- a/src/gui/UBLibraryWidget.h +++ b/src/gui/UBLibraryWidget.h @@ -72,6 +72,7 @@ private slots: void onSelectionChanged(); private: + void refreshView(); void generateItems(); void appendChainedElement(UBChainedLibElement* element, UBChainedLibElement* toElem); @@ -89,12 +90,19 @@ private: class UBNewFolderDlg : public QDialog { + Q_OBJECT + public: UBNewFolderDlg(QWidget* parent=0, const char* name="NewFolderDlg"); ~UBNewFolderDlg(); QString folderName(); +public slots: + void text_Changed(const QString &); + void text_Edited(const QString &); + + private: QLabel* mpLabel; QLineEdit* mpLineEdit;