Changeset View
Changeset View
Standalone View
Standalone View
krusader/KViewer/lister.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
49 | #include <QPrintDialog> | 49 | #include <QPrintDialog> | ||
50 | #include <QPrinter> | 50 | #include <QPrinter> | ||
51 | 51 | | |||
52 | #include <KCodecs/KCharsets> | 52 | #include <KCodecs/KCharsets> | ||
53 | #include <KConfigCore/KSharedConfig> | 53 | #include <KConfigCore/KSharedConfig> | ||
54 | #include <KCoreAddons/KJobTrackerInterface> | 54 | #include <KCoreAddons/KJobTrackerInterface> | ||
55 | #include <KI18n/KLocalizedString> | 55 | #include <KI18n/KLocalizedString> | ||
56 | #include <KIO/CopyJob> | 56 | #include <KIO/CopyJob> | ||
57 | #include <KIO/TransferJob> | ||||
57 | #include <KIO/JobUiDelegate> | 58 | #include <KIO/JobUiDelegate> | ||
58 | #include <KParts/GUIActivateEvent> | 59 | #include <KParts/GUIActivateEvent> | ||
59 | #include <KWidgetsAddons/KMessageBox> | 60 | #include <KWidgetsAddons/KMessageBox> | ||
60 | #include <KXmlGui/KActionCollection> | 61 | #include <KXmlGui/KActionCollection> | ||
61 | 62 | | |||
62 | #include "../krglobal.h" | 63 | #include "../krglobal.h" | ||
63 | #include "../icon.h" | 64 | #include "../icon.h" | ||
64 | #include "../kractions.h" | 65 | #include "../kractions.h" | ||
▲ Show 20 Lines • Show All 1249 Lines • ▼ Show 20 Line(s) | 1203 | { | |||
1314 | hbox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); | 1315 | hbox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); | ||
1315 | 1316 | | |||
1316 | _statusLabel = new QLabel(statusWidget); | 1317 | _statusLabel = new QLabel(statusWidget); | ||
1317 | hbox->addWidget(_statusLabel); | 1318 | hbox->addWidget(_statusLabel); | ||
1318 | 1319 | | |||
1319 | grid->addWidget(statusWidget, 1, 0, 1, 2); | 1320 | grid->addWidget(statusWidget, 1, 0, 1, 2); | ||
1320 | setWidget(widget); | 1321 | setWidget(widget); | ||
1321 | 1322 | | |||
1322 | connect(_scrollBar, SIGNAL(actionTriggered(int)), _textArea, SLOT(slotActionTriggered(int))); | 1323 | connect(_scrollBar, &QScrollBar::actionTriggered, _textArea, &ListerTextArea::slotActionTriggered); | ||
1323 | connect(&_searchUpdateTimer, &QTimer::timeout, this, &Lister::slotUpdate); | 1324 | connect(&_searchUpdateTimer, &QTimer::timeout, this, &Lister::slotUpdate); | ||
1324 | 1325 | | |||
1325 | new ListerBrowserExtension(this); | 1326 | new ListerBrowserExtension(this); | ||
1326 | enableSearch(false); | 1327 | enableSearch(false); | ||
1327 | 1328 | | |||
1328 | _tempFile = new QTemporaryFile(this); | 1329 | _tempFile = new QTemporaryFile(this); | ||
1329 | _tempFile->setFileTemplate(QDir::tempPath() + QLatin1String("/krusader_lister.XXXXXX")); | 1330 | _tempFile->setFileTemplate(QDir::tempPath() + QLatin1String("/krusader_lister.XXXXXX")); | ||
1330 | } | 1331 | } | ||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Line(s) | 1545 | while (!hexcontent.isEmpty()) { | |||
1553 | _searchHexQuery.push_back((char) c); | 1554 | _searchHexQuery.push_back((char) c); | ||
1554 | } | 1555 | } | ||
1555 | } else { | 1556 | } else { | ||
1556 | _searchQuery.setContent(_searchLineEdit->text(), caseSensitive, matchWholeWord, codec()->name(), regExp); | 1557 | _searchQuery.setContent(_searchLineEdit->text(), caseSensitive, matchWholeWord, codec()->name(), regExp); | ||
1557 | } | 1558 | } | ||
1558 | _searchIsForward = forward; | 1559 | _searchIsForward = forward; | ||
1559 | _searchHexadecimal = hex; | 1560 | _searchHexadecimal = hex; | ||
1560 | 1561 | | |||
1561 | QTimer::singleShot(0, this, SLOT(slotSearchMore())); | 1562 | QTimer::singleShot(0, this, &Lister::slotSearchMore); | ||
1562 | _searchInProgress = true; | 1563 | _searchInProgress = true; | ||
1563 | _searchProgressCounter = 3; | 1564 | _searchProgressCounter = 3; | ||
1564 | 1565 | | |||
1565 | enableActions(false); | 1566 | enableActions(false); | ||
1566 | } | 1567 | } | ||
1567 | 1568 | | |||
1568 | void Lister::enableActions(const bool state) | 1569 | void Lister::enableActions(const bool state) | ||
1569 | { | 1570 | { | ||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 1708 | } else if (_searchPosition <= 0 || _searchPosition >= _fileSize) { | |||
1708 | if (_restartFromBeginning) | 1709 | if (_restartFromBeginning) | ||
1709 | resetSearchPosition(); | 1710 | resetSearchPosition(); | ||
1710 | else { | 1711 | else { | ||
1711 | searchFailed(); | 1712 | searchFailed(); | ||
1712 | return; | 1713 | return; | ||
1713 | } | 1714 | } | ||
1714 | } | 1715 | } | ||
1715 | 1716 | | |||
1716 | QTimer::singleShot(0, this, SLOT(slotSearchMore())); | 1717 | QTimer::singleShot(0, this, &Lister::slotSearchMore); | ||
1717 | } | 1718 | } | ||
1718 | 1719 | | |||
1719 | void Lister::resetSearchPosition() | 1720 | void Lister::resetSearchPosition() | ||
1720 | { | 1721 | { | ||
1721 | _restartFromBeginning = false; | 1722 | _restartFromBeginning = false; | ||
1722 | _searchPosition = _searchIsForward ? 0 : _fileSize - 1; | 1723 | _searchPosition = _searchIsForward ? 0 : _fileSize - 1; | ||
1723 | } | 1724 | } | ||
1724 | 1725 | | |||
▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Line(s) | 1925 | } else { | |||
1925 | _savePosition = start; | 1926 | _savePosition = start; | ||
1926 | _saveEnd = end; | 1927 | _saveEnd = end; | ||
1927 | } | 1928 | } | ||
1928 | 1929 | | |||
1929 | const QUrl url = QFileDialog::getSaveFileUrl(_textArea, i18n("Lister")); | 1930 | const QUrl url = QFileDialog::getSaveFileUrl(_textArea, i18n("Lister")); | ||
1930 | if (url.isEmpty()) | 1931 | if (url.isEmpty()) | ||
1931 | return; | 1932 | return; | ||
1932 | 1933 | | |||
1933 | KIO::Job *saveJob = KIO::put(url, -1, KIO::Overwrite); | 1934 | KIO::Job *saveJob = KIO::put(url, -1, KIO::Overwrite); | ||
yurchor: Maybe it would be better to declare
```
KIO::TransferJob *saveJob = KIO::put(url, -1, KIO… | |||||
abika: yes, i agree. | |||||
1934 | connect(saveJob, SIGNAL(dataReq(KIO::Job*,QByteArray&)), | 1935 | connect(dynamic_cast<KIO::TransferJob*>(saveJob), &KIO::TransferJob::dataReq, this, &Lister::slotDataSend); | ||
1935 | this, SLOT(slotDataSend(KIO::Job*,QByteArray&))); | 1936 | connect(dynamic_cast<KIO::TransferJob*>(saveJob), &KIO::TransferJob::result, this, &Lister::slotSendFinished); | ||
1936 | connect(saveJob, SIGNAL(result(KJob*)), | | |||
1937 | this, SLOT(slotSendFinished(KJob*))); | | |||
1938 | 1937 | | |||
1939 | saveJob->setUiDelegate(new KIO::JobUiDelegate()); | 1938 | saveJob->setUiDelegate(new KIO::JobUiDelegate()); | ||
1940 | KIO::getJobTracker()->registerJob(saveJob); | 1939 | KIO::getJobTracker()->registerJob(saveJob); | ||
1941 | saveJob->uiDelegate()->setAutoErrorHandlingEnabled(true); | 1940 | saveJob->uiDelegate()->setAutoErrorHandlingEnabled(true); | ||
1942 | 1941 | | |||
1943 | _actionSaveSelected->setEnabled(false); | 1942 | _actionSaveSelected->setEnabled(false); | ||
1944 | } | 1943 | } | ||
1945 | 1944 | | |||
▲ Show 20 Lines • Show All 332 Lines • Show Last 20 Lines |
Maybe it would be better to declare
and avoid dynamic casts?