forked from osmocom/wireshark
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>
This commit is contained in:
parent
cdfc47d58d
commit
4ed3518c05
|
@ -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
|
||||
*
|
||||
|
|
|
@ -88,6 +88,7 @@ private slots:
|
|||
void showRecentContextMenu(QPoint pos);
|
||||
void showRecentFolder();
|
||||
void copyRecentPath();
|
||||
void removeRecentPath();
|
||||
};
|
||||
|
||||
#endif // MAIN_WELCOME_H
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue