Implemented a global included list. This list are common temporary and

lock files that should be ignored. The user can enable and disable them
if they so wish.

Additionally, set the ground for a later inclusion of a global list,
which the user enters and applies to all accounts.
This commit is contained in:
Juan Carlos Cornejo 2011-12-13 19:11:35 -05:00 коммит произвёл Klaas Freitag
Родитель 9505b119b1
Коммит c653a203de
5 изменённых файлов: 407 добавлений и 12 удалений

Просмотреть файл

@ -39,7 +39,8 @@
#include <kwallet.h>
#endif
OwnCloudSync::OwnCloudSync(QString name, WId id) : mAccountName(name),mWinId(id)
OwnCloudSync::OwnCloudSync(QString name, WId id,QSet<QString> *globalFilters)
: mAccountName(name),mWinId(id),mGlobalFilters(globalFilters)
{
mBusy = false;
mIsPaused = false;
@ -1527,9 +1528,11 @@ bool OwnCloudSync::isFileFiltered(QString name)
return true;
}
QList<QString> list = mFilters.toList();
list.append( mGlobalFilters->toList() );
syncDebug() << "Will check a total of " << list.size() << " filters";
// Else, look through the filters and see if this file is excluded
for( int i = 0; i < mFilters.size(); i++ ) {
for( int i = 0; i < list.size(); i++ ) {
QString filter = list[i];
if(filter.contains("*")) { // Must build general expression
filter.replace("?","\\\?");

Просмотреть файл

@ -41,7 +41,7 @@ class OwnCloudSync : public QObject
Q_OBJECT
public:
explicit OwnCloudSync(QString name, WId id);
explicit OwnCloudSync(QString name, WId id, QSet<QString> *globalFilters);
~OwnCloudSync();
void initialize(QString host, QString user, QString pass, QString remote,
QString local, qint64 time);
@ -107,6 +107,7 @@ private:
bool mNotifySyncEmitted;
bool mHardStop;
QSet<QString> mFilters;
QSet<QString> *mGlobalFilters;
QString mLastSync;
QSqlDatabase mDB;
QString mDBFileName;

Просмотреть файл

@ -51,6 +51,8 @@ SyncWindow::SyncWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::SyncWindow)
{
mSharedFilters = new QSet<QString>();
mIncludedFilters = g_GetIncludedFilterList();
mQuitAction = false;
mBusy = false;
ui->setupUi(this);
@ -58,6 +60,7 @@ SyncWindow::SyncWindow(QWidget *parent) :
mEditingConfig = -1;
mConflictsExist = false;
loadApplicationSettings();
updateSharedFilterList();
// Before anything else, connect to the SyncDebug
connect(getSyncDebug(),SIGNAL(debugMessage(const QString)),
@ -87,6 +90,8 @@ SyncWindow::SyncWindow(QWidget *parent) :
// Start with the default tab
ui->stackedWidget->setCurrentIndex(0);
ui->listFilterView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->listIncludedFilterView->setEditTriggers(QAbstractItemView::NoEditTriggers);
ui->listGlobalFilterView->setEditTriggers(QAbstractItemView::NoEditTriggers);
// Create the Accounts SignalMapper
mAccountsSignalMapper = new QSignalMapper(this);
@ -216,7 +221,7 @@ void SyncWindow::systemTrayActivated(QSystemTrayIcon::ActivationReason reason)
OwnCloudSync* SyncWindow::addAccount(QString name)
{
OwnCloudSync *account = new OwnCloudSync(name,winId());
OwnCloudSync *account = new OwnCloudSync(name,winId(),mSharedFilters);
mAccounts.append(account);
mAccountNames.append(name);
@ -621,11 +626,11 @@ void SyncWindow::editConfig(int row)
void SyncWindow::listFilters(int row)
{
if(row<0) {
// Show the filters list
// Show an empty filter list
ui->listFilterView->setModel(
new QStringListModel());
} else {
// Show the filters list
// Show the filter list
ui->listFilterView->setModel(
new QStringListModel(mAccounts[row]->getFilterList()));
// Create the filterView signals
@ -709,6 +714,15 @@ void SyncWindow::saveApplicationSettings()
ui->actionClose_Button_Hides_Window->isChecked());
settings.setValue("display_debug",mDisplayDebug);
settings.endGroup();
settings.beginGroup("DisabledIncludedFilters");
for(int i = 0; i < mIncludedFilters.size(); i++ ) {
if( !mIncludedFilters[i].enabled ) {
settings.setValue(mIncludedFilters[i].name,true);
} else {
settings.remove(mIncludedFilters[i].name);
}
}
settings.endGroup();
}
void SyncWindow::loadApplicationSettings()
@ -722,6 +736,12 @@ void SyncWindow::loadApplicationSettings()
mDisplayDebug = settings.value("display_debug").toBool();
ui->actionDisplay_Debug_Messages->setChecked(mDisplayDebug);
settings.endGroup();
settings.beginGroup("DisabledIncludedFilters");
for(int i = 0; i < mIncludedFilters.size(); i++ ) {
mIncludedFilters[i].enabled =
!settings.value(mIncludedFilters[i].name).toBool();
}
settings.endGroup();
}
void SyncWindow::on_actionEnable_Delete_Account_triggered()
@ -803,3 +823,74 @@ void SyncWindow::on_buttonPause_clicked()
ui->buttonResume->setEnabled(true);
ui->textBrowser->append(tr("Pausing..."));
}
void SyncWindow::on_actionConfigure_triggered()
{
ui->stackedWidget->setCurrentIndex(3);
ui->listIncludedFilterView->clear();
QListWidgetItem *item;
for( int i = 0; i < mIncludedFilters.size(); i++ ) {
item = new QListWidgetItem(mIncludedFilters[i].filter+
" [" + mIncludedFilters[i].description + "]",
ui->listIncludedFilterView,i);
if( mIncludedFilters[i].canBeDisabled ) {
if ( mIncludedFilters[i].enabled ) {
item->setCheckState(Qt::Checked);
} else {
item->setCheckState(Qt::Unchecked);
}
} else {
item->setFlags(Qt::NoItemFlags);
}
}
connect(ui->listIncludedFilterView,SIGNAL(itemChanged(QListWidgetItem *)),
this,SLOT(includedFilterListItemChanged(QListWidgetItem*)));
}
void SyncWindow::includedFilterListItemChanged(QListWidgetItem *item)
{
if(item->checkState() == Qt::Checked ) {
mIncludedFilters[item->type()].enabled = true;
} else {
mIncludedFilters[item->type()].enabled = false;
}
updateSharedFilterList();
// syncDebug() << "Item changed: " << mIncludedFilters[item->type()].name
// << "State: " << item->checkState() << " Enabled?: " <<
// mIncludedFilters[item->type()].enabled;
}
void SyncWindow::on_buttonEnableAllIncludedFilters_clicked()
{
for(int i = 0; i<mIncludedFilters.size(); i++) {
if(mIncludedFilters[i].canBeDisabled) {
ui->listIncludedFilterView->item(i)->setCheckState(Qt::Checked);
}
}
updateSharedFilterList();
}
void SyncWindow::on_buttonDisableAllIncludedFilters_clicked()
{
for(int i = 0; i<mIncludedFilters.size(); i++) {
if(mIncludedFilters[i].canBeDisabled) {
ui->listIncludedFilterView->item(i)->setCheckState(Qt::Unchecked);
}
}
updateSharedFilterList();
}
void SyncWindow::updateSharedFilterList()
{
mSharedFilters->clear();
for(int i = 0; i < mIncludedFilters.size(); i++ ) {
if(mIncludedFilters[i].enabled)
mSharedFilters->insert(mIncludedFilters[i].filter);
}
}
void SyncWindow::on_buttonReturn_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
}

Просмотреть файл

@ -33,11 +33,29 @@ class QTimer;
class OwnCloudSync;
class QSignalMapper;
class QMenu;
class QListWidgetItem;
namespace Ui {
class SyncWindow;
}
struct SyncIncludedFilterList {
QString name; // No spaces, must be unique!
QString filter;
QString description;
bool enabled;
bool canBeDisabled;
SyncIncludedFilterList(QString Name, QString Filter,
QString Description,
bool Disable = false)
{
name = Name;
filter = Filter;
description = Description;
canBeDisabled = Disable;
}
};
class SyncWindow : public QMainWindow
{
Q_OBJECT
@ -45,9 +63,11 @@ class SyncWindow : public QMainWindow
public:
explicit SyncWindow(QWidget *parent = 0);
~SyncWindow();
QSet<QString> *mSharedFilters;
private:
Ui::SyncWindow *ui;
QList<SyncIncludedFilterList> mIncludedFilters;
QSystemTrayIcon *mSystemTray;
QMenu *mSystemTrayMenu;
QList<OwnCloudSync*> mAccounts;
@ -89,6 +109,7 @@ private:
void saveApplicationSettings();
void loadApplicationSettings();
void deleteAccount();
void updateSharedFilterList();
public slots:
//void timeToSync();
@ -101,6 +122,7 @@ public slots:
QItemSelection deselected);
void slotAccountsSignalMapper(int row);
void processDebugMessage(const QString msg);
void includedFilterListItemChanged(QListWidgetItem* item);
// GUI related slots
void on_buttonSave_clicked();
@ -133,6 +155,7 @@ public slots:
void slotFinishedSync(OwnCloudSync*);
void slotToMessage(QString caption, QString body,
QSystemTrayIcon::MessageIcon icon);
private slots:
void on_action_Quit_triggered();
void on_actionEnable_Delete_Account_triggered();
@ -143,6 +166,30 @@ private slots:
void on_actionDisplay_Debug_Messages_toggled(bool arg1);
void on_buttonResume_clicked();
void on_buttonPause_clicked();
void on_actionConfigure_triggered();
void on_buttonEnableAllIncludedFilters_clicked();
void on_buttonDisableAllIncludedFilters_clicked();
void on_buttonReturn_clicked();
};
// Now create a global filter list
inline QList<SyncIncludedFilterList> g_GetIncludedFilterList()
{
QList<SyncIncludedFilterList> list;
// VIM
list.append(SyncIncludedFilterList("vim_tmp",".*.swp","Vim temporary file",true));
list.append(SyncIncludedFilterList("vim_tmp2",".*.swo","Vim temporary binary file",true));
// LibreOffice/OpenOffice lock files
list.append(SyncIncludedFilterList("libreoffice_lock",".~lock.*#","LibreOffice/OpenOffice lock files",true));
// General temporary files that I know of
list.append(SyncIncludedFilterList("tmp1","~*","General Temporary Files",true));
list.append(SyncIncludedFilterList("android_syncfolders","*.tacit.fs.part","Android Folder Sync temporary file",true));
// Internal Files (User cannot disable!!)
list.append(SyncIncludedFilterList("ocs_conflict",".ocs_conflicting.*","Internal Conflict Resolution File",false));
return list;
}
#endif // SYNCWINDOW_H

Просмотреть файл

@ -14,14 +14,14 @@
<string>SyncWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="1" column="1">
<widget class="QStackedWidget" name="stackedWidget">
<property name="lineWidth">
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_2">
@ -619,6 +619,252 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<widget class="QWidget" name="page_4">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="1" column="0">
<widget class="QPushButton" name="buttonReturn">
<property name="text">
<string>Return to Main Window</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QTabWidget" name="tabConfigurations">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabConfigure">
<property name="enabled">
<bool>false</bool>
</property>
<attribute name="title">
<string>Configure</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Save database every</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>seconds.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Save and clear log every</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_18">
<property name="text">
<string>syncs.</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabGlobalFilters">
<attribute name="title">
<string>Global Filters</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="1">
<widget class="QSplitter" name="splitter_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QTextBrowser" name="textBrowser_4">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Here you may add any filters that will be applied to &lt;span style=&quot; font-weight:600;&quot;&gt;all&lt;/span&gt; accounts. Additionally, on the right you may enable or disable the list of included filters. Some may not be disabled, as they are required for the program to function. They will be shown with the checkbox permanently checked. You may also export and import the global list you created. The included filters cannot be exported nor imported. They are built into the program. The only wildcard supported is *. Examples: .*.swp will exclude all temporary VIM files.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QFrame" name="frame_8">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="handleWidth">
<number>5</number>
</property>
<widget class="QFrame" name="frameFilter_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="2" column="0">
<widget class="QPushButton" name="buttonGlobalFilterInsert">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Insert</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="buttonGlobalFilterRemove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Export/Import</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QListView" name="listGlobalFilterView"/>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLineEdit" name="lineGlobalFilter"/>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_14">
<property name="text">
<string>Add Filter:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QFrame" name="frame_7">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QGridLayout" name="gridLayout_9">
<item row="1" column="0" colspan="3">
<widget class="QListWidget" name="listIncludedFilterView"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="buttonDisableAllIncludedFilters">
<property name="text">
<string>Disable All</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="buttonEnableAllIncludedFilters">
<property name="text">
<string>Enable All</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Included Filters:</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -636,7 +882,7 @@ p, li { white-space: pre-wrap; }
<property name="title">
<string>Program</string>
</property>
<addaction name="actionConfigure_Global_Filters"/>
<addaction name="actionConfigure"/>
<addaction name="action_Quit"/>
<addaction name="actionHide_on_start"/>
<addaction name="actionClose_Button_Hides_Window"/>
@ -677,9 +923,16 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
</action>
<action name="actionConfigure_Global_Filters">
<action name="actionConfigure">
<property name="icon">
<iconset resource="owncloud_sync.qrc">
<normaloff>:/images/owncloud.png</normaloff>:/images/owncloud.png</iconset>
</property>
<property name="text">
<string>Global Filters</string>
<string>Configure</string>
</property>
<property name="toolTip">
<string>Configure</string>
</property>
<property name="statusTip">
<string/>