Changeset 17047 in vbox
- Timestamp:
- Feb 24, 2009 9:43:09 AM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxFilePathSelectorWidget.h
r13564 r17047 50 50 Mode mode() const; 51 51 52 void setEditable (bool aOn); 53 bool isEditable() const; 54 52 55 void setResetEnabled (bool aEnabled); 53 56 bool isResetEnabled () const; 54 57 58 void setFileDialogTitle (const QString& aTitle); 59 QString fileDialogTitle() const; 60 61 void setFileFilters (const QString& aFilters); 62 QString fileFilters() const; 63 64 void resetModified(); 55 65 bool isModified() const; 56 66 bool isPathSelected() const; 57 67 58 68 QString path() const; 69 70 signals: 71 void pathChanged (const QString &); 59 72 60 73 public slots: … … 92 105 QString mPath; 93 106 QString mHomeDir; 107 QString mFileFilters; 108 QString mFileDialogTitle; 94 109 QString mNoneStr; 95 110 QString mNoneTip; 111 bool mIsEditable; 96 112 bool mIsEditableMode; 97 113 bool mIsMouseAwaited; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFilePathSelectorWidget.cpp
r13564 r17047 62 62 , mMode (Mode_Folder) 63 63 , mHomeDir (QDir::current().absolutePath()) 64 , mIsEditable (true) 64 65 , mIsEditableMode (false) 65 66 , mIsMouseAwaited (false) … … 81 82 82 83 /* Initial Setup */ 83 setEditable (true);84 Assert (lineEdit());85 84 setInsertPolicy (QComboBox::NoInsert); 86 85 setContextMenuPolicy (Qt::ActionsContextMenu); … … 89 88 /* Setup connections */ 90 89 connect (this, SIGNAL (activated (int)), this, SLOT (onActivated (int))); 91 connect (lineEdit(), SIGNAL (textEdited (const QString &)),92 this, SLOT (onTextEdited (const QString &)));93 90 connect (mCopyAction, SIGNAL (triggered (bool)), this, SLOT (copyToClipboard())); 91 92 /* Editable by default */ 93 setEditable (true); 94 94 95 95 /* Applying language settings */ 96 96 retranslateUi(); 97 98 /* Installing necessary event filters */99 lineEdit()->installEventFilter (this);100 97 } 101 98 … … 113 110 { 114 111 return mMode; 112 } 113 114 void VBoxFilePathSelectorWidget::setEditable (bool aOn) 115 { 116 mIsEditable = aOn; 117 118 if (mIsEditable) 119 { 120 QComboBox::setEditable (true); 121 Assert (lineEdit()); 122 connect (lineEdit(), SIGNAL (textEdited (const QString &)), 123 this, SLOT (onTextEdited (const QString &))); 124 125 /* Installing necessary event filters */ 126 lineEdit()->installEventFilter (this); 127 }else 128 { 129 if (lineEdit()) 130 { 131 /* Installing necessary event filters */ 132 lineEdit()->installEventFilter (this); 133 disconnect (lineEdit(), SIGNAL (textEdited (const QString &)), 134 this, SLOT (onTextEdited (const QString &))); 135 } 136 QComboBox::setEditable (false); 137 } 138 } 139 140 bool VBoxFilePathSelectorWidget::isEditable() const 141 { 142 return mIsEditable; 115 143 } 116 144 … … 132 160 } 133 161 162 void VBoxFilePathSelectorWidget::resetModified() 163 { 164 mModified = false; 165 } 166 134 167 bool VBoxFilePathSelectorWidget::isModified() const 135 168 { 136 169 return mModified; 170 } 171 172 void VBoxFilePathSelectorWidget::setFileDialogTitle (const QString& aTitle) 173 { 174 mFileDialogTitle = aTitle; 175 } 176 177 QString VBoxFilePathSelectorWidget::fileDialogTitle() const 178 { 179 return mFileDialogTitle; 180 } 181 182 void VBoxFilePathSelectorWidget::setFileFilters (const QString& aFilters) 183 { 184 mFileFilters = aFilters; 185 } 186 187 QString VBoxFilePathSelectorWidget::fileFilters() const 188 { 189 return mFileFilters; 137 190 } 138 191 … … 178 231 if (isPathSelected()) 179 232 { 180 mIsEditableMode = true; 233 if (mIsEditable) 234 mIsEditableMode = true; 181 235 if (aEvent->reason() == Qt::MouseFocusReason) 182 236 mIsMouseAwaited = true; … … 305 359 if (!mModified && mPath != oldPath) 306 360 mModified = true; 361 emit pathChanged (aPath); 307 362 } 308 363 … … 317 372 /* Open existing file or directory. */ 318 373 QString path = mMode == Mode_File ? 319 VBoxGlobal::getOpenFileName (initDir, QString::null, parentWidget(), QString::null) :320 VBoxGlobal::getExistingDirectory (initDir, parentWidget() );374 VBoxGlobal::getOpenFileName (initDir, mFileFilters, parentWidget(), mFileDialogTitle) : 375 VBoxGlobal::getExistingDirectory (initDir, parentWidget(), mFileDialogTitle); 321 376 if (path.isNull()) 322 377 return; … … 399 454 void VBoxFilePathSelectorWidget::refreshText() 400 455 { 401 if (mIsEditable Mode)456 if (mIsEditable && mIsEditableMode) 402 457 { 403 458 /* Cursor positioning variables */
Note:
See TracChangeset
for help on using the changeset viewer.