History

CR fixes

stojce committed 12 years ago

Commit b8db07b1 parent f4698061 file · +15 −12Browse files

Showing the changes to interface/src/ImportDialog.cpp (1 of 1 file). Show all

Unified · Split

interface/src/ImportDialog.cpp+15−12
@@ -25,6 +25,8 @@ const QString INFO_LABEL_TEXT = QObject::tr("<div style='line-height:20px;'>" · 24 unmodified lines
2525 "add mode (S or V keys will toggle mode) to place.</div>");
2626
2727 const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
28+const int SHORT_FILE_EXTENSION = 4;
29+const int SECOND_INDEX_LETTER = 1;
2830
2931 QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const {
3032
@@ -83,8 +85,9 @@ QIcon HiFiIconProvider::icon(const QFileInfo &info) const { · 52 unmodified lines
8385
8486 QString HiFiIconProvider::type(const QFileInfo &info) const {
8587 if (info.isFile()) {
86− if (info.suffix().size() > 4) {
87− return info.suffix().at(0).toUpper() + info.suffix().mid(1);
88+ if (info.suffix().size() > SHORT_FILE_EXTENSION) {
89+ // Capitalize extension
90+ return info.suffix().left(SECOND_INDEX_LETTER).toUpper() + info.suffix().mid(SECOND_INDEX_LETTER);
8891 }
8992 return info.suffix().toUpper();
9093 }
@@ -92,10 +95,10 @@ QString HiFiIconProvider::type(const QFileInfo &info) const { · 1 unmodified line
9295 return QFileIconProvider::type(info);
9396 }
9497
95−ImportDialog::ImportDialog(QWidget *parent) :
96−QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, NULL),
97−_importButton(IMPORT_BUTTON_NAME, this),
98−_cancelButton(CANCEL_BUTTON_NAME, this) {
98+ImportDialog::ImportDialog(QWidget* parent) :
99+ QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, NULL),
100+ _importButton(IMPORT_BUTTON_NAME, this),
101+ _cancelButton(CANCEL_BUTTON_NAME, this) {
99102
100103 setOption(QFileDialog::DontUseNativeDialog, true);
101104 setFileMode(QFileDialog::ExistingFile);
@@ -106,7 +109,7 @@ _cancelButton(CANCEL_BUTTON_NAME, this) { · 4 unmodified lines
106109 #else
107110 QString cmdString = ("Control");
108111 #endif
109− QLabel *infoLabel = new QLabel(QString(INFO_LABEL_TEXT).arg(cmdString));
112+ QLabel* infoLabel = new QLabel(QString(INFO_LABEL_TEXT).arg(cmdString));
110113 infoLabel->setObjectName("infoLabel");
111114
112115 QGridLayout* gridLayout = (QGridLayout*) layout();
@@ -206,7 +209,7 @@ void ImportDialog::setLayout() { · 93 unmodified lines
206209 widget = findChild<QWidget*>("buttonBox");
207210 widget->hide();
208211
209− QSplitter *splitter = findChild<QSplitter*>("splitter");
212+ QSplitter* splitter = findChild<QSplitter*>("splitter");
210213 splitter->setHandleWidth(0);
211214
212215 // remove blue outline on Mac
@@ -243,7 +246,7 @@ void ImportDialog::setImportTypes() { · 30 unmodified lines
243246 QJsonObject configObject = document.object();
244247 if (!configObject.isEmpty()) {
245248 QJsonArray fileFormats = configObject["importFormats"].toArray();
246− int ff = 0;
249+ int formatsCounter = 0;
247250 foreach (const QJsonValue& fileFormat, fileFormats) {
248251 QJsonObject fileFormatObject = fileFormat.toObject();
249252
@@ -251,19 +254,19 @@ void ImportDialog::setImportTypes() { · 1 unmodified line
251254 QString description(fileFormatObject.value("description").toString());
252255 QString icon(fileFormatObject.value("icon").toString());
253256
254− if (ff > 0) {
257+ if (formatsCounter > 0) {
255258 importFormatsInfo.append(",");
256259 }
257260
258261 // set ' or' on last import type text
259− if (ff == fileFormats.count() - 1) {
262+ if (formatsCounter == fileFormats.count() - 1) {
260263 importFormatsInfo.append(" or");
261264 }
262265
263266 importFormatsFilterList.append(QString("*.%1 ").arg(ext));
264267 importFormatsInfo.append(" .").append(ext);
265268 iconsMap[ext] = icon;
266− ff++;
269+ formatsCounter++;
267270 }
268271 }
269272

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t