diff --git a/iso/libisofs/isofs.h b/iso/libisofs/isofs.h index e368e708..52635398 100644 --- a/iso/libisofs/isofs.h +++ b/iso/libisofs/isofs.h @@ -1,172 +1,171 @@ /***************************************************************************** * Copyright (C) 2002 Szombathelyi György * * Copyright (C) 2004-2018 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef ISOFS_H #define ISOFS_H #ifdef __cplusplus extern "C" { #endif #include #include #include "iso_fs.h" #include "el_torito.h" #include "rock.h" typedef struct _rr_entry { int len; /* length of structure */ char *name; /* Name from 'NM' */ char *sl; /* symbolic link data */ time_t t_creat; time_t t_mtime; time_t t_atime; time_t t_ctime; time_t t_backup; time_t t_expire; time_t t_effect; int mode; /* POSIX file modes */ int nlink; int uid; int gid; int serno; int dev_major; int dev_minor; int pl; /* parent location */ int cl; /* child location */ int re; /* relocated */ char z_algo[2]; /* zizofs algorithm */ char z_params[2]; /* zizofs parameters */ unsigned int z_size; /* zizofs real_size */ } rr_entry; typedef struct _iso_vol_desc { struct _iso_vol_desc *next; struct _iso_vol_desc *prev; struct iso_volume_descriptor data; } iso_vol_desc; union default_entry_as_data { char c[32]; struct default_entry d_e; }; typedef struct _boot_entry { struct _boot_entry *next; struct _boot_entry *prev; struct _boot_entry *parent; struct _boot_entry *child; union default_entry_as_data data; } boot_entry; typedef struct _boot_head { struct validation_entry ventry; struct _boot_entry *defentry; struct _boot_entry *sections; } boot_head; /** * this callback function needs to read 'len' sectors from 'start' into 'buf' */ typedef int readfunc(char *buf, unsigned int start, unsigned int len, void *); /** * ProcessDir uses this callback */ typedef int dircallback(struct iso_directory_record *, void *); /** * Returns the Unix from the ISO9660 9.1.5 (7 bytes) time format * This function is from the linux kernel. * Set 'hs' to non-zero if it's a HighSierra volume */ time_t isodate_915(char * p, int hs); /** * Returns the Unix time from the ISO9660 8.4.26.1 (17 bytes) time format * BUG: hundredth of seconds are ignored, because time_t has one second * resolution (I think it's no problem at all) * Set 'hs' to non-zero if it's a HighSierra volume */ time_t isodate_84261(char * p, int hs); /** * Creates the linked list of the volume descriptors * 'sector' is the starting sector number of where the filesystem start * (starting sector of a session on a CD-ROM) * If the function fails, returns NULL * Don't forget to call FreeISO9660 after using the volume descriptor list! */ iso_vol_desc *ReadISO9660(readfunc *read, unsigned int sector, void *udata); /** - * Frees the linked list of volume descriptors - . + * Frees the linked list of volume descriptors. */ void FreeISO9660(iso_vol_desc *data); /** * Iterates over the directory entries. The directory is in 'buf', * the size of the directory is 'size'. 'callback' is called for each * directory entry with the parameter 'udata'. */ int ProcessDir(readfunc *read, int extent, int size, dircallback *callback, void *udata); /** * Parses the System Use area and fills rr_entry with values */ int ParseRR(struct iso_directory_record *idr, rr_entry *rrentry); /** * Frees the strings in 'rrentry' */ void FreeRR(rr_entry *rrentry); /** * returns the joliet level from the volume descriptor */ int JolietLevel(struct iso_volume_descriptor *ivd); /** * Returns the size of the boot image (in 512 byte sectors) */ long long BootImageSize(int media, unsigned int len); /** * Frees the boot catalog entries in 'boot'. If you ever called ReadBootTable, * then don't forget to call FreeBootTable! */ void FreeBootTable(boot_head *boot); /** * Reads the boot catalog into 'head'. Don't forget to call FreeBootTable! */ int ReadBootTable(readfunc *read, unsigned int sector, boot_head *head, void *udata); #ifdef __cplusplus } //extern "C" #endif #endif diff --git a/krusader/FileSystem/filesystemprovider.h b/krusader/FileSystem/filesystemprovider.h index 6cb536a1..237bfd4a 100644 --- a/krusader/FileSystem/filesystemprovider.h +++ b/krusader/FileSystem/filesystemprovider.h @@ -1,105 +1,106 @@ /***************************************************************************** * Copyright (C) 2003 Shie Erlich * * Copyright (C) 2003 Rafi Yanai * * Copyright (C) 2004-2018 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef FILESYSTEMPROVIDER_H #define FILESYSTEMPROVIDER_H // QtCore #include #include #include #include "filesystem.h" /** * @brief Provider for virtual file systems. * * This is a singleton. */ class FileSystemProvider : public QObject { Q_OBJECT public: /** * Get a filesystem implementation for the filesystem target specified by URL. oldFilesystem is returned if * the filesystem did not change. * * The filesystem instances returned by this method are already connected with this handler and will * notify each other about filesystem changes. */ FileSystem *getFilesystem(const QUrl &url, FileSystem *oldFilesystem = 0); /** * Start a copy job for copying, moving or linking files to a destination directory. * Operation may be implemented async depending on destination filesystem. */ void startCopyFiles(const QList &urls, const QUrl &destination, KIO::CopyJob::CopyMode mode = KIO::CopyJob::Copy, bool showProgressInfo = true, JobMan::StartMode startMode = JobMan::Default); /** * Handle file dropping. Starts a copy job for copying, moving or linking files to a destination * directory after user choose the action in a context menu. * * Operation may implemented async depending on destination filesystem. */ void startDropFiles(QDropEvent *event, const QUrl &destination); /** * Start a delete job for trashing or deleting files. * * Operation implemented async. */ void startDeleteFiles(const QList &urls, bool moveToTrash = true); static FileSystemProvider &instance(); static FileSystem::FS_TYPE getFilesystemType(const QUrl &url); /** Get ACL permissions for a file */ static void getACL(FileItem *file, QString &acl, QString &defAcl); public slots: /** * Notify filesystems if they are affected by changes made by another filesystem. * * Only works if filesystem is connected to this provider. * * @param directory the directory that was changed (deleted, moved, content changed,...) + * @param removed whether the directory was removed */ void refreshFilesystems(const QUrl &directory, bool removed); private: FileSystem *getFilesystemInstance(const QUrl &directory); FileSystem *createFilesystem(const FileSystem::FS_TYPE type); FileSystemProvider(); // filesystem instances for directory independent file operations, lazy initialized FileSystem *_defaultFileSystem; FileSystem *_virtFileSystem; QList> _fileSystems; static QString getACL(const QString & path, int type); }; #endif diff --git a/krusader/Konfigurator/konfiguratorpage.h b/krusader/Konfigurator/konfiguratorpage.h index 6f0a844a..8f643b65 100644 --- a/krusader/Konfigurator/konfiguratorpage.h +++ b/krusader/Konfigurator/konfiguratorpage.h @@ -1,515 +1,513 @@ /***************************************************************************** * Copyright (C) 2003 Csaba Karai * * Copyright (C) 2004-2018 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef KONFIGURATORPAGE_H #define KONFIGURATORPAGE_H // QtWidgets #include #include #include #include #include #include "konfiguratoritems.h" struct KONFIGURATOR_CHECKBOX_PARAM; /** * KonfiguratorPage is responsible for handling pages in Konfigurator. * It provides simple methods for create and manage Konfigurator pages. * * @short The base class of a page in Konfigurator */ class KonfiguratorPage : public QScrollArea { Q_OBJECT public: /** * The constructor of the KonfiguratorPage class. * * @param firstTime this parameter is true if it is the first call of Konfigurator * @param parent reference to the parent widget */ KonfiguratorPage(bool firstTime, QWidget *parent); /** * Applies the changes in the Konfigurator page. * * Writes out all relevant information to the configuration object and synchronizes * it with the file storage (hard disk, krusaderrc file). This function calls the apply() * method of each konfigurator item and finally performs the synchronization. * * @return a boolean value indicates that Krusader restart is needed for the correct change */ virtual bool apply(); /** * Sets every konfigurator item to its default value on the page. * * This method calls the setDefaults() method of each konfigurator item. This function * doesn't modify the current configuration, only the values of the GUI items. The * apply() method must be called for finalizing the changes. */ virtual void setDefaults(); /** * Reloads the original value of each konfigurator item from the configuration object. * * This function calls the loadInitialValue() method of each konfigurator item. * Used to rollback the changes on the konfigurator page. Called if the user * responds 'No' to the "Apply changes" question. */ virtual void loadInitialValues(); /** * Checks whether the page was changed. * * This function calls the isChanged() method of each konfigurator item and * performs logical OR operation on them. Actually, this function returns true * if any of the konfigurator items was changed. * * @return true if at least one of the konfigurator items was changed */ virtual bool isChanged(); /** * Flag, indicates the first call of Konfigurator * @return true if konfigurator was started at the first time */ inline bool isFirst() { return firstCall; } /** * This method is used to query the active subpage from the Konfigurator * @return the active page (by default the first page) */ virtual int activeSubPage() { return FIRST_PAGE; } /** * Adds a new checkbox item to the page. *
The checkbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorCheckBox *myCheckBox = createCheckBox( "class", "name", false, parentWidget);
* myLayout->addWidget( myCheckBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the checkbox * @param text The text field of the checkbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param toolTip Tooltip used for this checkbox * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created checkbox */ KonfiguratorCheckBox *createCheckBox(QString configGroup, QString name, bool defaultValue, QString text, QWidget *parent = 0, bool restart = false, QString toolTip = QString(), int page = FIRST_PAGE); /** * Adds a new spinbox item to the page. *
The spinbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorSpinBox *mySpinBox = createSpinBox( "class", "name", 10, 1, 100, parentWidget);
* myLayout->addWidget( mySpinBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") - * @param name The item name used in KConfig (ex. "Do Tar") + * @param configName The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the spinbox * @param min The minimum value of the spinbox * @param max The maximum value of the spinbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created spinbox */ KonfiguratorSpinBox *createSpinBox(QString configGroup, QString configName, int defaultValue, int min, int max, QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); /** * Adds a new editbox item to the page. *
The editbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorEditBox *myEditBox = createEditBox( "class", "name", "default", parentWidget);
* myLayout->addWidget( myEditBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The itemname used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the editbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created editbox */ KonfiguratorEditBox *createEditBox(QString configGroup, QString name, QString defaultValue, QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); /** * Adds a new listbox item to the page. *
The listbox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* QStringList valueList;
* valueList += "item";
* KonfiguratorListBox *myListBox = createListBox( "class", "name", valueList, parentWidget);
* myLayout->addWidget( myListBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The itemname used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the listbox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created editbox */ KonfiguratorListBox *createListBox(QString configGroup, QString name, QStringList defaultValue, QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); /** * Adds a new URL requester item to the page. *
The URL requester widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorURLRequester *myURLRequester = createURLRequester( "class", "name", "default", parentWidget );
* myLayout->addWidget( myURLRequester, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The itemname used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the URL requester - * @param text The text field of the URL requester * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * @param expansion Whether to perform url expansion * * @return reference to the newly created URL requester */ KonfiguratorURLRequester *createURLRequester(QString configGroup, QString name, QString defaultValue, QWidget *parent, bool restart, int page = FIRST_PAGE, bool expansion = true); /** * Adds a new font chooser item to the page. *
The font chooser widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorFontChooser *myFontChooser = createFontChooser( "class", "name", QFont(), parentWidget );
* myLayout->addWidget( myFontChooser, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the font chooser * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created font chooser */ KonfiguratorFontChooser *createFontChooser(QString configGroup, QString name, QFont defaultValue, QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); /** * Adds a new combobox item to the page. *
The combobox widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KONFIGURATOR_NAME_VALUE_PAIR comboInfo[] =
*  {{ i18n( "combo text1" ), "value1" },
*   { i18n( "combo text2" ), "value2" },
*   { i18n( "combo text3" ), "value3" }};

* KonfiguratorComboBox *myComboBox = createComboBox( "class", "name", "value2", comboInfo, 3, parentWidget );
* myLayout->addWidget( myComboBox, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the combobox * @param params Pointer to the name-value pair array (combo elements) * @param paramNum Number of the combobox elements - * @param text The text field of the combobox * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param editable Flag indicates that the combo can be edited * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created combobox */ KonfiguratorComboBox *createComboBox(QString configGroup, QString name, QString defaultValue, KONFIGURATOR_NAME_VALUE_PAIR *params, int paramNum, QWidget *parent = 0, bool restart = false, bool editable = false, int page = FIRST_PAGE); /** * Creates a frame on the page. * * Sample:

* QGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );
* myLayout->addWidget( myGroup, 0, 0 ); * * @param text The text written out onto the frame * @param parent Reference to the parent widget * * @return reference to the newly created frame */ QGroupBox *createFrame(QString text = QString(), QWidget *parent = 0); /** * Creates a new QGridLayout element and sets its margins. * * Sample:

* QGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );
* QGridLayout *myLayout = createGridLayout( myGroup ) );
* myLayout->addWidget( myGroup, 0, 0 ); * * @param parent Reference to the parent layout * * @return reference to the newly created QGridLayout */ QGridLayout *createGridLayout(QWidget *parent); /** * Adds a new label to a grid layout. * * Sample:

* QGroupBox *myGroup = createFrame( i18n( "MyFrameName" ), parentWidget, "frameName" );
* QGridLayout *myLayout = createGridLayout( myGroup->layout() );
* addLabel( myLayout, 0, 0, i18n( "Hello world!" ), myGroup, "myLabel" );
* mainLayout->addWidget( myGroup, 0, 0 ); * * @param layout The grid layout on which the item will be placed * @param x the column to which the label will be placed * @param y the row to which the label will be placed * @param label the text of the label * @param parent Reference to the parent widget * * @return reference to the newly created label */ QLabel *addLabel(QGridLayout *layout, int x, int y, QString label, QWidget *parent = 0); /** * Creates a spacer object (for justifying in QHBox). * * Sample:

* QHBox *hbox = new QHBox( myParent, "hbox" );
* createSpinBox( "class", "spin", 5, 1, 10, hbox );
* createSpacer( hbox );
* myLayout->addWidget( hbox, 0, 0 ); * * @param parent Reference to the parent widget * * @return reference to the newly created spacer widget */ QWidget *createSpacer(QWidget *parent = 0); /** * Creates a separator line. * * Sample:

* QFrame *myLine = createLine( myParent, "myLine" );
* myLayout->addWidget( myLine, 1, 0 );
* * @param parent Reference to the parent widget * @param vertical Means vertical line * * @return reference to the newly created spacer widget */ QFrame *createLine(QWidget *parent = 0, bool vertical = false); /** * Creates a checkbox group. A checkbox group contains a lot of checkboxes. * The grouped checkboxes are embedded into one widget, which can be placed anywhere * on the GUI. The placing of the elements can be horizontal or vertical in the group. * At horizontal placing the sizex integer defines the maximum element number in * one row, sizey is 0. At vertical placing sizex is 0, and sizey defines the * maximum row number in one column.
* * One specific element can be reached by its name or index with the find methods. * The first element is checkBoxGroup->find( 0 ), "myCb" element is checkBoxGroup->find( "myCb") ... * * Sample:

* KONFIGURATOR_CHECKBOX_PARAM myCBArray[] =
*  {{"CbClass","CbName1", false, i18n( "name1" ), false, "tooltip1"},
*   {"CbClass","CbName2", true, i18n( "name2" ), false, "tooltip2"},
*   {"CbClass","CbName3", true, i18n( "name3" ), false, "tooltip3"}};

* KonfiguratorCheckBoxGroup *myCheckBoxGroup = createCheckBoxGroup( 1, 0, myCBArray, 3, myParent, "myCheckboxGroup" );
* myCheckBoxGroup->find( 0 )->setEnabled( false );

* myLayout->addWidget( myCheckBoxGroup, 0, 0 );
* * @param sizex the maximum column number at horizontal placing * @param sizey the maximum row number at vertical placing * @param params pointer to the checkbox array * @param paramNum number of the checkbox elements * @param parent Reference to the parent widget * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created checkbox group widget */ KonfiguratorCheckBoxGroup *createCheckBoxGroup(int sizex, int sizey, KONFIGURATOR_CHECKBOX_PARAM *params, int paramNum, QWidget *parent = 0, int page = FIRST_PAGE); /** * Creates a radio button group. A radio button group contains a lot of radio buttons. * The grouped buttons are embedded into one widget, which can be placed anywhere * on the GUI. The placing of the elements can be horizontal or vertical in the group. * At horizontal placing the sizex integer defines the maximum element number in * one row, sizey is 0. At vertical placing sizex is 0, and sizey defines the * maximum row number in one column.
* * The references of the buttons can be accessed by the find methods of KonfiguratorRadioButtons. * The first element is myRadioGrp->find( 0 ), "myRadio" element is myRadioGrp->find( "myRadio") ... * * Sample:

* KONFIGURATOR_NAME_VALUE_TIP radioInfo[] =
*  {{ i18n( "radio text1" ), "value1", i18n( "tooltip1" ) },
*   { i18n( "radio text2" ), "value2", i18n( "tooltip2" ) },
*   { i18n( "radio text3" ), "value3", i18n( "tooltip3" ) }};

* KonfiguratorRadioButtons *myRadioGroup = createRadioButtonGroup( "class", "name", "value1", * 1, 0, radioInfo, 3, myParent, "myRadioGroup" );
* myRadioGroup->find( i18n( "radio text1" ) )->setEnabled( false );
* myLayout->addWidget( myRadioGroup, 0, 0 );
* * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the radio buttons * @param sizex the maximum column number at horizontal placing * @param sizey the maximum row number at vertical placing * @param params pointer to the checkbox array * @param paramNum number of the checkbox elements * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created radio button group widget */ KonfiguratorRadioButtons *createRadioButtonGroup(QString configGroup, QString name, QString defaultValue, int sizex, int sizey, KONFIGURATOR_NAME_VALUE_TIP *params, int paramNum, QWidget *parent = 0, bool restart = false, int page = FIRST_PAGE); /** * This function is used to insert new, unknown items into KonfiguratorPage. The * item must be derived from KonfiguratorExtension class, which have * isChanged(), apply(), setDefaults, loadInitialValue() methods. After that, the * object is properly handled by Konfigurator page. * * * @param item The item to be added to KonfiguratorPage */ void registerObject(KonfiguratorExtension *item); /** * This function is used to remove elements from KonfiguratorPage. * * Sample:

* KonfiguratorEditBox *myEditBox = createEditBox( "class", "name", "default", parentWidget);
* myLayout->addWidget( myEditBox, 0, 0 );
* removeObject( myEditBox->extension() ); * * After the removeObject myEditBox will be untouched at apply(), setDefaults(), isChanged(), * loadInitialValues() methods of the KonfiguratorPage. * * @param item The item to be removed from KonfiguratorPage */ void removeObject(KonfiguratorExtension *item); /** * Adds a new color chooser combobox item to the page. *
The chooser's widget's name is QString(configGroup + "/" + name).ascii()
* * Sample:

* KonfiguratorColorChooser *myColorChooser = createColorChooser( "class", "name", QColor( 255, 0, 255 ), parentWidget );
* myLayout->addWidget( myColorChooser, 0, 0 ); * * @param configGroup The class name used in KConfig (ex. "Archives") * @param name The item name used in KConfig (ex. "Do Tar") * @param defaultValue The default value of the color chooser * @param parent Reference to the parent widget * @param restart The change of this parameter requires Krusader restart * @param addColPtr The additional color values * @param restart Number of additional colors * @param page The subpage of a Konfigurator page (because of setDefaults) * * @return reference to the newly created combobox */ KonfiguratorColorChooser *createColorChooser(QString configGroup, QString name, QColor defaultValue, QWidget *parent = 0, bool restart = false, ADDITIONAL_COLOR *addColPtr = 0, int addColNum = 0, int page = FIRST_PAGE); signals: /** * The signal is emitted if the changed flag was modified in any konfigurator item. * Used for enabling/disabling the apply button. */ void sigChanged(); protected: QList itemList; private: bool firstCall; }; /** * KONFIGURATOR_CHECKBOX_PARAM is the basic item of checkbox arrays. It contains * every information related to a checkbox. */ struct KONFIGURATOR_CHECKBOX_PARAM { /** * The class used in KConfig (ex. "Archives") */ QString configClass; /** * The item name used in KConfig (ex. "Do Tar") */ QString configName; /** * The default value of the checkbox */ bool defaultValue; /** * The text field of the checkbox */ QString text; /** * The change of this parameter requires Krusader restart */ bool restart; /** * The checkbox's tooltip */ QString toolTip; }; #endif /* __KONFIGURATOR_PAGE_H__ */ diff --git a/krusader/Konfigurator/krresulttable.h b/krusader/Konfigurator/krresulttable.h index 7b500b70..bf73fca8 100644 --- a/krusader/Konfigurator/krresulttable.h +++ b/krusader/Konfigurator/krresulttable.h @@ -1,119 +1,119 @@ /***************************************************************************** * Copyright (C) 2005 Dirk Eschler * * Copyright (C) 2005-2018 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef KRRESULTTABLE_H #define KRRESULTTABLE_H // QtCore #include #include #include // QtWidgets #include #include #include #include #include #include #include "searchobject.h" class KrResultTable : public QWidget { public: explicit KrResultTable(QWidget* parent); virtual ~KrResultTable(); /** * Adds a row of search results to the end of a QGridLayout * Each KrResultTable has to implement it * - * @param const SearchObject* search Name of the SearchObject - * @param const QGridLayout* grid The GridLayout where the row is inserted + * @param search Name of the SearchObject + * @param grid The GridLayout where the row is inserted * * @return bool True if row was added successfully to rows, else false */ virtual bool addRow(SearchObject* search, QGridLayout* grid) = 0; protected: QStringList _supported; QStringList _tableHeaders; int _numColumns; int _numRows; QGridLayout* _grid; QLabel* _label; // generic label /** * Creates the main grid layout and attaches the table header * * @return bool Pointer to the main grid layout */ QGridLayout* initTable(); /** * Applies settings to each cell of the grid layout * Supposed to be run after a row was added * - * @param const QGridLayout* grid The GridLayout + * @param grid The GridLayout */ void adjustRow(QGridLayout* grid); }; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- class KrArchiverResultTable : public KrResultTable { Q_OBJECT public: explicit KrArchiverResultTable(QWidget* parent); virtual ~KrArchiverResultTable(); bool addRow(SearchObject* search, QGridLayout* grid) Q_DECL_OVERRIDE; protected: KUrlLabel* _nameLabel; protected slots: void website(const QString&); }; // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- class KrToolResultTable : public KrResultTable { Q_OBJECT public: explicit KrToolResultTable(QWidget* parent); virtual ~KrToolResultTable(); bool addRow(SearchObject* search, QGridLayout* grid) Q_DECL_OVERRIDE; protected: QList _apps; protected slots: void website(const QString&); }; #endif diff --git a/krusader/Panel/PanelView/krview.h b/krusader/Panel/PanelView/krview.h index 6371cdb4..d1781123 100644 --- a/krusader/Panel/PanelView/krview.h +++ b/krusader/Panel/PanelView/krview.h @@ -1,382 +1,384 @@ /***************************************************************************** * Copyright (C) 2000-2002 Shie Erlich * * Copyright (C) 2000-2002 Rafi Yanai * * Copyright (C) 2004-2018 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef KRVIEW_H #define KRVIEW_H // QtCore #include #include #include #include #include #include // QtGui #include #include #include "krviewproperties.h" class KrView; class KrViewItem; class KrPreviews; class KrViewInstance; class DirListerInterface; typedef QList KrViewItemList; // operator can handle two ways of doing things: // 1. if the view is a widget (inherits krview and klistview for example) // 2. if the view HAS A widget (a krview-son has a member of klistview) // this is done by specifying the view and the widget in the constructor, // even if they are actually the same object (specify it twice in that case) class KrViewOperator : public QObject { Q_OBJECT public: KrViewOperator(KrView *view, QWidget *widget); ~KrViewOperator(); KrView *view() const { return _view; } QWidget *widget() const { return _widget; } void startDrag(); void emitGotDrop(QDropEvent *e) { emit gotDrop(e); } void emitLetsDrag(QStringList items, QPixmap icon) { emit letsDrag(items, icon); } void emitItemDescription(const QString &desc) { emit itemDescription(desc); } void emitContextMenu(const QPoint &point) { emit contextMenu(point); } void emitEmptyContextMenu(const QPoint &point) { emit emptyContextMenu(point); } void emitRenameItem(const QString &oldName, const QString &newName) { emit renameItem(oldName, newName); } void emitExecuted(const QString &name) { emit executed(name); } void emitGoInside(const QString &name) { emit goInside(name); } void emitNeedFocus() { emit needFocus(); } void emitMiddleButtonClicked(KrViewItem *item) { emit middleButtonClicked(item); } void emitCurrentChanged(KrViewItem *item) { emit currentChanged(item); } void emitPreviewJobStarted(KJob *job) { emit previewJobStarted(job); } void emitGoHome() { emit goHome(); } void emitDirUp() { emit dirUp(); } void emitQuickCalcSpace(KrViewItem *item) { emit quickCalcSpace(item); } void emitDefaultDeleteFiles() { emit defaultDeleteFiles(); } void emitRefreshActions() { emit refreshActions(); } void emitGoBack() { emit goBack(); } void emitGoForward() { emit goForward(); } /** * Search for an item by file name beginning at the current cursor position and set the * cursor to it. * * @param text file name to search for, can be regex + * @param caseSensitive whether the search is case sensitive + * @param direction @c 0 is for forward, @c 1 is for backward * @return true if there is a next/previous item matching the text, else false */ bool searchItem(const QString &text, bool caseSensitive, int direction = 0); /** * Filter view items. */ bool filterSearch(const QString &, bool); void setMassSelectionUpdate(bool upd); bool isMassSelectionUpdate() { return _massSelectionUpdate; } void settingsChanged(KrViewProperties::PropertyType properties); public slots: void emitSelectionChanged() { if (!_massSelectionUpdate) emit selectionChanged(); } void startUpdate(); void cleared(); void fileAdded(FileItem *fileitem); void fileUpdated(FileItem *newFileitem); signals: void selectionChanged(); void gotDrop(QDropEvent *e); void letsDrag(QStringList items, QPixmap icon); void itemDescription(const QString &desc); void contextMenu(const QPoint &point); void emptyContextMenu(const QPoint &point); void renameItem(const QString &oldName, const QString &newName); void executed(const QString &name); void goInside(const QString &name); void needFocus(); void middleButtonClicked(KrViewItem *item); void currentChanged(KrViewItem *item); void previewJobStarted(KJob *job); void goHome(); void defaultDeleteFiles(); void dirUp(); void quickCalcSpace(KrViewItem *item); void refreshActions(); void goBack(); void goForward(); protected slots: void saveDefaultSettings(); protected: // never delete those KrView *_view; QWidget *_widget; private: bool _massSelectionUpdate; QTimer _saveDefaultSettingsTimer; static KrViewProperties::PropertyType _changedProperties; static KrView *_changedView; }; /**************************************************************************** * READ THIS FIRST: Using the view * * You always hold a pointer to KrView, thus you can only use functions declared * in this class. If you need something else, either this class is missing something * or you are ;-) * * The functions you'd usually want: * 1) getSelectedItems - returns all selected items, or (if none) the current item. * it never returns anything which includes the "..", and thus can return an empty list! * 2) getSelectedKrViewItems - the same as (1), but returns a QValueList with KrViewItems * 3) getCurrentItem, setCurrentItem - work with QString * 4) getFirst, getNext, getPrev, getCurrentKrViewItem - all work with KrViewItems, and * used to iterate through a list of items. note that getNext and getPrev accept a pointer * to the current item (used in detailedview for safe iterating), thus your loop should be: * for (KrViewItem *it = view->getFirst(); it!=0; it = view->getNext(it)) { blah; } * 5) nameToMakeCurrent(), setNameToMakeCurrent() - work with QString * * IMPORTANT NOTE: every one who subclasses this must call initProperties() in the constructor !!! */ class KrView { friend class KrViewItem; friend class KrViewOperator; public: class IconSizes : public QVector { public: IconSizes() : QVector() { *this << 12 << 16 << 22 << 32 << 48 << 64 << 128 << 256; } }; // instantiating a new view // 1. new KrView // 2. view->init() // notes: constructor does as little as possible, setup() does the rest. esp, note that // if you need something from operator or properties, move it into setup() void init(bool enableUpdateDefaultSettings = true); KrViewInstance *instance() { return &_instance; } static const IconSizes iconSizes; protected: void initProperties(); KrViewOperator *createOperator() { return new KrViewOperator(this, _widget); } virtual void setup() = 0; /////////////////////////////////////////////////////// // Every view must implement the following functions // /////////////////////////////////////////////////////// public: // interview related functions virtual QModelIndex getCurrentIndex() = 0; virtual bool isSelected(const QModelIndex &) = 0; virtual bool ensureVisibilityAfterSelect() = 0; virtual void selectRegion(KrViewItem *, KrViewItem *, bool) = 0; virtual uint numSelected() const = 0; virtual QList selectedUrls() = 0; virtual void setSelectionUrls(const QList urls) = 0; virtual KrViewItem *getFirst() = 0; virtual KrViewItem *getLast() = 0; virtual KrViewItem *getNext(KrViewItem *current) = 0; virtual KrViewItem *getPrev(KrViewItem *current) = 0; virtual KrViewItem *getCurrentKrViewItem() = 0; virtual KrViewItem *getKrViewItemAt(const QPoint &vp) = 0; virtual KrViewItem *findItemByName(const QString &name) = 0; virtual KrViewItem *findItemByUrl(const QUrl &url) = 0; virtual QString getCurrentItem() const = 0; virtual void setCurrentItem(const QString &name, bool scrollToCurrent = true, const QModelIndex &fallbackToIndex = QModelIndex()) = 0; virtual void setCurrentKrViewItem(KrViewItem *item, bool scrollToCurrent = true) = 0; virtual void makeItemVisible(const KrViewItem *item) = 0; virtual bool isItemVisible(const KrViewItem *item) = 0; virtual void updateView() = 0; virtual void sort() = 0; virtual void refreshColors() = 0; virtual void redraw() = 0; virtual bool handleKeyEvent(QKeyEvent *e); virtual void prepareForActive() = 0; virtual void prepareForPassive() = 0; virtual void renameCurrentItem() = 0; // Rename current item. returns immediately virtual int itemsPerPage() = 0; virtual void showContextMenu(const QPoint &point = QPoint(0, 0)) = 0; protected: virtual KrViewItem *preAddItem(FileItem *fileitem) = 0; virtual void preDeleteItem(KrViewItem *item) = 0; virtual void copySettingsFrom(KrView *other) = 0; virtual void populate(const QList &fileItems, FileItem *dummy) = 0; virtual void intSetSelected(const FileItem *fileitem, bool select) = 0; virtual void clear(); void addItem(FileItem *fileItem, bool onUpdate = false); void deleteItem(const QString &name, bool onUpdate = false); void updateItem(FileItem *newFileItem); public: ////////////////////////////////////////////////////// // the following functions are already implemented, // // and normally - should NOT be re-implemented. // ////////////////////////////////////////////////////// uint numFiles() const { return _count - _numDirs; } uint numDirs() const { return _numDirs; } uint count() const { return _count; } void getSelectedItems(QStringList *names, bool fallbackToFocused = true); void getItemsByMask(QString mask, QStringList *names, bool dirs = true, bool files = true); void getSelectedKrViewItems(KrViewItemList *items); void selectAllIncludingDirs() { changeSelection(KRQuery("*"), true, true); } void select(const KRQuery &filter = KRQuery("*")) { changeSelection(filter, true); } void unselect(const KRQuery &filter = KRQuery("*")) { changeSelection(filter, false); } void unselectAll() { changeSelection(KRQuery("*"), false, true); } void invertSelection(); QString nameToMakeCurrent() const { return _nameToMakeCurrent; } void setNameToMakeCurrent(const QString name) { _nameToMakeCurrent = name; } QString firstUnmarkedBelowCurrent(const bool skipCurrent); QString statistics(); const KrViewProperties *properties() const { return _properties; } KrViewOperator *op() const { return _operator; } void showPreviews(bool show); bool previewsShown() { return _previews != 0; } void applySettingsToOthers(); void setFiles(DirListerInterface *files); /** * Refresh the file view items after the underlying file model changed. * * Tries to preserve current file and file selection if applicable. */ void refresh(); bool changeSelection(const KRQuery &filter, bool select); bool changeSelection(const KRQuery &filter, bool select, bool includeDirs, bool makeVisible = false); bool isFiltered(FileItem *fileitem); void setSelected(const FileItem *fileitem, bool select); ///////////////////////////////////////////////////////////// // the following functions have a default and minimalistic // // implementation, and may be re-implemented if needed // ///////////////////////////////////////////////////////////// virtual void setSortMode(KrViewProperties::ColumnType sortColumn, bool descending) { sortModeUpdated(sortColumn, descending); } const KRQuery &filterMask() const { return _properties->filterMask; } KrViewProperties::FilterSpec filter() const { return _properties->filter; } void setFilter(KrViewProperties::FilterSpec filter); void setFilter(KrViewProperties::FilterSpec filter, FilterSettings customFilter, bool applyToDirs); void customSelection(bool select); int defaultFileIconSize(); virtual void setFileIconSize(int size); void setDefaultFileIconSize() { setFileIconSize(defaultFileIconSize()); } void zoomIn(); void zoomOut(); // save this view's settings to be restored after restart virtual void saveSettings(KConfigGroup grp, KrViewProperties::PropertyType properties = KrViewProperties::AllProperties); inline QWidget *widget() { return _widget; } inline int fileIconSize() const { return _fileIconSize; } inline bool isFocused() const { return _focused; } QPixmap getIcon(FileItem *fileitem); void setMainWindow(QWidget *mainWindow) { _mainWindow = mainWindow; } // save this view's settings as default for new views of this type void saveDefaultSettings( KrViewProperties::PropertyType properties = KrViewProperties::AllProperties); // restore the default settings for this view type void restoreDefaultSettings(); // call this to restore this view's settings after restart void restoreSettings(KConfigGroup grp); void saveSelection(); void restoreSelection(); bool canRestoreSelection() { return !_savedSelection.isEmpty(); } void clearSavedSelection(); void markSameBaseName(); void markSameExtension(); // todo: what about selection modes ??? virtual ~KrView(); static QPixmap getIcon(FileItem *fileitem, bool active, int size = 0); static QPixmap processIcon(const QPixmap &icon, bool dim, const QColor &dimColor, int dimFactor, bool symlink); // Get GUI strings for file item properties static QString krPermissionText(const FileItem *fileitem); static QString permissionsText(const KrViewProperties *properties, const FileItem *fileItem); static QString sizeText(const KrViewProperties *properties, KIO::filesize_t size); static QString mimeTypeText(FileItem *fileItem); protected: KrView(KrViewInstance &instance, KConfig *cfg); virtual void doRestoreSettings(KConfigGroup grp); virtual KIO::filesize_t calcSize() = 0; virtual KIO::filesize_t calcSelectedSize() = 0; void sortModeUpdated(KrViewProperties::ColumnType sortColumn, bool descending); inline void setWidget(QWidget *w) { _widget = w; } bool drawCurrent() const; KConfig *_config; KrViewProperties *_properties; KrViewOperator *_operator; bool _focused; int _fileIconSize; private: void updatePreviews(); void saveSortMode(KConfigGroup &group); void restoreSortMode(KConfigGroup &group); KrViewInstance &_instance; DirListerInterface *_files; QWidget *_mainWindow; QWidget *_widget; QList _savedSelection; QString _nameToMakeCurrent; KrPreviews *_previews; bool _updateDefaultSettings; bool _ignoreSettingsChange; QRegExp _quickFilterMask; uint _count, _numDirs; FileItem *_dummyFileItem; }; #endif /* KRVIEW_H */ diff --git a/krusader/UserAction/expander.h b/krusader/UserAction/expander.h index fb3e78f1..732c9b8b 100644 --- a/krusader/UserAction/expander.h +++ b/krusader/UserAction/expander.h @@ -1,283 +1,285 @@ /***************************************************************************** * Copyright (C) 2004 Jonas Bähr * * Copyright (C) 2004 Shie Erlich * * Copyright (C) 2004-2018 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef EXPANDER_H #define EXPANDER_H // QtCore #include #include #include # include "tstring.h" class KrPanel; class Expander; class Error; typedef TagString_t TagString; typedef QList TagStringList; /** * This holds the information about each parameter */ class exp_parameter { public: exp_parameter() {} inline exp_parameter(QString desc, QString pre, bool ness) { _description = desc; _preset = pre; _necessary = ness; } inline QString description() const { ///< A description of the parameter return _description; } inline QString preset() const { ///< the default of the parameter return _preset; } inline bool necessary() const { ///< false if the parameter is optional return _necessary; } private: QString _description; QString _preset; bool _necessary; }; #define EXP_FUNC virtual TagString expFunc ( const KrPanel*, const TagStringList&, const bool&, Expander& ) const #define SIMPLE_EXP_FUNC virtual TagString expFunc ( const KrPanel*, const QStringList&, const bool&, Expander& ) const /** * Abstract baseclass for all expander-functions (which replace placeholder). * A Placeholder is an entry containing the expression, * its expanding function and Parameter. * * Not to be created on the heap */ class exp_placeholder { public: inline QString expression() const { ///< The placeholder (without '%' or panel-prefix) return _expression; } inline QString description() const { ///< A description of the placeholder return _description; } inline bool needPanel() const { ///< true if the placeholder needs a panel to operate on return _needPanel; } inline void addParameter(exp_parameter parameter) { ///< adds parameter to the placeholder _parameter.append(parameter); } inline int parameterCount() const { ///< returns the number of placeholders return _parameter.count(); } inline const exp_parameter& parameter(int id) const { ///< returns a specific parameter return _parameter[ id ]; } EXP_FUNC = 0; protected: static void setError(Expander& exp, const Error& e); static void panelMissingError(const QString &s, Expander& exp); static QStringList splitEach(const TagString& s); static QStringList fileList(const KrPanel* const panel, const QString& type, const QString& mask, const bool omitPath, const bool useUrl, Expander&, const QString&); exp_placeholder(); exp_placeholder(const exp_placeholder& p); virtual ~exp_placeholder() { } QString _expression; QString _description; QList _parameter; bool _needPanel; }; class Error { public: enum Cause { exp_C_USER, exp_C_SYNTAX, exp_C_WORLD, exp_C_ARGUMENT }; enum Severity { exp_S_OK, exp_S_WARNING, exp_S_ERROR, exp_S_FATAL }; Error() : m_severity(exp_S_OK) {} Error(Severity severity, Cause cause) : m_severity(severity), m_cause(cause), m_description() {} Error(Severity severity, Cause cause, QString description) : m_severity(severity), m_cause(cause), m_description(description) {} operator bool() const { return m_severity != exp_S_OK; } Cause cause() const { return m_cause; } const QString &description() const { return m_description; } private: Severity m_severity; Cause m_cause; QString m_description; }; /** * The Expander expands the command of an UserAction by replacing all * placeholders by their current values.@n * Each placeholder begins with a '%'-sign, followed by one char indicating * the panel, followed by a command which may have some parameter enclosed * in brackets and also ends with a '%'-sign. * Examples are %aPath% or %rBookmark("/home/jonas/src/krusader_kde3", "yes")%.@n * The panel-indicator has to be either * 'a' for the active * 'o' for the other * 'r' for the right * 'l' for the left * '_' for panel-independence. * * Currently supported are these commands can be ordered in three groups * (children are the parameter in the right order): * - Placeholders for Krusaders panel-data (panel-indicator has to be 'a', 'o', 'r' or 'l') * - @em Path is replaced by the panel's path * - @em Count is replaced by a nomber of * -# Either "All", "Files", "Dirs", "Selected" * . * - @em Filter is preplaced by the panels filter-mask (ex: "*.cpp *.h") * - @em Current is replaced by the current item or, in case of onmultiple="call_each", by each selected item. * -# If "yes", only the filename (without path) is returned * . * - @em List isreplaced by a list of * -# Either "All", "Files", "Dirs", "Selected" * -# A separator between the items (default: " " [one space]) * -# If "yes", only the filename (without path) is returned * -# (for all but "Selected") a filter-mask (default: "*") * . * . * - Access to panel-dependent, krusader-internal, parameter-needed functions * (panel-indicator has to be 'a', 'o', 'r' or 'l') * - @em Select manipulates the selection of the panel * -# A filter-mask (necessary) * -# Either "Add", "Remove", "Set" (default) * . * - @em Bookmark manipulates the selection of the panel * -# A path or URL (necessary) * -# If "yes", the location is opened in a new tab * . * . * - Access to panel-independent, krusader-internal, parameter-needed functions * (panel-indicator doesn't matter but should be set to '_') * - @em Ask displays a lineedit and is replaced by its return * -# The question (necessary) * -# A default answer * -# A cation for the popup * . * - @em Clipboard manipulates the system-wide clipboard * -# The string copied to clip (ex: "%aCurrent%") (necessary) * -# A separator. If set, parameter1 is append with this to the current clipboard content * . * . * . * Since all placeholders are expanded in the order they appear in the command, * little one-line-scripts are possible */ class Expander { public: inline static int placeholderCount() { ///< returns the number of placeholders return _placeholder().count(); } inline static const exp_placeholder* placeholder(int id) { return _placeholder()[ id ]; } /** * This expands a whole commandline * * @param stringToExpand the commandline with the placeholder * @param useUrl true iff the path's should be expanded to an URL instead of an local path * @return a list of all commands */ void expand(const QString& stringToExpand, bool useUrl); /** * Returns the list of all commands to be executed, provided that #expand was called * before, and there was no error (see #error). Otherwise, calls #abort * * @return The list of commands to be executed */ const QStringList& result() const { assert(!error()); return resultList; } /** * Returns the error object of this Expander. You can test whether there was * any error by * \code * if(exp.error()) * error behaviour... * else * no error... * \endcode * * @return The error object */ const Error& error() const { return _err; } protected: /** * This expands a whole commandline by calling for each Placeholder the corresponding expander * * @param stringToExpand the commandline with the placeholder * @param useUrl true if the path's should be expanded to an URL instead of an local path * @return the expanded commanline for the current item */ TagString expandCurrent(const QString& stringToExpand, bool useUrl); /** - * This function searches for "@EACH"-marks to split the string in a list for each %_Each%-item + * This function searches for "\@EACH"-marks to split the string in a list for each %_Each%-item * * @param stringToSplit the string which should be split * @return the split list */ static QStringList splitEach(TagString stringToSplit); /** * @param panelIndicator either '_' for panel-independent placeholders, 'a', 'o', 'r', or 'l' for the active, other (inactive), right or left panel + * @param pl placeholder + * @param exp expander * @return a pointer to the right panel or NULL if no panel is needed. */ static KrPanel* getPanel(const char panelIndicator , const exp_placeholder*, Expander&); /** * This splits the parameter-string into separate parameter and expands each * @param exp the string holding all parameter * @param useUrl true if the path's should be expanded to an URL instead of an local path * @return a list of all parameter */ TagStringList separateParameter(QString* const exp, bool useUrl); /** * This finds the end of a placeholder, taking care of the parameter * @return the position where the placeholder ends */ int findEnd(const QString& str, int start); void setError(const Error &e) { _err = e; } friend class exp_placeholder; private: static QList & _placeholder(); Error _err; QStringList resultList; }; #endif // ifndef EXPANDER_H diff --git a/krusader/UserAction/useraction.h b/krusader/UserAction/useraction.h index ce4ce3de..00cce108 100644 --- a/krusader/UserAction/useraction.h +++ b/krusader/UserAction/useraction.h @@ -1,166 +1,170 @@ /***************************************************************************** * Copyright (C) 2004 Jonas Bähr * * Copyright (C) 2004-2018 Krusader Krew [https://krusader.org] * * * * This file is part of Krusader [https://krusader.org]. * * * * Krusader is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 2 of the License, or * * (at your option) any later version. * * * * Krusader is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * *****************************************************************************/ #ifndef USERACTION_H #define USERACTION_H // QtCore #include #include #include class QDomDocument; class QDomElement; class QStringList; class KrAction; class QUrl; class KActionMenu; /** * Useractions are Krusaders backend for user-defined actions on * current/selected files in its panels and for krusader's internal actions * which need some parameter. * * There are several components: * - The UserAction class as a Manager * - The interface to KDE's action-system (the KrAction) * - The Expander, which parses the commandline for placeholders and calls * the internal actions * - A widget to manipulate the UserAction's Properties via GUI * (ActionProperty) * * The Useractions are stored in XML-files. Currently there are two main files. * The first is a global example-file which is read only (read after the other * actionfiles, duplicates are ignored) and a local file where the actions are * saved. * This class reads only the container and passes each action-tag to the new * KrAction, which reads it's data itself. */ class UserAction { public: typedef QList KrActionList; enum ReadMode { renameDoublicated, ignoreDoublicated }; /** * The constructor reads all useractions, see readAllFiles() */ UserAction(); ~UserAction(); /** * adds an action to the collection. */ void addKrAction(KrAction* action) { _actions.append(action); }; /** * Use this to access the whole list of registered KrActions. * currently only used to fill the usermenu with all available actions. This should change... * @return A reference to the internal KrActionList */ const KrActionList &actionList() { return _actions; }; /** * @return how many useractions exist */ int count() const { return _actions.count(); }; /** * removes a KrAction from the internal list but does not delete it. * @param action the KrAction which should be removed */ void removeKrAction(KrAction* action); /** * check for each KrAction if it is available for the current location / file and disables it if not */ void setAvailability(); /** * same as above but check for a specitic file * @param currentURL Check for this file */ void setAvailability(const QUrl ¤tURL); /** * Fills a KActionMenu with all available UserActions in the list - * @param popupmenu to populate + * @param menu popupmenu to populate + * @param currentURL the current URL */ void populateMenu(KActionMenu* menu, const QUrl *currentURL); QStringList allCategories(); QStringList allNames(); /** * reads all predefined useractionfiles. */ void readAllFiles(); /** * writes all actions to the local actionfile */ bool writeActionFile(); /** * Reads UserActions from a xml-file. + * @param filename the XML file + * @param mode the read mode * @param list If provided, all new actions will also be added to this list */ void readFromFile(const QString& filename, ReadMode mode = renameDoublicated, KrActionList* list = 0); /** * Reads UserActions from a XML-Element. * @param element a container with action-elements + * @param mode the read mode * @param list If provided, all new actions will also be added to this list */ void readFromElement(const QDomElement& element, ReadMode mode = renameDoublicated, KrActionList* list = 0); /** * creates an empty QDomDocument for the UserActions */ static QDomDocument createEmptyDoc(); /** * Writes a QDomDocument to an UTF-8 encodes text-file * @param doc the XML-Tree * @param filename the filename where to save * @return true on success, false otherwise * @warning any existing file will get overwritten! */ static bool writeToFile(const QDomDocument& doc, const QString& filename); private: KrActionList _actions; QSet _defaultActions; QSet _deletedActions; }; #define ACTION_XML "krusader/useractions.xml" #define ACTION_XML_EXAMPLES "krusader/useraction_examples.xml" #define ACTION_DOCTYPE "KrusaderUserActions" // in well formed XML the root-element has to have the same name then the doctype: #define ACTION_ROOT ACTION_DOCTYPE #define ACTION_PROCESSINSTR "version=\"1.0\" encoding=\"UTF-8\" " #endif // ifndef USERACTION_H