summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2016-09-19 21:12:34 +0200
committerStig Bjørlykke <stig@bjorlykke.org>2016-09-19 20:49:01 +0000
commit4ed3518c052f2b17cb35bc5aaa5c819dcfe9603c (patch)
tree091ce8cbf79d321c115c7047d3d3e8a7b886b6df /ui
parentcdfc47d58dd52d028dee4797b9a151d4d06633fe (diff)
downloadwireshark-4ed3518c052f2b17cb35bc5aaa5c819dcfe9603c.tar.gz
Qt: Added option to Remove from recent files list
Change-Id: If87e1bf4796d45582bc2490720683e4072971f56 Reviewed-on: https://code.wireshark.org/review/17804 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/main_welcome.cpp21
-rw-r--r--ui/qt/main_welcome.h1
-rw-r--r--ui/qt/wireshark_application.cpp27
-rw-r--r--ui/qt/wireshark_application.h1
4 files changed, 48 insertions, 2 deletions
diff --git a/ui/qt/main_welcome.cpp b/ui/qt/main_welcome.cpp
index 3074f84f89..0393dbc68e 100644
--- a/ui/qt/main_welcome.cpp
+++ b/ui/qt/main_welcome.cpp
@@ -404,7 +404,7 @@ void MainWelcome::updateRecentFiles() {
}
int row = recent_files_->count();
- while (row > 0 && row > (int) prefs.gui_recent_files_count_max) {
+ while (row > 0 && (row > (int) prefs.gui_recent_files_count_max || row > rfRow)) {
row--;
delete recent_files_->item(row);
}
@@ -464,8 +464,8 @@ void MainWelcome::showRecentContextMenu(QPoint pos)
recent_ctx_menu_->clear();
QString cf_path = li->data(Qt::UserRole).toString();
- QAction *show_action = recent_ctx_menu_->addAction(show_in_str_);
+ QAction *show_action = recent_ctx_menu_->addAction(show_in_str_);
show_action->setData(cf_path);
connect(show_action, SIGNAL(triggered(bool)), this, SLOT(showRecentFolder()));
@@ -473,6 +473,12 @@ void MainWelcome::showRecentContextMenu(QPoint pos)
copy_action->setData(cf_path);
connect(copy_action, SIGNAL(triggered(bool)), this, SLOT(copyRecentPath()));
+ recent_ctx_menu_->addSeparator();
+
+ QAction *remove_action = recent_ctx_menu_->addAction(tr("Remove"));
+ remove_action->setData(cf_path);
+ connect(remove_action, SIGNAL(triggered(bool)), this, SLOT(removeRecentPath()));
+
recent_ctx_menu_->exec(recent_files_->mapToGlobal(pos));
}
@@ -496,6 +502,17 @@ void MainWelcome::copyRecentPath()
wsApp->clipboard()->setText(cf_path);
}
+void MainWelcome::removeRecentPath()
+{
+ QAction *ria = qobject_cast<QAction*>(sender());
+ if (!ria) return;
+
+ QString cf_path = ria->data().toString();
+ if (cf_path.isEmpty()) return;
+
+ wsApp->removeRecentItem(cf_path);
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/main_welcome.h b/ui/qt/main_welcome.h
index 1c142cc1eb..40ae2f0bdd 100644
--- a/ui/qt/main_welcome.h
+++ b/ui/qt/main_welcome.h
@@ -88,6 +88,7 @@ private slots:
void showRecentContextMenu(QPoint pos);
void showRecentFolder();
void copyRecentPath();
+ void removeRecentPath();
};
#endif // MAIN_WELCOME_H
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index 13ed4d9be4..41de756f35 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -1052,6 +1052,33 @@ void WiresharkApplication::addRecentItem(const QString filename, qint64 size, bo
itemStatusFinished(filename, size, accessible);
}
+void WiresharkApplication::removeRecentItem(const QString &filename)
+{
+ QMutableListIterator<recent_item_status *> rii(recent_items_);
+
+ while (rii.hasNext()) {
+ recent_item_status *ri = rii.next();
+#ifdef _WIN32
+ /* Do a case insensitive compare on win32 */
+ if (ri->filename.compare(filename, Qt::CaseInsensitive) == 0) {
+#else
+ /* Do a case sensitive compare on UN*Xes.
+ *
+ * XXX - on UN*Xes such as macOS, where you can use pathconf()
+ * to check whether a given file system is case-sensitive or
+ * not, we should check whether this particular file system
+ * is case-sensitive and do the appropriate comparison.
+ */
+ if (ri->filename.compare(filename) == 0) {
+#endif
+ rii.remove();
+ delete(ri);
+ }
+ }
+
+ emit updateRecentItemStatus(NULL, 0, false);
+}
+
static void switchTranslator(QTranslator& myTranslator, const QString& filename,
const QString& searchPath)
{
diff --git a/ui/qt/wireshark_application.h b/ui/qt/wireshark_application.h
index b2adf0a052..0d486ee3d2 100644
--- a/ui/qt/wireshark_application.h
+++ b/ui/qt/wireshark_application.h
@@ -98,6 +98,7 @@ public:
struct _e_prefs * readConfigurationFiles(char **gdp_path, char **dp_path, bool reset);
QList<recent_item_status *> recentItems() const;
void addRecentItem(const QString filename, qint64 size, bool accessible);
+ void removeRecentItem(const QString &filename);
QDir lastOpenDir();
void setLastOpenDir(const char *dir_name);
void setLastOpenDir(QString *dir_str);